[PATCH] [ELF] Fix allocation of program headers
Patrick Oppenlander via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 19 20:54:23 PST 2021
Hi,
I'm posting this here following the one-off patch recommendations from
the LLVM developer policy.
While porting an embedded project to LLVM/clang I ran into a problem
with how lld allocates program headers into the program image.
The target requires a link script similar to:
PHDRS {
ph1 PT_LOAD FILEHDR PHDRS;
ph2 PT_LOAD;
}
MEMORY {
mem1 : ORIGIN = 0x1000000000000000, LENGTH = 64K
mem2 : ORIGIN = 0, LENGTH = 128K
}
SECTIONS {
.text ORIGIN(mem1) + SIZEOF_HEADERS : {
*(.text*)
} >mem1 :ph1
.data : {
*(.data*)
} >mem2 :ph2
}
GNU ld happily links this, but unfortunately lld fails with "error:
could not allocate headers".
I've attached a patch for review which is my attempt to address the
issue. It passes the lld testsuite and includes a new test case.
Kind regards,
Patrick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ELF-Fix-allocation-of-program-headers.patch
Type: text/x-patch
Size: 6144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210120/3d977391/attachment.bin>
More information about the llvm-commits
mailing list