Bug 31133 - [riscv64] -z now breaks glibc testsuite
Summary: [riscv64] -z now breaks glibc testsuite
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.41
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-10 17:13 UTC by Aurelien Jarno
Modified: 2023-12-12 17:46 UTC (History)
2 users (show)

See Also:
Host: riscv64-unknown-linux-gnu
Target: riscv64-unknown-linux-gnu
Build: riscv64-unknown-linux-gnu
Last reconfirmed:


Attachments
Reproducer (9.44 MB, application/x-xz)
2023-12-10 17:19 UTC, Aurelien Jarno
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2023-12-10 17:13:10 UTC
Building glibc 2.38 with --enable-bind-now on riscv64 with the current binutils binutils-2_41-branch branch (actually through the sid debian package in version 2.41.50.20231206-1) causes the elf/tst-audit1 elf/tst-audit2 elf/tst-audit8 tests to fail with a segfault.

Not using --enable-bind-now, that is not passing -z now to ld, workaround the issue. This is a regression from version 2.41, for which the tests pass with both with and without --enable-bind-now.
Comment 1 Aurelien Jarno 2023-12-10 17:19:47 UTC
Created attachment 15251 [details]
Reproducer

I have attached a (big) reproduced for this bug. This is basically the files from the glibc build tree and the associated tests. Just use run.sh to link libc.so with and without -z now and see the difference in the testsuite result
Comment 2 Aurelien Jarno 2023-12-12 06:15:42 UTC
A bisect pointed me to the following commit:

7345d05aafde53a48d5a587a6d9c1778db78e0f3 is the first bad commit
commit 7345d05aafde53a48d5a587a6d9c1778db78e0f3
Author: Andreas Schwab <schwab@suse.de>
Date:   Thu Sep 21 16:49:41 2023 +0200

    RISC-V: Protect .got with relro

    Move .got before .data so that it can be protected with -zrelro.  Also
    separate .got.plt from .got if -znow is not in effect; the first two words
    of .got.plt are placed within the relro region.

    ld:
            PR ld/30877
            * emulparams/elf32lriscv-defs.sh (DATA_GOT, SEPARATE_GOTPLT):
            Define.
            * emulparams/elf64lriscv-defs.sh (SEPARATE_GOTPLT): Define.
            * testsuite/ld-elf/binutils.exp (binutils_test): Remove riscv*-*-*
            from relro_got expression.

 ld/emulparams/elf32lriscv-defs.sh | 4 ++++
 ld/emulparams/elf64lriscv-defs.sh | 1 +
 ld/testsuite/ld-elf/binutils.exp  | 1 -
 3 files changed, 5 insertions(+), 1 deletion(-)
Comment 3 Andreas Schwab 2023-12-12 09:23:05 UTC
Which means it is a bug in glibc.
Comment 4 Aurelien Jarno 2023-12-12 17:46:30 UTC
(In reply to Andreas Schwab from comment #3)
> Which means it is a bug in glibc.

Ok, thanks, I have opened bug #31151.

Closing the bug here.