Patching code/symbols into a dynamic-linked ELF binary

前端 未结 4 1462
無奈伤痛
無奈伤痛 2021-02-15 02:17

Suppose I have an ELF binary that\'s dynamic linked, and I want to override/redirect certain library calls. I know I can do this with LD_PRELOAD, but I want a solut

4条回答
  •  长发绾君心
    2021-02-15 02:56

    ld has the option --wrap that lets you replace a given symbol like malloc by a symbol you'd call __wrap_malloc. With that you could write some stubs for the functions you are interested in and link that to the library in question.

提交回复
热议问题