NetBSD Problem Report #59296
From www@netbsd.org Mon Apr 14 01:48:41 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 9BCE31A9239
for <gnats-bugs@gnats.NetBSD.org>; Mon, 14 Apr 2025 01:48:41 +0000 (UTC)
Message-Id: <20250414014840.92A7B1A923D@mollari.NetBSD.org>
Date: Mon, 14 Apr 2025 01:48:40 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: t_rtld_r_debug test is failing
X-Send-Pr-Version: www-1.0
>Number: 59296
>Category: port-mips
>Synopsis: t_rtld_r_debug test is failing
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-mips-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Apr 14 01:50:00 +0000 2025
>Closed-Date: Sat Oct 10 17:08:36 +0000 2026
>Last-Modified: Sat Oct 10 17:08:36 +0000 2026
>Originator: Taylor R Campbell
>Release: current, 10, 9, ...
>Organization:
The MipsBSDynamic Rtldebugation
>Environment:
>Description:
tc-end: 1744594643.532930, dlopen, failed, /usr/src/current/tests/libexec/ld.elf_so/t_rtld_r_debug.c:104: debug != NULL not met
This presumably happens because:
335 /*
336 * Don't process DT_DEBUG on MIPS as the dynamic section
337 * is mapped read-only. DT_MIPS_RLD_MAP is used instead.
338 * XXX: n32/n64 may use DT_DEBUG, not sure yet.
339 */
340 #ifndef __mips__
341 case DT_DEBUG:
342 #ifdef RTLD_LOADER
343 dynp->d_un.d_ptr = (Elf_Addr)&_rtld_debug;
344 #endif
345 break;
346 #endif
https://nxr.netbsd.org/xref/src/libexec/ld.elf_so/headers.c?r=1.72#335
So either ld.elf_so needs to be fixed to make this happen (for n32 and/or n64?), or t_rtld_r_debug needs to be adapted to use DT_MIPS_RLD_MAP, and either way, both places should have a comment citing the relevant ABI reference.
>How-To-Repeat:
cd /usr/tests/libexec/ld.elf_so
atf-run t_rtld_r_debug | atf-report
>Fix:
Yes, please!
>Release-Note:
>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59296 CVS commit: src/tests/libexec/ld.elf_so
Date: Mon, 14 Apr 2025 02:07:07 +0000
Module Name: src
Committed By: riastradh
Date: Mon Apr 14 02:07:07 UTC 2025
Modified Files:
src/tests/libexec/ld.elf_so: t_rtld_r_debug.c
Log Message:
t_rtld_r_debug: Mark this xfail on mips.
PR port-mips/59296: t_rtld_r_debug test is failing
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/libexec/ld.elf_so/t_rtld_r_debug.c
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/59296 CVS commit: src/tests/libexec/ld.elf_so
Date: Tue, 15 Apr 2025 22:19:39 +0000
Module Name: src
Committed By: riastradh
Date: Tue Apr 15 22:19:39 UTC 2025
Modified Files:
src/tests/libexec/ld.elf_so: t_rtld_r_debug.c
Log Message:
t_rtld_r_debug: Fix xfail on mips.
There was an earlier assertion, oops.
Add __RCSID while here.
PR port-mips/59296: t_rtld_r_debug test is failing
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/libexec/ld.elf_so/t_rtld_r_debug.c
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/59296 CVS commit: src
Date: Wed, 16 Apr 2025 01:56:53 +0000
Module Name: src
Committed By: riastradh
Date: Wed Apr 16 01:56:53 UTC 2025
Modified Files:
src/libexec/ld.elf_so: headers.c
src/sys/arch/mips/include: elf_machdep.h
src/tests/libexec/ld.elf_so: t_rtld_r_debug.c
Log Message:
ld.elf_so: Teach this to handle MIPS PIE rtld debug data.
Adapt t_rtld_r_debug to handle the two MIPS cases too.
XXX t_rtld_r_debug should be tested both as PIE and non-PIE to
exercise both cases.
Context:
The value of a DT_DEBUG .dynamic entry is initialized at load-time,
by ld.elf_so, to a pointer to a data structure set up by ld.elf_so
describing the shared objects loaded by the executable, so debuggers
can find them from, e.g., core dumps. None of this is really
documented anywhere that I can find. Best reference is this post on
the gdb mailing list from a quarter century ago saying there's no
real documentation:
https://web.archive.org/web/20250414021320/https://sourceware.org/pipermail/gdb/2000-April/004509.html
However, on MIPS, the .dynamic section is mapped read-only, so
ld.elf_so can't properly modify it (I imagine technically it could
with some mprotect shenanigans but that's not how it's done on MIPS).
Instead, the linker reserves a location in read/write memory and uses
a DT_MIPS_RLD_MAP entry with a pointer to that location.
However, in position-independent executables, the .dynamic entry
can't have an absolute pointer to that location because it's not
known up front. Instead, the the linker uses a DT_MIPS_RLD_MAP_REL
entry with the relative offset to that location from the Elf_Dyn
entry itself.
I would add a reference for this but it's basically a matter of UTSL
plus some oblique mentions on the web and mailing list discussions:
https://web.archive.org/web/20250414024823/https://cygwin.com/legacy-ml/binutils/2016-04/msg00244.html
https://web.archive.org/web/20250403151803/https://maskray.me/blog/2023-09-04-toolchain-notes-on-mips
https://web.archive.org/web/20211024050833/https://reviews.llvm.org/D12794?id=34533
https://web.archive.org/web/20250407052145/https://wiki.debian.org/MIPSPort
https://web.archive.org/web/20250414024924/https://reviews.freebsd.org/D17867?id=50122
PR port-mips/59296: t_rtld_r_debug test is failing
To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/libexec/ld.elf_so/headers.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/mips/include/elf_machdep.h
cvs rdiff -u -r1.10 -r1.11 src/tests/libexec/ld.elf_so/t_rtld_r_debug.c
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/59296 CVS commit: src
Date: Wed, 16 Apr 2025 02:16:54 +0000
Module Name: src
Committed By: riastradh
Date: Wed Apr 16 02:16:54 UTC 2025
Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/libexec/ld.elf_so: Makefile
Log Message:
t_rtld_r_debug: Test this as a non-PIE executable too.
On MIPS, non-PIEs can use DT_MIPS_RLD_MAP or DT_MIPS_RLD_MAP_REL,
while PIEs can't use DT_MIPS_RLD_MAP because it relies on an absolute
virtual address baked into the file. So it's important to test both.
PR port-mips/59296: t_rtld_r_debug test is failing
To generate a diff of this commit:
cvs rdiff -u -r1.475 -r1.476 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1368 -r1.1369 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.24 -r1.25 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.
State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Wed, 16 Apr 2025 12:06:46 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-9 and pullup-10 -- not just a matter of a
test failing, but gdb is broken on position-independent executables
without these changes
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59296 CVS commit: src/tests/libexec/ld.elf_so
Date: Wed, 16 Apr 2025 12:05:52 +0000
Module Name: src
Committed By: riastradh
Date: Wed Apr 16 12:05:52 UTC 2025
Modified Files:
src/tests/libexec/ld.elf_so: t_rtld_r_debug.c
Log Message:
t_rtld_r_debug: Break once we've found DT_MIPS_RLD_MAP_REL.
No need to keep searching at that point (though maybe it wouldn't
hurt to verify that if we have both DT_MIPS_RLD_MAP and
DT_MIPS_RLD_MAP_REL, they agree).
PR port-mips/59296: t_rtld_r_debug test is failing
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/libexec/ld.elf_so/t_rtld_r_debug.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Thu, 08 Oct 2026 19:49:49 +0000
State-Changed-Why:
fixed in HEAD before the netbsd-11 branch
pullup-10 #1354
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59296 CVS commit: [netbsd-10] src
Date: Fri, 9 Oct 2026 15:01:12 +0000
Module Name: src
Committed By: martin
Date: Fri Oct 9 15:01:12 UTC 2026
Modified Files:
src/libexec/ld.elf_so [netbsd-10]: headers.c
src/sys/arch/mips/include [netbsd-10]: elf_machdep.h
src/tests/libexec/ld.elf_so [netbsd-10]: t_dlinfo.c t_rtld_r_debug.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1354):
libexec/ld.elf_so/headers.c: revision 1.73
tests/libexec/ld.elf_so/t_rtld_r_debug.c: revision 1.4
tests/libexec/ld.elf_so/t_rtld_r_debug.c: revision 1.5
tests/libexec/ld.elf_so/t_rtld_r_debug.c: revision 1.7
tests/libexec/ld.elf_so/t_rtld_r_debug.c: revision 1.8
tests/libexec/ld.elf_so/t_rtld_r_debug.c: revision 1.9
tests/libexec/ld.elf_so/t_dlinfo.c: revision 1.7
tests/libexec/ld.elf_so/t_rtld_r_debug.c: revision 1.10
tests/libexec/ld.elf_so/t_dlinfo.c: revision 1.8
tests/libexec/ld.elf_so/t_rtld_r_debug.c: revision 1.11
sys/arch/mips/include/elf_machdep.h: revision 1.21
rtld tests: Don't use RZ for dlinfo.
Use
ATF_REQUIRE_EQ_MSG(dlinfo(...), 0, "dlinfo: %s", dlerror())
instead, in order to accurately report the error on failure. RZ is
only for functions like pthread_create(3) that return zero on success
and errno(3) code on failure, but dlinfo returns -1 on failure and
sets dlerror() to report the nature of the error.
t_dlinfo, t_rtld_r_debug: Audit ATF_REQUIRE/CHECK, sprinkle messages.
Make sure to use ATF_REQUIRE when the subsequent code doesn't work if
the check fails.
t_rtld_r_debug: Use ATF_REQUIRE where we can't proceed on failure.
Not helpful for the test program to crash with SIGSEGV on null
pointer dereference -- just make it stop when we detect the null
pointer.
t_rtld_r_debug: Print some diagnostics as we go.
t_rtld_r_debug: Mark this xfail on mips.
PR port-mips/59296: t_rtld_r_debug test is failing
t_rtld_r_debug: Fix xfail on mips.
There was an earlier assertion, oops.
Add __RCSID while here.
PR port-mips/59296: t_rtld_r_debug test is failing
ld.elf_so: Teach this to handle MIPS PIE rtld debug data.
Adapt t_rtld_r_debug to handle the two MIPS cases too.
XXX t_rtld_r_debug should be tested both as PIE and non-PIE to
exercise both cases.
Context:
The value of a DT_DEBUG .dynamic entry is initialized at load-time,
by ld.elf_so, to a pointer to a data structure set up by ld.elf_so
describing the shared objects loaded by the executable, so debuggers
can find them from, e.g., core dumps. None of this is really
documented anywhere that I can find. Best reference is this post on
the gdb mailing list from a quarter century ago saying there's no
real documentation:
https://web.archive.org/web/20250414021320/https://sourceware.org/pipermail/gdb/2000-April/004509.html
However, on MIPS, the .dynamic section is mapped read-only, so
ld.elf_so can't properly modify it (I imagine technically it could
with some mprotect shenanigans but that's not how it's done on MIPS).
Instead, the linker reserves a location in read/write memory and uses
a DT_MIPS_RLD_MAP entry with a pointer to that location.
However, in position-independent executables, the .dynamic entry
can't have an absolute pointer to that location because it's not
known up front. Instead, the the linker uses a DT_MIPS_RLD_MAP_REL
entry with the relative offset to that location from the Elf_Dyn
entry itself.
I would add a reference for this but it's basically a matter of UTSL
plus some oblique mentions on the web and mailing list discussions:
https://web.archive.org/web/20250414024823/https://cygwin.com/legacy-ml/binutils/2016-04/msg00244.html
https://web.archive.org/web/20250403151803/https://maskray.me/blog/2023-09-04-toolchain-notes-on-mips
https://web.archive.org/web/20211024050833/https://reviews.llvm.org/D12794?id=34533
https://web.archive.org/web/20250407052145/https://wiki.debian.org/MIPSPort
https://web.archive.org/web/20250414024924/https://reviews.freebsd.org/D17867?id=50122
PR port-mips/59296: t_rtld_r_debug test is failing
To generate a diff of this commit:
cvs rdiff -u -r1.70.2.2 -r1.70.2.3 src/libexec/ld.elf_so/headers.c
cvs rdiff -u -r1.20 -r1.20.34.1 src/sys/arch/mips/include/elf_machdep.h
cvs rdiff -u -r1.6 -r1.6.10.1 src/tests/libexec/ld.elf_so/t_dlinfo.c
cvs rdiff -u -r1.3 -r1.3.6.1 src/tests/libexec/ld.elf_so/t_rtld_r_debug.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 10 Oct 2026 17:08:36 +0000
State-Changed-Why:
fixed and pullups complete
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.