What is the LD_PRELOAD trick?

前端 未结 9 1200
攒了一身酷
攒了一身酷 2020-11-21 07:27

I came across a reference to it recently on proggit and (as of now) it is not explained.

I suspect this might be it, but I don\'t know for sure.

9条回答
  •  执念已碎
    2020-11-21 08:01

    If you set LD_PRELOAD to the path of a shared object, that file will be loaded before any other library (including the C runtime, libc.so). So to run ls with your special malloc() implementation, do this:

    $ LD_PRELOAD=/path/to/my/malloc.so /bin/ls
    

提交回复
热议问题