问题
I defined a new code section in my assembly program, which is going to be compiled into 32-bit ELF binary, on x86.
I use the linker scripts to assign a specified address for this new code section, it works. However, I noticed that this new section does not be loaded to the memory, after some debugging!
I use readelf
and figure out that there is no "execution" privilege of this new section:
[15] .trampoline PROGBITS 080483d0 004020 000117 00 0 0 16
Then I did this:
objcopy --set-section-flags .trampoline=alloc,code a.out
However, I got this warning:
BFD: stQWykoH: warning: allocated section `.trampoline' not in segment
Now I realize that I didn't explicitly assign a segment
information to my new section!!
So here is my question:
How to assign a
segment
information to a new code section I defined? I double-checked the linker script (follow instruction here to dump), and I have no idea how to modify the script...I just want to add a new executable section to my assembly program, and assign a fixed address to this new section. So am I on the right way now?
来源:https://stackoverflow.com/questions/28440283/define-new-code-section-in-assembly-code-to-compile-elf-binary