Reputation: 745
I know we can use the LD_PRELOAD
trick to replace a libc function, e.g., malloc()
. So how exactly LD_PRELOAD
works? Does it replace the GOT/PLT entry?
Upvotes: 0
Views: 211
Reputation: 33719
It puts the preloaded library at the start of the symbol search path. This way, all references to malloc
are bound to its implementation, and not the implementation in libc.
In glibc, you can see the code in elf/rtld.c
(the call to _dl_map_object_deps
) and the implementation of the _dl_map_object_deps
function in elf/dl-deps.c
.
Upvotes: 1