bfd/
authorRichard Sandiford <rdsandiford@googlemail.com>
Thu, 16 Apr 2009 23:07:00 +0000 (23:07 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Thu, 16 Apr 2009 23:07:00 +0000 (23:07 +0000)
* 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.

43 files changed:
bfd/ChangeLog
bfd/aout-adobe.c
bfd/aout-target.h
bfd/aout-tic30.c
bfd/bfd-in2.h
bfd/binary.c
bfd/bout.c
bfd/coff-alpha.c
bfd/coff-mips.c
bfd/coff-rs6000.c
bfd/coff64-rs6000.c
bfd/coffcode.h
bfd/elfxx-target.h
bfd/i386msdos.c
bfd/i386os9k.c
bfd/ieee.c
bfd/ihex.c
bfd/libbfd-in.h
bfd/libbfd.h
bfd/libcoff-in.h
bfd/libcoff.h
bfd/linker.c
bfd/mach-o.c
bfd/mmo.c
bfd/nlm-target.h
bfd/oasys.c
bfd/pef.c
bfd/ppcboot.c
bfd/som.c
bfd/srec.c
bfd/targets.c
bfd/tekhex.c
bfd/versados.c
bfd/vms.c
bfd/xcoff-target.h
bfd/xcofflink.c
bfd/xsym.c
ld/ChangeLog
ld/ldlang.c
ld/testsuite/ChangeLog
ld/testsuite/ld-powerpc/aix-export-2.nd [new file with mode: 0644]
ld/testsuite/ld-powerpc/aix-export-2.s [new file with mode: 0644]
ld/testsuite/ld-powerpc/aix52.exp

index 0917e65159f83eb40f987126041701b0e649d656..2eadbd0ad4837cfc3c2764b20cce333aa68d80bd 100644 (file)
@@ -1,3 +1,47 @@
+2009-04-16  Richard Sandiford  <r.sandiford@uk.ibm.com>
+
+       * 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.
+
 2009-04-15  Anthony Green  <green@moxielogic.com>
 
        * targets.c: Add moxie support.
index 8ccaf429f98f32e53e75aeeac8e6458b6b110e25..a8b13f497ad8a8764179c986b3a3c0adb67dcd66 100644 (file)
@@ -463,6 +463,7 @@ aout_adobe_sizeof_headers (bfd *ignore_abfd ATTRIBUTE_UNUSED,
 #define aout_32_bfd_is_group_section               bfd_generic_is_group_section
 #define aout_32_bfd_discard_group                  bfd_generic_discard_group
 #define aout_32_section_already_linked              _bfd_generic_section_already_linked
+#define aout_32_bfd_define_common_symbol            bfd_generic_define_common_symbol
 #define aout_32_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define aout_32_bfd_link_hash_table_free            _bfd_generic_link_hash_table_free
 #define aout_32_bfd_link_add_symbols               _bfd_generic_link_add_symbols
index c063d039566776378f14b172e16001b5161370d6..07a0870c9aa38402e6eedb0be7b9ab1f10bbad91 100644 (file)
@@ -493,6 +493,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #define MY_section_already_linked \
   _bfd_generic_section_already_linked
 #endif
+#ifndef MY_bfd_define_common_symbol
+#define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
+#endif
 #ifndef MY_bfd_reloc_type_lookup
 #define MY_bfd_reloc_type_lookup NAME (aout, reloc_type_lookup)
 #endif
index 49815c4fdfb47f1413d0d9ca50f830a0371680f4..a95bca15207deeeb40be4b6d5cb65055b1d30fd0 100644 (file)
@@ -950,6 +950,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #define MY_section_already_linked \
   _bfd_generic_section_already_linked
 #endif
+#ifndef MY_bfd_define_common_symbol
+#define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
+#endif
 #ifndef MY_bfd_reloc_type_lookup
 #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
 #endif
index bb2cbc3c061bd6034f46845de2755c82fd4661be..2c6452ff6fec1dd454fc99eb6f734c8f6dc87c96 100644 (file)
@@ -5458,7 +5458,8 @@ typedef struct bfd_target
   NAME##_bfd_merge_sections, \
   NAME##_bfd_is_group_section, \
   NAME##_bfd_discard_group, \
-  NAME##_section_already_linked \
+  NAME##_section_already_linked, \
+  NAME##_bfd_define_common_symbol
 
   int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
   bfd_byte *  (*_bfd_get_relocated_section_contents)
@@ -5506,6 +5507,10 @@ typedef struct bfd_target
   void (*_section_already_linked) (bfd *, struct bfd_section *,
                                    struct bfd_link_info *);
 
+  /* Define a common symbol.  */
+  bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
+                                            struct bfd_link_hash_entry *);
+
   /* Routines to handle dynamic symbols and relocs.  */
 #define BFD_JUMP_TABLE_DYNAMIC(NAME) \
   NAME##_get_dynamic_symtab_upper_bound, \
@@ -5570,6 +5575,13 @@ void bfd_section_already_linked (bfd *abfd, asection *sec,
 #define bfd_section_already_linked(abfd, sec, info) \
        BFD_SEND (abfd, _section_already_linked, (abfd, sec, info))
 
+bfd_boolean bfd_generic_define_common_symbol
+   (bfd *output_bfd, struct bfd_link_info *info,
+    struct bfd_link_hash_entry *h);
+
+#define bfd_define_common_symbol(output_bfd, info, h) \
+       BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
+
 /* Extracted from simple.c.  */
 bfd_byte *bfd_simple_get_relocated_section_contents
    (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table);
index c4aec2ba61505d3de7aa56dcd0a3160db0903611..7e9bf102dd315f470c41e545c428a0234e4128f6 100644 (file)
@@ -316,6 +316,7 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define binary_bfd_is_group_section                bfd_generic_is_group_section
 #define binary_bfd_discard_group                   bfd_generic_discard_group
 #define binary_section_already_linked             _bfd_generic_section_already_linked
+#define binary_bfd_define_common_symbol            bfd_generic_define_common_symbol
 #define binary_bfd_link_hash_table_create         _bfd_generic_link_hash_table_create
 #define binary_bfd_link_hash_table_free           _bfd_generic_link_hash_table_free
 #define binary_bfd_link_just_syms                 _bfd_generic_link_just_syms
index b6c710631aca4a835e3675ebc00c53f53e36205c..f4800d5acdc2664b192bfcd0dd1e53c76e9a9c0f 100644 (file)
@@ -1389,6 +1389,7 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd,
 #define b_out_bfd_is_group_section             bfd_generic_is_group_section
 #define b_out_bfd_discard_group                bfd_generic_discard_group
 #define b_out_section_already_linked           _bfd_generic_section_already_linked
+#define b_out_bfd_define_common_symbol         bfd_generic_define_common_symbol
 #define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
 
 extern const bfd_target b_out_vec_little_host;
index efe2dd395587ec27c4e3af9790d65468525afe72..cd69043a26e27f8aa5378ffed175331eee19f6cc 100644 (file)
@@ -2398,6 +2398,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
 #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group
 #define _bfd_ecoff_section_already_linked \
   _bfd_generic_section_already_linked
+#define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
 
 const bfd_target ecoffalpha_little_vec =
 {
index f82c52dec91816c427b2435c473c7aa751ff0003..5fd35104c22e5342d5a770975445022e747b6d12 100644 (file)
@@ -1417,6 +1417,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group
 #define _bfd_ecoff_section_already_linked \
   _bfd_generic_section_already_linked
+#define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
 
 extern const bfd_target ecoff_big_vec;
 
index c5a486bab6b273aaf3be1e4c42c1f8ed16a0d851..4859f31b2b4c3f57511684fa9e8b71b7d402d327 100644 (file)
@@ -4233,6 +4233,7 @@ const bfd_target rs6000coff_vec =
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
+    _bfd_xcoff_define_common_symbol,
 
     /* Dynamic */
     _bfd_xcoff_get_dynamic_symtab_upper_bound,
@@ -4485,6 +4486,7 @@ const bfd_target pmac_xcoff_vec =
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
+    _bfd_xcoff_define_common_symbol,
 
     /* Dynamic */
     _bfd_xcoff_get_dynamic_symtab_upper_bound,
index 1a0ff59713e892e50dd96ae29b89b04a3cd2643f..3a27ee07ce51ff856b0771578faedfd729b6b3e3 100644 (file)
@@ -2805,6 +2805,7 @@ const bfd_target rs6000coff64_vec =
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
+    _bfd_xcoff_define_common_symbol,
 
     /* Dynamic */
     _bfd_xcoff_get_dynamic_symtab_upper_bound,
@@ -3058,6 +3059,7 @@ const bfd_target aix5coff64_vec =
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
+    _bfd_xcoff_define_common_symbol,
 
     /* Dynamic */
     _bfd_xcoff_get_dynamic_symtab_upper_bound,
index 35c6f70758238995ae08af293903d8cc1eb5acc1..11cc457f207da727033c23515e9ad6b22cf8b62a 100644 (file)
@@ -5600,6 +5600,10 @@ static bfd_coff_backend_data ticoff1_swap_table =
   _bfd_generic_section_already_linked
 #endif
 
+#ifndef coff_bfd_define_common_symbol
+#define coff_bfd_define_common_symbol      bfd_generic_define_common_symbol
+#endif
+
 #define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE)    \
 const bfd_target VAR =                                                 \
 {                                                                      \
index 4aa8dd4b68f88ae7eb9bcc7953af396332b51308..d4cad168d91f51912c859bfc875bb9bbe34d2c5c 100644 (file)
   _bfd_elf_section_already_linked
 #endif
 
+#ifndef bfd_elfNN_bfd_define_common_symbol
+#define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol
+#endif
+
 #ifndef bfd_elfNN_bfd_make_debug_symbol
 #define bfd_elfNN_bfd_make_debug_symbol \
   ((asymbol * (*) (bfd *, void *, unsigned long)) bfd_nullvoidptr)
index 46489fa74635e24fa52f111a45d72d0504d99330..317adb80e41c72ba771ae00c6d7589a20ab984f6 100644 (file)
@@ -148,6 +148,7 @@ msdos_set_section_contents (bfd *abfd,
 #define msdos_bfd_discard_group bfd_generic_discard_group
 #define msdos_section_already_linked \
   _bfd_generic_section_already_linked
+#define msdos_bfd_define_common_symbol bfd_generic_define_common_symbol
 #define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define msdos_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
index fa4fc425565344b48c3fdb444b0ed1ffd8a9a3f7..17c437204614f764755aac174ba7866f81d13022 100644 (file)
@@ -172,6 +172,7 @@ os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define os9k_bfd_discard_group bfd_generic_discard_group
 #define os9k_section_already_linked \
   _bfd_generic_section_already_linked
+#define os9k_bfd_define_common_symbol bfd_generic_define_common_symbol
 #define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define os9k_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
index d032e9c133a3246913b59ff7e933433c4753f9f9..7d79124f3d7a76551fab21e523f9297e2e948b07 100644 (file)
@@ -3770,6 +3770,7 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ieee_bfd_discard_group bfd_generic_discard_group
 #define ieee_section_already_linked \
   _bfd_generic_section_already_linked
+#define ieee_bfd_define_common_symbol bfd_generic_define_common_symbol
 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
index 47e857ca1a0497dfa48772b797ba4b6a6bf34ed4..c14c17ade28ab22526b3abd91d11b18e6a62f681 100644 (file)
@@ -933,6 +933,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ihex_bfd_is_group_section                 bfd_generic_is_group_section
 #define ihex_bfd_discard_group                    bfd_generic_discard_group
 #define ihex_section_already_linked               _bfd_generic_section_already_linked
+#define ihex_bfd_define_common_symbol             bfd_generic_define_common_symbol
 #define ihex_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define ihex_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
 #define ihex_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
index 949a2d2dc7494d7bba35957cc0319a5b21c0f72d..c860a29312c00cac6bfa3f064997548d317a4a55 100644 (file)
@@ -416,6 +416,9 @@ extern bfd_boolean _bfd_generic_set_section_contents
   ((bfd_boolean (*) (bfd *, struct bfd_section *)) bfd_false)
 #define _bfd_nolink_section_already_linked \
   ((void (*) (bfd *, struct bfd_section *, struct bfd_link_info *)) bfd_void)
+#define _bfd_nolink_bfd_define_common_symbol \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, \
+                    struct bfd_link_hash_entry *)) bfd_false)
 
 /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
    have dynamic symbols or relocs.  Use BFD_JUMP_TABLE_DYNAMIC
index 9d83209d35980b5456a98cc100e78609b316963d..7fc58a4e677b5f2239c3f931f70d8e536a5b96f1 100644 (file)
@@ -421,6 +421,9 @@ extern bfd_boolean _bfd_generic_set_section_contents
   ((bfd_boolean (*) (bfd *, struct bfd_section *)) bfd_false)
 #define _bfd_nolink_section_already_linked \
   ((void (*) (bfd *, struct bfd_section *, struct bfd_link_info *)) bfd_void)
+#define _bfd_nolink_bfd_define_common_symbol \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, \
+                    struct bfd_link_hash_entry *)) bfd_false)
 
 /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
    have dynamic symbols or relocs.  Use BFD_JUMP_TABLE_DYNAMIC
index c041be232bfcf477780c590c7336147567e8e9f7..0aa3d3707aebd9b510c114cf9411357100be34e2 100644 (file)
@@ -589,6 +589,8 @@ extern bfd_boolean _bfd_xcoff_bfd_link_add_symbols
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean _bfd_xcoff_bfd_final_link
   (bfd *, struct bfd_link_info *);
+extern bfd_boolean _bfd_xcoff_define_common_symbol
+  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
 extern bfd_boolean _bfd_ppc_xcoff_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    struct internal_reloc *, struct internal_syment *, asection **);
index f963ce163c57c13eee4742d6e02e572df80963c8..a053f6bf9e2f8e1e56b428c958d613059639083e 100644 (file)
@@ -593,6 +593,8 @@ extern bfd_boolean _bfd_xcoff_bfd_link_add_symbols
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean _bfd_xcoff_bfd_final_link
   (bfd *, struct bfd_link_info *);
+extern bfd_boolean _bfd_xcoff_define_common_symbol
+  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
 extern bfd_boolean _bfd_ppc_xcoff_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    struct internal_reloc *, struct internal_syment *, asection **);
index 6242bcbc65dd108fa826150d3b591774d7026167..bfbd8861ddd50708121f84d031cfad872047b85b 100644 (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;
+}
index e0a6fa4772fcdda89612a69e0a5811af2e131f80..df15312b3cf61814532111dbc8b312fd47fe3ced 100644 (file)
@@ -72,6 +72,7 @@
 #define bfd_mach_o_bfd_is_group_section               bfd_generic_is_group_section
 #define bfd_mach_o_bfd_discard_group                  bfd_generic_discard_group
 #define bfd_mach_o_section_already_linked             _bfd_generic_section_already_linked
+#define bfd_mach_o_bfd_define_common_symbol           bfd_generic_define_common_symbol
 #define bfd_mach_o_bfd_copy_private_header_data       _bfd_generic_bfd_copy_private_header_data
 #define bfd_mach_o_core_file_matches_executable_p     generic_core_file_matches_executable_p
 
index c0e8082826f81f5092a4292423d93bc48677f51e..084ce3f6a7f722ef48e88aa457386f5fa9e540de 100644 (file)
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3211,6 +3211,7 @@ mmo_write_object_contents (bfd *abfd)
 #define mmo_bfd_discard_group bfd_generic_discard_group
 #define mmo_section_already_linked \
   _bfd_generic_section_already_linked
+#define mmo_bfd_define_common_symbol bfd_generic_define_common_symbol
 
 /* We want to copy time of creation, otherwise we'd use
    BFD_JUMP_TABLE_COPY (_bfd_generic).  */
index d346dc5a1f99bd12584c87b2ad351cfc94cb5061..f817714c54e3ce85c5df7fb4c32aed9c961822f1 100644 (file)
@@ -49,6 +49,7 @@
 #define nlm_bfd_is_group_section                bfd_generic_is_group_section
 #define nlm_bfd_discard_group                   bfd_generic_discard_group
 #define nlm_section_already_linked              _bfd_generic_section_already_linked
+#define nlm_bfd_define_common_symbol            bfd_generic_define_common_symbol
 #define nlm_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define nlm_bfd_link_hash_table_free            _bfd_generic_link_hash_table_free
 #define nlm_bfd_link_add_symbols                _bfd_generic_link_add_symbols
index b1ca5271aab1fd80ef99da884a3889ce5abdb6d4..c83d3ea257bb38830ca3002337489318ee6683a4 100644 (file)
@@ -1198,6 +1198,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define oasys_bfd_is_group_section                 bfd_generic_is_group_section
 #define oasys_bfd_discard_group                    bfd_generic_discard_group
 #define oasys_section_already_linked               _bfd_generic_section_already_linked
+#define oasys_bfd_define_common_symbol             bfd_generic_define_common_symbol
 #define oasys_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define oasys_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
 #define oasys_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
index b839095146d157529eaf9eba5b39509074dd054b..f275ee77f073255d96bbf4286cd6ff4afe53d29c 100644 (file)
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -52,6 +52,7 @@
 #define bfd_pef_bfd_is_group_section               bfd_generic_is_group_section
 #define bfd_pef_bfd_discard_group                   bfd_generic_discard_group
 #define bfd_pef_section_already_linked             _bfd_generic_section_already_linked
+#define bfd_pef_bfd_define_common_symbol            bfd_generic_define_common_symbol
 #define bfd_pef_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define bfd_pef_bfd_link_hash_table_free            _bfd_generic_link_hash_table_free
 #define bfd_pef_bfd_link_add_symbols                _bfd_generic_link_add_symbols
index d51280c8d8a6f4c7653a349c841a0782bb722afd..a420df3f54d4e62cac9de8e9d32efc33f65530f6 100644 (file)
@@ -475,6 +475,7 @@ ppcboot_bfd_print_private_bfd_data (abfd, farg)
 #define ppcboot_bfd_discard_group bfd_generic_discard_group
 #define ppcboot_section_already_linked \
   _bfd_generic_section_already_linked
+#define ppcboot_bfd_define_common_symbol bfd_generic_define_common_symbol
 #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ppcboot_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
index ccf760ab5d44e7ced71ec6a097acefcf13b961d4..96da72e53fde87d6f57a48728b0618245307fa3e 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6349,6 +6349,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 #define som_bfd_is_group_section               bfd_generic_is_group_section
 #define som_bfd_discard_group                  bfd_generic_discard_group
 #define som_section_already_linked              _bfd_generic_section_already_linked
+#define som_bfd_define_common_symbol            bfd_generic_define_common_symbol
 #define som_bfd_merge_private_bfd_data         _bfd_generic_bfd_merge_private_bfd_data
 #define som_bfd_copy_private_header_data       _bfd_generic_bfd_copy_private_header_data
 #define som_bfd_set_private_flags              _bfd_generic_bfd_set_private_flags
index b7d515ccb9ec60e1919d9ff354bf942df9a29a75..83e4538d2a3c6f11516c242c9ba7e35f8a44df54 100644 (file)
@@ -1255,6 +1255,7 @@ srec_print_symbol (bfd *abfd,
 #define srec_bfd_is_group_section                 bfd_generic_is_group_section
 #define srec_bfd_discard_group                    bfd_generic_discard_group
 #define srec_section_already_linked               _bfd_generic_section_already_linked
+#define srec_bfd_define_common_symbol             bfd_generic_define_common_symbol
 #define srec_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define srec_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
 #define srec_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
index a52b37d44280a3136c4d1dc7d89ce0b5178c05cc..c9d4c31fab0aec071f09dfd1960c9ea5b1b75307 100644 (file)
@@ -441,7 +441,8 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_merge_sections, \
 .  NAME##_bfd_is_group_section, \
 .  NAME##_bfd_discard_group, \
-.  NAME##_section_already_linked \
+.  NAME##_section_already_linked, \
+.  NAME##_bfd_define_common_symbol
 .
 .  int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
 .  bfd_byte *  (*_bfd_get_relocated_section_contents)
@@ -489,6 +490,10 @@ BFD_JUMP_TABLE macros.
 .  void (*_section_already_linked) (bfd *, struct bfd_section *,
 .                                  struct bfd_link_info *);
 .
+.  {* Define a common symbol.  *}
+.  bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
+.                                           struct bfd_link_hash_entry *);
+.
 .  {* Routines to handle dynamic symbols and relocs.  *}
 .#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
 .  NAME##_get_dynamic_symtab_upper_bound, \
index 2df774fc00fce971450f6de0817f82d4c774ede0..01853da06d33cce97ac1a7e4734815b428361a6b 100644 (file)
@@ -943,6 +943,7 @@ tekhex_print_symbol (bfd *abfd,
 #define tekhex_bfd_is_group_section                 bfd_generic_is_group_section
 #define tekhex_bfd_discard_group                    bfd_generic_discard_group
 #define tekhex_section_already_linked               _bfd_generic_section_already_linked
+#define tekhex_bfd_define_common_symbol             bfd_generic_define_common_symbol
 #define tekhex_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define tekhex_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
 #define tekhex_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
index c4decd6f3ed5bf858a841729e08e963cb50d2cbd..db9bd53fe0b39056e555dce5922f3822f93b96d7 100644 (file)
@@ -808,6 +808,7 @@ versados_canonicalize_reloc (bfd *abfd,
 #define versados_bfd_is_group_section                 bfd_generic_is_group_section
 #define versados_bfd_discard_group                    bfd_generic_discard_group
 #define versados_section_already_linked               _bfd_generic_section_already_linked
+#define versados_bfd_define_common_symbol             bfd_generic_define_common_symbol
 #define versados_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define versados_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
 #define versados_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
index 8111d4955e2de5a99ea957b4d71627a3e97f5927..ac03480278d3875be97538bebf4e193f9f70a870 100644 (file)
--- a/bfd/vms.c
+++ b/bfd/vms.c
@@ -144,6 +144,7 @@ static bfd_boolean vms_bfd_set_private_flags (bfd *abfd, flagword flags);
 #define vms_bfd_is_group_section          bfd_generic_is_group_section
 #define vms_bfd_discard_group             bfd_generic_discard_group
 #define vms_section_already_linked        _bfd_generic_section_already_linked
+#define vms_bfd_define_common_symbol      bfd_generic_define_common_symbol
 #define vms_bfd_copy_private_header_data  _bfd_generic_bfd_copy_private_header_data
 #define vms_get_synthetic_symtab          _bfd_nodynamic_get_synthetic_symtab
 
index 8212a0da400b259415c315eabba7bfa1aaa53e45..bcea6508696dbe6b8ea72a9605c8ff18c0d1ea98 100644 (file)
@@ -57,6 +57,7 @@
 #define _bfd_xcoff_bfd_merge_sections                  coff_bfd_merge_sections
 #define _bfd_xcoff_bfd_discard_group                   bfd_generic_discard_group
 #define _bfd_xcoff_section_already_linked              _bfd_generic_section_already_linked
+#define _bfd_xcoff_bfd_define_common_symbol            _bfd_xcoff_define_common_symbol
 #define _bfd_xcoff_bfd_link_split_section              coff_bfd_link_split_section
 
 #define CORE_FILE_P _bfd_dummy_target
index 26500c6bd3116e61bdf4c062ef2b370a899c4f68..896292b393e8f8685dbcad1bb74e86c4dbae1953 100644 (file)
@@ -2471,6 +2471,21 @@ _bfd_xcoff_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
     }
 }
 \f
+bfd_boolean
+_bfd_xcoff_define_common_symbol (bfd *output_bfd ATTRIBUTE_UNUSED,
+                                struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                                struct bfd_link_hash_entry *harg)
+{
+  struct xcoff_link_hash_entry *h;
+
+  if (!bfd_generic_define_common_symbol (output_bfd, info, harg))
+    return FALSE;
+
+  h = (struct xcoff_link_hash_entry *) harg;
+  h->flags |= XCOFF_DEF_REGULAR;
+  return TRUE;
+}
+\f
 /* If symbol H has not been interpreted as a function descriptor,
    see whether it should be.  Set up its descriptor information if so.  */
 
@@ -3330,19 +3345,6 @@ xcoff_post_gc_symbol (struct xcoff_link_hash_entry *h, void * p)
   if (h->flags & XCOFF_RTINIT)
     return TRUE;
 
-  /* If this is a final link, and the symbol was defined as a common
-     symbol in a regular object file, and there was no definition in
-     any dynamic object, then the linker will have allocated space for
-     the symbol in a common section but the XCOFF_DEF_REGULAR flag
-     will not have been set.  */
-  if (h->root.type == bfd_link_hash_defined
-      && (h->flags & XCOFF_DEF_REGULAR) == 0
-      && (h->flags & XCOFF_REF_REGULAR) != 0
-      && (h->flags & XCOFF_DEF_DYNAMIC) == 0
-      && (bfd_is_abs_section (h->root.u.def.section)
-         || (h->root.u.def.section->owner->flags & DYNAMIC) == 0))
-    h->flags |= XCOFF_DEF_REGULAR;
-
   /* We don't want to garbage collect symbols which are not defined in
      XCOFF files.  This is a convenient place to mark them.  */
   if (xcoff_hash_table (ldinfo->info)->gc
index 793dd2414460dada0751f4be41234ef2255e85ca..706310ac6166c73b061f2775c7e2bff50076c238 100644 (file)
@@ -46,6 +46,7 @@
 #define bfd_sym_bfd_is_group_section                bfd_generic_is_group_section
 #define bfd_sym_bfd_discard_group                   bfd_generic_discard_group
 #define bfd_sym_section_already_linked              _bfd_generic_section_already_linked
+#define bfd_sym_bfd_define_common_symbol            bfd_generic_define_common_symbol
 #define bfd_sym_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define bfd_sym_bfd_link_hash_table_free            _bfd_generic_link_hash_table_free
 #define bfd_sym_bfd_link_add_symbols                _bfd_generic_link_add_symbols
index 099275dd487bf2b028fa67b47e8bd5c478c30cb0..befe0c68446b8f78688f03bc52a0c9d46cc1e995 100644 (file)
@@ -1,3 +1,7 @@
+2009-04-16  Richard Sandiford  <r.sandiford@uk.ibm.com>
+
+       * ldlang.c (lang_one_common): Use bfd_define_common_symbol.
+
 2009-04-15  Anthony Green  <green@moxielogic.com>
 
        * configure.tgt: Add moxie support.
index 412a86c5a4dfba5d99380a27bec1eefdfea44dc9..230994a90e5105e0acc4dcacc505b9f50c316b44 100644 (file)
@@ -5639,27 +5639,9 @@ lang_one_common (struct bfd_link_hash_entry *h, void *info)
     return TRUE;
 
   section = h->u.c.p->section;
-
-  /* Increase the size of the section to align the common sym.  */
-  section->size += ((bfd_vma) 1 << (power_of_two + opb_shift)) - 1;
-  section->size &= (- (bfd_vma) 1 << (power_of_two + opb_shift));
-
-  /* Adjust the 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;
+  if (!bfd_define_common_symbol (link_info.output_bfd, &link_info, h))
+    einfo (_("%P%F: Could not define common symbol `%T': %E\n"),
+          h->root.string);
 
   if (config.map_file != NULL)
     {
index 7718d840d952b948af406abf7c3c15af49f4296d..75b90500268dd139b94a8eb67ae603412acfb35d 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-16  Richard Sandiford  <r.sandiford@uk.ibm.com>
+
+       * ld-powerpc/aix-export-2.s, ld-powerpc/aix-export-2.nd: New test.
+       * ld-powerpc/aix52.exp: Run it.
+
 2009-04-16  Alan Modra  <amodra@bigpond.net.au>
 
        * ld-libs/lib-1.s: Use "==" instead of ".set".
diff --git a/ld/testsuite/ld-powerpc/aix-export-2.nd b/ld/testsuite/ld-powerpc/aix-export-2.nd
new file mode 100644 (file)
index 0000000..6f97433
--- /dev/null
@@ -0,0 +1 @@
+0*10000000 B x
diff --git a/ld/testsuite/ld-powerpc/aix-export-2.s b/ld/testsuite/ld-powerpc/aix-export-2.s
new file mode 100644 (file)
index 0000000..f720635
--- /dev/null
@@ -0,0 +1 @@
+       .comm   x,4
index 4d32b2d0065b9a28540281200d8a4e5fbd0c3a34..25479ddb39059860453722caa52b802e92a9fbdd 100644 (file)
@@ -128,6 +128,10 @@ set aix52tests {
      {{objdump -dj.data aix-export-1-full.dd}}
      "aix-export-1-full.so"}
 
+    {"Export test 2" "-shared -bexpall"
+     {} {aix-export-2.s}
+     {{nm -D aix-export-2.nd}} "aix-export-2.so"}
+
     {"Garbage collection test 1"
      "-shared -binitfini:init_function:fini_function -bE:aix-gc-1.ex"
      "" {aix-gc-1.s}