Swap sections in ELF

自闭症网瘾萝莉.ら 提交于 2019-12-11 01:45:34

问题


Is there a way to force gcc or ld place code section at the end of output ELF-format file?

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?


回答1:


The minimal version of script that worked for me looked like:

ENTRY(_start)

SECTIONS 
{ 
    .data : { *(.data) }
    .bss :  { *(.bss)  *(COMMON) }  
    .text : { *(.text) }
} 

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.



来源:https://stackoverflow.com/questions/41882899/swap-sections-in-elf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!