From: Matthias Klose Date: Wed, 18 Sep 2024 08:36:17 +0000 (+0200) Subject: branch-updates X-Git-Tag: archive/raspbian/2.43.1-5+rpi1^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=993bc93843b6f226d2b72f18a0874a57912aa9d1;p=binutils.git branch-updates # 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 --- diff --git a/bfd/development.sh b/bfd/development.sh index ad74927b5..850391489 100644 --- a/bfd/development.sh +++ b/bfd/development.sh @@ -16,7 +16,7 @@ # along with this program. If not, see . # Controls whether to enable development-mode features by default. -development=false +development=true # Indicate whether this is a release branch. experimental=false diff --git a/bfd/elf.c b/bfd/elf.c index f85f79e1e..389c1560d 100644 --- 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 diff --git a/bfd/version.h b/bfd/version.h index c9a311b12..ae004727f 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -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 index 000000000..b4f616aee --- /dev/null +++ b/ld/testsuite/ld-plugin/common-1.c @@ -0,0 +1,11 @@ +#include + +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 index 000000000..fccfca728 --- /dev/null +++ b/ld/testsuite/ld-plugin/common-2a.c @@ -0,0 +1,11 @@ +#include + +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 index 000000000..c014c673f --- /dev/null +++ b/ld/testsuite/ld-plugin/common-2b.c @@ -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 index 000000000..a244740a3 --- /dev/null +++ b/ld/testsuite/ld-plugin/definition-1.c @@ -0,0 +1 @@ +int foo = 1; diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 604dc8c28..602d94ed7 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -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 +# 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