Rewrite __start and __stop symbol handling
authorAlan Modra <amodra@gmail.com>
Fri, 16 Jun 2017 10:11:41 +0000 (19:41 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 16 Jun 2017 14:08:28 +0000 (23:38 +0930)
This arranges for __start and __stop symbols to be defined before
garbage collection, for all target formats.  That should allow the
COFF and PE --gc-sections to keep a singleton orphan input section,
a feature lost by 2017-06-13 commit cbd0eecf26.  The fancier ELF
treatment of keeping all input sections associated with a __start or
__stop symbol, from 2015-10-23 commit 1cce69b9dc, is retained.

.startof. and .sizeof. symbols are deliberately not defined before
garbage collection, so these won't affect garbage collection of
sections.

The patch also ensures __start, __stop, .startof. and .sizeof. symbols
are defined before target size_dynamic_sections is called, albeit
with a preliminary value, so that target code doesn't need to cope
with a symbol changing from undefined at size_dynamic_sections to
defined at relocate_section.

Also, a number of problems with the testcases have been fixed.

PR ld/20022
PR ld/21557
PR ld/21562
PR ld/21571
include/
* bfdlink.h (struct bfd_link_hash_entry): Delete undef.section.
bfd/
* targets.c (struct bfd_target): Add _bfd_define_start_stop.
(BFD_JUMP_TABLE_LINK): Likewise.
* elf-bfd.h (bfd_elf_define_start_stop): Declare.
* elflink.c (_bfd_elf_gc_mark_rsec): Update comment.
(bfd_elf_define_start_stop): New function.
* linker.c (bfd_generic_define_start_stop): New function.
* coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Init
new field.
* aout-adobe.c (aout_32_bfd_define_start_stop): Define.
* aout-target.h (MY_bfd_define_start_stop): Define.
* aout-tic30.c (MY_bfd_define_start_stop): Define.
* binary.c (binary_bfd_define_start_stop): Define.
* bout.c (b_out_bfd_define_start_stop): Define.
* coff-alpha.c (_bfd_ecoff_bfd_define_start_stop): Define.
* coff-mips.c (_bfd_ecoff_bfd_define_start_stop): Define.
* coff-rs6000.c (_bfd_xcoff_bfd_define_start_stop): Define.
* coffcode.h (coff_bfd_define_start_stop): Define.
* elfxx-target.h (bfd_elfNN_bfd_define_start_stop): Define.
* i386msdos.c (msdos_bfd_define_start_stop): Define.
* i386os9k.c (os9k_bfd_define_start_stop): Define.
* ieee.c (ieee_bfd_define_start_stop): Define.
* ihex.c (ihex_bfd_define_start_stop): Define.
* libbfd-in.h (_bfd_nolink_bfd_define_start_stop): Define.
* mach-o-target.c (bfd_mach_o_bfd_define_start_stop): Define.
* mmo.c (mmo_bfd_define_start_stop): Define.
* nlm-target.h (nlm_bfd_define_start_stop): Define.
* oasys.c (oasys_bfd_define_start_stop): Define.
* pef.c (bfd_pef_bfd_define_start_stop): Define.
* plugin.c (bfd_plugin_bfd_define_start_stop): Define.
* ppcboot.c (ppcboot_bfd_define_start_stop): Define.
* som.c (som_bfd_define_start_stop): Define.
* srec.c (srec_bfd_define_start_stop): Define.
* tekhex.c (tekhex_bfd_define_start_stop): Define.
* versados.c (versados_bfd_define_start_stop): Define.
* vms-alpha.c (vms_bfd_define_start_stop): Define.
(alpha_vms_bfd_define_start_stop): Define.
* xsym.c (bfd_sym_bfd_define_start_stop): Define.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't set
__start/__stop syms here.
* ldlang.c (lang_set_startof): Delete.
(start_stop_syms, start_stop_count, start_stop_alloc): New vars.
(lang_define_start_stop, lang_init_start_stop, foreach_start_stop,
undef_start_stop, lang_undef_start_stop, lang_init_startof_sizeof,
set_start_stop, lang_finalize_start_stop): New functions.
(lang_process): Call _start_stop functions.
* testsuite/ld-elf/pr21562a.d: Use xfail rather than notarget.
Correct typos and list of xfail targets.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562e.d: Likewise.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/sizeofa.d: Likewise.  Adjust to pass for generic ELF.
* testsuite/ld-elf/sizeofb.d: Likewise.
* testsuite/ld-elf/startofa.d: Likewise.
* testsuite/ld-elf/startofb.d: Likewise.

59 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/elf-bfd.h
bfd/elflink.c
bfd/elfxx-target.h
bfd/i386msdos.c
bfd/i386os9k.c
bfd/ieee.c
bfd/ihex.c
bfd/libbfd-in.h
bfd/libbfd.h
bfd/linker.c
bfd/mach-o-target.c
bfd/mmo.c
bfd/nlm-target.h
bfd/oasys.c
bfd/pef.c
bfd/plugin.c
bfd/ppcboot.c
bfd/som.c
bfd/srec.c
bfd/targets.c
bfd/tekhex.c
bfd/versados.c
bfd/vms-alpha.c
bfd/xsym.c
include/ChangeLog
include/bfdlink.h
ld/ChangeLog
ld/emultempl/elf32.em
ld/ldlang.c
ld/testsuite/ld-elf/pr21562a.d
ld/testsuite/ld-elf/pr21562b.d
ld/testsuite/ld-elf/pr21562c.d
ld/testsuite/ld-elf/pr21562d.d
ld/testsuite/ld-elf/pr21562e.d
ld/testsuite/ld-elf/pr21562f.d
ld/testsuite/ld-elf/pr21562g.d
ld/testsuite/ld-elf/pr21562h.d
ld/testsuite/ld-elf/pr21562i.d
ld/testsuite/ld-elf/pr21562j.d
ld/testsuite/ld-elf/pr21562k.d
ld/testsuite/ld-elf/pr21562l.d
ld/testsuite/ld-elf/pr21562m.d
ld/testsuite/ld-elf/pr21562n.d
ld/testsuite/ld-elf/sizeofa.d
ld/testsuite/ld-elf/sizeofb.d
ld/testsuite/ld-elf/startofa.d
ld/testsuite/ld-elf/startofb.d

index c7241babfeb4b7535dd8629189bc09907cf5656a..8d01021ffd4f233dacb8c7d8bf0ecc4c9ffffc91 100644 (file)
@@ -1,3 +1,49 @@
+2017-06-16  Alan Modra  <amodra@gmail.com>
+
+       PR ld/20022
+       PR ld/21557
+       PR ld/21562
+       PR ld/21571
+       * targets.c (struct bfd_target): Add _bfd_define_start_stop.
+       (BFD_JUMP_TABLE_LINK): Likewise.
+       * elf-bfd.h (bfd_elf_define_start_stop): Declare.
+       * elflink.c (_bfd_elf_gc_mark_rsec): Update comment.
+       (bfd_elf_define_start_stop): New function.
+       * linker.c (bfd_generic_define_start_stop): New function.
+       * coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Init
+       new field.
+       * aout-adobe.c (aout_32_bfd_define_start_stop): Define.
+       * aout-target.h (MY_bfd_define_start_stop): Define.
+       * aout-tic30.c (MY_bfd_define_start_stop): Define.
+       * binary.c (binary_bfd_define_start_stop): Define.
+       * bout.c (b_out_bfd_define_start_stop): Define.
+       * coff-alpha.c (_bfd_ecoff_bfd_define_start_stop): Define.
+       * coff-mips.c (_bfd_ecoff_bfd_define_start_stop): Define.
+       * coff-rs6000.c (_bfd_xcoff_bfd_define_start_stop): Define.
+       * coffcode.h (coff_bfd_define_start_stop): Define.
+       * elfxx-target.h (bfd_elfNN_bfd_define_start_stop): Define.
+       * i386msdos.c (msdos_bfd_define_start_stop): Define.
+       * i386os9k.c (os9k_bfd_define_start_stop): Define.
+       * ieee.c (ieee_bfd_define_start_stop): Define.
+       * ihex.c (ihex_bfd_define_start_stop): Define.
+       * libbfd-in.h (_bfd_nolink_bfd_define_start_stop): Define.
+       * mach-o-target.c (bfd_mach_o_bfd_define_start_stop): Define.
+       * mmo.c (mmo_bfd_define_start_stop): Define.
+       * nlm-target.h (nlm_bfd_define_start_stop): Define.
+       * oasys.c (oasys_bfd_define_start_stop): Define.
+       * pef.c (bfd_pef_bfd_define_start_stop): Define.
+       * plugin.c (bfd_plugin_bfd_define_start_stop): Define.
+       * ppcboot.c (ppcboot_bfd_define_start_stop): Define.
+       * som.c (som_bfd_define_start_stop): Define.
+       * srec.c (srec_bfd_define_start_stop): Define.
+       * tekhex.c (tekhex_bfd_define_start_stop): Define.
+       * versados.c (versados_bfd_define_start_stop): Define.
+       * vms-alpha.c (vms_bfd_define_start_stop): Define.
+       (alpha_vms_bfd_define_start_stop): Define.
+       * xsym.c (bfd_sym_bfd_define_start_stop): Define.
+       * bfd-in2.h: Regenerate.
+       * libbfd.h: Regenerate.
+
 2017-06-16  Jiong Wang  <jiong.wang@arm.com>
 
        * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use
index a2c927da23a66253dd1e2572c6a905c9b2798a0d..487ed8cb31f5aaacc73bf40ecb7bde530f06c199 100644 (file)
@@ -466,6 +466,7 @@ aout_adobe_sizeof_headers (bfd *ignore_abfd ATTRIBUTE_UNUSED,
 #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_define_start_stop               bfd_generic_define_start_stop
 #define aout_32_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define aout_32_bfd_link_add_symbols               _bfd_generic_link_add_symbols
 #define aout_32_bfd_link_just_syms                 _bfd_generic_link_just_syms
index 2e98c4d0f9d3191fc6310a5c7c8f1ef28924aa01..65bc44c8856b5f2669640226a3ac530e5dee885c 100644 (file)
@@ -513,6 +513,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_define_start_stop
+#define MY_bfd_define_start_stop bfd_generic_define_start_stop
+#endif
 #ifndef MY_bfd_reloc_type_lookup
 #define MY_bfd_reloc_type_lookup NAME (aout, reloc_type_lookup)
 #endif
index 5db3da7c34a5acc78ff5f9f5748ac5a872aa5251..068428c103faeba748d9bc3cac99d53c8a484899 100644 (file)
@@ -968,6 +968,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_define_start_stop
+#define MY_bfd_define_start_stop bfd_generic_define_start_stop
+#endif
 #ifndef MY_bfd_reloc_type_lookup
 #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
 #endif
index a23bb98b86f95324f3a376bac261246bc7a7aaf6..434879355b80c2892883c0c0b1804468ff4c5bdc 100644 (file)
@@ -7593,7 +7593,8 @@ typedef struct bfd_target
   NAME##_bfd_is_group_section, \
   NAME##_bfd_discard_group, \
   NAME##_section_already_linked, \
-  NAME##_bfd_define_common_symbol
+  NAME##_bfd_define_common_symbol, \
+  NAME##_bfd_define_start_stop
 
   int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
   bfd_byte *  (*_bfd_get_relocated_section_contents)
@@ -7657,6 +7658,11 @@ typedef struct bfd_target
   bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
                                             struct bfd_link_hash_entry *);
 
+  /* Define a __start, __stop, .startof. or .sizeof. symbol.  */
+  struct bfd_link_hash_entry *(*_bfd_define_start_stop) (struct bfd_link_info *,
+                                                         const char *,
+                                                         asection *);
+
   /* Routines to handle dynamic symbols and relocs.  */
 #define BFD_JUMP_TABLE_DYNAMIC(NAME) \
   NAME##_get_dynamic_symtab_upper_bound, \
@@ -7736,6 +7742,13 @@ bfd_boolean bfd_generic_define_common_symbol
 #define bfd_define_common_symbol(output_bfd, info, h) \
        BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
 
+struct bfd_link_hash_entry *bfd_generic_define_start_stop
+   (struct bfd_link_info *info,
+    const char *symbol, asection *sec);
+
+#define bfd_define_start_stop(output_bfd, info, symbol, sec) \
+       BFD_SEND (output_bfd, _bfd_define_start_stop, (info, symbol, sec))
+
 struct bfd_elf_version_tree * bfd_find_version_for_sym
    (struct bfd_elf_version_tree *verdefs,
     const char *sym_name, bfd_boolean *hide);
index 0a811cf2d223b96ed1fac2245e904909e74e081d..1018d562496780d759e424455966b59a6eabf9b9 100644 (file)
@@ -310,6 +310,7 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #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_define_start_stop               bfd_generic_define_start_stop
 #define binary_bfd_link_hash_table_create         _bfd_generic_link_hash_table_create
 #define binary_bfd_link_just_syms                 _bfd_generic_link_just_syms
 #define binary_bfd_copy_link_hash_symbol_type     _bfd_generic_copy_link_hash_symbol_type
index 0a6f8db0fbed17e1e7232d38a0cd929d9f46b546..33692d6c852118612e262b68001e463dd865fbae 100644 (file)
@@ -1390,6 +1390,7 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd,
 #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 b_out_bfd_define_start_stop            bfd_generic_define_start_stop
 #define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
 #define b_out_bfd_link_check_relocs            _bfd_generic_link_check_relocs
 #define b_out_set_reloc                               _bfd_generic_set_reloc
index 8ecba2f0d8f03fd7746adbee7ee718086ccb6b5e..47e3740568f0e436055e49584f0d0e59f02bbd1a 100644 (file)
@@ -2340,6 +2340,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_ecoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
 /* Installing internal relocations in a section is also generic.  */
index 45c65f8f8e7df82d528efd28c5030ed7f4b93e48..c3ade6216999d6d6ee206530af23e894f76c0f20 100644 (file)
@@ -1356,6 +1356,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
 #define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
 
 extern const bfd_target mips_ecoff_be_vec;
index b49e393e48f43938400985125293f64fe0086874..fabf971346fe863fed2232ec634b5def3498f78d 100644 (file)
@@ -4013,6 +4013,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 #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_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_xcoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
 /* For dynamic symbols and relocs entry points.  */
index 56458e0f0afe3388afa658510b5b515a57cf7154..525b079c44e09c3da241d2ca1a15cca58f24ad6d 100644 (file)
@@ -2746,6 +2746,7 @@ const bfd_target rs6000_xcoff64_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    bfd_generic_define_start_stop,
 
     /* Dynamic */
     _bfd_xcoff_get_dynamic_symtab_upper_bound,
@@ -3006,6 +3007,7 @@ const bfd_target rs6000_xcoff64_aix_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    bfd_generic_define_start_stop,
 
     /* Dynamic */
     _bfd_xcoff_get_dynamic_symtab_upper_bound,
index f9d3978b2d55a82963a1d8c6bc381a474df66190..3331f4cc51cb5f22e8d4ebe61bd1d21d1d46397b 100644 (file)
@@ -6061,6 +6061,10 @@ static bfd_coff_backend_data bigobj_swap_table =
 #define coff_bfd_define_common_symbol      bfd_generic_define_common_symbol
 #endif
 
+#ifndef coff_bfd_define_start_stop
+#define coff_bfd_define_start_stop         bfd_generic_define_start_stop
+#endif
+
 #define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE)    \
 const bfd_target VAR =                                                 \
 {                                                                      \
index fe15b93342ac7aa507b06744a28a314c051fd2a9..b889720e1f2e32c25f2000df031b1db0d07befe2 100644 (file)
@@ -2273,6 +2273,9 @@ extern bfd_reloc_status_type bfd_elf_perform_complex_relocation
 extern bfd_boolean _bfd_elf_setup_sections
   (bfd *);
 
+extern struct bfd_link_hash_entry *bfd_elf_define_start_stop
+  (struct bfd_link_info *, const char *, asection *);
+
 extern void _bfd_elf_post_process_headers (bfd * , struct bfd_link_info *);
 
 extern const bfd_target *bfd_elf32_object_p
index 9b0f54435201df5fdaab792490883957282a09bb..1a83b88be08018835508930a3a66c523ed398db4 100644 (file)
@@ -12738,11 +12738,9 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
 
       if (start_stop != NULL)
        {
-         /* To work around a glibc bug, mark all XXX input sections
-            when there is an as yet undefined reference to __start_XXX
-            or __stop_XXX symbols.  The linker will later define such
-            symbols for orphan input sections that have a name
-            representable as a C identifier.  */
+         /* To work around a glibc bug, mark XXX input sections
+            when there is a reference to __start_XXX or __stop_XXX
+            symbols.  */
          if (h->start_stop)
            {
              asection *s = h->u2.start_stop_section;
@@ -14193,3 +14191,25 @@ elf_append_rel (bfd *abfd, asection *s, Elf_Internal_Rela *rel)
   BFD_ASSERT (loc + bed->s->sizeof_rel <= s->contents + s->size);
   bed->s->swap_reloc_out (abfd, rel, loc);
 }
+
+/* Define __start, __stop, .startof. or .sizeof. symbol.  */
+
+struct bfd_link_hash_entry *
+bfd_elf_define_start_stop (struct bfd_link_info *info,
+                          const char *symbol, asection *sec)
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_generic_define_start_stop (info, symbol, sec);
+  if (h != NULL)
+    {
+      struct elf_link_hash_entry *eh = (struct elf_link_hash_entry *) h;
+      eh->start_stop = 1;
+      eh->u2.start_stop_section = sec;
+      _bfd_elf_link_hash_hide_symbol (info, eh, TRUE);
+      if (ELF_ST_VISIBILITY (eh->other) != STV_INTERNAL)
+       eh->other = ((eh->other & ~ELF_ST_VISIBILITY (-1))
+                    | STV_HIDDEN);
+    }
+  return h;
+}
index 072efaa93d7bf5735889657abe7c800ad5bac61f..551883fa094c73373acf01cbaac9b8f2ca70780b 100644 (file)
 #ifndef bfd_elfNN_bfd_link_add_symbols
 #define bfd_elfNN_bfd_link_add_symbols bfd_elf_link_add_symbols
 #endif
+#ifndef bfd_elfNN_bfd_define_start_stop
+#define bfd_elfNN_bfd_define_start_stop bfd_elf_define_start_stop
+#endif
 #ifndef bfd_elfNN_bfd_final_link
 #define bfd_elfNN_bfd_final_link       bfd_elf_final_link
 #endif
 #ifndef bfd_elfNN_bfd_link_add_symbols
 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #endif
+#ifndef bfd_elfNN_bfd_define_start_stop
+#define bfd_elfNN_bfd_define_start_stop bfd_generic_define_start_stop
+#endif
 #ifndef bfd_elfNN_bfd_final_link
 #define bfd_elfNN_bfd_final_link       _bfd_generic_final_link
 #endif
index 5062506c53d03a5bcd4a607eece1fa5de3807e38..62d2696600ec1239a41e03dfbefa3630c0e0ff6e 100644 (file)
@@ -149,6 +149,7 @@ msdos_set_section_contents (bfd *abfd,
 #define msdos_section_already_linked \
   _bfd_generic_section_already_linked
 #define msdos_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define msdos_bfd_define_start_stop bfd_generic_define_start_stop
 #define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define msdos_bfd_link_just_syms _bfd_generic_link_just_syms
index 7f79b2357f42a34f0027304b7bebc31f2785f4ae..78c58fd6ab6b73e3777b05ab810d024dee0da87c 100644 (file)
@@ -178,6 +178,7 @@ os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define os9k_section_already_linked \
   _bfd_generic_section_already_linked
 #define os9k_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define os9k_bfd_define_start_stop bfd_generic_define_start_stop
 #define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define os9k_bfd_link_just_syms _bfd_generic_link_just_syms
index f7ea4bd3e2b7fcce5a74d9235360b62c3b200ba7..d5220b6ab1551a8e8f533b534586d3147ea64929 100644 (file)
@@ -3872,6 +3872,7 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ieee_section_already_linked \
   _bfd_generic_section_already_linked
 #define ieee_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ieee_bfd_define_start_stop bfd_generic_define_start_stop
 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define ieee_bfd_link_just_syms _bfd_generic_link_just_syms
index 6dda98fd2994cfba36a6c0daddc5a92ee6713e88..a0c704a1c0a380e28390345f440c6229c5dd2a8c 100644 (file)
@@ -945,6 +945,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #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_define_start_stop                bfd_generic_define_start_stop
 #define ihex_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define ihex_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
 #define ihex_bfd_link_just_syms                   _bfd_generic_link_just_syms
index 2d1bf27f71df5b5053c29f47874992b6faef4a15..7adee993d350dca3fc95f898badbb2f953cec301 100644 (file)
@@ -515,6 +515,9 @@ extern bfd_boolean _bfd_generic_set_section_contents
 #define _bfd_nolink_bfd_define_common_symbol \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *, \
                     struct bfd_link_hash_entry *)) bfd_false)
+#define _bfd_nolink_bfd_define_start_stop \
+  ((struct bfd_link_hash_entry * (*) (struct bfd_link_info *, \
+                                     const char *, asection *)) bfd_nullvoidptr)
 #define _bfd_nolink_bfd_link_check_relocs \
   _bfd_generic_link_check_relocs
 
index 7e58598b908bb4c40bf0fe87b848637028990994..09df3b2e0507491fcb4357d632d07c6c89bfd571 100644 (file)
@@ -520,6 +520,9 @@ extern bfd_boolean _bfd_generic_set_section_contents
 #define _bfd_nolink_bfd_define_common_symbol \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *, \
                     struct bfd_link_hash_entry *)) bfd_false)
+#define _bfd_nolink_bfd_define_start_stop \
+  ((struct bfd_link_hash_entry * (*) (struct bfd_link_info *, \
+                                     const char *, asection *)) bfd_nullvoidptr)
 #define _bfd_nolink_bfd_link_check_relocs \
   _bfd_generic_link_check_relocs
 
index f94d2f8f9e386faaa2ed29fb2eb8e7a8540af470..72d5705e639beb4af631099bd54ffb1b342323fb 100644 (file)
@@ -3095,6 +3095,43 @@ bfd_generic_define_common_symbol (bfd *output_bfd,
   return TRUE;
 }
 
+/*
+FUNCTION
+       bfd_generic_define_start_stop
+
+SYNOPSIS
+       struct bfd_link_hash_entry *bfd_generic_define_start_stop
+         (struct bfd_link_info *info,
+          const char *symbol, asection *sec);
+
+DESCRIPTION
+       Define a __start, __stop, .startof. or .sizeof. symbol.
+       Return the symbol or NULL if no such undefined symbol exists.
+
+.#define bfd_define_start_stop(output_bfd, info, symbol, sec) \
+.       BFD_SEND (output_bfd, _bfd_define_start_stop, (info, symbol, sec))
+.
+*/
+
+struct bfd_link_hash_entry *
+bfd_generic_define_start_stop (struct bfd_link_info *info,
+                              const char *symbol, asection *sec)
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_link_hash_lookup (info->hash, symbol, FALSE, FALSE, TRUE);
+  if (h != NULL
+      && (h->type == bfd_link_hash_undefined
+         || h->type == bfd_link_hash_undefweak))
+    {
+      h->type = bfd_link_hash_defined;
+      h->u.def.section = sec;
+      h->u.def.value = 0;
+      return h;
+    }
+  return NULL;
+}
+
 /*
 FUNCTION
        bfd_find_version_for_sym
index c25a74365d8a1392a3db2ce35b748884ccf0f33c..9c01df86cfe4d085fbd9a0789c08b483368e4800 100644 (file)
@@ -55,6 +55,7 @@
 #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_define_start_stop              bfd_generic_define_start_stop
 #define bfd_mach_o_bfd_copy_private_bfd_data          _bfd_generic_bfd_copy_private_bfd_data
 #define bfd_mach_o_core_file_matches_executable_p     generic_core_file_matches_executable_p
 #define bfd_mach_o_core_file_pid                      _bfd_nocore_core_file_pid
index 6b2772b4ea7d741c5aeb476265b2e5aaf06b63d4..99a591bc74963892d492b21c21c47eb44c66c54c 100644 (file)
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3320,6 +3320,7 @@ mmo_write_object_contents (bfd *abfd)
 #define mmo_section_already_linked \
   _bfd_generic_section_already_linked
 #define mmo_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define mmo_bfd_define_start_stop bfd_generic_define_start_stop
 
 /* We want to copy time of creation, otherwise we'd use
    BFD_JUMP_TABLE_COPY (_bfd_generic).  */
index 872ee320ca281d9268e308b77b446654c8f11298..4dadb333ff9c66866e442835c75a71a0f42235d8 100644 (file)
@@ -53,6 +53,7 @@
 #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_define_start_stop               bfd_generic_define_start_stop
 #define nlm_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define nlm_bfd_link_add_symbols                _bfd_generic_link_add_symbols
 #define nlm_bfd_link_just_syms                  _bfd_generic_link_just_syms
index defb25abfd87513517b1df00cc7bc1cd71146ab3..efe0d7c14d72d8b9e45c85e245c09c83988f851d 100644 (file)
@@ -1186,6 +1186,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #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_define_start_stop                bfd_generic_define_start_stop
 #define oasys_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define oasys_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
 #define oasys_bfd_link_just_syms                   _bfd_generic_link_just_syms
index 5f64d44ade07468eb45e4a33f10f73522eadd508..7f03d173f277c95a83f07d4682737a6acab2dbf6 100644 (file)
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -59,6 +59,7 @@
 #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_define_start_stop               bfd_generic_define_start_stop
 #define bfd_pef_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define bfd_pef_bfd_link_add_symbols                _bfd_generic_link_add_symbols
 #define bfd_pef_bfd_link_just_syms                  _bfd_generic_link_just_syms
index 1c8c3fb7bd2fef6d33ad25492caa4acbf188a5c5..af50be12b89cb6a4b0ee1726d1dddd56e7574d67 100644 (file)
@@ -105,6 +105,7 @@ dlerror (void)
 #define bfd_plugin_bfd_discard_group                  bfd_generic_discard_group
 #define bfd_plugin_section_already_linked             _bfd_generic_section_already_linked
 #define bfd_plugin_bfd_define_common_symbol           bfd_generic_define_common_symbol
+#define bfd_plugin_bfd_define_start_stop              bfd_generic_define_start_stop
 #define bfd_plugin_bfd_copy_link_hash_symbol_type     _bfd_generic_copy_link_hash_symbol_type
 #define bfd_plugin_bfd_link_check_relocs              _bfd_generic_link_check_relocs
 
index e27e915853c37308f03205e01b6f9aebe18a0456..a0f96214819bc0eab85b7ab2b36656c708593718 100644 (file)
@@ -461,6 +461,7 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg)
 #define ppcboot_section_already_linked \
   _bfd_generic_section_already_linked
 #define ppcboot_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ppcboot_bfd_define_start_stop bfd_generic_define_start_stop
 #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define ppcboot_bfd_link_just_syms _bfd_generic_link_just_syms
index 496040c3f0faa2fed2b9180ee5b136a1ee6e787d..8575c891a4734841d803cc8da65359a9bef3ab85 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6754,6 +6754,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 #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_define_start_stop               bfd_generic_define_start_stop
 #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 6d9b9a47fce3569b53917c37311c0c362415cdef..d7b240dba2f30a5a6f4fa6c0b6f646449480c56d 100644 (file)
@@ -1278,6 +1278,7 @@ srec_print_symbol (bfd *abfd,
 #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_define_start_stop                bfd_generic_define_start_stop
 #define srec_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define srec_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
 #define srec_bfd_link_just_syms                   _bfd_generic_link_just_syms
index 2f3ea1346e2803afc152eb06ad7d7dd5fd8a9273..05224c4fa71a6d4d4750d57041bd89efe69faafb 100644 (file)
@@ -462,7 +462,8 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_is_group_section, \
 .  NAME##_bfd_discard_group, \
 .  NAME##_section_already_linked, \
-.  NAME##_bfd_define_common_symbol
+.  NAME##_bfd_define_common_symbol, \
+.  NAME##_bfd_define_start_stop
 .
 .  int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
 .  bfd_byte *  (*_bfd_get_relocated_section_contents)
@@ -526,6 +527,11 @@ BFD_JUMP_TABLE macros.
 .  bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
 .                                           struct bfd_link_hash_entry *);
 .
+.  {* Define a __start, __stop, .startof. or .sizeof. symbol.  *}
+.  struct bfd_link_hash_entry *(*_bfd_define_start_stop) (struct bfd_link_info *,
+.                                                        const char *,
+.                                                        asection *);
+.
 .  {* Routines to handle dynamic symbols and relocs.  *}
 .#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
 .  NAME##_get_dynamic_symtab_upper_bound, \
index bbc2ccdc7987744cb41bad7722e6ec10d08270bb..214b54a8177b8f70ad6b38d75f0899a209a0eead 100644 (file)
@@ -977,6 +977,7 @@ tekhex_print_symbol (bfd *abfd,
 #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_define_start_stop                bfd_generic_define_start_stop
 #define tekhex_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define tekhex_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
 #define tekhex_bfd_link_just_syms                   _bfd_generic_link_just_syms
index f0c5fdf87d76df76d8cec5c3db6e67b9e1358031..d9ede273d76622510017a9142acf2dc93f7036ae 100644 (file)
@@ -871,6 +871,7 @@ versados_canonicalize_reloc (bfd *abfd,
 #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_define_start_stop                bfd_generic_define_start_stop
 #define versados_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
 #define versados_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
 #define versados_bfd_link_just_syms                   _bfd_generic_link_just_syms
index 38237cd0acde73150a4350e2d3b31acb6c26c0ef..83b6638cd7000140298103fd628e414a5f433687 100644 (file)
@@ -9311,6 +9311,7 @@ bfd_vms_get_data (bfd *abfd)
 #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_define_start_stop      bfd_generic_define_start_stop
 #define vms_bfd_copy_private_header_data  _bfd_generic_bfd_copy_private_header_data
 
 #define vms_bfd_copy_private_bfd_data    _bfd_generic_bfd_copy_private_bfd_data
@@ -9358,6 +9359,7 @@ bfd_vms_get_data (bfd *abfd)
   _bfd_generic_section_already_linked
 
 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
 #define alpha_vms_bfd_copy_link_hash_symbol_type \
   _bfd_generic_copy_link_hash_symbol_type
index 6a4a7509d88fbef6e33999cacbfad8cfd849250f..3160c1082aec5efe8cdb9a7b870b9fb7ea73714e 100644 (file)
@@ -51,6 +51,7 @@
 #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_define_start_stop               bfd_generic_define_start_stop
 #define bfd_sym_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
 #define bfd_sym_bfd_link_add_symbols                _bfd_generic_link_add_symbols
 #define bfd_sym_bfd_link_just_syms                  _bfd_generic_link_just_syms
index 1c7766f90a50f0161f1d8b9d858489a5fdd57d50..44905d7da9f2d42dd38c205d2f1d3b0572e33b51 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-16  Alan Modra  <amodra@gmail.com>
+
+       PR ld/20022
+       PR ld/21557
+       PR ld/21562
+       PR ld/21571
+       * bfdlink.h (struct bfd_link_hash_entry): Delete undef.section.
+
 2017-06-14  Yao Qi  <yao.qi@linaro.org>
 
        * dis-asm.h (print_insn_aarch64): Move it to opcodes/disassemble.h.
index 2e3f0b15aea88fde6e8a30941c4c500328328a2a..69232c45491ed9bcb5772d001b64064b96dccb5b 100644 (file)
@@ -144,9 +144,6 @@ struct bfd_link_hash_entry
          struct bfd_link_hash_entry *next;
          /* BFD symbol was found in.  */
          bfd *abfd;
-         /* For __start_<name> and __stop_<name> symbols, the first
-            input section matching the name.  */
-         asection *section;
        } undef;
       /* bfd_link_hash_defined, bfd_link_hash_defweak.  */
       struct
index 751699d67333d6470a87556554400d13e5af2c80..583a936d0ba7e9f8e8eae8d60dcc193281351c8f 100644 (file)
@@ -1,3 +1,37 @@
+2017-06-16  Alan Modra  <amodra@gmail.com>
+
+       PR ld/20022
+       PR ld/21557
+       PR ld/21562
+       PR ld/21571
+       * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't set
+       __start/__stop syms here.
+       * ldlang.c (lang_set_startof): Delete.
+       (start_stop_syms, start_stop_count, start_stop_alloc): New vars.
+       (lang_define_start_stop, lang_init_start_stop, foreach_start_stop,
+       undef_start_stop, lang_undef_start_stop, lang_init_startof_sizeof,
+       set_start_stop, lang_finalize_start_stop): New functions.
+       (lang_process): Call _start_stop functions.
+       * testsuite/ld-elf/pr21562a.d: Use xfail rather than notarget.
+       Correct typos and list of xfail targets.
+       * testsuite/ld-elf/pr21562b.d: Likewise.
+       * testsuite/ld-elf/pr21562c.d: Likewise.
+       * testsuite/ld-elf/pr21562d.d: Likewise.
+       * testsuite/ld-elf/pr21562e.d: Likewise.
+       * testsuite/ld-elf/pr21562f.d: Likewise.
+       * testsuite/ld-elf/pr21562g.d: Likewise.
+       * testsuite/ld-elf/pr21562h.d: Likewise.
+       * testsuite/ld-elf/pr21562i.d: Likewise.
+       * testsuite/ld-elf/pr21562j.d: Likewise.
+       * testsuite/ld-elf/pr21562k.d: Likewise.
+       * testsuite/ld-elf/pr21562l.d: Likewise.
+       * testsuite/ld-elf/pr21562m.d: Likewise.
+       * testsuite/ld-elf/pr21562n.d: Likewise.
+       * testsuite/ld-elf/sizeofa.d: Likewise.  Adjust to pass for generic ELF.
+       * testsuite/ld-elf/sizeofb.d: Likewise.
+       * testsuite/ld-elf/startofa.d: Likewise.
+       * testsuite/ld-elf/startofb.d: Likewise.
+
 2017-06-16  Jiong Wang  <jiong.wang@arm.com>
 
        * testsuite/ld-aarch64/aarch64-elf.exp: Update test name
index 9468f7d29f2b221c0446e25f3a39872f25dd37d2..325d8477d058c98f3fccebfb7a5398944395c446 100644 (file)
@@ -1218,7 +1218,6 @@ gld${EMULATION_NAME}_after_open (void)
   struct elf_link_hash_table *htab;
   asection *s;
   bfd *abfd;
-  char leading_char;
 
   after_open_default ();
 
@@ -1277,62 +1276,6 @@ gld${EMULATION_NAME}_after_open (void)
       return;
     }
 
-  leading_char = bfd_get_symbol_leading_char (link_info.output_bfd);
-
-  /* Check for input sections whose names match references to
-     __start_SECNAME or __stop_SECNAME symbols.  Mark the matched
-     symbols as hidden and set start_stop for garbage collection.  */
-  for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
-    for (s = abfd->sections; s; s = s->next)
-      {
-       const char *name = bfd_get_section_name (abfd, s);
-       const char *ps;
-
-       for (ps = name; *ps != '\0'; ps++)
-         if (!ISALNUM ((unsigned char) *ps) && *ps != '_')
-           break;
-       if (*ps == '\0')
-         {
-           struct elf_link_hash_entry *h;
-           char *symbol = (char *) xmalloc (ps - name
-                                            + sizeof "__start_" + 1);
-
-           symbol[0] = leading_char;
-           sprintf (symbol + (leading_char != 0), "__start_%s", name);
-           h = elf_link_hash_lookup (elf_hash_table (&link_info),
-                                     symbol, FALSE, FALSE, TRUE);
-           if (h != NULL
-               && (h->root.type == bfd_link_hash_undefined
-                   || h->root.type == bfd_link_hash_undefweak)
-               && h->u2.start_stop_section == NULL)
-             {
-               h->start_stop = 1;
-               h->u2.start_stop_section = s;
-               _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE);
-               if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
-                 h->other = ((h->other & ~ELF_ST_VISIBILITY (-1))
-                             | STV_HIDDEN);
-             }
-
-           symbol[0] = leading_char;
-           sprintf (symbol + (leading_char != 0), "__stop_%s", name);
-           h = elf_link_hash_lookup (elf_hash_table (&link_info),
-                                     symbol, FALSE, FALSE, TRUE);
-           if (h != NULL
-               && (h->root.type == bfd_link_hash_undefined
-                   || h->root.type == bfd_link_hash_undefweak)
-               && h->u2.start_stop_section == NULL)
-             {
-               h->start_stop = 1;
-               h->u2.start_stop_section = s;
-               _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE);
-               if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
-                 h->other = ((h->other & ~ELF_ST_VISIBILITY (-1))
-                             | STV_HIDDEN);
-             }
-         }
-      }
-
   if (!link_info.traditional_format)
     {
       bfd *elfbfd = NULL;
index eb4ba9eee467e6cbc21a5786c5faced538a1df52..726bc8e3846944a0e34d9b127e000a68a07ee0ad 100644 (file)
@@ -5878,97 +5878,173 @@ section_for_dot (void)
   return bfd_abs_section_ptr;
 }
 
-/* Fix any .startof., .sizeof., __start or __stop symbols.  When the
-   assemblers see the operator .startof. (section_name), it produces
-   an undefined symbol .startof.section_name.  Similarly, when it sees
-   .sizeof. (section_name), it produces an undefined symbol
-   .sizeof.section_name.  Also for ELF linker, __start_XXX or __stop_XXX
-   symbols should be resolved to the start and end of section XXX.  For
-   all the output sections, we look for such symbols, and set them to
-   the correct value.  */
+/* Array of __start/__stop/.startof./.sizeof/ symbols.  */
+
+static struct bfd_link_hash_entry **start_stop_syms;
+static size_t start_stop_count = 0;
+static size_t start_stop_alloc = 0;
+
+/* Give start/stop SYMBOL for SEC a preliminary definition, and add it
+   to start_stop_syms.  */
+
+static void
+lang_define_start_stop (const char *symbol, asection *sec)
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_define_start_stop (link_info.output_bfd, &link_info, symbol, sec);
+  if (h != NULL)
+    {
+      if (start_stop_count == start_stop_alloc)
+       {
+         start_stop_alloc = 2 * start_stop_alloc + 10;
+         start_stop_syms
+           = xrealloc (start_stop_syms,
+                       start_stop_alloc * sizeof (*start_stop_syms));
+       }
+      start_stop_syms[start_stop_count++] = h;
+    }
+}
+
+/* Check for input sections whose names match references to
+   __start_SECNAME or __stop_SECNAME symbols.  Give the symbols
+   preliminary definitions.  */
 
 static void
-lang_set_startof (void)
+lang_init_start_stop (void)
 {
+  bfd *abfd;
   asection *s;
-  char leading_char;
-  bfd_boolean is_elf;
-  bfd_boolean is_relocatable;
+  char leading_char = bfd_get_symbol_leading_char (link_info.output_bfd);
+
+  for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link.next)
+    for (s = abfd->sections; s != NULL; s = s->next)
+      {
+       const char *ps;
+       const char *secname = s->name;
+
+       for (ps = secname; *ps != '\0'; ps++)
+         if (!ISALNUM ((unsigned char) *ps) && *ps != '_')
+           break;
+       if (*ps == '\0')
+         {
+           char *symbol = (char *) xmalloc (10 + strlen (secname));
 
-  if (!config.build_constructors)
+           symbol[0] = leading_char;
+           sprintf (symbol + (leading_char != 0), "__start_%s", secname);
+           lang_define_start_stop (symbol, s);
+
+           symbol[1] = leading_char;
+           memcpy (symbol + 1 + (leading_char != 0), "__stop", 6);
+           lang_define_start_stop (symbol + 1, s);
+
+           free (symbol);
+         }
+      }
+}
+
+/* Iterate over start_stop_syms.  */
+
+static void
+foreach_start_stop (void (*func) (struct bfd_link_hash_entry *))
+{
+  size_t i;
+
+  for (i = 0; i < start_stop_count; ++i)
+    func (start_stop_syms[i]);
+}
+
+/* __start and __stop symbols are only supposed to be defined by the
+   linker for orphan sections, but we now extend that to sections that
+   map to an output section of the same name.  The symbols were
+   defined early for --gc-sections, before we mapped input to output
+   sections, so undo those that don't satisfy this rule.  */
+
+static void
+undef_start_stop (struct bfd_link_hash_entry *h)
+{
+  if (h->ldscript_def)
     return;
 
-  is_elf = (bfd_get_flavour (link_info.output_bfd)
-           == bfd_target_elf_flavour);
-  is_relocatable = bfd_link_relocatable (&link_info);
+  if (h->u.def.section->output_section == NULL
+      || h->u.def.section->output_section->owner != link_info.output_bfd
+      || strcmp (h->u.def.section->name,
+                h->u.def.section->output_section->name) != 0)
+    {
+      h->type = bfd_link_hash_undefined;
+      h->u.undef.abfd = NULL;
+    }
+}
+
+static void
+lang_undef_start_stop (void)
+{
+  foreach_start_stop (undef_start_stop);
+}
+
+/* Check for output sections whose names match references to
+   .startof.SECNAME or .sizeof.SECNAME symbols.  Give the symbols
+   preliminary definitions.  */
 
-  leading_char = bfd_get_symbol_leading_char (link_info.output_bfd);
+static void
+lang_init_startof_sizeof (void)
+{
+  asection *s;
 
   for (s = link_info.output_bfd->sections; s != NULL; s = s->next)
     {
-      const char *secname;
-      char *buf;
-      struct bfd_link_hash_entry *h;
+      const char *secname = s->name;
+      char *symbol = (char *) xmalloc (10 + strlen (secname));
 
-      secname = bfd_get_section_name (link_info.output_bfd, s);
-      buf = (char *) xmalloc (10 + strlen (secname));
+      sprintf (symbol, ".startof.%s", secname);
+      lang_define_start_stop (symbol, s);
 
-      if (!is_relocatable)
-       {
-         sprintf (buf, ".startof.%s", secname);
-         h = bfd_link_hash_lookup (link_info.hash, buf, FALSE, FALSE,
-                                   TRUE);
-         if (h != NULL && h->type == bfd_link_hash_undefined)
-           {
-             h->type = bfd_link_hash_defined;
-             h->u.def.value = 0;
-             h->u.def.section = s;
-           }
+      memcpy (symbol + 1, ".size", 5);
+      lang_define_start_stop (symbol + 1, s);
+      free (symbol);
+    }
+}
 
-         sprintf (buf, ".sizeof.%s", secname);
-         h = bfd_link_hash_lookup (link_info.hash, buf, FALSE, FALSE,
-                                   TRUE);
-         if (h != NULL && h->type == bfd_link_hash_undefined)
-           {
-             h->type = bfd_link_hash_defined;
-             h->u.def.value = TO_ADDR (s->size);
-             h->u.def.section = bfd_abs_section_ptr;
-           }
-       }
+/* Set .startof., .sizeof., __start and __stop symbols final values.  */
 
-      buf[0] = leading_char;
-      sprintf (buf + (buf[0] != 0), "__start_%s", secname);
-      h = bfd_link_hash_lookup (link_info.hash, buf, FALSE, FALSE,
-                               TRUE);
-      if (h != NULL
-         && (h->type == bfd_link_hash_undefined
-             || h->type == bfd_link_hash_undefweak))
+static void
+set_start_stop (struct bfd_link_hash_entry *h)
+{
+  if (h->ldscript_def
+      || h->type != bfd_link_hash_defined)
+    return;
+
+  if (h->root.string[0] == '.')
+    {
+      /* .startof. or .sizeof. symbol.
+        .startof. already has final value.  */
+      if (h->root.string[2] == 'i')
        {
-         h->type = bfd_link_hash_defined;
-         h->u.def.value = 0;
-         h->u.def.section = s;
-         if (is_elf)
-           ((struct elf_link_hash_entry *) h)->def_regular = 1;
+         /* .sizeof.  */
+         h->u.def.value = TO_ADDR (h->u.def.section->size);
+         h->u.def.section = bfd_abs_section_ptr;
        }
+    }
+  else
+    {
+      /* __start or __stop symbol.  */
+      int has_lead = bfd_get_symbol_leading_char (link_info.output_bfd) != 0;
 
-      buf[0] = leading_char;
-      sprintf (buf + (buf[0] != 0), "__stop_%s", secname);
-      h = bfd_link_hash_lookup (link_info.hash, buf, FALSE, FALSE,
-                               TRUE);
-      if (h != NULL
-         && (h->type == bfd_link_hash_undefined
-             || h->type == bfd_link_hash_undefweak))
+      h->u.def.section = h->u.def.section->output_section;
+      if (h->root.string[4 + has_lead] == 'o')
        {
-         h->type = bfd_link_hash_defined;
-         h->u.def.value = TO_ADDR (s->size);
-         h->u.def.section = s;
-         if (is_elf)
-           ((struct elf_link_hash_entry *) h)->def_regular = 1;
+         /* __stop_ */
+         h->u.def.value = TO_ADDR (h->u.def.section->size);
        }
-      free (buf);
     }
 }
 
+static void
+lang_finalize_start_stop (void)
+{
+  foreach_start_stop (set_start_stop);
+}
+
 static void
 lang_end (void)
 {
@@ -7035,6 +7111,12 @@ lang_process (void)
      files.  */
   ldctor_build_sets ();
 
+  /* Give initial values for __start and __stop symbols, so that  ELF
+     gc_sections will keep sections referenced by these symbols.  Must
+     be done before lang_do_assignments below.  */
+  if (config.build_constructors)
+    lang_init_start_stop ();
+
   /* PR 13683: We must rerun the assignments prior to running garbage
      collection in order to make sure that all symbol aliases are resolved.  */
   lang_do_assignments (lang_mark_phase_enum);
@@ -7089,6 +7171,17 @@ lang_process (void)
   /* Copy forward lma regions for output sections in same lma region.  */
   lang_propagate_lma_regions ();
 
+  /* Defining __start/__stop symbols early for --gc-sections to work
+     around a glibc build problem can result in these symbols being
+     defined when they should not be.  Fix them now.  */
+  if (config.build_constructors)
+    lang_undef_start_stop ();
+
+  /* Define .startof./.sizeof. symbols with preliminary values before
+     dynamic symbols are created.  */
+  if (!bfd_link_relocatable (&link_info))
+    lang_init_startof_sizeof ();
+
   /* Do anything special before sizing sections.  This is where ELF
      and other back-ends size dynamic sections.  */
   ldemul_before_allocation ();
@@ -7108,8 +7201,8 @@ lang_process (void)
      everything is.  This is where relaxation is done.  */
   ldemul_after_allocation ();
 
-  /* Fix any .startof. or .sizeof. symbols.  */
-  lang_set_startof ();
+  /* Fix any __start, __stop, .startof. or .sizeof. symbols.  */
+  lang_finalize_start_stop ();
 
   /* Do all the assignments, now that we know the final resting places
      of all the symbols.  */
index 3b0dc6517e32ed60fe067001baab0bdd764841b0..1f57569d3ea8e71f2ceb68fc754d866eae829fd5 100644 (file)
@@ -1,12 +1,12 @@
 #ld: -shared -z defs --gc-sections
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index af82bb8b69b3045a990185373cf72ff2cf7443ee..dd28b66ca695da092d7df301bdd434aef7f7d127 100644 (file)
@@ -1,12 +1,12 @@
 #ld: -shared -z defs --gc-sections
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index 0fcc25ab9d747477934edd0b5c0bb5a65ca11a5a..69eb6aacb4d6592dad67b1647f090fc8666cd92b 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562a.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index b966b80114775e5aa879bcb0c88f16198fdf87d2..7e1382190336e75c6e8a96019d6408becbe12f5b 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562a.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index 6f73c7b7182e18b2573ce06071bb8782c9613d8a..0172a069d8b041d1eb736ffa647595d15ed195d0 100644 (file)
@@ -2,10 +2,10 @@
 #ld: -shared -z defs
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 
 #...
   \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
index 244f917c52c56e78e50d98649c55e3b68ff55725..a0f1a24d82a4fa2c8e1f9eafc65829b838bd426b 100644 (file)
@@ -2,10 +2,10 @@
 #ld: -shared -z defs
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 
 #...
   \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
index 411e1e31e73a4a53f573b5cf7476f1517346130e..289ab75191ba1ac33acedf0004b6bbe62fd18bcd 100644 (file)
@@ -2,10 +2,10 @@
 #ld: -shared -z defs -T pr21562a.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 
 #...
   \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
index dc4b72a760b690662df83c7eb188a1f007635b68..c94e63669f2930b772865eff1ce11e2e2f3b67a4 100644 (file)
@@ -2,10 +2,10 @@
 #ld: -shared -z defs -T pr21562a.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 
 #...
   \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
index 47b9cad0be66d0ef844ae4bd2f99299a9bbc1df1..2670f60537d50e6042f7b5a518be11824d392522 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562b.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index eba248786a3da4dc71255c9a2aaff62b997ecae3..7c5508a5b43f568e71d5edd4b4685d69bdba9d2f 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562b.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index 594bc896a32caac1f245da7a4604304853e61a68..7f76d08c82c69ea6ba6d806c7a1bdf40dfe42573 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562c.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index 1a9c2d663b1bde0b43cf5843ae658b69e72f81c5..1ad601c554ea8fb13ec3d8c20b4825fb4b81424f 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562c.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index b21698a3ccd2ab96080cb302afa351a28dd174f5..2fedacdb5f8232a0c074dde0860f85f0e87a7603 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562d.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index 561ec6bec1bf6a309b7943dad73899aae15f8f11..f12b23d7ea03941e8d579312f9496e4df3d6fe55 100644 (file)
@@ -2,12 +2,12 @@
 #ld: -shared -z defs --gc-sections -T pr21562d.t
 #readelf: -s -S --wide
 #target: *-*-linux* *-*-gnu*
-#notarget: d30v-*-* dlx-*-* i960-*-* pj*-*-*
-#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: d30v-*-* dlx-*-* i960-*-* pj*-*-*
+#xfail: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 # generic linker targets don't support --gc-sections, nor do a bunch of others
 
 #...
index d4432a0f068d9bf5620c54360757338285367048..340456de8a328868384e174c62b9877b6c5b55c2 100644 (file)
@@ -1,16 +1,17 @@
 #source: sizeof.s
 #ld: -Ur
 #readelf: -sW
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* cris*-*-elf crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* sh*-*-elf* sh*-*-kaos* sh*-*-nto* sh-*-rtems*
+#xfail: sh*-*-symbianelf* sh*-*-vxworks v850*-*-*
+# Targets with a leading char will fail this test.
 
 Symbol table '\.symtab' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__stop_scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +(LOC|GLOB)AL +DEFAULT +[0-9]+ +__stop_scnfoo
 #...
  +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +.sizeof.scnfoo
 #pass
index cd3920b006d0b4a63fbe095532b9d936e97e4b09..e25d88f06fe6e2832d28b9964ff2f9e0a47342cd 100644 (file)
@@ -2,10 +2,10 @@
 #ld: -shared
 #readelf: -sW
 #target: *-*-linux* *-*-gnu*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 
 Symbol table '\.dynsym' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
@@ -13,5 +13,5 @@ Symbol table '\.dynsym' contains [0-9]+ entries:
 #...
  +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__stop_scnfoo
 #...
- +[0-9]+: 0+10 + +0 +NOTYPE +GLOBAL +DEFAULT +ABS +.sizeof.scnfoo
+ +[0-9]+: 0+10 + +0 +NOTYPE +LOCAL +DEFAULT +ABS +.sizeof.scnfoo
 #pass
index cb261df7f5a819e320881ae66497302f20ef1c8f..19ac29d2ee145e5b6068df0fce5c5a6b6e16d6ad 100644 (file)
@@ -1,16 +1,17 @@
 #source: startof.s
 #ld: -Ur
 #readelf: -sW
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* cris*-*-elf crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* sh*-*-elf* sh*-*-kaos* sh*-*-nto* sh-*-rtems*
+#xfail: sh*-*-symbianelf* sh*-*-vxworks v850*-*-*
+# Targets with a leading char will fail this test.
 
 Symbol table '\.symtab' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +.startof.scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +(LOCAL +DEFAULT +[0-9]+ +__start_scnfoo|GLOBAL +DEFAULT +UND +.startof.scnfoo)
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__start_scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +(UND +.startof.scnfoo|[0-9]+ +__start_scnfoo)
 #pass
index 0d1da663bdd5be17bcc4bfc4a90d463a5d4597c2..2cc1b86149013db78b8b78262a3296aabe3dbe4d 100644 (file)
@@ -2,16 +2,16 @@
 #ld: -shared
 #readelf: -sW
 #target: *-*-linux* *-*-gnu*
-#notarget: bfin-*-* cr16-*-* cr16c-*-* cris*-*-* crx-*-* epiphany-*-*
-#notarget: h8300-*-* ip2k-*-* m10200-*-* m10300-*-* m32c-*-* metag-*-*
-#notarget: metag-*-* rl78-*-* rx-*-* sh*-*-* v850*-*-*
-# Targets with a leading char will faill this test.
+#xfail: bfin-*-* cr16-*-* cr16c-*-* crx-*-* epiphany-*-*
+#xfail: h8300-*-* ip2k-*-* mn10200-*-* mn10300-*-* m32c-*-* metag-*-*
+#xfail: rl78-*-* rx-*-* v850*-*-*
+# Targets with a leading char will fail this test.
 
 Symbol table '\.dynsym' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +.startof.scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +.startof.scnfoo
 #...
  +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__start_scnfoo
 #pass