NetBSD Problem Report #59360
From www@netbsd.org Sat Apr 26 15:59:02 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 06A0B1A923C
for <gnats-bugs@gnats.NetBSD.org>; Sat, 26 Apr 2025 15:59:02 +0000 (UTC)
Message-Id: <20250426155900.C3EE51A923E@mollari.NetBSD.org>
Date: Sat, 26 Apr 2025 15:59:00 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: ld.elf_so(8): missing RELR support
X-Send-Pr-Version: www-1.0
>Number: 59360
>Category: bin
>Synopsis: ld.elf_so(8): missing RELR support
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Apr 26 16:00:00 +0000 2025
>Last-Modified: Fri May 02 23:05:03 +0000 2025
>Originator: Taylor R Campbell
>Release: current
>Organization:
The PackedBSD Relocation Elves, Inc.
>Environment:
>Description:
The RELR format is a compact format for R_*_RELATIVE-type relocations that dramatically reduces the size of relocation sections, which directly saves disk space and memory, and indirectly saves load time by reducing I/O and memory transactions.
No formal reference in the ELF gABI yet (https://www.sco.com/developers/gabi/latest/ch4.sheader.html) but here's a large dump of information about the background, motivation, and format:
https://maskray.me/blog/2021-10-31-relative-relocations-and-relr
GNU ld supports generating these sections on i386, amd64, amd64-with-ilp32, and powerpc64, with -Wl,-z,pack-relative-relocs.
>How-To-Repeat:
XXX add a simple test case that illustrates ld.elf_so's missing support for RELR
>Fix:
Yes, please!
>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src/sys/sys
Date: Sun, 27 Apr 2025 00:11:27 +0000
Module Name: src
Committed By: riastradh
Date: Sun Apr 27 00:11:27 UTC 2025
Modified Files:
src/sys/sys: exec_elf.h
Log Message:
sys/exec_elf.h: Nix trailing whitespace.
No functional change intended.
Preparation for:
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 src/sys/sys/exec_elf.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src/sys/sys
Date: Sun, 27 Apr 2025 00:11:41 +0000
Module Name: src
Committed By: riastradh
Date: Sun Apr 27 00:11:40 UTC 2025
Modified Files:
src/sys/sys: exec_elf.h
Log Message:
sys/exec_elf.h: Add some missing numbers from the ELF gABI.
Fix the meta-number DT_ENCODING while here: it is defined to be 32,
not 31; it is a name for the smallest DT_* tag that follows the rule
of only even-numbered tags using d_ptr, and odd-numbered tags using
either nothing or d_val. Nothing uses DT_ENCODING directly, though,
so this shouldn't affect anything.
https://www.sco.com/developers/gabi/latest/ch5.dynamic.html
Preparation for:
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/sys/exec_elf.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src/tests/libexec/ld.elf_so
Date: Sun, 27 Apr 2025 00:11:57 +0000
Module Name: src
Committed By: riastradh
Date: Sun Apr 27 00:11:57 UTC 2025
Modified Files:
src/tests/libexec/ld.elf_so: Makefile
Log Message:
tests/libexec/ld.elf_so/Makefile: Sort.
Preparation for:
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/libexec/ld.elf_so/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src
Date: Fri, 2 May 2025 03:26:27 +0000
Module Name: src
Committed By: riastradh
Date: Fri May 2 03:26:26 UTC 2025
Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/libexec/ld.elf_so: Makefile
Added Files:
src/tests/libexec/ld.elf_so: h_r_rel.c t_r_rel.sh
Log Message:
ld.elf_so: Add a trivial test for R_*_RELATIVE relocations.
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.480 -r1.481 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1373 -r1.1374 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.26 -r1.27 src/tests/libexec/ld.elf_so/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/libexec/ld.elf_so/h_r_rel.c \
src/tests/libexec/ld.elf_so/t_r_rel.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src
Date: Fri, 2 May 2025 22:30:29 +0000
Module Name: src
Committed By: riastradh
Date: Fri May 2 22:30:29 UTC 2025
Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/lib/csu: Makefile t_hello.sh
Log Message:
lib/csu: Test a static PIE with RELR relocations.
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.482 -r1.483 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1375 -r1.1376 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/csu/Makefile
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/csu/t_hello.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src/sys/sys
Date: Fri, 2 May 2025 23:02:55 +0000
Module Name: src
Committed By: riastradh
Date: Fri May 2 23:02:55 UTC 2025
Modified Files:
src/sys/sys: exec_elf.h
Log Message:
sys/exec_elf.h: Add RELR definitions.
The SHT_RELR .relr.dyn section, identified in DT_RELR dynamic tag,
holds compressed R_*_RELATIVE-type relocations, substantially
reducing the disk space occupied by many programs.
Reference:
Rahul Chaudhry, `Re: Proposal for a new section type SHT_RELR',
generic-abi mailing list, 2018-02-07.
https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ
https://web.archive.org/web/20241213012330/https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ
Proposed on tech-userlevel:
https://mail-index.NetBSD.org/tech-userlevel/2025/04/27/msg014727.html
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/sys/exec_elf.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src
Date: Fri, 2 May 2025 23:03:16 +0000
Module Name: src
Committed By: riastradh
Date: Fri May 2 23:03:16 UTC 2025
Modified Files:
src/libexec/ld.elf_so: headers.c reloc.c rtld.h
src/tests/libexec/ld.elf_so: t_r_rel.sh
Log Message:
ld.elf_so: Implement RELR relocations.
The SHT_RELR-type .relr.dyn section, pointed to by the DT_RELR
dynamic tag, holds compressed R_*_RELATIVE-type relocations,
substantially reducing the disk space occupied by many programs.
This commit adds support in ld.elf_so for relocating dynamically
linked executables with RELR relocations.
Reference:
Rahul Chaudhry, `Re: Proposal for a new section type SHT_RELR',
generic-abi mailing list, 2018-02-07.
https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ
https://web.archive.org/web/20241213012330/https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ
Proposed on tech-userlevel:
https://mail-index.NetBSD.org/tech-userlevel/2025/04/27/msg014727.html
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/libexec/ld.elf_so/headers.c
cvs rdiff -u -r1.119 -r1.120 src/libexec/ld.elf_so/reloc.c
cvs rdiff -u -r1.148 -r1.149 src/libexec/ld.elf_so/rtld.h
cvs rdiff -u -r1.1 -r1.2 src/tests/libexec/ld.elf_so/t_r_rel.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59360 CVS commit: src
Date: Fri, 2 May 2025 23:04:06 +0000
Module Name: src
Committed By: riastradh
Date: Fri May 2 23:04:06 UTC 2025
Modified Files:
src/lib/csu/common: crt0-common.c
src/tests/lib/csu: t_hello.sh
Log Message:
lib/csu: Add support for RELR relocations in static PIEs.
Same logic as in ld.elf_so, but baked into the executable itself for
static PIEs.
Addendum to proposal on tech-userlevel:
https://mail-index.NetBSD.org/tech-userlevel/2025/04/27/msg014727.html
PR bin/59360: ld.elf_so(8): missing RELR support
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/csu/common/crt0-common.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/csu/t_hello.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.