Blame SOURCES/binutils-plugin-as-needed.patch

5affbb
diff -rup binutils.orig/ld/testsuite/ld-plugin/lto.exp binutils-2.35.1/ld/testsuite/ld-plugin/lto.exp
5affbb
--- binutils.orig/ld/testsuite/ld-plugin/lto.exp	2020-10-09 11:46:13.571665439 +0100
5affbb
+++ binutils-2.35.1/ld/testsuite/ld-plugin/lto.exp	2020-10-09 11:47:59.113302758 +0100
5affbb
@@ -319,27 +319,6 @@ set lto_link_elf_tests [list \
5affbb
   [list "PR ld/13244" \
5affbb
    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
5affbb
    {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
5affbb
-  [list "Build libpr15146a.a" \
5affbb
-   "$plug_opt" "-flto -O2" \
5affbb
-   {pr15146a.c} {} "lib15146a.a"] \
5affbb
-  [list "Build pr15146b.so" \
5affbb
-   "-shared" "-O2 -fpic" \
5affbb
-   {pr15146b.c} {} "pr15146b.so" "c"] \
5affbb
-  [list "Build pr15146c.so" \
5affbb
-   "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic" \
5affbb
-   {pr15146c.c} {} "pr15146c.so" "c"] \
5affbb
-  [list "PR ld/15146 (1)" \
5affbb
-   "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" "" \
5affbb
-   {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"] \
5affbb
-  [list "Build libpr15146d.a" \
5affbb
-   "$plug_opt" "-flto -O2" \
5affbb
-   {pr15146d.c} {} "lib15146d.a"] \
5affbb
-  [list "Build libpr16746a.a" \
5affbb
-   "" "" \
5affbb
-   {pr16746a.c pr16746b.c} {} "lib15146a.a"] \
5affbb
-  [list "Build libpr16746b.a" \
5affbb
-   "$plug_opt" "-O2 -flto" \
5affbb
-   {pr16746c.c pr16746d.c} {} "lib15146b.a"] \
5affbb
   [list "PR ld/16746 (1)" \
5affbb
    "-O2 -flto -fuse-linker-plugin tmpdir/pr16746a.o tmpdir/pr16746c.o" "-O2 -flto" \
5affbb
    {dummy.c} {} "pr16746a.exe"] \
5affbb
@@ -602,13 +581,6 @@ run_cc_link_tests $lto_compile_elf_tests
5affbb
 # Restrict these to ELF targets that support shared libs and PIC.
5affbb
 if { [is_elf_format] && [check_lto_shared_available] } {
5affbb
     run_cc_link_tests $lto_link_elf_tests
5affbb
-    set testname "PR ld/15146 (2)"
5affbb
-    set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
5affbb
-    if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
5affbb
-	pass $testname
5affbb
-    } {
5affbb
-	fail $testname
5affbb
-    }
5affbb
     set testname "PR ld/16746 (3)"
5affbb
     set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
5affbb
     if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
5affbb
5affbb
diff -rup binutils.orig/bfd/elflink.c binutils-2.35.1/bfd/elflink.c
5affbb
--- binutils.orig/bfd/elflink.c	2020-10-09 11:46:14.151663446 +0100
5affbb
+++ binutils-2.35.1/bfd/elflink.c	2020-10-09 11:46:27.222618528 +0100
5affbb
@@ -4970,11 +4970,7 @@ elf_link_add_object_symbols (bfd *abfd,
5affbb
 	     object and a shared object.  */
5affbb
 	  bfd_boolean dynsym = FALSE;
5affbb
 
5affbb
-	  /* Plugin symbols aren't normal.  Don't set def_regular or
5affbb
-	     ref_regular for them, or make them dynamic.  */
5affbb
-	  if ((abfd->flags & BFD_PLUGIN) != 0)
5affbb
-	    ;
5affbb
-	  else if (! dynamic)
5affbb
+	  if (! dynamic)
5affbb
 	    {
5affbb
 	      if (! definition)
5affbb
 		{
5affbb
@@ -5155,10 +5151,6 @@ elf_link_add_object_symbols (bfd *abfd,
5affbb
 	      && !bfd_link_relocatable (info))
5affbb
 	    dynsym = FALSE;
5affbb
 
5affbb
-	  /* Nor should we make plugin symbols dynamic.  */
5affbb
-	  if ((abfd->flags & BFD_PLUGIN) != 0)
5affbb
-	    dynsym = FALSE;
5affbb
-
5affbb
 	  if (definition)
5affbb
 	    {
5affbb
 	      h->target_internal = isym->st_target_internal;
5affbb
@@ -5185,7 +5177,7 @@ elf_link_add_object_symbols (bfd *abfd,
5affbb
 		}
5affbb
 	    }
5affbb
 
5affbb
-	  if (dynsym && h->dynindx == -1)
5affbb
+	  if (dynsym && (abfd->flags & BFD_PLUGIN) == 0 && h->dynindx == -1)
5affbb
 	    {
5affbb
 	      if (! bfd_elf_link_record_dynamic_symbol (info, h))
5affbb
 		goto error_free_vers;
5affbb
5affbb
--- binutils.orig/ld/testsuite/ld-plugin/lto.exp	2020-10-28 12:23:49.034685727 +0000
5affbb
+++ binutils-2.30/ld/testsuite/ld-plugin/lto.exp	2020-10-28 12:24:48.288484833 +0000
5affbb
@@ -265,12 +265,6 @@ set lto_link_elf_tests [list \
5affbb
   [list "PR ld/13244" \
5affbb
    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
5affbb
    {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
5affbb
-  [list "PR ld/16746 (1)" \
5affbb
-   "-O2 -flto -fuse-linker-plugin tmpdir/pr16746a.o tmpdir/pr16746c.o" "-O2 -flto" \
5affbb
-   {dummy.c} {} "pr16746a.exe"] \
5affbb
-  [list "PR ld/16746 (2)" \
5affbb
-   "-O2 -flto -fuse-linker-plugin tmpdir/pr16746c.o tmpdir/pr16746a.o" "-O2 -flto" \
5affbb
-   {dummy.c} {} "pr16746b.exe"] \
5affbb
   [list "Build pr21382a.o" \
5affbb
    "" "-O2 -flto" \
5affbb
    {pr21382a.c} {} "" "c"] \
5affbb
@@ -424,25 +418,6 @@ run_cc_link_tests $lto_link_tests
5affbb
 # by some elf tests besides shared libs tests.  So, always compile them.
5affbb
 run_cc_link_tests $lto_compile_elf_tests
5affbb
 
5affbb
-# Restrict these to ELF targets that support shared libs and PIC.
5affbb
-if { [is_elf_format] && [check_lto_shared_available] } {
5affbb
-    run_cc_link_tests $lto_link_elf_tests
5affbb
-    set testname "PR ld/16746 (3)"
5affbb
-    set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
5affbb
-    if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
5affbb
-	pass $testname
5affbb
-    } {
5affbb
-	fail $testname
5affbb
-    }
5affbb
-    set testname "PR ld/16746 (4)"
5affbb
-    set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"]
5affbb
-    if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
5affbb
-	pass $testname
5affbb
-    } {
5affbb
-	fail $testname
5affbb
-    }
5affbb
-}
5affbb
-
5affbb
 set testname "Build liblto-11.a"
5affbb
 remote_file host delete "tmpdir/liblto-11.a"
5affbb
 set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
5affbb
--- binutils.orig/ld/testsuite/ld-plugin/lto.exp	2020-10-28 12:47:18.581911539 +0000
5affbb
+++ binutils-2.30/ld/testsuite/ld-plugin/lto.exp	2020-10-28 12:50:25.048280769 +0000
5affbb
@@ -418,6 +418,11 @@ run_cc_link_tests $lto_link_tests
5affbb
 # by some elf tests besides shared libs tests.  So, always compile them.
5affbb
 run_cc_link_tests $lto_compile_elf_tests
5affbb
 
5affbb
+# Restrict these to ELF targets that support shared libs and PIC.
5affbb
+if { [is_elf_format] && [check_lto_shared_available] } {
5affbb
+    run_cc_link_tests $lto_link_elf_tests
5affbb
+}
5affbb
+
5affbb
 set testname "Build liblto-11.a"
5affbb
 remote_file host delete "tmpdir/liblto-11.a"
5affbb
 set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]