* aout-adobe.c (aout_32_bfd_define_common_symbol): Define.
	* aout-target.h (MY_bfd_define_common_symbol): Likewise.
	* aout-tic30.c (MY_bfd_define_common_symbol): Likewise.
	* binary.c (binary_bfd_define_common_symbol): Likewise.
	* bout.c (b_out_bfd_define_common_symbol): Likewise.
	* coff-alpha.c (_bfd_ecoff_bfd_define_common_symbol): Likewise.
	* coff-mips.c (_bfd_ecoff_bfd_define_common_symbol): Likewise.
	* coffcode.h (coff_bfd_define_common_symbol): Likewise.
	* elfxx-target.h (bfd_elfNN_bfd_define_common_symbol): Likewise.
	* i386msdos.c (msdos_bfd_define_common_symbol): Likewise.
	* i386os9k.c (os9k_bfd_define_common_symbol): Likewise.
	* ieee.c (ieee_bfd_define_common_symbol): Likewise.
	* ihex.c (ihex_bfd_define_common_symbol): Likewise.
	* libbfd-in.h (_bfd_nolink_bfd_define_common_symbol): Likewise.
	* mach-o.c (bfd_mach_o_bfd_define_common_symbol): Likewise.
	* mmo.c (mmo_bfd_define_common_symbol): Likewise.
	* nlm-target.h (nlm_bfd_define_common_symbol): Likewise.
	* oasys.c (oasys_bfd_define_common_symbol): Likewise.
	* pef.c (bfd_pef_bfd_define_common_symbol): Likewise.
	* ppcboot.c (ppcboot_bfd_define_common_symbol): Likewise.
	* som.c (som_bfd_define_common_symbol): Likewise.
	* srec.c (srec_bfd_define_common_symbol): Likewise.
	* tekhex.c (tekhex_bfd_define_common_symbol): Likewise.
	* versados.c (versados_bfd_define_common_symbol): Likewise.
	* vms.c (vms_bfd_define_common_symbol): Likewise.
	* xcoff-target.h (_bfd_xcoff_bfd_define_common_symbol): Likewise.
	* xsym.c (bfd_sym_bfd_define_common_symbol): Likewise.
	* coff-rs6000.c (rs6000coff_vec): Add _bfd_xcoff_define_common_symbol.
	(pmac_xcoff_vec): Likewise.
	* coff64-rs6000.c (rs6000coff64_vec): Likewise.
	(aix5coff64_vec): Likewise.
	* linker.c (bfd_generic_define_common_symbol): New function.
	* targets.c (BFD_JUMP_TABLE_LINK): Add NAME##_bfd_define_common_symbol.
	(_bfd_define_common_symbol): New field.
	* libcoff-in.h (_bfd_xcoff_define_common_symbol): Declare.
	* xcofflink.c (_bfd_xcoff_define_common_symbol): New function.
	(xcoff_build_ldsyms): Don't set XCOFF_DEF_REGULAR for common
	symbols here.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Likewise.
	* libcoff.h: Likewise.

ld/
	* ldlang.c (lang_one_common): Use bfd_define_common_symbol.

ld/testsuite/
	* ld-powerpc/aix-export-2.s, ld-powerpc/aix-export-2.nd: New test.
	* ld-powerpc/aix52.exp: Run it.
This commit is contained in:
Richard Sandiford
2009-04-16 23:07:00 +00:00
parent 1554e9be88
commit 3023e3f66a
43 changed files with 205 additions and 36 deletions

View File

@@ -3186,3 +3186,62 @@ _bfd_fix_excluded_sec_syms (bfd *obfd, struct bfd_link_info *info)
{
bfd_link_hash_traverse (info->hash, fix_syms, obfd);
}
/*
FUNCTION
bfd_generic_define_common_symbol
SYNOPSIS
bfd_boolean bfd_generic_define_common_symbol
(bfd *output_bfd, struct bfd_link_info *info,
struct bfd_link_hash_entry *h);
DESCRIPTION
Convert common symbol @var{h} into a defined symbol.
Return TRUE on success and FALSE on failure.
.#define bfd_define_common_symbol(output_bfd, info, h) \
. BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
.
*/
bfd_boolean
bfd_generic_define_common_symbol (bfd *output_bfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
struct bfd_link_hash_entry *h)
{
unsigned int power_of_two;
bfd_vma alignment, size;
asection *section;
BFD_ASSERT (h != NULL && h->type == bfd_link_hash_common);
size = h->u.c.size;
power_of_two = h->u.c.p->alignment_power;
section = h->u.c.p->section;
/* Increase the size of the section to align the common symbol.
The alignment must be a power of two. */
alignment = bfd_octets_per_byte (output_bfd) << power_of_two;
BFD_ASSERT (alignment != 0 && (alignment & -alignment) == alignment);
section->size += alignment - 1;
section->size &= -alignment;
/* Adjust the section's overall alignment if necessary. */
if (power_of_two > section->alignment_power)
section->alignment_power = power_of_two;
/* Change the symbol from common to defined. */
h->type = bfd_link_hash_defined;
h->u.def.section = section;
h->u.def.value = section->size;
/* Increase the size of the section. */
section->size += size;
/* Make sure the section is allocated in memory, and make sure that
it is no longer a common section. */
section->flags |= SEC_ALLOC;
section->flags &= ~SEC_IS_COMMON;
return TRUE;
}