在ELF中交换部分 [英] Swap sections in ELF
问题描述
是否可以在输出ELF格式文件的末尾强制 gcc
或 ld
位置代码部分?
Is there a way to force gcc
or ld
place code section at the end of output ELF-format file?
例如,如果例如我没有,我可以强迫他们除了 .text
以外不产生其他任何节 .data,.rodata,.bss
和其他部分中的任何内容?
Maybe I can force them not to produce any other section except .text
if, for example, I dont have anything in .data, .rodata, .bss
and other sections?
推荐答案
最适合我的脚本版本如下:
The minimal version of script that worked for me looked like:
ENTRY(_start)
SECTIONS
{
.data : { *(.data) }
.bss : { *(.bss) *(COMMON) }
.text : { *(.text) }
}
但是在我进行了更多研究之后(此处的文档)我已将此脚本替换为默认脚本( ld --verbose
)。然后,我将代码部分放在冗长的脚本的最后,并且效果很好。
But after I've made some more research (docs here) I've replaced this script with default one (ld --verbose
). Then I've just placed code section in the very end of verbose script and it worked perfectly.
这篇关于在ELF中交换部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!