Setting my lib for LD_PRELOAD makes some processes produce loader errors

前端 未结 2 1806
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 19:33

I get the following error when I try to run a script I have only execution access for:

uname: symbol lookup error: /home/dumindara/random/sotest/a.out: undefined s

2条回答
  •  灰色年华
    2021-02-05 20:28

    I am unable to comment to the accepted answer, however it is worth to mention here that one can encounter issue of not having libdl.so.2 linked properly when -ldl is used in front of compile command (assuming that linking and compilation is executed by the same command; this is possible since LD_PRELOAD libs are usually based on one source file).

    So call gcc with -ldl at the end:

    gcc -shared -fPIC fakeuname.c -o libfakeuname.so -ldl

    In my case, having -ldl at front resulted in error same as in question:

    uname: symbol lookup error: ./libfakehostname.so: undefined symbol: dlsym

提交回复
热议问题