How to 'link' object file to executable/compiled binary?

后端 未结 6 2154
失恋的感觉
失恋的感觉 2020-12-24 08:41

Problem

I wish to inject an object file into an existing binary. As a concrete example, consider a source Hello.c:

#inc         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 09:13

    You must make room for the relocatable code to fit in the executable by extending the executables text segment, just like a virus infection. Then after writing the relocatable code into that space, update the symbol table by adding symbols for anything in that relocatable object, and then apply the necessary relocation computations. I've written code that does this pretty well with 32bit ELF's.

提交回复
热议问题