使用objcopy 弱化符号 和 替换 符号

之前文章讲过 使用 ld_preload 来实现函数替换 


$ arm--linux-gnu-ar x libc.a malloc.o
$ arm-linux-gnu-objcopy -W malloc malloc.o
$ arm--linux-gnu-objcopy -W realloc malloc.o
$ arm--linux-gnu-objcopy -W free malloc.o
$ arm--linux-gnu-ar r libc.a malloc.o


这样的代码里malloc 同名函数就会被使用, libc 原生malloc 就被替换了

objcopy --redefine-sym test1=test2 test.o new_test.o

--redefine-sym old=new
Change the name of a symbol old, to new. This can be useful when one is trying link two things together for which you have no source, and there are name collisions.

--redefine-syms=filename
Apply --redefine-sym to each symbol pair "old new" listed in the file filename. filename is simply a flat file, with one symbol pair per line. Line comments may be introduced by the hash character. This option may be given more than once.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值