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

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