Bug 31151 - [RISC-V] missing support for profile/audit PLT setup
Summary: [RISC-V] missing support for profile/audit PLT setup
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.39
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-12 17:45 UTC by Aurelien Jarno
Modified: 2023-12-30 10:02 UTC (History)
2 users (show)

See Also:
Host: riscv*-*-*
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2023-12-12 17:45:20 UTC
The following patch has been recently merged in binutils:

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(-)

It causes the elf/audit1 elf/tst-audit2 elf/tst-audit8 glibc tests to fail with a segmentation fault if configured with --enable-bind-now. It appears to be a bug in glibc.
Comment 1 Andreas Schwab 2023-12-13 12:43:36 UTC
riscv is missing all of the required profile/audit setup.
Comment 2 Aurelien Jarno 2023-12-13 18:02:18 UTC
(In reply to Andreas Schwab from comment #1)
> riscv is missing all of the required profile/audit setup.

Thanks for looking at that, it makes sense. Do you plan to work on that, or should I look what I can do?
Comment 3 Sourceware Commits 2023-12-30 10:00:32 UTC
The master branch has been updated by Aurelien Jarno <aurel32@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6b32696116e0097f5dd578ec087bcbef483f2a07

commit 6b32696116e0097f5dd578ec087bcbef483f2a07
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Sat Dec 30 11:00:10 2023 +0100

    RISC-V: Add support for dl_runtime_profile (BZ #31151)
    
    Code is mostly inspired from the LoongArch one, which has a similar ABI,
    with minor changes to support riscv32 and register differences.
    
    This fixes elf/tst-sprof-basic. This also fixes elf/tst-audit1,
    elf/tst-audit2 and elf/tst-audit8 with recent binutils snapshots when
    --enable-bind-now is used.
    
    Resolves: BZ #31151
    
    Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Comment 4 Aurelien Jarno 2023-12-30 10:02:31 UTC
Fixed in glibc master.