Hi David,
When explicit PHDRs and memory regions are used with orphan input
sections, the default placement of these sections can generate either
very large files or a SEEK overflow.
Note - your problem could also be overcome by fixing the linker script
to provide a better definition for the memory regions. For example in
your script if you change:
MEMORY
{
normal_seg : ORIGIN = 0xd0000000, LENGTH = 0x10000
}
To:
MEMORY
{
normal_seg (wax) : ORIGIN = 0xd0000000, LENGTH = 0x10000
}
The link will work. But anyway, this is only a workaround, not a full
solution.
An alternative is the patch below will also work. It "fixes"
lang_memory_default() so that if a memory region does not have any
flags set, then it will accept any input section. This seems to be a
better interpretation of how a memory region without attributes is
supposed to behave.
This behavior seems a little extreme for misnaming a loadable
section, but I'm not sure what a good solution would be. The ld
orphan placement algorithm seems to be looking for a good place to
put the section in the emulation statements. Perhaps it just needs
to look for a good memory region while placing an orphan as well.
Alternatively, when explicit PHDRS are used, the linker could do a
better job of placing the default memory section so that it was
reasonably contiguous with an existing PHDR. Or perhaps orphan
loadable sections should generate an error when using explicit PHDRs
before the attempt is made to build a multi-gigabyte file.
I think that the linker ought to try to be a little bit better about
choosing memory regions for orphan sections. Ideally it ought to
attempt to discover if the section it has chosen to inherit the orphan
has a memory region associated with it, and if so, use that region.
(Assuming that there is room of course).
Let me know what you think
Cheers
Nick