aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 41b518d..6cf1ba9 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2609,6 +2609,52 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data)
return TRUE;
}
+/* Adjust the dynamic symbol, H, for copy in the dynamic bss section,
+ DYNBSS. */
+
+bfd_boolean
+_bfd_elf_adjust_dynamic_copy (struct elf_link_hash_entry *h,
+ asection *dynbss)
+{
+ unsigned int power_of_two, orig_power_of_two;
+ bfd_vma mask;
+ asection *sec = h->root.u.def.section;
+
+ /* The section aligment of definition is the maximum alignment
+ requirement of symbols defined in the section. */
+ power_of_two = bfd_get_section_alignment (dynbss->owner, dynbss);
+ orig_power_of_two = bfd_get_section_alignment (sec->owner, sec);
+
+ if (orig_power_of_two > power_of_two)
+ {
+ /* Adjust the section alignment if needed. */
+ if (! bfd_set_section_alignment (dynbss->owner, dynbss,
+ orig_power_of_two))
+ return FALSE;
+ }
+
+ /* We make sure that the symbol will be aligned properly. Since we
+ don't know its alignment requirement, we start with the maximum
+ alignment and check low bits of the symbol address for the
+ minimum alignment. */
+ mask = ((bfd_vma) 1 << orig_power_of_two) - 1;
+ while ((h->root.u.def.value & mask) != 0)
+ {
+ mask >>= 1;
+ --orig_power_of_two;
+ }
+ dynbss->size = BFD_ALIGN (dynbss->size, mask + 1);
+
+ /* Define the symbol as being at this point in DYNBSS. */
+ h->root.u.def.section = dynbss;
+ h->root.u.def.value = dynbss->size;
+
+ /* Increment the size of DYNBSS to make room for the symbol. */
+ dynbss->size += h->size;
+
+ return TRUE;
+}
+
/* Adjust all external symbols pointing into SEC_MERGE sections
to reflect the object merging within the sections. */