public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Mark all weak aliases for copy relocations
Date: Tue, 28 Jan 2020 01:14:00 -0000	[thread overview]
Message-ID: <3024a17ae029ec7f55b498e99ddd6238e22fe565@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 3024a17ae029ec7f55b498e99ddd6238e22fe565 ***

commit 3024a17ae029ec7f55b498e99ddd6238e22fe565
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Mon Jan 27 10:27:42 2020 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Mon Jan 27 10:53:00 2020 +1030

    Mark all weak aliases for copy relocations
    
    bfd/
            PR ld/25458
            * elflink.c (_bfd_elf_gc_mark_rsec): Mark all weak aliases.
    ld/
            PR ld/25458
            * testsuite/ld-elf/pr25458.map: New file.
            * testsuite/ld-elf/pr25458.rd: Likewise.
            * testsuite/ld-elf/pr25458a.s: Likewise.
            * testsuite/ld-elf/pr25458b.s: Likewise.
            * testsuite/ld-elf/shared.exp: Run PR ld/25458 test.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 558e11eda3..3deba430f1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-27  H.J. Lu  <hongjiu.lu@intel.com>
+	    Alan Modra  <amodra@gmail.com>
+
+	PR ld/25458
+	* elflink.c (_bfd_elf_gc_mark_rsec): Mark all weak aliases.
+
 2020-01-24  Jim Wilson  <jimw@sifive.com>
 
 	* elfxx-riscv.c (riscv_get_prefix_class): Format s case like others.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 300be3f743..5217528a79 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -13123,7 +13123,7 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
 		       bfd_boolean *start_stop)
 {
   unsigned long r_symndx;
-  struct elf_link_hash_entry *h;
+  struct elf_link_hash_entry *h, *hw;
 
   r_symndx = cookie->rel->r_info >> cookie->r_sym_shift;
   if (r_symndx == STN_UNDEF)
@@ -13143,12 +13143,16 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
 	     || h->root.type == bfd_link_hash_warning)
 	h = (struct elf_link_hash_entry *) h->root.u.i.link;
       h->mark = 1;
-      /* If this symbol is weak and there is a non-weak definition, we
-	 keep the non-weak definition because many backends put
-	 dynamic reloc info on the non-weak definition for code
-	 handling copy relocs.  */
-      if (h->is_weakalias)
-	weakdef (h)->mark = 1;
+      /* Keep all aliases of the symbol too.  If an object symbol
+	 needs to be copied into .dynbss then all of its aliases
+	 should be present as dynamic symbols, not just the one used
+	 on the copy relocation.  */
+      hw = h;
+      while (hw->is_weakalias)
+	{
+	  hw = hw->u.alias;
+	  hw->mark = 1;
+	}
 
       if (start_stop != NULL)
 	{
diff --git a/ld/ChangeLog b/ld/ChangeLog
index f71c13564d..b39c8c09b2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
+2020-01-27  H.J. Lu  <hongjiu.lu@intel.com>
+	    Alan Modra  <amodra@gmail.com>
+
+	PR ld/25458
+	* testsuite/ld-elf/pr25458.map: New file.
+	* testsuite/ld-elf/pr25458.rd: Likewise.
+	* testsuite/ld-elf/pr25458a.s: Likewise.
+	* testsuite/ld-elf/pr25458b.s: Likewise.
+	* testsuite/ld-elf/shared.exp: Run PR ld/25458 test.
+
 2020-01-22  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/25416
diff --git a/ld/testsuite/ld-elf/pr25458.map b/ld/testsuite/ld-elf/pr25458.map
new file mode 100644
index 0000000000..5578d1fae7
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458.map
@@ -0,0 +1,4 @@
+FOO {
+global:
+  __environ; _environ; environ;
+};
diff --git a/ld/testsuite/ld-elf/pr25458.rd b/ld/testsuite/ld-elf/pr25458.rd
new file mode 100644
index 0000000000..d0fc6b9bed
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458.rd
@@ -0,0 +1,10 @@
+#...
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
+#...
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
+#...
+ +[0-9]+: [0-9a-f]+ +(4|8)+ OBJECT +(WEAK|GLOBAL) +DEFAULT +[0-9]+ _*environ@FOO \(2\)
+#pass
diff --git a/ld/testsuite/ld-elf/pr25458a.s b/ld/testsuite/ld-elf/pr25458a.s
new file mode 100644
index 0000000000..59e6af2c19
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458a.s
@@ -0,0 +1,6 @@
+	.text
+	.globl	_start
+	.type	_start, %function
+_start:
+	.dc.a	environ
+	.size	_start, .-_start
diff --git a/ld/testsuite/ld-elf/pr25458b.s b/ld/testsuite/ld-elf/pr25458b.s
new file mode 100644
index 0000000000..ff64cc7584
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25458b.s
@@ -0,0 +1,11 @@
+	.data
+	.globl __environ
+	.type __environ,%object
+__environ:
+	.dc.a	0
+	.size	__environ, .-__environ
+	.weak _environ
+	.globl _environ
+	.set _environ, __environ
+	.weak environ
+	.set environ, __environ
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index e03906a142..b1762aff9b 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -337,6 +337,38 @@ if { [check_gc_sections_available] } {
 	    "pr22150" \
 	] \
     ]
+
+    switch -glob $target_triplet {
+	# exclude targets that don't support copy relocs
+	bfin-*-* { }
+	frv-*-* { }
+	lm32-*-* { }
+	mips*-*-* { }
+	tic6x-*-* { }
+	xtensa-*-* { }
+	default {
+	    run_ld_link_tests [list \
+		[list \
+		     "Build pr25458.so" \
+		     "$LFLAGS -shared --version-script=pr25458.map" \
+		     "" \
+		     "$AFLAGS_PIC" \
+		     {pr25458b.s} \
+		     {} \
+		     "pr25458.so" \
+		] \
+		[list \
+		     "Build pr25458" \
+		     "$LFLAGS -e _start --gc-sections" \
+		     "tmpdir/pr25458.so" \
+		     "$AFLAGS_PIC" \
+		     {pr25458a.s} \
+		     {{readelf {--dyn-sym --wide} pr25458.rd}} \
+		     "pr25458" \
+		] \
+	    ]
+	}
+    }
 }
 
 set ASFLAGS $old_ASFLAGS


             reply	other threads:[~2020-01-28  0:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28  1:14 gdb-buildbot [this message]
2020-01-28  0:47 ` Failures on Fedora-i686, branch master gdb-buildbot
2020-01-28  1:21 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-01-28  1:40 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-01-28  1:54 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-28  2:06 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-01-28  2:34 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-28  4:13 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-01-28  4:36 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot
2020-01-28  4:36 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3024a17ae029ec7f55b498e99ddd6238e22fe565@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).