forked from M-Labs/artiq
occheung
b30ed75e69
ld.lld has a habit of not putting the headers under any load sections. However, the headers are needed by libunwind to handle exception raised by the kernel. Creating PT_LOAD section with FILEHDR and PHDRS solves this issue. Other PHDRS are also specified as linkers (not limited to ld.lld) will not create additional unspecified headers even when necessary.
54 lines
840 B
Plaintext
54 lines
840 B
Plaintext
/* Force ld to make the ELF header as loadable. */
|
|
PHDRS
|
|
{
|
|
headers PT_LOAD FILEHDR PHDRS ;
|
|
text PT_LOAD ;
|
|
data PT_LOAD ;
|
|
dynamic PT_DYNAMIC ;
|
|
eh_frame PT_GNU_EH_FRAME ;
|
|
}
|
|
|
|
SECTIONS
|
|
{
|
|
/* Push back .text section enough so that ld.lld not complain */
|
|
. = SIZEOF_HEADERS;
|
|
|
|
.text :
|
|
{
|
|
*(.text .text.*)
|
|
} : text
|
|
|
|
.rodata :
|
|
{
|
|
*(.rodata .rodata.*)
|
|
}
|
|
|
|
.eh_frame :
|
|
{
|
|
KEEP(*(.eh_frame))
|
|
} : text
|
|
|
|
.eh_frame_hdr :
|
|
{
|
|
KEEP(*(.eh_frame_hdr))
|
|
} : text : eh_frame
|
|
|
|
.data :
|
|
{
|
|
*(.data)
|
|
} : data
|
|
|
|
.dynamic :
|
|
{
|
|
*(.dynamic)
|
|
} : data : dynamic
|
|
|
|
.bss (NOLOAD) : ALIGN(4)
|
|
{
|
|
__bss_start = .;
|
|
*(.sbss .sbss.* .bss .bss.*);
|
|
. = ALIGN(4);
|
|
_end = .;
|
|
}
|
|
}
|