diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-03-04 21:01:22 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-03-04 21:01:22 +0000 |
commit | a2037dba7e8671c533ede60b8fdb3f09c03b565d (patch) | |
tree | 3e11795f8cc6bae96851bcb314cdf368ea4bc1b0 /stand/i386/gptboot | |
parent | 89839cad79b2ce3ca08dbca0914a1204dc492763 (diff) | |
download | src-a2037dba7e8671c533ede60b8fdb3f09c03b565d.tar.gz src-a2037dba7e8671c533ede60b8fdb3f09c03b565d.zip |
Link stand/i386 components using a linker script
LLD 10.0.0 changed the behavior of the -Ttext option, so that using
-Ttext=0x0 now causes linking of the loaders to fail with:
ld: error: output file too large: 18446744073707016908 bytes
I reported this in https://bugs.llvm.org/show_bug.cgi?id=44715, and
initially reverted the upstream change in r357259 to work around it.
However, after some discussion with Fangrui Song in the upstream ticket,
I think we can classify this as an unfortunate interaction between using
-Ttext=0 in combination with --no-rosegment. (We added the latter
in r332090, because btxld does not correctly handle input with more
than 2 PT_LOAD segments.)
Fangrui suggested to use a linker script instead, and Warner was already
attempting this in r305353, but had to revert it due to "crypto-using
boot problems" (not sure what those were :).
This review updates the stand/i386/boot.ldscript to handle more
sections, inserts some symbols like _edata and such that we use in
libsa, and also discards any .interp section.
It uses ORG which is defined on the linker command line using
--defsym ORG=value to set the start of all the sections.
Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D23952
Notes
Notes:
svn path=/head/; revision=358643
Diffstat (limited to 'stand/i386/gptboot')
-rw-r--r-- | stand/i386/gptboot/Makefile | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stand/i386/gptboot/Makefile b/stand/i386/gptboot/Makefile index 9666c7ab9d99..5ca6ca96535f 100644 --- a/stand/i386/gptboot/Makefile +++ b/stand/i386/gptboot/Makefile @@ -51,7 +51,7 @@ gptldr.bin: gptldr.out ${OBJCOPY} -S -O binary gptldr.out ${.TARGET} gptldr.out: gptldr.o - ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o + ${LD} ${LD_FLAGS} -e start --defsym ORG=${ORG1} -T ${LDSCRIPT} -o ${.TARGET} gptldr.o CLEANFILES+= gptboot.bin gptboot.out gptboot.o sio.o drv.o \ cons.o ${OPENCRYPTO_XTS} @@ -60,6 +60,6 @@ gptboot.bin: gptboot.out ${OBJCOPY} -S -O binary gptboot.out ${.TARGET} gptboot.out: ${BTXCRT} gptboot.o sio.o drv.o cons.o ${OPENCRYPTO_XTS} - ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSA32} + ${LD} ${LD_FLAGS} --defsym ORG=${ORG2} -T ${LDSCRIPT} -o ${.TARGET} ${.ALLSRC} ${LIBSA32} .include <bsd.prog.mk> |