I was trying to make the .text
section of an elf
binary writable using objcopy --writable-text executable_name
. The command executes normally without any errors.
On checking the section permission through readelf
I can see that the text section is still has only read and execute permissions.
On going through the objcopy
man pages for this particular option is is mentioned that the option is not meaningful for all the binary formats. (Is this the reason I am not able to do so ?).
Can anyone point out what I am missing here.
Thanks
(Ubuntu x86_64 bit machine, GNU objcopy (GNU Binutils for Ubuntu) 2.22.90.20120924)
On going through the objcopy man pages for this particular option is is mentioned that the option is not meaningful for all the binary formats. (Is this the reason I am not able to do so ?).
Yes.
At this rather detailed description of special sections of the ELF format, you see that .text
has the SHF_ALLOC + SHF_EXECINSTR
attributes (has space allocated for it and the space has executable code in it), but not SHF_WRITE
(space can be written to). What you are asking objcopy
to do simply isn't valid for ELF .text
sections.