什么是LD_ preLOAD把戏? [英] What is the LD_PRELOAD trick?
问题描述
我最近碰到一个参考吧上<一个href=\"http://www.reddit.com/r/programming/comments/7o8d9/tcmalloca_faster_malloc_than_glibcs_open_sourced/c06wjka\">proggit和(截至目前),它没有解释。
I came across a reference to it recently on proggit and (as of now) it is not explained.
我怀疑<一个href=\"http://stackoverflow.com/questions/335108/hide-symbols-in-shared-object-from-ld#335253\">this也许是吧,但我不知道。
I suspect this might be it, but I don't know for sure.
推荐答案
如果您设置 LD_ preLOAD
共享对象的路径,该文件将成为加载的之前任何其他库(包括C运行时, libc.so
)。因此,要运行 LS
与您的特殊的malloc()
执行,这样做:
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
这篇关于什么是LD_ preLOAD把戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!