Does Clang/GCC really support a delay loading feature?

前端 未结 2 1774
北荒
北荒 2020-12-09 22:12

Would you mind to leave your comment on this if you have really experienced which relates to the title above? I have tried to make a shared object to be del

2条回答
  •  旧巷少年郎
    2020-12-09 22:26

    Linux does not support delay loading of libraries out of the box but it can easily be implemented using the same mechanism that is used on Windows i.e. by linking against small stub static library which dlopens main shared library on first call to any of it's functions.

    You can implement such stub library by hand, via custom script tailored for your project or use Implib.so to generate it automatically:

    $ clang bar.c -fPIC -shared -o libbar.so
    $ implib-gen.py libbar.so
    $ clang foo.c libbar.tramp.S libbar.init.c -o foo
    

提交回复
热议问题