-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a new section & segment to .ELF without disrupting file #719
Comments
There's code in the Another option would be to extend the |
I tried using object-rewrite, but it seems to not want to move to adjust for the new program header entry:
Commenting out the block addition for the program headers (just for fun, probably would break things anyways) leads to the same error as before:
I'm unsure if resizing the program headers is even something that's possible... 🤔 |
Ah okay, in my tests so far the section following the program headers has been safe to move. I'm not sure, but it's likely that the The alternative is to try moving the elf header and program headers down a page to make room. I think this is theoretically possible, but not something I've tried. |
Could you not keep the ELF header in the same spot and move the program header table to the end of the file? Program header entries if I recall don't use any sort of relative positioning / can be placed anywhere in the ELF. |
That is a possibility. There was a linux bug that meant it didn't support program headers that aren't in the first
|
Hi, I was wondering if it's possible to add a custom section/segment to an ELF file. For context, I'm currently working on a tool to patch PlayStation 3 ELFs to allow custom code. I need to add a bit of shellcode into the executable, so I wanted to make a custom section to store my code in and then modify the entrypoint. My code to modify the executable is a little complex, so I made this simple example:
However, when running this, it panics:
I assume this is because the addition of the new section/segment into the program header table has shifted the file offsets by 0x38 (the size of the new entry). Is it possible to repair these offsets such that the modified ELF writes successfully? I tried just shifting every sh_offset by 0x38, but that didn't seem to work. I suspect there is more work to be done here (or it's just flat out impossible).
The text was updated successfully, but these errors were encountered: