branch-updates
authorMatthias Klose <doko@debian.org>
Wed, 18 Sep 2024 08:36:17 +0000 (10:36 +0200)
committerMatthias Klose <doko@debian.org>
Wed, 18 Sep 2024 08:36:17 +0000 (10:36 +0200)
# DP: updates from the binutils-2.43 branch

# DP: updates from the binutils-2.43 branch

# git diff beb2cdbcda911764b2bed5e57921fe90493260bd a470646786e9c0e02b03668166d757aec1f6da0b

Gbp-Pq: Name branch-updates.diff

bfd/development.sh
bfd/elf.c
bfd/version.h
ld/testsuite/ld-plugin/common-1.c [new file with mode: 0644]
ld/testsuite/ld-plugin/common-2a.c [new file with mode: 0644]
ld/testsuite/ld-plugin/common-2b.c [new file with mode: 0644]
ld/testsuite/ld-plugin/definition-1.c [new file with mode: 0644]
ld/testsuite/ld-plugin/lto.exp

index ad74927b5cb1a919472e1f60728d8ac174e84a67..8503914896c44bb87a1350e57b500196eb49c9b2 100644 (file)
@@ -16,7 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Controls whether to enable development-mode features by default.
-development=false
+development=true
 
 # Indicate whether this is a release branch.
 experimental=false
index f85f79e1e35e8c8570dca7e69f48b36fac34aa8b..389c1560d816e56fbac45528f73ea17636f8fdaf 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -285,9 +285,7 @@ bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
       offset = i_shdrp[shindex]->sh_offset;
       shstrtabsize = i_shdrp[shindex]->sh_size;
 
-      /* Allocate and clear an extra byte at the end, to prevent crashes
-        in case the string table is not terminated.  */
-      if (shstrtabsize + 1 <= 1
+      if (shstrtabsize == 0
          || bfd_seek (abfd, offset, SEEK_SET) != 0
          || (shstrtab
              = _bfd_mmap_readonly_persistent (abfd, shstrtabsize)) == NULL)
@@ -297,14 +295,13 @@ bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
             the string table over and over.  */
          i_shdrp[shindex]->sh_size = 0;
        }
-      else if (shstrtab[shstrtabsize - 1] != '\0')
+      else if (shstrtab[shstrtabsize - 1] != 0)
        {
          /* It is an error if a string table isn't terminated.  */
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%pB(%pA): string table is corrupt"),
-            abfd, i_shdrp[shindex]->bfd_section);
-         return NULL;
+           (_("%pB: string table [%u] is corrupt"), abfd, shindex);
+         shstrtab[shstrtabsize - 1] = 0;
        }
       i_shdrp[shindex]->contents = shstrtab;
     }
@@ -1914,7 +1911,7 @@ _bfd_elf_get_dynamic_symbols (bfd *abfd, Elf_Internal_Phdr *phdr,
       _bfd_error_handler
        /* xgettext:c-format */
        (_("%pB: DT_STRTAB table is corrupt"), abfd);
-      goto error_return;
+      strbuf[dt_strsz - 1] = 0;
     }
 
   /* Get the real symbol count from DT_HASH or DT_GNU_HASH.  Prefer
index c9a311b12669588b1465c7d1bf02dd523724cd93..ae004727f44dc3566ace4b6b2eac50f972b8c906 100644 (file)
@@ -16,7 +16,7 @@
 
    In releases, the date is not included in either version strings or
    sonames.  */
-#define BFD_VERSION_DATE 20240817
+#define BFD_VERSION_DATE 20240912
 #define BFD_VERSION @bfd_version@
 #define BFD_VERSION_STRING  @bfd_version_package@ @bfd_version_string@
 #define REPORT_BUGS_TO @report_bugs_to@
diff --git a/ld/testsuite/ld-plugin/common-1.c b/ld/testsuite/ld-plugin/common-1.c
new file mode 100644 (file)
index 0000000..b4f616a
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int foo;
+
+int main()
+{
+  if (foo == 1)
+    printf ("PASS\n");
+
+  return 0;
+}
diff --git a/ld/testsuite/ld-plugin/common-2a.c b/ld/testsuite/ld-plugin/common-2a.c
new file mode 100644 (file)
index 0000000..fccfca7
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int foo;
+
+int main()
+{
+  if (foo == 0)
+    printf ("PASS\n");
+
+  return 0;
+}
diff --git a/ld/testsuite/ld-plugin/common-2b.c b/ld/testsuite/ld-plugin/common-2b.c
new file mode 100644 (file)
index 0000000..c014c67
--- /dev/null
@@ -0,0 +1,6 @@
+int foo;
+
+void
+func (void)
+{
+}
diff --git a/ld/testsuite/ld-plugin/definition-1.c b/ld/testsuite/ld-plugin/definition-1.c
new file mode 100644 (file)
index 0000000..a244740
--- /dev/null
@@ -0,0 +1 @@
+int foo = 1;
index 604dc8c284d172fbd385c0348e947a6b9d2abb44..602d94ed7b37fdd9eb039d7821c6aedd4e9d8676 100644 (file)
@@ -231,6 +231,30 @@ set lto_link_tests [list \
    "$plug_opt" "-flto $lto_no_fat -fcommon" \
    {pr26389.c} \
    [list [list "nm" "$plug_opt" "pr26389.d"]]] \
+  [list "Build libdefinition-1.a" \
+   "$plug_opt" \
+   "-O2 -fcommon -flto $lto_no_fat" \
+   {definition-1.c} \
+   {} \
+   "libdefinition-1.a" \
+  ] \
+  [list \
+   "Build common-2a.o" \
+   "" \
+   "-O2 -fcommon -flto $lto_no_fat" \
+   {common-2a.c} \
+   {} \
+   "" \
+   "c" \
+  ] \
+  [list \
+   "Build libcommon-2.a" \
+   "$plug_opt" \
+   "-O2 -fcommon -flto $lto_no_fat" \
+   {common-2b.c} \
+   {} \
+   "libcommon-2.a" \
+  ] \
 ]
 
 if { [at_least_gcc_version 10 0] && [check_lto_shared_available] } {
@@ -763,6 +787,17 @@ set lto_run_tests [list \
    {pr26262a.c} "pr26262b" "pass.out" \
    "-flto -O2" "c" "" \
    ""] \
+  [list "Run common-1" \
+   "-O2 -flto" \
+   "" \
+   {common-1.c} \
+   "common-1" \
+   "pass.out" \
+   "-O2 -fcommon -flto $lto_no_fat" \
+   "c" \
+   "" \
+   "tmpdir/libdefinition-1.a" \
+  ] \
 ]
 
 if { [at_least_gcc_version 4 7] } {
@@ -862,6 +897,26 @@ run_cc_link_tests $lto_link_tests
 # by some elf tests besides shared libs tests.  So, always compile them.
 run_cc_link_tests $lto_compile_elf_tests
 
+# Xfail PR ld/32083 test for GCC without the fix:
+#
+# commit a98dd536b1017c2b814a3465206c6c01b2890998
+# Author: H.J. Lu <hjl.tools@gmail.com>
+# Date:   Wed Aug 21 07:25:25 2024 -0700
+#
+#    Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook
+#
+set exec_output [run_host_cmd "$CC_FOR_TARGET" \
+                             "-O2 -fcommon -flto -o tmpdir/common-2 \
+                              tmpdir/common-2a.o tmpdir/libcommon-2.a \
+                              tmpdir/libcommon-2.a"]
+if [string match "" $exec_output] then {
+    pass "PR ld/32083"
+} elseif { [ regexp "lto1: fatal error: multiple prevailing defs for 'func'" $exec_output ] } {
+    xfail "PR ld/32083"
+} else {
+    fail "PR ld/32083"
+}
+
 # Restrict these to ELF targets that support shared libs and PIC.
 if { [is_elf_format] && [check_lto_shared_available] } {
     run_cc_link_tests $lto_link_elf_tests