Browse Source

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.
binutils-2_18-branch
H.J. Lu 20 years ago
parent
commit
027297b7a8
  1. 28
      bfd/ChangeLog
  2. 3
      bfd/elf-bfd.h
  3. 24
      bfd/elf-m10300.c
  4. 24
      bfd/elf32-arm.c
  5. 27
      bfd/elf32-cris.c
  6. 24
      bfd/elf32-hppa.c
  7. 24
      bfd/elf32-i370.c
  8. 23
      bfd/elf32-i386.c
  9. 24
      bfd/elf32-m32r.c
  10. 24
      bfd/elf32-m68k.c
  11. 24
      bfd/elf32-ppc.c
  12. 23
      bfd/elf32-s390.c
  13. 24
      bfd/elf32-sh.c
  14. 24
      bfd/elf32-vax.c
  15. 23
      bfd/elf64-ppc.c
  16. 23
      bfd/elf64-s390.c
  17. 24
      bfd/elf64-sh64.c
  18. 26
      bfd/elf64-x86-64.c
  19. 46
      bfd/elflink.c
  20. 22
      bfd/elfxx-mips.c
  21. 23
      bfd/elfxx-sparc.c

28
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

3
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 *);

24
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. */

24
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

27
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. */

24
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.

24
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

23
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

24
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

24
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. */

24
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

23
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

24
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

24
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. */

23
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

23
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

24
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

26
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

46
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. */

22
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.

23
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

Loading…
Cancel
Save