rr icon indicating copy to clipboard operation
rr copied to clipboard

.symver under gcc 9.x and 10.x

Open signalogic opened this issue 1 year ago • 6 comments

In overrides.c, this line:

asm(".symver dlsym, dlsym@GLIBC_2.2.5");

fails under gcc 9.x and 10.x with:

no symbol version section for versioned symbol `dlsym@GLIBC_2.2.5'

but works under gcc versions lower and higher (or at least doesn't issue an error). Notes:

-same error occurs with version script of GLIBC_2.2.5 { dlsym; }; (or global: dlsym) -flto is enabled -with just the version script, functionality is achieved, but I'm hoping there is way to avoid gcc version work-arounds -symver attribute might be an option, but I don't see how to apply it for glibc functions

Did you guys find a work-around to build overrides.c on a range of gcc versions, for example linker command line options or symver attribute ? Thanks

signalogic avatar Mar 11 '24 03:03 signalogic

I have no idea about this.

rocallahan avatar Mar 11 '24 06:03 rocallahan

Ok thanks. I documented the problem in detail in the comments section at:

https://maskray.me/blog/2020-11-26-all-about-symbol-versioning

it seems corrected under gcc 11.x and higher

signalogic avatar Mar 12 '24 20:03 signalogic

-with just the version script, functionality is achieved, but I'm hoping there is way to avoid gcc version work-arounds

What do you mean "with just the version script"?

rocallahan avatar Mar 13 '24 03:03 rocallahan

cat > a.map <<e GLIBC_2.2.5 { dlsym; }; e gcc cmd line ... -Wl,--version-script=a.map -o a.so

signalogic avatar Mar 13 '24 05:03 signalogic

So that works with all versions of gcc? Any reason to not use that all the time?

rocallahan avatar Mar 13 '24 05:03 rocallahan

with gcc 4.x thru 10.x and only the version script, objdump on the resulting lib shows:

0000000000000000 g DO ABS 0000000000000000 GLIBC_2.2.5 GLIBC_2.2.5

which looks odd to me. With 11.x, the .symver is required, and objdump shows:

0000000000000000 DF UND 0000000000000000 GLIBC_2.2.5 dlsym

which looks correct to me. I haven't tried 12.x yet, planning to do that

signalogic avatar Mar 13 '24 06:03 signalogic