如何将2个部分放在1个段中(使用ld脚本) [英] How to put 2 sections in 1 segment (Using ld scripts)
本文介绍了如何将2个部分放在1个段中(使用ld脚本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下链接描述文件:
I have the following linker script:
SECTIONS {
.arora_exec_free_space 4399531 :
{
*(.text)
*(.rodata)
*(.data.rel.ro.local)
}
.arora_data_free_space (ADDR(.arora_exec_free_space) + SIZEOF(.arora_exec_free_space)) : AT (7592352)
{
*(.data)
*(.bss)
*(.got)
}
}
编译程序时,两个部分(exec和data)位于不同的LOAD段中.我想将两个部分(.arora_data_free_space和.arora_exec_free_space)合而为一LOAD段.有什么方法可以使用链接描述文件吗?我该怎么做?谢谢.
When I compile my program the two section (exec and data) are in different LOAD segments. I want to put the two sections (.arora_data_free_space and .arora_exec_free_space) into one LOAD segment. Is there any way to do it using linker scripts? How can I do it? Thanks.
推荐答案
Sure - you just need to use PHDRS. The example at that link is pretty much exactly what you want to do, I think. Here is an (untested) example I made from your linker script:
PHDRS
{
mysegment PT_LOAD;
}
SECTIONS
{
.arora_exec_free_space 4399531 :
{
*(.text)
*(.rodata)
*(.data.rel.ro.local)
} :mysegment
.arora_data_free_space (ADDR(.arora_exec_free_space) + SIZEOF(.arora_exec_free_space)) : AT (7592352)
{
*(.data)
*(.bss)
*(.got)
} :mysegment
}
这篇关于如何将2个部分放在1个段中(使用ld脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文