From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7A6953858D37; Sun, 24 Mar 2024 05:20:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A6953858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1711257656; bh=Ct2+i5ZT9DkZL04Zjr/ysXNu+YNQAkLRre2L5BKugAY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PRYsTtYVngG3dloXhVs5mSeAwo1yvWGHbORVNS1T45uX+2FLdD4j4aFOvdE+5bzH1 enKyAlMuiSXtidV3p29itEQwvMTTt6VDDoHfjyhxr8PSn1I05eWpx2Df3dKFUGWfaZ nNzMI5Uo6WMLwBNMpK8grumYIHhSo9Fv7zLCzG14= From: "i at maskray dot me" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/31541] rtld: Support DT_CREL relocation format Date: Sun, 24 Mar 2024 05:20:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31541 --- Comment #1 from Fangrui Song --- Stefan O'Rear has developed a musl patch for quantitative assessment https://0x0.st/XsrV.diff=20 > This resolves DT_CREL relocations in dynamically linked executables and shared libraries, and for non-relative relocations in the dyanmic linker and static PIE. It does not support DT_CREL for relative relocations in static PIE and the dynamic linker itself; if DT_CREL is used in static PIE or the dynamic linker, DT_RELR must also be used. I've checked lib/libc.so size w/ and w/o CREL support. * (w/o CREL support) orig: 782064; relr: 780504 * (w/ CREL support) orig: 782736; relr: 781184; relr+crel: 780704 In an x86-64 `-O2` build, CREL support linked with `-z pack-relative-relocs= -z crel` increases the size of `libc.so` by just 200 bytes (0.0256%) compared = to a non-CREL build with `-z pack-relative-relocs`. --- In glibc, elf/dynamic-link.h ELF_DYNAMIC_RELOCATE has extra complexity beca= use DT_JMPREL processing is wired into DT_REL/DT_RELA. This is related to the SPARC: /* On some machines, notably SPARC, DT_REL* includes DT_JMPREL in its range. Note that according to the ELF spec, this is completely legal! We are guaranteed that we have one of three situations. Either DT_JMP= REL comes immediately after DT_REL*, or there is overlap and DT_JMPREL consumes precisely the very end of the DT_REL*, or DT_JMPREL and DT_RE= L* are completely separate and there is a gap between them. */ If this is untangled, CREL support can probably be straightforwardly added. Since libc.so.6, libpthread.so.0, etc have many non-relative relocations. I believe RELR+CREL built glibc would be smaller without CREL support :) --=20 You are receiving this mail because: You are on the CC list for the bug.=