Another try after https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/KBHQU4O...
The only change is the removal of `Makefile: Change ET_EXEC to ET_REL so that lld can link bios.bin.elf` since 699a4e5d6919cc8eae5342443025ceb6909dc276 ("ldnoexec: Add script to remove ET_EXEC flag from intermediate build objects") has done the same thing.
For your convenience, the patch series is available on https://github.com/MaskRay/seabios/tree/lld
Re-sending. I posted this 3 days but got bounced. I have now ensured there is my email address record on (previously not) https://mail.coreboot.org/postorius/lists/seabios.seabios.org/ as well as https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/
Fangrui Song (4): romlayout.S: Add missing SHF_ALLOC flag to .fixedaddr.\addr Make rom16.o linkable with lld romlayout32flag.lds: Use `. +=` instead of `. =` test-build.sh: Delete unneeded LD capability test
scripts/layoutrom.py | 8 +++++++- scripts/test-build.sh | 42 +----------------------------------------- src/romlayout.S | 2 +- 3 files changed, 9 insertions(+), 43 deletions(-)
It does not make sense to reference a SHF_ALLOC section from a non-SHF_ALLOC section via R_386_PC16. Conceptually, even if a non-SHF_ALLOC is loaded as part of the memory image, the distance between it and a SHF_ALLOC section may not be a constant, so the linker cannot reasonably resolve the relocation.
GNU ld allows it but lld will warn. Add the SHF_ALLOC flag.
Signed-off-by: Fangrui Song maskray@google.com --- src/romlayout.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/romlayout.S b/src/romlayout.S index c4a4635..a854783 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -587,7 +587,7 @@ entry_18:
// Specify a location in the fixed part of bios area. .macro ORG addr - .section .fixedaddr.\addr + .section .fixedaddr.\addr,"a" .endm
ORG 0xe05b
lld requires output section descriptions to be sorted by address. Just sort the addresses beforehand.
-- Changes v2 -> v3 * Sort sections by finalloc unconditionally
Signed-off-by: Fangrui Song maskray@google.com --- scripts/layoutrom.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index abebf02..fa270ef 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -321,6 +321,7 @@ def outXRefs(sections, useseg=0, exportsyms=[], forcedelta=0):
# Write LD script includes for the given sections def outSections(sections, useseg=0): + sections = sorted(sections, key=lambda x: x.finalloc) out = "" for section in sections: loc = section.finalloc
This improves the portability of the linker script and allows lld to link rom.o
Dot assignment inside an output section has an inconsistent behavior which makes lld difficult to implement. See https://bugs.llvm.org/show_bug.cgi?id=43083
Dropping `. =` turns out to be beneficial to older GNU ld as well because we can delete an ld check detecting "cannot move location counter backwards".
Signed-off-by: Fangrui Song maskray@google.com --- scripts/layoutrom.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index fa270ef..7bc4a57 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -336,14 +336,19 @@ def outRelSections(sections, startsym, useseg=0): if section.finalloc is not None] sections.sort(key=operator.itemgetter(0)) out = "" + location = "_reloc_init_end" for addr, section in sections: loc = section.finalloc if useseg: loc = section.finalsegloc - out += ". = ( 0x%x - %s ) ;\n" % (loc, startsym) + if location == "_reloc_init_end": + out += ". += 0x%x - %s ;\n" % (loc, location) + elif location < loc: + out += ". += 0x%x ;\n" % (loc-location,) if section.name in ('.rodata.str1.1', '.rodata'): out += "_rodata%s = . ;\n" % (section.fileid,) out += "*%s.*(%s)\n" % (section.fileid, section.name) + location = loc + section.size return out
# Build linker script output for a list of relocations.
The previous commit changed romlayout32flag.lds to use `. += ` instead of `. =`. We no longer need the LD capability test checking https://sourceware.org/bugzilla/show_bug.cgi?id=12726
Signed-off-by: Fangrui Song maskray@google.com --- scripts/test-build.sh | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-)
diff --git a/scripts/test-build.sh b/scripts/test-build.sh index 25cc2f2..8b35d6f 100755 --- a/scripts/test-build.sh +++ b/scripts/test-build.sh @@ -4,50 +4,10 @@ mkdir -p ${OUT} TMPFILE1=${OUT}/tmp_testcompile1.c TMPFILE1o=${OUT}/tmp_testcompile1.o -TMPFILE1_ld=${OUT}/tmp_testcompile1.lds TMPFILE2=${OUT}/tmp_testcompile2.c TMPFILE2o=${OUT}/tmp_testcompile2.o TMPFILE3o=${OUT}/tmp_testcompile3.o
-# Test if ld's alignment handling is correct. This is a known problem -# with the linker that ships with Ubuntu 11.04. -cat - > $TMPFILE1 <<EOF -const char v1[] __attribute__((section(".text.v1"))) = "0123456789"; -const char v2[] __attribute__((section(".text.v2"))) = "0123456789"; -EOF -cat - > $TMPFILE1_ld <<EOF -SECTIONS -{ - .mysection 0x88f0 : { -. = 0x10 ; -*(.text.v1) -. = 0x20 ; -*(.text.v2) -. = 0x30 ; - } -} -EOF -$CC -O -g -c $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "Unable to execute the C compiler ($CC)." >&2 - echo "" >&2 - echo "Please install a working compiler and retry." >&2 - echo -1 - exit 0 -fi -$LD -T $TMPFILE1_ld $TMPFILE1o -o $TMPFILE2o > /dev/null 2>&1 -if [ $? -ne 0 ]; then - echo "The version of LD on this system ($LD) does not properly handle" >&2 - echo "alignments. As a result, this project can not be built." >&2 - echo "" >&2 - echo "The problem may be the result of this LD bug report:" >&2 - echo " http://sourceware.org/bugzilla/show_bug.cgi?id=12726" >&2 - echo "" >&2 - echo "Please update to a working version of binutils and retry." >&2 - echo -1 - exit 0 -fi - # Test for "-fwhole-program". Older versions of gcc (pre v4.1) don't # support the whole-program optimization - detect that. $CC -fwhole-program -S -o /dev/null -xc /dev/null > /dev/null 2>&1 @@ -87,4 +47,4 @@ echo 0 # "ebp" register is clobberred in an "asm" statement. The code has # been modified to not clobber "ebp" - no test is available yet.
-rm -f $TMPFILE1 $TMPFILE1o $TMPFILE1_ld $TMPFILE2 $TMPFILE2o $TMPFILE3o +rm -f $TMPFILE1 $TMPFILE1o $TMPFILE2 $TMPFILE2o $TMPFILE3o
On Tue, 2022-07-12 at 18:35, Fangrui Song via SeaBIOS seabios@seabios.org wrote:
Another try after https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/KBHQU4O...
The only change is the removal of `Makefile: Change ET_EXEC to ET_REL so that lld can link bios.bin.elf` since 699a4e5d6919cc8eae5342443025ceb6909dc276 ("ldnoexec: Add script to remove ET_EXEC flag from intermediate build objects") has done the same thing.
For your convenience, the patch series is available on https://github.com/MaskRay/seabios/tree/lld
Re-sending. I posted this 3 days but got bounced. I have now ensured there is my email address record on (previously not) https://mail.coreboot.org/postorius/lists/seabios.seabios.org/ as well as https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/
Fangrui Song (4): romlayout.S: Add missing SHF_ALLOC flag to .fixedaddr.\addr Make rom16.o linkable with lld romlayout32flag.lds: Use `. +=` instead of `. =` test-build.sh: Delete unneeded LD capability test
scripts/layoutrom.py | 8 +++++++- scripts/test-build.sh | 42 +----------------------------------------- src/romlayout.S | 2 +- 3 files changed, 9 insertions(+), 43 deletions(-)
Hello all,
FreeBSD ports developer here. Is there anything we can do to help get this series of patches evaluated?
Thanks,
Joe
On Wed, Nov 30, 2022 at 05:46:26PM -0400, Joseph Mingrone wrote:
On Tue, 2022-07-12 at 18:35, Fangrui Song via SeaBIOS seabios@seabios.org wrote:
Another try after https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/KBHQU4O...
Hello all,
FreeBSD ports developer here. Is there anything we can do to help get this series of patches evaluated?
Can you elaborate on the part of the series that you need and why it is needed?
This changeset has a long history and there is little desire to revisit it.
https://www.mail-archive.com/seabios@seabios.org/msg12169.html https://www.mail-archive.com/seabios@seabios.org/msg12285.html https://www.mail-archive.com/seabios@seabios.org/msg12683.html
-Kevin
On Wed, 2022-12-07 at 13:24, Kevin O'Connor kevin@koconnor.net wrote:
On Wed, Nov 30, 2022 at 05:46:26PM -0400, Joseph Mingrone wrote:
On Tue, 2022-07-12 at 18:35, Fangrui Song via SeaBIOS seabios@seabios.org wrote:
Another try after https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/KBHQU4O...
Hello all,
FreeBSD ports developer here. Is there anything we can do to help get this series of patches evaluated?
Can you elaborate on the part of the series that you need and why it is needed?
This changeset has a long history and there is little desire to revisit it.
https://www.mail-archive.com/seabios@seabios.org/msg12169.html https://www.mail-archive.com/seabios@seabios.org/msg12285.html https://www.mail-archive.com/seabios@seabios.org/msg12683.html
-Kevin
Hello,
I don't understand all the constraints and history, but it would be nice to be able to build SeaBIOS on FreeBSD with our in-tree tools. The differences between LLVM objdump and GNU objdump means that swapping in LLVM objdump is not straightforward.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267854
Joe