Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: [netbsd-10] src



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.




Home | Main Index | Thread Index | Old Index