This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Always define referenced __start_SECNAME/__stop_SECNAME


Currently, linker will define __start_SECNAME and __stop_SECNAME symbols
only for orphaned sections.  However, during garbage collection, ELF
linker marks all sections with references to __start_SECNAME and
__stop_SECNAME symbols as used even when section SECNAME isn't an orphaned
section and linker won't define __start_SECNAME nor __stop_SECNAME.

This patch changes linker to always define referenced __start_SECNAME and
__stop_SECNAME if the input section name is the same output section name,
which is always true for orphaned sections, and SECNAME is a C identifier.
Also __start_SECNAME and __stop_SECNAME symbols are marked as hidden by
ELF linker.

bfd/

	PR ld/20022
	PR ld/21557
	PR ld/21562
	* elf-bfd.h (elf_link_hash_entry): Add start_stop.
	(_bfd_elf_is_start_stop): Removed.
	* elf32-i386.c (elf_i386_convert_load_reloc): Also check for
	__start_SECNAME/__stop_SECNAME symbols.
	* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
	* elflink.c (_bfd_elf_is_start_stop): Removed.
	(_bfd_elf_gc_mark_rsec): Check start_stop instead of calling
	_bfd_elf_is_start_stop.

ld/

	PR ld/20022
	PR ld/21557
	PR ld/21562
	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Mark
	referenced __start_SECNAME/__stop_SECNAME symbols as hidden and
	set start_stop for garbage collection.
	* ld.texinfo: Update __start_SECNAME/__stop_SECNAME symbols.
	* ldlang.c (lang_insert_orphan): Move handling of __start_SECNAME
	and __stop_SECNAME symbols to ...
	(lang_set_startof): Here.
	* testsuite/ld-elf/pr21562.t: New test.
	* testsuite/ld-elf/pr21562a.d: Likewise.
	* testsuite/ld-elf/pr21562a.s: Likewise.
	* testsuite/ld-elf/pr21562b.d: Likewise.
	* testsuite/ld-elf/pr21562b.s: 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-gc/pr20022.d: Likewise.
	* testsuite/ld-gc/pr20022a.s: Likewise.
	* testsuite/ld-gc/pr20022b.s: Likewise.
	* testsuite/ld-gc/gc.exp: Run PR ld/20022 tests.
	* testsuite/ld-gc/pr19161.d: Also accept local __start_SECNAME
	symbol.
	* testsuite/ld-gc/start.d: Likewise.
	* testsuite/ld-x86-64/lea1a.d: Updated.
	* testsuite/ld-x86-64/lea1b.d: Updated.
	* testsuite/ld-x86-64/lea1d.d: Updated.
	* testsuite/ld-x86-64/lea1e.d: Likewise.
---
 bfd/elf-bfd.h                  |  5 +--
 bfd/elf32-i386.c               |  4 +-
 bfd/elf64-x86-64.c             |  8 +++-
 bfd/elflink.c                  | 54 +-----------------------
 ld/emultempl/elf32.em          | 64 +++++++++++++++++++++++++++--
 ld/ld.texinfo                  | 16 ++++----
 ld/ldlang.c                    | 93 +++++++++++++++++++-----------------------
 ld/testsuite/ld-elf/pr21562.t  |  3 ++
 ld/testsuite/ld-elf/pr21562a.d |  9 ++++
 ld/testsuite/ld-elf/pr21562a.s |  8 ++++
 ld/testsuite/ld-elf/pr21562b.d |  9 ++++
 ld/testsuite/ld-elf/pr21562b.s |  8 ++++
 ld/testsuite/ld-elf/pr21562c.d | 10 +++++
 ld/testsuite/ld-elf/pr21562d.d | 10 +++++
 ld/testsuite/ld-elf/pr21562e.d | 10 +++++
 ld/testsuite/ld-elf/pr21562f.d | 10 +++++
 ld/testsuite/ld-elf/pr21562g.d | 10 +++++
 ld/testsuite/ld-elf/pr21562h.d | 10 +++++
 ld/testsuite/ld-gc/gc.exp      |  6 +++
 ld/testsuite/ld-gc/pr19161.d   |  2 +-
 ld/testsuite/ld-gc/pr20022.d   | 11 +++++
 ld/testsuite/ld-gc/pr20022a.s  |  8 ++++
 ld/testsuite/ld-gc/pr20022b.s  |  8 ++++
 ld/testsuite/ld-gc/start.d     |  2 +-
 ld/testsuite/ld-x86-64/lea1a.d |  2 +-
 ld/testsuite/ld-x86-64/lea1b.d |  2 +-
 ld/testsuite/ld-x86-64/lea1d.d |  2 +-
 ld/testsuite/ld-x86-64/lea1e.d |  2 +-
 28 files changed, 259 insertions(+), 127 deletions(-)
 create mode 100644 ld/testsuite/ld-elf/pr21562.t
 create mode 100644 ld/testsuite/ld-elf/pr21562a.d
 create mode 100644 ld/testsuite/ld-elf/pr21562a.s
 create mode 100644 ld/testsuite/ld-elf/pr21562b.d
 create mode 100644 ld/testsuite/ld-elf/pr21562b.s
 create mode 100644 ld/testsuite/ld-elf/pr21562c.d
 create mode 100644 ld/testsuite/ld-elf/pr21562d.d
 create mode 100644 ld/testsuite/ld-elf/pr21562e.d
 create mode 100644 ld/testsuite/ld-elf/pr21562f.d
 create mode 100644 ld/testsuite/ld-elf/pr21562g.d
 create mode 100644 ld/testsuite/ld-elf/pr21562h.d
 create mode 100644 ld/testsuite/ld-gc/pr20022.d
 create mode 100644 ld/testsuite/ld-gc/pr20022a.s
 create mode 100644 ld/testsuite/ld-gc/pr20022b.s

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 820bc98..b523d70 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -213,6 +213,8 @@ struct elf_link_hash_entry
   /* Symbol is defined by a shared library with non-default visibility
      in a read/write section.  */
   unsigned int protected_def : 1;
+  /* Symbol is __start_XXX or __stop_XXX to mark section XXX.  */
+  unsigned int start_stop : 1;
 
   /* String table index in .dynstr if this is a dynamic symbol.  */
   unsigned long dynstr_index;
@@ -2445,9 +2447,6 @@ extern bfd_boolean bfd_elf_gc_common_finalize_got_offsets
 extern bfd_boolean bfd_elf_gc_common_final_link
   (bfd *, struct bfd_link_info *);
 
-extern asection *_bfd_elf_is_start_stop
-  (const struct bfd_link_info *, struct elf_link_hash_entry *);
-
 extern bfd_boolean bfd_elf_reloc_symbol_deleted_p
   (bfd_vma, void *);
 
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index e447e3d..9e10225 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1787,8 +1787,10 @@ convert_branch:
 	return TRUE;
 
       /* def_regular is set by an assignment in a linker script in
-	 bfd_elf_record_link_assignment.  */
+	 bfd_elf_record_link_assignment.  forced_local is set on
+	 __start_XXX/__stop_XXX which mark section XXX.  */
       if ((h->def_regular
+	   || (h->forced_local && h->start_stop)
 	   || h->root.type == bfd_link_hash_defined
 	   || h->root.type == bfd_link_hash_defweak)
 	  && SYMBOL_REFERENCES_LOCAL (link_info, h))
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index c94d7ff..479538c 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1921,6 +1921,7 @@ elf_x86_64_convert_load_reloc (bfd *abfd, asection *sec,
       /* Avoid optimizing GOTPCREL relocations againt _DYNAMIC since
 	 ld.so may use its link-time address.  */
       else if ((h->def_regular
+		|| (h->forced_local && h->start_stop)
 		|| h->root.type == bfd_link_hash_defined
 		|| h->root.type == bfd_link_hash_defweak)
 	       && h != htab->elf.hdynamic
@@ -1928,8 +1929,11 @@ elf_x86_64_convert_load_reloc (bfd *abfd, asection *sec,
 	{
 	  /* bfd_link_hash_new or bfd_link_hash_undefined is
 	     set by an assignment in a linker script in
-	     bfd_elf_record_link_assignment.   */
-	  if (h->def_regular
+	     bfd_elf_record_link_assignment.   forced_local
+	     is set on __start_XXX/__stop_XXX which mark
+	     section XXX.  */
+	  if ((h->def_regular
+	       || (h->forced_local && h->start_stop))
 	      && (h->root.type == bfd_link_hash_new
 		  || h->root.type == bfd_link_hash_undefined
 		  || ((h->root.type == bfd_link_hash_defined
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 1b447bb..2dc138e 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12683,55 +12683,6 @@ elf_gc_mark_debug_section (asection *sec ATTRIBUTE_UNUSED,
   return NULL;
 }
 
-/* For undefined __start_<name> and __stop_<name> symbols, return the
-   first input section matching <name>.  Return NULL otherwise.  */
-
-asection *
-_bfd_elf_is_start_stop (const struct bfd_link_info *info,
-			struct elf_link_hash_entry *h)
-{
-  asection *s;
-  const char *sec_name;
-
-  if (h->root.type != bfd_link_hash_undefined
-      && h->root.type != bfd_link_hash_undefweak)
-    return NULL;
-
-  s = h->root.u.undef.section;
-  if (s != NULL)
-    {
-      if (s == (asection *) 0 - 1)
-	return NULL;
-      return s;
-    }
-
-  sec_name = NULL;
-  if (strncmp (h->root.root.string, "__start_", 8) == 0)
-    sec_name = h->root.root.string + 8;
-  else if (strncmp (h->root.root.string, "__stop_", 7) == 0)
-    sec_name = h->root.root.string + 7;
-
-  if (sec_name != NULL && *sec_name != '\0')
-    {
-      bfd *i;
-
-      for (i = info->input_bfds; i != NULL; i = i->link.next)
-	{
-	  s = bfd_get_section_by_name (i, sec_name);
-	  if (s != NULL)
-	    {
-	      h->root.u.undef.section = s;
-	      break;
-	    }
-	}
-    }
-
-  if (s == NULL)
-    h->root.u.undef.section = (asection *) 0 - 1;
-
-  return s;
-}
-
 /* COOKIE->rel describes a relocation against section SEC, which is
    a section we've decided to keep.  Return the section that contains
    the relocation symbol, or NULL if no section contains it.  */
@@ -12777,10 +12728,9 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
 	     or __stop_XXX symbols.  The linker will later define such
 	     symbols for orphan input sections that have a name
 	     representable as a C identifier.  */
-	  asection *s = _bfd_elf_is_start_stop (info, h);
-
-	  if (s != NULL)
+	  if (h->start_stop)
 	    {
+	      asection *s = h->root.u.undef.section;
 	      *start_stop = !s->gc_mark;
 	      return s;
 	    }
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 0260b7a..7a06afe 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1216,6 +1216,9 @@ gld${EMULATION_NAME}_after_open (void)
 {
   struct bfd_link_needed_list *needed, *l;
   struct elf_link_hash_table *htab;
+  asection *s;
+  bfd *abfd;
+  char leading_char;
 
   after_open_default ();
 
@@ -1239,8 +1242,6 @@ gld${EMULATION_NAME}_after_open (void)
 
   if (emit_note_gnu_build_id != NULL)
     {
-      bfd *abfd;
-
       /* Find an ELF input.  */
       for (abfd = link_info.input_bfds;
 	   abfd != (bfd *) NULL; abfd = abfd->link.next)
@@ -1276,11 +1277,66 @@ 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_XXX
+     or __stop_XXX 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->root.u.undef.section == NULL)
+	      {
+		h->start_stop = 1;
+		h->root.u.undef.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->root.u.undef.section == NULL)
+	      {
+		h->start_stop = 1;
+		h->root.u.undef.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 *abfd, *elfbfd = NULL;
+      bfd *elfbfd = NULL;
       bfd_boolean warn_eh_frame = FALSE;
-      asection *s;
       int seen_type = 0;
 
       for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 790b52f..44ad84b 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -4657,6 +4657,14 @@ SECTIONS @{
 @end group
 @end smallexample
 
+If an output section's name is the same as the input section's name
+and is representable as a C identifier, then the linker will
+automatically @pxref{PROVIDE} two symbols: __start_SECNAME and
+__stop_SECNAME, where SECNAME is the name of the section.  These
+indicate the start address and end address of the output section
+respectively.  Note: most section names are not representable as
+C identifiers because they contain a @samp{.} character.
+
 @node Output Section Data
 @subsection Output Section Data
 @cindex data
@@ -5841,14 +5849,6 @@ The command line options @samp{--orphan-handling} and @samp{--unique}
 (@pxref{Options,,Command Line Options}) can be used to control which
 output sections an orphan is placed in.
 
-If an orphaned section's name is representable as a C identifier then
-the linker will automatically @pxref{PROVIDE} two symbols:
-__start_SECNAME and __stop_SECNAME, where SECNAME is the name of the
-section.  These indicate the start address and end address of the
-orphaned section respectively.  Note: most section names are not
-representable as C identifiers because they contain a @samp{.}
-character.
-
 @node Location Counter
 @subsection The Location Counter
 @kindex .
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 252400b..69619cd 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1829,8 +1829,6 @@ lang_insert_orphan (asection *s,
 		    lang_statement_list_type *add_child)
 {
   lang_statement_list_type add;
-  const char *ps;
-  lang_assignment_statement_type *start_assign;
   lang_output_section_statement_type *os;
   lang_output_section_statement_type **os_tail;
 
@@ -1852,29 +1850,6 @@ lang_insert_orphan (asection *s,
   os = lang_enter_output_section_statement (secname, address, normal_section,
 					    NULL, NULL, NULL, constraint, 0);
 
-  ps = NULL;
-  start_assign = NULL;
-  if (config.build_constructors && *os_tail == os)
-    {
-      /* If the name of the section is representable in C, then create
-	 symbols to mark the start and the end of the section.  */
-      for (ps = secname; *ps != '\0'; ps++)
-	if (!ISALNUM ((unsigned char) *ps) && *ps != '_')
-	  break;
-      if (*ps == '\0')
-	{
-	  char *symname;
-
-	  symname = (char *) xmalloc (ps - secname + sizeof "__start_" + 1);
-	  symname[0] = bfd_get_symbol_leading_char (link_info.output_bfd);
-	  sprintf (symname + (symname[0] != 0), "__start_%s", secname);
-	  start_assign
-	    = lang_add_assignment (exp_provide (symname,
-						exp_nameop (NAME, "."),
-						FALSE));
-	}
-    }
-
   if (add_child == NULL)
     add_child = &os->children;
   lang_add_section (add_child, s, NULL, os);
@@ -1894,27 +1869,6 @@ lang_insert_orphan (asection *s,
     lang_leave_output_section_statement (NULL, DEFAULT_MEMORY_REGION, NULL,
 					 NULL);
 
-  if (start_assign != NULL)
-    {
-      char *symname;
-      lang_assignment_statement_type *stop_assign;
-      bfd_vma dot;
-
-      symname = (char *) xmalloc (ps - secname + sizeof "__stop_" + 1);
-      symname[0] = bfd_get_symbol_leading_char (link_info.output_bfd);
-      sprintf (symname + (symname[0] != 0), "__stop_%s", secname);
-      stop_assign
-	= lang_add_assignment (exp_provide (symname,
-					    exp_nameop (NAME, "."),
-					    FALSE));
-      /* Evaluate the expression to define the symbol if referenced,
-	 before sizing dynamic sections.  */
-      dot = os->bfd_section->vma;
-      exp_fold_tree (start_assign->exp, os->bfd_section, &dot);
-      dot += TO_ADDR (s->size);
-      exp_fold_tree (stop_assign->exp, os->bfd_section, &dot);
-    }
-
   /* Restore the global list pointer.  */
   if (after != NULL)
     pop_stat_ptr ();
@@ -5924,21 +5878,29 @@ section_for_dot (void)
   return bfd_abs_section_ptr;
 }
 
-/* Fix any .startof. or .sizeof. symbols.  When the assemblers see the
-   operator .startof. (section_name), it produces an undefined symbol
-   .startof.section_name.  Similarly, when it sees
+/* 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.  For all the output sections, we look for
-   such symbols, and set them to the correct value.  */
+   .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.  */
 
 static void
 lang_set_startof (void)
 {
   asection *s;
+  bfd_boolean is_elf;
+  char leading_char;
 
   if (bfd_link_relocatable (&link_info))
     return;
 
+  is_elf = (bfd_get_flavour (link_info.output_bfd)
+	    == bfd_target_elf_flavour);
+  leading_char = bfd_get_symbol_leading_char (link_info.output_bfd);
+
   for (s = link_info.output_bfd->sections; s != NULL; s = s->next)
     {
       const char *secname;
@@ -5966,6 +5928,35 @@ lang_set_startof (void)
 	  h->u.def.section = bfd_abs_section_ptr;
 	}
 
+      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))
+	{
+	  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;
+	}
+
+      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->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;
+	}
       free (buf);
     }
 }
diff --git a/ld/testsuite/ld-elf/pr21562.t b/ld/testsuite/ld-elf/pr21562.t
new file mode 100644
index 0000000..01478e6
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562.t
@@ -0,0 +1,3 @@
+SECTIONS {
+        scnfoo : { *(scnfoo) }
+}
diff --git a/ld/testsuite/ld-elf/pr21562a.d b/ld/testsuite/ld-elf/pr21562a.d
new file mode 100644
index 0000000..009dcfc
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562a.d
@@ -0,0 +1,9 @@
+#ld: -shared -z defs --gc-sections
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__start_scnfoo
+#pass
diff --git a/ld/testsuite/ld-elf/pr21562a.s b/ld/testsuite/ld-elf/pr21562a.s
new file mode 100644
index 0000000..ec36da4
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562a.s
@@ -0,0 +1,8 @@
+        .section        scnfoo,"aw",%progbits
+        .zero 0x10
+
+        .globl  bar
+        .data
+        .type   bar, %object
+bar:
+        .dc.a   __start_scnfoo
diff --git a/ld/testsuite/ld-elf/pr21562b.d b/ld/testsuite/ld-elf/pr21562b.d
new file mode 100644
index 0000000..a03dbad
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562b.d
@@ -0,0 +1,9 @@
+#ld: -shared -z defs --gc-sections
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__stop_scnfoo
+#pass
diff --git a/ld/testsuite/ld-elf/pr21562b.s b/ld/testsuite/ld-elf/pr21562b.s
new file mode 100644
index 0000000..1732ee2
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562b.s
@@ -0,0 +1,8 @@
+        .section        scnfoo,"aw",%progbits
+        .zero 0x10
+
+        .globl  bar
+        .data
+        .type   bar, %object
+bar:
+        .dc.a   __stop_scnfoo
diff --git a/ld/testsuite/ld-elf/pr21562c.d b/ld/testsuite/ld-elf/pr21562c.d
new file mode 100644
index 0000000..1d63f0c
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562c.d
@@ -0,0 +1,10 @@
+#source: pr21562a.s
+#ld: -shared -z defs --gc-sections -T pr21562.t
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__start_scnfoo
+#pass
diff --git a/ld/testsuite/ld-elf/pr21562d.d b/ld/testsuite/ld-elf/pr21562d.d
new file mode 100644
index 0000000..d87725e
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562d.d
@@ -0,0 +1,10 @@
+#source: pr21562b.s
+#ld: -shared -z defs --gc-sections -T pr21562.t
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__stop_scnfoo
+#pass
diff --git a/ld/testsuite/ld-elf/pr21562e.d b/ld/testsuite/ld-elf/pr21562e.d
new file mode 100644
index 0000000..afaf7e5
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562e.d
@@ -0,0 +1,10 @@
+#source: pr21562a.s
+#ld: -shared -z defs
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__start_scnfoo
+#pass
diff --git a/ld/testsuite/ld-elf/pr21562f.d b/ld/testsuite/ld-elf/pr21562f.d
new file mode 100644
index 0000000..b9c324a
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562f.d
@@ -0,0 +1,10 @@
+#source: pr21562b.s
+#ld: -shared -z defs
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__stop_scnfoo
+#pass
diff --git a/ld/testsuite/ld-elf/pr21562g.d b/ld/testsuite/ld-elf/pr21562g.d
new file mode 100644
index 0000000..0760027
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562g.d
@@ -0,0 +1,10 @@
+#source: pr21562a.s
+#ld: -shared -z defs -T pr21562.t
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__start_scnfoo
+#pass
diff --git a/ld/testsuite/ld-elf/pr21562h.d b/ld/testsuite/ld-elf/pr21562h.d
new file mode 100644
index 0000000..e654140
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21562h.d
@@ -0,0 +1,10 @@
+#source: pr21562b.s
+#ld: -shared -z defs -T pr21562.t
+#readelf: -s -S --wide
+#target: *-*-linux* *-*-gnu*
+
+#...
+  \[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__stop_scnfoo
+#pass
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index ba5c46b..364c73b 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -119,6 +119,12 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
 	run_dump_test "personality"
     }
     run_dump_test "pr18223"
+    if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/pr20022a.s tmpdir/pr20022a.o]
+	|| ![ld_link $ld tmpdir/pr20022.so "-shared --gc-sections tmpdir/pr20022a.o"] } then {
+	fail pr20022
+    } else {
+	run_dump_test "pr20022"
+    }
 }
 
 if { [is_remote host] || [which $CC] != 0 } {
diff --git a/ld/testsuite/ld-gc/pr19161.d b/ld/testsuite/ld-gc/pr19161.d
index c36e663..baee8da 100644
--- a/ld/testsuite/ld-gc/pr19161.d
+++ b/ld/testsuite/ld-gc/pr19161.d
@@ -6,5 +6,5 @@
 #xfail: mips64vr-*-* msp430-*-* powerpc*-*-eabivle rl78-*-* rx-*-* sh*-*-*
 
 #...
-0*[1-9a-f]+[0-9a-f]*[ 	](D)[ 	]_*__start_my_section
+0*[1-9a-f]+[0-9a-f]*[ 	](d|D)[ 	]_*__start_my_section
 #...
diff --git a/ld/testsuite/ld-gc/pr20022.d b/ld/testsuite/ld-gc/pr20022.d
new file mode 100644
index 0000000..b51ec19
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr20022.d
@@ -0,0 +1,11 @@
+#source: pr20022b.s
+#ld: --gc-sections -e _start tmpdir/pr20022.so
+#readelf: -SsW
+#target: *-*-linux* *-*-gnu*
+#notarget: *-*-*aout *-*-*oldld frv-*-linux* metag-*-linux*
+
+#...
+  \[[ 0-9]+\] _foo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+[ \t]+.*
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__start__foo
+#pass
diff --git a/ld/testsuite/ld-gc/pr20022a.s b/ld/testsuite/ld-gc/pr20022a.s
new file mode 100644
index 0000000..6bd346f
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr20022a.s
@@ -0,0 +1,8 @@
+	.data
+	.globl bar
+	.type bar,%object
+bar:
+	.dc.a	__start__foo
+	.section _foo,"aw",%progbits
+foo:
+	.ascii "This is bar"
diff --git a/ld/testsuite/ld-gc/pr20022b.s b/ld/testsuite/ld-gc/pr20022b.s
new file mode 100644
index 0000000..2306c59
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr20022b.s
@@ -0,0 +1,8 @@
+	.text
+	.globl _start
+_start:
+	.dc.a	__start__foo
+	.dc.a	bar
+	.section _foo,"aw",%progbits
+foo:
+	.ascii "This is foo"
diff --git a/ld/testsuite/ld-gc/start.d b/ld/testsuite/ld-gc/start.d
index 18e74c1..9113b48 100644
--- a/ld/testsuite/ld-gc/start.d
+++ b/ld/testsuite/ld-gc/start.d
@@ -5,5 +5,5 @@
 #notarget: *-*-*aout *-*-*oldld frv-*-linux* metag-*-linux*
 
 #...
-[0-9a-f]+ D +__start__foo
+[0-9a-f]+ d +__start__foo
 #...
diff --git a/ld/testsuite/ld-x86-64/lea1a.d b/ld/testsuite/ld-x86-64/lea1a.d
index 9b662cb..28ea4b9 100644
--- a/ld/testsuite/ld-x86-64/lea1a.d
+++ b/ld/testsuite/ld-x86-64/lea1a.d
@@ -15,5 +15,5 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    -0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <foo>
 [ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <bar>
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <__start_my_section>
-[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <__stop_my_section>
+[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <.*>
 #pass
diff --git a/ld/testsuite/ld-x86-64/lea1b.d b/ld/testsuite/ld-x86-64/lea1b.d
index 9108149..c7873cd 100644
--- a/ld/testsuite/ld-x86-64/lea1b.d
+++ b/ld/testsuite/ld-x86-64/lea1b.d
@@ -15,5 +15,5 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    -0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <foo>
 [ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <bar>
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <__start_my_section>
-[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <__stop_my_section>
+[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <.*>
 #pass
diff --git a/ld/testsuite/ld-x86-64/lea1d.d b/ld/testsuite/ld-x86-64/lea1d.d
index 4d708d2..70fc603 100644
--- a/ld/testsuite/ld-x86-64/lea1d.d
+++ b/ld/testsuite/ld-x86-64/lea1d.d
@@ -15,5 +15,5 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    -0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <foo>
 [ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <bar>
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <__start_my_section>
-[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <__stop_my_section>
+[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <.*>
 #pass
diff --git a/ld/testsuite/ld-x86-64/lea1e.d b/ld/testsuite/ld-x86-64/lea1e.d
index da60137..123fcd2 100644
--- a/ld/testsuite/ld-x86-64/lea1e.d
+++ b/ld/testsuite/ld-x86-64/lea1e.d
@@ -15,5 +15,5 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    -0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <foo>
 [ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <bar>
 [ 	]*[a-f0-9]+:	48 8d 05 ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%rax        # [a-f0-9]+ <__start_my_section>
-[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <__stop_my_section>
+[ 	]*[a-f0-9]+:	4c 8d 1d ([0-9a-f]{2} ){4} *	lea    0x[a-f0-9]+\(%rip\),%r11        # [a-f0-9]+ <.*>
 #pass
-- 
2.9.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]