DragonFly commits List (threaded) for 2012-02
git: kern build: Tweak ldscripts for gold linker
Author: John Marino <firstname.lastname@example.org>
Date: Thu Feb 23 19:03:04 2012 +0100
kern build: Tweak ldscripts for gold linker
The gold linker v2.21 was able to link a working kernel although its
modules were unloadable. The gold linker v2.22 could build loadable
modules, but the kernel wouldn't boot! It's not clear why the modules
started to work -- my guess is that the ancient ldscripts used during
the 2.21 trial were the culprit.
The gold linker changed its ELF program header handling defaults for
version 2.22, and this resulted in an extra LOAD segment reserved only
for the program headers. The DragonFly loader wasn't expecting that
and instantly rebooted when trying to load a gold kernel.
The solution was to add a PHDRS section to the ldscripts to specify
exactly the section to segment mapping, and prevent gold from putting
the elf headers in their own load segment. Now gold matches gnu ld
linker in having only two LOAD segments, text and data.
As a curiousity, gold sets the LOAD segment alignment value at 0x1000
for both i386 and x86_64, where gnu ld sets the segment alignment at
0x1000 for i386 and 0x200000 for x86_64. This seems to have no impact
on the loading of the kernel.
Summary of changes:
sys/platform/pc32/conf/ldscript.i386 | 20 +++++++++++++++-----
sys/platform/pc64/conf/ldscript.x86_64 | 20 +++++++++++++++-----
sys/platform/vkernel/conf/ldscript.i386 | 20 +++++++++++++++-----
sys/platform/vkernel64/conf/ldscript.x86_64 | 20 +++++++++++++++-----
4 files changed, 60 insertions(+), 20 deletions(-)
DragonFly BSD source repository