Linking against older symbol version in a .so file

前端 未结 11 1837
长发绾君心
长发绾君心 2020-11-27 11:25

Using gcc and ld on x86_64 linux I need to link against a newer version of a library (glibc 2.14) but the executable needs to run on a system with an older version (2.5). Si

11条回答
  •  佛祖请我去吃肉
    2020-11-27 11:38

    For nim-lang, I elaborated on a solution I found using the C compiler --include= flag as follows:

    Create a file symver.h with:

    __asm__(".symver fcntl,fcntl@GLIBC_2.4");
    

    Build your program with nim c ---passC:--include=symver.h

    As for me I'm cross compiling too. I compile with nim c --cpu:arm --os:linux --passC:--include=symver.h ... and I can get symbol versions using arm-linux-gnueabihf-objdump -T ../arm-libc.so.6 | grep fcntl

    I had to remove ~/.cache/nim at some point. And it seems to work.

提交回复
热议问题