On binutils 2.39 (~ release branch as of now), running on aarch64 Gentoo, we get two ld test failures: FAIL: ld-aarch64/tls-relax-gdesc-le-now FAIL: BTI PLT with only GNU PROP Any ideas what's going on? More info on request. Test log snippets follow: /var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../gas/as-new -o tmpdir/tls-relax-gdesc-le.o /var/tmp/portage/sys-devel/binutils-2.39-r4/work/binutils-2.39/ld/testsuite/ ld-aarch64/tls-relax-gdesc-le.s Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../gas/as-new -o tmpdir/tls-relax-gdesc-le.o /var/tmp/portage/sys-devel/binutils-2.39-r4/work/b inutils-2.39/ld/testsuite/ld-aarch64/tls-relax-gdesc-le.s 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] ./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-2.39-r4/work/binutils-2.39/ld/testsuite/ld-aarch64 -shared -z now -o tmpdir/dump tmpdir/tls-relax-gdesc-l e.o Executing on host: sh -c {./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-2.39-r4/work/binutils-2.39/ld/testsuite/ld-aarch64 -shared -z now -o tmpdir/dum p tmpdir/tls-relax-gdesc-le.o 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] /var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../binutils/readelf -dr tmpdir/dump > tmpdir/dump.out Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../binutils/readelf -dr tmpdir/dump > tmpdir/dump.out 2>dump.tmp} /dev/null (timeout = 300) spawn [open ...] regexp_diff match failure regexp "^ 0x.+ \(BIND_NOW\) \s+$" line " 0x000000000000001e (FLAGS) BIND_NOW" FAIL: ld-aarch64/tls-relax-gdesc-le-now /var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../gas/as-new -mabi=lp64 -defsym __property_bti__=1 -o tmpdir/property-bti-pac1.o /var/tmp/portage/sys-devel/binutils-2.39- r4/work/binutils-2.39/ld/testsuite/ld-aarch64/property-bti-pac1.s Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../gas/as-new -mabi=lp64 -defsym __property_bti__=1 -o tmpdir/property-bti-pac1.o /var/tmp/portag e/sys-devel/binutils-2.39-r4/work/binutils-2.39/ld/testsuite/ld-aarch64/property-bti-pac1.s 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] ./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-2.39-r4/work/binutils-2.39/ld/testsuite/ld-aarch64 -e _start -L./tmpdir -lbti-plt-so -o tmpdir/dump tmpdi r/property-bti-pac1.o Executing on host: sh -c {./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-2.39-r4/work/binutils-2.39/ld/testsuite/ld-aarch64 -e _start -L./tmpdir -lbti-p lt-so -o tmpdir/dump tmpdir/property-bti-pac1.o 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] /var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../binutils/objdump -dr -j .plt tmpdir/dump > tmpdir/dump.out Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-2.39-r4/work/build/ld/../binutils/objdump -dr -j .plt tmpdir/dump > tmpdir/dump.out 2>dump.tmp} /dev/null (timeout = 3 00) spawn [open ...] regexp_diff match failure regexp "^.*: f9421611 ldr x17, \[x16, #1064\]$" line " 40028c: f941fe11 ldr x17, [x16, #1016]" regexp_diff match failure regexp "^.*: 9110a210 add x16, x16, #0x428$" line " 400290: 910fe210 add x16, x16, #0x3f8" regexp_diff match failure regexp "^.*: f9421a11 ldr x17, \[x16, #1072\]$" line " 4002a8: f9420211 ldr x17, [x16, #1024]" regexp_diff match failure regexp "^.*: 9110c210 add x16, x16, #0x430$" line " 4002ac: 91100210 add x16, x16, #0x400" FAIL: BTI PLT with only GNU PROP
> FAIL: ld-aarch64/tls-relax-gdesc-le-now > regexp_diff match failure > regexp "^ 0x.+ \(BIND_NOW\) \s+$" > line " 0x000000000000001e (FLAGS) BIND_NOW" > FAIL: ld-aarch64/tls-relax-gdesc-le-now This should be harmless (but why it causes a test failure is a mystery to me). As far as I understand it right now, marking something with DT_BIND_NOW (which the regexp checks for) is an older way, and nowadays binaries are marked with DF_BIND_NOW (which is the value that fails the regexp). Did the test never work? Or did the code at some point change (i.e. something was unified between arches and aarch switched to the common variant)?
> spawn [open ...] > regexp_diff match failure > regexp "^.*: f9421611 ldr x17, \[x16, #1064\]$" > line " 40028c: f941fe11 ldr x17, [x16, #1016]" > regexp_diff match failure > regexp "^.*: 9110a210 add x16, x16, #0x428$" > line " 400290: 910fe210 add x16, x16, #0x3f8" > regexp_diff match failure > regexp "^.*: f9421a11 ldr x17, \[x16, #1072\]$" > line " 4002a8: f9420211 ldr x17, [x16, #1024]" > regexp_diff match failure > regexp "^.*: 9110c210 add x16, x16, #0x430$" > line " 4002ac: 91100210 add x16, x16, #0x400" > FAIL: BTI PLT with only GNU PROP CC'ing test author
> > FAIL: BTI PLT with only GNU PROP > Tried to find a commit where it started to fail (by building from git), but could not find one (fails all the way back to the introduction of the test). Assuming it worked in the beginning, the cause for the failure must lie outside binutils.
Hi Andreas, These tests appear to be passing now - at least they are for me on the 2.40 branch and the current mainline. Do you get the same results ? If so, then I think that we can close this PR. Cheers Nick
I just tried with current master (5aea5eca6c873334deb41f996dec255786a6f84d) and still get the same failures. Full build log upload following. We apply a small patchset but I dont immediately see how it could be relevant. https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/tree/9999 FAIL: ld-aarch64/tls-relax-gdesc-le-now FAIL: BTI PLT with only GNU PROP PASS: ld-aarch64/tls-relax-gdesc-le /var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../gas/as-new -o tmpdir/tls-relax-gdesc-le.o /var/tmp/portage/sys-devel/binutils-9999/work/binutils/ld/testsuite/ld-aarch64/tls-relax- gdesc-le.s Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../gas/as-new -o tmpdir/tls-relax-gdesc-le.o /var/tmp/portage/sys-devel/binutils-9999/work/binutils/ld/tests uite/ld-aarch64/tls-relax-gdesc-le.s 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] ./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-9999/work/binutils/ld/testsuite/ld-aarch64 -shared -z now -o tmpdir/dump tmpdir/tls-relax-gdesc-le.o Executing on host: sh -c {./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-9999/work/binutils/ld/testsuite/ld-aarch64 -shared -z now -o tmpdir/dump tmpdir/tls-relax -gdesc-le.o 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] /var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../binutils/readelf -dr tmpdir/dump > tmpdir/dump.out Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../binutils/readelf -dr tmpdir/dump > tmpdir/dump.out 2>dump.tmp} /dev/null (timeout = 300) spawn [open ...] regexp_diff match failure regexp "^ 0x.+ \(BIND_NOW\) \s+$" line " 0x000000000000001e (FLAGS) BIND_NOW" FAIL: ld-aarch64/tls-relax-gdesc-le-now PASS: Check -z force-bti emits BTI feature (exec) /var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../gas/as-new -mabi=lp64 -defsym __property_bti__=1 -o tmpdir/property-bti-pac1.o /var/tmp/portage/sys-devel/binutils-9999/work/binutils /ld/testsuite/ld-aarch64/property-bti-pac1.s Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../gas/as-new -mabi=lp64 -defsym __property_bti__=1 -o tmpdir/property-bti-pac1.o /var/tmp/portage/sys-devel/b inutils-9999/work/binutils/ld/testsuite/ld-aarch64/property-bti-pac1.s 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] ./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-9999/work/binutils/ld/testsuite/ld-aarch64 -e _start -L./tmpdir -lbti-plt-so -o tmpdir/dump tmpdir/property-bti-pac 1.o Executing on host: sh -c {./ld-new --hash-style=sysv -z norelro -L/var/tmp/portage/sys-devel/binutils-9999/work/binutils/ld/testsuite/ld-aarch64 -e _start -L./tmpdir -lbti-plt-so -o tmpdir/du mp tmpdir/property-bti-pac1.o 2>&1} /dev/null dump.tmp (timeout = 300) spawn [open ...] /var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../binutils/objdump -dr -j .plt tmpdir/dump > tmpdir/dump.out Executing on host: sh -c {/var/tmp/portage/sys-devel/binutils-9999/work/build/ld/../binutils/objdump -dr -j .plt tmpdir/dump > tmpdir/dump.out 2>dump.tmp} /dev/null (timeout = 300) spawn [open ...] regexp_diff match failure regexp "^.*: f9421611 ldr x17, \[x16, #1064\]$" line " 40028c: f941fe11 ldr x17, [x16, #1016]" regexp_diff match failure regexp "^.*: 9110a210 add x16, x16, #0x428$" line " 400290: 910fe210 add x16, x16, #0x3f8" regexp_diff match failure regexp "^.*: f9421a11 ldr x17, \[x16, #1072\]$" line " 4002a8: f9420211 ldr x17, [x16, #1024]" regexp_diff match failure regexp "^.*: 9110c210 add x16, x16, #0x430$" line " 4002ac: 91100210 add x16, x16, #0x400" FAIL: BTI PLT with only GNU PROP
Created attachment 14550 [details] build log
(In reply to Andreas K. Huettel from comment #5) > I just tried with current master (5aea5eca6c873334deb41f996dec255786a6f84d) > and still get the same failures. Full build log upload following. > > We apply a small patchset but I dont immediately see how it could be > relevant. > https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/tree/9999 > > FAIL: ld-aarch64/tls-relax-gdesc-le-now > FAIL: BTI PLT with only GNU PROP I agree that at first glance that patch set does not look like it would cause these problems. But it would be nice to have it confirmed. ie, if you build a toolchain without any patches applied, do the failures still occur ? I suspect that the issue might be cross-builds vs native. I was running the tests on an x86_64 Fedora box. Are you running the tests on native hardware ? Cheers Nick
> > We apply a small patchset but I dont immediately see how it could be > > relevant. > > https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/tree/9999 > > > > FAIL: ld-aarch64/tls-relax-gdesc-le-now > > FAIL: BTI PLT with only GNU PROP > > I agree that at first glance that patch set does not look like it would cause > these problems. But it would be nice to have it confirmed. ie, if you > build > a toolchain without any patches applied, do the failures still occur ? Same result with the patchset disabled. > I suspect that the issue might be cross-builds vs native. I was running the > tests on an x86_64 Fedora box. Are you running the tests on native hardware > ? Yes, this is on native hardware. My main suspicion lies on our gcc hardening patchset, I'm setting up a chroot with a less-hardened gcc right now. jiji /var/db/repos/gentoo/sys-devel/binutils # uname -a Linux jiji 5.15.64-gentoo-dist #1 SMP Wed Aug 31 17:57:10 -00 2022 aarch64 GNU/Linux jiji /var/db/repos/gentoo/sys-devel/binutils # ld.so --version ld.so (Gentoo 2.36-r5 p5) stable release version 2.36. Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. jiji /var/db/repos/gentoo/sys-devel/binutils # ld --version GNU ld (Gentoo 2.39 p5) 2.39.0 Copyright (C) 2022 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. jiji /var/db/repos/gentoo/sys-devel/binutils # gcc --version gcc (Gentoo Hardened 11.3.1_p20221209 p3) 11.3.1 20221209 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. jiji /var/db/repos/gentoo/sys-devel/binutils # lscpu Architecture: aarch64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 80 On-line CPU(s) list: 0-79 Vendor ID: ARM BIOS Vendor ID: Ampere(R) Model name: Neoverse-N1 BIOS Model name: Ampere(R) Altra(R) Processor Q80-30 CPU @ 2.8GHz BIOS CPU family: 257 Model: 1 Thread(s) per core: 1 Core(s) per socket: 80 Socket(s): 1 Stepping: r3p1 Frequency boost: disabled CPU(s) scaling MHz: 54% CPU max MHz: 3000.0000 CPU min MHz: 1000.0000 BogoMIPS: 50.08 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs Caches (sum of all): L1d: 5 MiB (80 instances) L1i: 5 MiB (80 instances) L2: 80 MiB (80 instances) NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0-79 Vulnerabilities: Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Not affected Retbleed: Not affected Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Spectre v1: Mitigation; __user pointer sanitization Spectre v2: Mitigation; CSV2, BHB Srbds: Not affected Tsx async abort: Not affected jiji /var/db/repos/gentoo/sys-devel/binutils #
( (In reply to Andreas K. Huettel from comment #8) > Same result with the patchset disabled. OK, good. > Yes, this is on native hardware. Either way, it is obvious that the tests need to relax their regexps slightly, so would you like to propose a patch to do this ? If not, then I will make one myself. Cheers Nick
> > My main suspicion lies on our gcc hardening patchset, I'm setting up a > chroot with a less-hardened gcc right now. > OK, so it's *not* the gcc hardening patchset. Also, same fails with gcc-12. > > Either way, it is obvious that the tests need to relax their regexps > slightly, so would you like to propose a patch to do this ? If not, then I > will make one myself. > On it.
Created attachment 14553 [details] git patch relaxing the regexps Here's a git patch that makes the two tests pass here. It should also work elsewhere (but of course double-checking is better).
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=502c7218da3c486e58d6ce039b36fb4fa62d3a92 commit 502c7218da3c486e58d6ce039b36fb4fa62d3a92 Author: Andreas K. Huettel <dilfridge@gentoo.org> Date: Wed Jan 4 09:30:14 2023 +0000 Fix AArch64 linker testsuite failures trigeered by differences in build environments. PR 29843 * testsuite/ld-aarch64/bti-plt-5.d: Relax regxps slightly to allow for differences in build environments. * testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: Likewise.
The binutils-2_40-branch branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f4e184b2747542b123cd06c7f9a4fbaaedc1bbca commit f4e184b2747542b123cd06c7f9a4fbaaedc1bbca Author: Andreas K. Huettel <dilfridge@gentoo.org> Date: Wed Jan 4 09:31:12 2023 +0000 Fix AArch64 linker testsuite failures triggered by differences in build environments. PR 29843 * testsuite/ld-aarch64/bti-plt-5.d: Relax regxps slightly to allow for differences in build environments. * testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: Likewise.
(In reply to Andreas K. Huettel from comment #11) > Here's a git patch that makes the two tests pass here. > It should also work elsewhere (but of course double-checking is better). It works fine and did not trigger any regressions in my build farm, so I have gone ahead and applied the patch. (To the mainline and the 2.40 branch). Thanks for taking the time to work on this issue. Cheers Nick