re: Fixing Elf##_Versym
matthew green <[email protected]> Thu, 13 Nov 2025 06:15:34 +1100
| Newsgroups | gmane.os.netbsd.devel.toolchain |
|---|---|
| Message-ID | <[email protected]> |
Christos Zoulas writes: > In article <[email protected]>, > Joseph Koshy <[email protected]> wrote: > >Hello tech-toolchain, > > > >Many ELF toolkits define an Elf##_Versym to be a 16-bit unsigned > >quantity: > > > > /* Solaris, FreeBSD, Elfutils, Elftoolchain, maybe others. */ > > typedef Elf32_Half Elf32_Versym; > > typedef Elf64_Half Elf64_Versym; > > > >NetBSD however defines it as a struct with a sole 16-bit unsigned > >member: > > > > /* NetBSD: <sys/exec_elf.h> */ > > typedef struct { > > Elf32_Half vs_vers; > > } Elf32_Versym; > > typedef Elf32_Versym Elf64_Versym; > > > >I would like to align NetBSD's definitions with those in the > >other toolkits, so that it becomes easier to port ELF-handling > >code to NetBSD. > > > >Would anyone have objections to the below patch? Per my > >understanding, the patch does not change runtime behavior. > > I am fine with the change, it reduces diff in rtld with FreeBSD too. unfortunately, this is breaking several things in pkgsrc. they're all the same chunk of code that is #ifdef __NetBSD__. we need a way to identify this so we can build code either side of this change.. eg, the 4th version of this same code i just worked around is pkgsrc/devel/abseil: --- absl/debugging/internal/elf_mem_image.cc.orig 2025-09-22 11:24:3= 8.000000000 -0700 +++ absl/debugging/internal/elf_mem_image.cc 2025-11-12 11:09:48.791740= 924 -0800 @@ -377,7 +379,7 @@ void ElfMemImage::SymbolIterator::Update const ElfW(Versym) *version_symbol =3D image->GetVersym(index_); ABSL_RAW_CHECK(symbol && version_symbol, ""); const char *const symbol_name =3D image->GetDynstr(symbol->st_name); -#if defined(__NetBSD__) +#if defined(__NetBSD__) && 0 const int version_index =3D version_symbol->vs_vers & VERSYM_VERSION; #else const ElfW(Versym) version_index =3D version_symbol[0] & VERSYM_VERSION= ; i've also seen this same code in firefox, firefox140 and nodejs so far.. i did not commit any fixes because i don't know of a way to detect this via #ifdef. we need something. Joseph, can you have a look please? thanks. .mrg.