diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2007-05-15 13:55:54 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2007-05-15 13:55:54 +0000 |
commit | 027297b7a82f2545233997e2b5383595390beeb9 (patch) | |
tree | 77844326b69133a5686b896a9fa201d33b6dc71a /bfd | |
parent | 069ed9311569a8d87c9c341f95d5613f8c759e8f (diff) | |
download | gdb-027297b7a82f2545233997e2b5383595390beeb9.zip gdb-027297b7a82f2545233997e2b5383595390beeb9.tar.gz gdb-027297b7a82f2545233997e2b5383595390beeb9.tar.bz2 |
2007-05-15 H.J. Lu <hongjiu.lu@intel.com>
Alan Modra <amodra@bigpond.net.au>
PR ld/4504
* elf-bfd.h (_bfd_elf_adjust_dynamic_copy): New.
* elflink.c (_bfd_elf_adjust_dynamic_copy): New.
* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Call
_bfd_elf_adjust_dynamic_copy to adjust for the copy in dynamic
bss section.
* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf64_x86_64_adjust_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_vxworks_adjust_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 28 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 3 | ||||
-rw-r--r-- | bfd/elf-m10300.c | 24 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 24 | ||||
-rw-r--r-- | bfd/elf32-cris.c | 27 | ||||
-rw-r--r-- | bfd/elf32-hppa.c | 24 | ||||
-rw-r--r-- | bfd/elf32-i370.c | 24 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 23 | ||||
-rw-r--r-- | bfd/elf32-m32r.c | 24 | ||||
-rw-r--r-- | bfd/elf32-m68k.c | 24 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 24 | ||||
-rw-r--r-- | bfd/elf32-s390.c | 23 | ||||
-rw-r--r-- | bfd/elf32-sh.c | 24 | ||||
-rw-r--r-- | bfd/elf32-vax.c | 24 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 23 | ||||
-rw-r--r-- | bfd/elf64-s390.c | 23 | ||||
-rw-r--r-- | bfd/elf64-sh64.c | 24 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 26 | ||||
-rw-r--r-- | bfd/elflink.c | 46 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 22 | ||||
-rw-r--r-- | bfd/elfxx-sparc.c | 23 |
21 files changed, 95 insertions, 412 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8e22a913..a46bc09 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,31 @@ +2007-05-15 H.J. Lu <hongjiu.lu@intel.com> + Alan Modra <amodra@bigpond.net.au> + + PR ld/4504 + * elf-bfd.h (_bfd_elf_adjust_dynamic_copy): New. + * elflink.c (_bfd_elf_adjust_dynamic_copy): New. + + * elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Call + _bfd_elf_adjust_dynamic_copy to adjust for the copy in dynamic + bss section. + * elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise. + * elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise. + * elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise. + * elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise. + * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise. + * elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise. + * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise. + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise. + * elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise. + * elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise. + * elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise. + * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise. + * elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise. + * elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise. + * elf64-x86-64.c (elf64_x86_64_adjust_dynamic_symbol): Likewise. + * elfxx-mips.c (_bfd_mips_vxworks_adjust_dynamic_symbol): Likewise. + * elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise. + 2007-05-15 Richard Sandiford <richard@codesourcery.com> * elfxx-mips.c (mips_elf_create_local_got_entry): Remove diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 33ef613..3ead565 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1739,6 +1739,9 @@ extern bfd_boolean _bfd_elf_fix_symbol_flags extern bfd_boolean _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *, void *); +extern bfd_boolean _bfd_elf_adjust_dynamic_copy + (struct elf_link_hash_entry *, asection *); + extern bfd_boolean _bfd_elf_link_sec_merge_syms (struct elf_link_hash_entry *, void *); diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index ef47a87..992b2a4 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -4096,7 +4096,6 @@ _bfd_mn10300_elf_adjust_dynamic_symbol (info, h) { bfd * dynobj; asection * s; - unsigned int power_of_two; dynobj = elf_hash_table (info)->dynobj; @@ -4236,28 +4235,7 @@ _bfd_mn10300_elf_adjust_dynamic_symbol (info, h) h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (! bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Set the sizes of the dynamic sections. */ diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 7ad4a4a..8b5d31e 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -8377,7 +8377,6 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, { bfd * dynobj; asection * s; - unsigned int power_of_two; struct elf32_arm_link_hash_entry * eh; struct elf32_arm_link_hash_table *globals; @@ -8490,28 +8489,7 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (! bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index e20de14..04f563b 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -2221,7 +2221,6 @@ elf_cris_adjust_dynamic_symbol (info, h) { bfd *dynobj; asection *s; - unsigned int power_of_two; bfd_size_type plt_entry_size; dynobj = elf_hash_table (info)->dynobj; @@ -2429,31 +2428,7 @@ elf_cris_adjust_dynamic_symbol (info, h) h->needs_copy = 1; } - /* Historic precedent: m68k and i386 allow max 8-byte alignment for the - thing to copy; so do we. */ - - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (!bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Look through the relocs for a section during the first phase. */ diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 35b7b41..4952921 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1819,7 +1819,6 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, { struct elf32_hppa_link_hash_table *htab; asection *sec; - unsigned int power_of_two; /* If this is a function, put it in the procedure linkage table. We will fill in the contents of the procedure linkage table later. */ @@ -1929,30 +1928,9 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, eh->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how other ELF linkers handle this. */ - - power_of_two = bfd_log2 (eh->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ sec = htab->sdynbss; - sec->size = BFD_ALIGN (sec->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->etab.dynobj, sec)) - { - if (! bfd_set_section_alignment (htab->etab.dynobj, sec, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - eh->root.u.def.section = sec; - eh->root.u.def.value = sec->size; - /* Increment the section size to make room for the symbol. */ - sec->size += eh->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (eh, sec); } /* Allocate space in the .plt for entries that won't have relocations. diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index b66c294..0ec34b8 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -461,7 +461,6 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info, { bfd *dynobj = elf_hash_table (info)->dynobj; asection *s; - unsigned int power_of_two; #ifdef DEBUG fprintf (stderr, "i370_elf_adjust_dynamic_symbol called for %s\n", @@ -546,28 +545,7 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 4) - power_of_two = 4; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (! bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Increment the index of a dynamic symbol by a given amount. Called diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 35cb7c6..0e023df 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1419,7 +1419,6 @@ elf_i386_adjust_dynamic_symbol (struct bfd_link_info *info, { struct elf_i386_link_hash_table *htab; asection *s; - unsigned int power_of_two; /* If this is a function, put it in the procedure linkage table. We will fill in the contents of the procedure linkage table later, @@ -1539,29 +1538,9 @@ elf_i386_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ s = htab->sdynbss; - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) - { - if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) - return FALSE; - } - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 98ad8ee..31151fc 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1833,7 +1833,6 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, struct elf_m32r_dyn_relocs *p; bfd *dynobj; asection *s; - unsigned int power_of_two; #ifdef DEBUG_PIC printf ("m32r_elf_adjust_dynamic_symbol()\n"); @@ -1961,28 +1960,7 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (! bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 70d82ec..82fad32 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -1215,7 +1215,6 @@ elf_m68k_adjust_dynamic_symbol (info, h) struct elf_m68k_link_hash_table *htab; bfd *dynobj; asection *s; - unsigned int power_of_two; htab = elf_m68k_hash_table (info); dynobj = elf_hash_table (info)->dynobj; @@ -1360,28 +1359,7 @@ elf_m68k_adjust_dynamic_symbol (info, h) h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (!bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Set the sizes of the dynamic sections. */ diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 2f394d9..bf5bcf3 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -4136,7 +4136,6 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, { struct ppc_elf_link_hash_table *htab; asection *s; - unsigned int power_of_two; #ifdef DEBUG fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called for %s\n", @@ -4278,28 +4277,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 4) - power_of_two = 4; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) - { - if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Generate a symbol to mark plt call stubs. For non-PIC code the sym is diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 0b5ae80..9e36a5d 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1582,7 +1582,6 @@ elf_s390_adjust_dynamic_symbol (info, h) { struct elf_s390_link_hash_table *htab; asection *s; - unsigned int power_of_two; /* If this is a function, put it in the procedure linkage table. We will fill in the contents of the procedure linkage table later @@ -1703,29 +1702,9 @@ elf_s390_adjust_dynamic_symbol (info, h) h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ s = htab->sdynbss; - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) - { - if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) - return FALSE; - } - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 3d59e53..c982860 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -2489,7 +2489,6 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info, struct elf_sh_link_hash_entry *eh; struct elf_sh_dyn_relocs *p; asection *s; - unsigned int power_of_two; htab = sh_elf_hash_table (info); @@ -2613,28 +2612,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->root.dynobj, s)) - { - if (! bfd_set_section_alignment (htab->root.dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index ab7f7e24..aac81c1 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -925,7 +925,6 @@ elf_vax_adjust_dynamic_symbol (info, h) { bfd *dynobj; asection *s; - unsigned int power_of_two; dynobj = elf_hash_table (info)->dynobj; @@ -1079,28 +1078,7 @@ elf_vax_adjust_dynamic_symbol (info, h) h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (!bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Set the sizes of the dynamic sections. */ diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 8ffd70a..0e4f725 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -5799,7 +5799,6 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, { struct ppc_link_hash_table *htab; asection *s; - unsigned int power_of_two; htab = ppc_hash_table (info); @@ -5920,29 +5919,9 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 4) - power_of_two = 4; - - /* Apply the required alignment. */ s = htab->dynbss; - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) - { - if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) - return FALSE; - } - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* If given a function descriptor symbol, hide both the function code diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 78e8c84..47fbff6 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1557,7 +1557,6 @@ elf_s390_adjust_dynamic_symbol (info, h) { struct elf_s390_link_hash_table *htab; asection *s; - unsigned int power_of_two; /* If this is a function, put it in the procedure linkage table. We will fill in the contents of the procedure linkage table later @@ -1678,29 +1677,9 @@ elf_s390_adjust_dynamic_symbol (info, h) h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ s = htab->sdynbss; - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) - { - if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) - return FALSE; - } - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index b7600ec..969e312 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -3324,7 +3324,6 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info, { bfd *dynobj; asection *s; - unsigned int power_of_two; dynobj = elf_hash_table (info)->dynobj; @@ -3464,28 +3463,7 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 3) - power_of_two = 3; - - /* Apply the required alignment. */ - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (! bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* This function is called via sh_elf_link_hash_traverse if we are diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 236079a..0ee75ce 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1287,7 +1287,6 @@ elf64_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info, { struct elf64_x86_64_link_hash_table *htab; asection *s; - unsigned int power_of_two; /* If this is a function, put it in the procedure linkage table. We will fill in the contents of the procedure linkage table later, @@ -1405,32 +1404,9 @@ elf64_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. 16-bytes is the size - of the largest type that requires hard alignment -- long double. */ - /* FIXME: This is VERY ugly. Should be fixed for all architectures using - this construct. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 4) - power_of_two = 4; - - /* Apply the required alignment. */ s = htab->sdynbss; - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) - { - if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) - return FALSE; - } - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for 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. */ diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 4c0fbcf..e4ddb37 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -7018,7 +7018,6 @@ _bfd_mips_vxworks_adjust_dynamic_symbol (struct bfd_link_info *info, bfd *dynobj; struct mips_elf_link_hash_entry *hmips; struct mips_elf_link_hash_table *htab; - unsigned int power_of_two; htab = mips_elf_hash_table (info); dynobj = elf_hash_table (info)->dynobj; @@ -7141,26 +7140,7 @@ _bfd_mips_vxworks_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > 4) - power_of_two = 4; - - /* Apply the required alignment. */ - htab->sdynbss->size = BFD_ALIGN (htab->sdynbss->size, - (bfd_size_type) 1 << power_of_two); - if (power_of_two > bfd_get_section_alignment (dynobj, htab->sdynbss) - && !bfd_set_section_alignment (dynobj, htab->sdynbss, power_of_two)) - return FALSE; - - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = htab->sdynbss; - h->root.u.def.value = htab->sdynbss->size; - - /* Increment the section size to make room for the symbol. */ - htab->sdynbss->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, htab->sdynbss); } /* Return the number of dynamic section symbols required by OUTPUT_BFD. diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index 3fab8ee..708af29 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -1701,7 +1701,6 @@ _bfd_sparc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, struct _bfd_sparc_elf_link_hash_entry * eh; struct _bfd_sparc_elf_dyn_relocs *p; asection *s; - unsigned int power_of_two; htab = _bfd_sparc_elf_hash_table (info); @@ -1818,29 +1817,9 @@ _bfd_sparc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - /* We need to figure out the alignment required for this symbol. I - have no idea how ELF linkers handle this. */ - power_of_two = bfd_log2 (h->size); - if (power_of_two > htab->align_power_max) - power_of_two = htab->align_power_max; - - /* Apply the required alignment. */ s = htab->sdynbss; - s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); - if (power_of_two > bfd_get_section_alignment (dynobj, s)) - { - if (! bfd_set_section_alignment (dynobj, s, power_of_two)) - return FALSE; - } - /* Define the symbol as being at this point in the section. */ - h->root.u.def.section = s; - h->root.u.def.value = s->size; - - /* Increment the section size to make room for the symbol. */ - s->size += h->size; - - return TRUE; + return _bfd_elf_adjust_dynamic_copy (h, s); } /* Allocate space in .plt, .got and associated reloc sections for |