Linking to .so with newer symbol

35 Views Asked by At

I have libs that build with gcc 11.3 and 9.4 to take advantage of AVX optimizations, but they must link with run-times built under 4.6 and up. They call dlsym(), grepping objdump on either libdl.so.2 or libc.so.6 shows GLIBC_2.34 and GLIBC_2.2.5 dlsym symbols. Per the discussion at Linking against an old version of libc to provide greater application coverage, I add to the lib:

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

to force the older, likely symbol on a wide range of run-time systems. This builds fine under 11.3 (ld 2.38), but 9.4 (2.34) produces:

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

Thinking that this might be something 9.4 and earlier, I tried gcc 4.6 (ld 2.22) and that builds fine. I also tried 11.2 (ld 2.34) which builds ok. On the 9.4 system I can verify the symbol is available in libdl using:

  objdump -T /lib/x86_64-linux-gnu/libdl.so.2 | grep -w dlsym

which shows:

  00000000000014b0 g DF .text 00000000000000c1 GLIBC_2.2.5 dlsym

is there a link option or other way to avoid this ? Or perhaps a better approach that supersedes the aforementioned stackoverflow thread or others along the same lines (e.g. Linking against older symbol version in a .so file)

0

There are 0 best solutions below