Is there any way to add instructions to a library in IDA? My predicament is that there is no room in a game library (.so ELF, android) to fit my own code. There is an empty bss segment but IDA doesn't like to write to it, and I believe the game needs it for it's variables.

I've tried adding additional bytes to the end of the file with a hex editor, and then opening it with IDA, but IDA will not show it possibly because it's not in a segment.

Can I make my own library / modify the existing one so that the code segment is larger? My own library would need to be imported by the other library in order to work, I believe, because it needs functions and such from the original library.


1 Answer 1


IDA not the most convenient tool for what you're trying to do. There are basically 3 ways to do it, and it seems you're already mentioning all of them in your question :

  • Search for a code cave big enough to fit your payload
  • Create a new section in your executable with a sufficient size for your payload
  • Proxify your library and add functions or hook existing ones

Now depending on what exactly you're trying to inject and how you're reaching it, each method has its specific pro/cons and will require a different approach. They should all be fairly well documented on the Internet.

(Without more context/details about what you're trying to do, it's hard to tell you which one to pick though)

  • Thank you for your answer. I am trying to create a new section in my executable, but when I do, IDA will not patch the bytes that I put in the section. Is there any way around this? Thanks
    – Aspire
    Feb 5, 2016 at 0:00
  • The simplest way would be with either an hex editor or an ELF lib for your favorite language to add a section directly in the ELF header. Feb 5, 2016 at 19:26
  • What hex editor would you recommend for this? HxD, I believe, does not support adding sections into the ELF header.
    – Aspire
    Feb 5, 2016 at 19:35
  • 010 Editor with an ELF template? But the hex editor is the "quick and dirty" way, do it programatically with a lib would be more reliable. Feb 5, 2016 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.