Re: git: 4617a6cb82a6 - main - nlist: Handle multiple symbol tables
Date: Sat, 29 Aug 2026 17:07:44 UTC
On 8/28/26 14:30, Dag-Erling Smørgrav wrote:
> John Baldwin <jhb@FreeBSD.org> writes:
>> The _Foo vs Foo change broke many uses of kvm_nlist in the tree. In
>> particular, ktrdump no longer works on crashdumps now, and I finally
>> single-stepped through it today to figure out why.
>>
>> A quick grep shows me all these places that are now broken:
>> [...]
>> Would you rather revert the underscore change or fix all these?
>
> Looks to me like they were all incorrect to begin with and only worked
> because of the hack in nlist(), so I would vote for fixing the calls.
> But perhaps kib@ should weigh in since he was the one who suggested
> dropping the hack.
>
> Cc: to re@ as this is a regression in 14.5.
I think a.out required the leading underscore, so when many of these
were originally added they were in fact correct, and the hack was
required to allow libkvm to work across both a.out and ELF. It may
very well be that we no longer care about a.out, but this should be
an intentional decision if so. It is (almost) an ABI change in the
sense that it changes the original API contract.
Some related commits:
commit 66422f5b7a1a6055f0b2358268eb902aab6e2e3e
Author: Peter Wemm <peter@FreeBSD.org>
Date: Tue Sep 17 01:49:00 2002 +0000
Initiate deorbit burn for the i386-only a.out related support. Moves are
under way to move the remnants of the a.out toolchain to ports. As the
comment in src/Makefile said, this stuff is deprecated and one should not
expect this to remain beyond 4.0-REL. It has already lasted WAY beyond
that.
Notable exceptions:
gcc - I have not touched the a.out generation stuff there.
ldd/ldconfig - still have some code to interface with a.out rtld.
old as/ld/etc - I have not removed these yet, pending their move to ports.
some includes - necessary for ldd/ldconfig for now.
Tested on: i386 (extensively), alpha
(Removed a.out variants of CNAME/HIDENAME in sys/i386/include/asm.h)
Prior to this in sys/i386/include/asm.h you had:
/*
* CNAME and HIDENAME manage the relationship between symbol names in C
* and the equivalent assembly language names. CNAME is given a name as
* it would be used in a C program. It expands to the equivalent assembly
* language name. HIDENAME is given an assembly-language name, and expands
* to a possibly-modified form that will be invisible to C programs.
*/
#ifdef __ELF__
#define CNAME(csym) csym
#define HIDENAME(asmsym) __CONCAT(.,asmsym)
#else
#define CNAME(csym) __CONCAT(_,csym)
#define HIDENAME(asmsym) asmsym
#endif
This was first added here:
commit f1703dfbaa221da46f40b698359be2b048e5d6ad
Author: Peter Wemm <peter@FreeBSD.org>
Date: Sun May 5 07:56:21 1996 +0000
Add support to enable libc to be compiled in ELF format. (#ifdef __ELF__)
In a nutshell, this macroizes the local/global symbol scoping rules
that are different in a.out and ELF. It also makes the i386 assembler
stubs conform to i386 PIC calling conventions - the a.out ld.so didn't
object, but the ELF one needs it as it implements PIC jumps via PLT's as
well as calls. The a.out rtld only worked because it was accidently
snooping the grandparent calling function's return address off the stack..
This also affects the libc_r code a little, because of cpp macro nesting.
The original version ELF nlist support does reference (albeit rather
obscurely) the leading underscores (and included the leading underscore
check):
commit 77909f597881d791b96ebecf808df8ff54a9855b
Author: Peter Wemm <peter@FreeBSD.org>
Date: Sun Aug 31 00:08:35 1997 +0000
Initial elf nlist support, mostly stolen from OpenBSD (they use standard
#defines that are compatable with ours). I made some some minor tweaks
to the leading '_' tests.
Again, this is off by default for the moment. This probably should be
split into seperate files (like some of our other libc files that could
do with some splitting).
Obtained from: OpenBSD (plus some minor tweaks)
--
John Baldwin