tech-toolchain archive

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

re: Fixing Elf##_Versym



Christos Zoulas writes:
> In article <4d8ba3e2-e981-4fa8-8685-17c1ba27b191%app.fastmail.com@localhost>,
> Joseph Koshy <netbsd-ml%jkoshy.net@localhost> 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:38.000000000 -0700
+++ absl/debugging/internal/elf_mem_image.cc    2025-11-12 11:09:48.791740924 -0800

@@ -377,7 +379,7 @@ void ElfMemImage::SymbolIterator::Update
   const ElfW(Versym) *version_symbol = image->GetVersym(index_);
   ABSL_RAW_CHECK(symbol && version_symbol, "");
   const char *const symbol_name = image->GetDynstr(symbol->st_name);
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) && 0
   const int version_index = version_symbol->vs_vers & VERSYM_VERSION;
 #else
   const ElfW(Versym) version_index = 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.


Home | Main Index | Thread Index | Old Index