Patching code/symbols into a dynamic-linked ELF binary

前端 未结 4 2148
盖世英雄少女心
盖世英雄少女心 2021-02-15 02:12

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 03:01

    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.

提交回复
热议问题