[SeaBIOS] [PATCH] Discard .comment via linker script and delete unneeded PHDRS

2020-03-14 Thread Fangrui Song
Signed-off-by: Fangrui Song --- Makefile | 10 +++--- scripts/layoutrom.py | 7 ++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 7a16195..e52b395 100644 --- a/Makefile +++ b/Makefile @@ -182,13 +182,13 @@ $(OUT)rom32seg.o: $(OUT

[SeaBIOS] [PATCH] Delete unneeded PHDRS and redundant .comment stripping

2020-03-14 Thread Fangrui Song
headers or non-SHF_ALLOC sections, so the PHDRS command and strip -R .comment are redundant. Signed-off-by: Fangrui Song --- Makefile | 10 +++--- scripts/layoutrom.py | 6 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 7a16195

[SeaBIOS] [PATCH] Use readelf -WSrs instead of objdump -thr so that llvm-readelf can be used as a replacement

2020-03-14 Thread Fangrui Song
is difficult to emulate in llvm-objdump. Signed-off-by: Fangrui Song --- Makefile | 18 +++--- scripts/checkrom.py | 2 +- scripts/layoutrom.py | 146 +-- 3 files changed, 80 insertions(+), 86 deletions(-) diff --git a/Makefile b/Makefile

[SeaBIOS] Re: [PATCH 1/4] Make rom16.o linkable with lld

2020-04-06 Thread Fangrui Song
On 2020-04-06, Kevin O'Connor wrote: On Wed, Apr 01, 2020 at 10:29:12AM -0700, Fangrui Song wrote: (1) In romlayout.S, .fixedaddr.\addr sections do have not the SHF_ALLOC flag. It does not make sense to reference a SHF_ALLOC section from a non-SHF_ALLOC section via R_386_PC16. GNU ld allows

[SeaBIOS] [PATCH v3 4/5] romlayout32flag.lds: Use `. +=` instead of `. =`

2020-04-06 Thread Fangrui Song
as well because we can delete an ld check detecting "cannot move location counter backwards". -- Changes v2 -> v3 * Add `first` to avoid overloading `location` * Delete startsym from the parameters Signed-off-by: Fangrui Song --- scripts/layoutrom.py | 12 +--- 1 fi

[SeaBIOS] Re: [PATCH 4/4] test-build.sh: Delete unneeded LD capability test

2020-04-06 Thread Fangrui Song
On 2020-04-06, Kevin O'Connor wrote: On Wed, Apr 01, 2020 at 10:29:15AM -0700, Fangrui Song wrote: 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 Thanks

[SeaBIOS] Re: [PATCH 2/4] Makefile: Change ET_EXEC to ET_REL so that lld can link bios.bin.elf

2020-04-06 Thread Fangrui Song
On 2020-04-06, Kevin O'Connor wrote: On Wed, Apr 01, 2020 at 10:29:13AM -0700, Fangrui Song wrote: Accepting ET_EXEC as an input file is an extremely rare GNU ld feature that lld does not intend to support, because this is error-prone. See Linux kernel commit

[SeaBIOS] Re: [PATCH 3/4] romlayout32flag.lds: Use `. +=` instead of `. =`

2020-04-06 Thread Fangrui Song
On 2020-04-06, Kevin O'Connor wrote: On Wed, Apr 01, 2020 at 10:29:14AM -0700, Fangrui Song wrote: 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

[SeaBIOS] Re: [PATCH v2] Use readelf -WSrs instead of objdump -thr so that llvm-readelf can be used as a replacement

2020-04-06 Thread Fangrui Song
On 2020-04-06, Kevin O'Connor wrote: On Wed, Apr 01, 2020 at 06:12:09PM -0700, Fangrui Song wrote: objdump -h relies heavily on BFD internals and the BFD flags are difficult to emulate in llvm-objdump. llvm-objdump -h has a different output (https://reviews.llvm.org/D57146) Switch to readelf

[SeaBIOS] [PATCH v3 3/5] Makefile: Change ET_EXEC to ET_REL so that lld can link bios.bin.elf

2020-04-06 Thread Fangrui Song
ine. This suppresses dd's stderr output. * Move dd command to a separate command Signed-off-by: Fangrui Song --- Makefile | 4 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 5f7d537..118dec0 100644 --- a/Makefile +++ b/Makefile @@ -177,10 +177,14 @@ $(

[SeaBIOS] [PATCH v3 0/5] Make seabios linkable with lld

2020-04-06 Thread Fangrui Song
of This drops the only instance https://sourceware.org/bugzilla/show_bug.cgi?id=12726 1, 2, 3 and 4 are really independent and can be applied in arbitrary order. 5 depends on 4. I originally combined 4 and 5 and that was why I don't think a patch series made sense. Fangrui Song (5): romlayout.S

[SeaBIOS] [PATCH v3 5/5] test-build.sh: Delete unneeded LD capability test

2020-04-06 Thread Fangrui Song
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 --- scripts/test-build.sh | 42 +- 1 file

[SeaBIOS] [PATCH v3 2/5] Make rom16.o linkable with lld

2020-04-06 Thread Fangrui Song
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 --- scripts/layoutrom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/layoutrom.p

[SeaBIOS] [PATCH v3 1/5] romlayout.S: Add missing SHF_ALLOC flag to .fixedaddr.\addr

2020-04-06 Thread Fangrui Song
the relocation. GNU ld allows it but lld will warn. Add the SHF_ALLOC flag. Signed-off-by: Fangrui Song --- 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

[SeaBIOS] [PATCH] Makefile: Change ET_EXEC to ET_REL so that lld can link bios.bin.elf

2020-03-15 Thread Fangrui Song
.) bios.bin.elf uses an extremely rare feature of GNU ld: an ET_EXEC can be linked as if it were an ET_REL. lld is rigid and will reject this use case. With this patch, I can link bios.bin.elf with lld 7. Signed-off-by: Fangrui Song --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

[SeaBIOS] [PATCH] Makefile: Delete compiler driver option -nopie

2020-03-15 Thread Fangrui Song
(This does no harm because we use LD directly.) -nopie is a typo. The actual option is -no-pie. CFLAGS does not need to include a link option. Signed-off-by: Fangrui Song --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 8d087af..1400bf2 100644

[SeaBIOS] -fno-merge-constants and clang

2020-03-15 Thread Fangrui Song
// a.c #include int main() { puts("hello"); } gcc -O2 -fdata-sections -c a.c && readelf -WS a.o | grep .rodata [ 4] .rodata.str1.1PROGBITS 40 06 01 AMS 0 0 1 gcc -O2 -fdata-sections -fno-merge-constants -c a.c && readelf -WS a.o | grep .rodata [

[SeaBIOS] [PATCH v2] Makefile: Use -mstack-alignment=4 instead of -mpreferred-stack-boundary=2 for clang

2020-03-15 Thread Fangrui Song
Sorry, v1 does not work with GCC. gcc x86_64 rejects -mpreferred-stack-boundary=2, so we need to check -mpreferred-stack-boundary=4 instead Signed-off-by: Fangrui Song --- Makefile | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7720db9

[SeaBIOS] [PATCH] Makefile: Refactor cc-option

2020-03-15 Thread Fangrui Song
(This will be used by my next patch which will fix clang warning/error for -fno-merge-constants -mpreferred-stack-boundary=2) Suppress stderr output and add -Werror. clang emits [-Wignored-optimization-argument] for certain ignored GCC options. Signed-off-by: Fangrui Song --- Makefile | 26

[SeaBIOS] [PATCH] Makefile: Use -mstack-alignment=4 instead of -mpreferred-stack-boundary=2 for clang

2020-03-15 Thread Fangrui Song
( depends on https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/SWDV7MB6KSP2ZJF3SEVB3W3H3SOJMXEB/ "[PATCH] Makefile: Refactor cc-option" see linux/arch/x86/Makefile for a similar use case ) Signed-off-by: Fangrui Song --- Makefile | 3 ++- 1 file changed, 2

[SeaBIOS] [PATCH] Make rom16.o linkable with lld

2020-03-13 Thread Fangrui Song
by address. Signed-off-by: Fangrui Song (Note: with https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/CJR7WU6TTHVQEG5XHCRI75EA6SBV72SW/ and this patch, qemu-system-x86_64 -boot menu=on,splash-time=15000 -bios out/bios.bin -nographic seems to work for me with a small change

[SeaBIOS] [PATCH] romlayout32flag.lds: Use `. +=` instead of `. =`

2020-03-13 Thread Fangrui Song
See https://bugs.llvm.org/show_bug.cgi?id=43083 Signed-off-by: Fangrui Song --- scripts/layoutrom.py | 7 ++- scripts/test-build.sh | 42 +- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index 661672

[SeaBIOS] [PATCH 0/4] Make seabios linkable with lld

2020-04-01 Thread Fangrui Song
of This drops the only instance https://sourceware.org/bugzilla/show_bug.cgi?id=12726 1, 2 and 3 are really independent and can be applied in arbitrary order. 4 depends on 3. I originally combined 3 and 4 and that was why I don't think a patch series made sense. Fangrui Song (4): Make rom16.o

[SeaBIOS] [PATCH 1/4] Make rom16.o linkable with lld

2020-04-01 Thread Fangrui Song
by address. Just sort the addresses beforehand. Signed-off-by: Fangrui Song --- scripts/layoutrom.py | 4 src/romlayout.S | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index 6616721..4c55390 100755 --- a/scripts

[SeaBIOS] [PATCH 4/4] test-build.sh: Delete unneeded LD capability test

2020-04-01 Thread Fangrui Song
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 --- scripts/test-build.sh | 42 +- 1 file

[SeaBIOS] [PATCH 2/4] Makefile: Change ET_EXEC to ET_REL so that lld can link bios.bin.elf

2020-04-01 Thread Fangrui Song
ine. This suppresses dd's stderr output. * Move dd command to a separate command Signed-off-by: Fangrui Song --- Makefile | 4 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 5f7d537..118dec0 100644 --- a/Makefile +++ b/Makefile @@ -177,10 +177,14 @@ $(

[SeaBIOS] [PATCH 3/4] romlayout32flag.lds: Use `. +=` instead of `. =`

2020-04-01 Thread Fangrui Song
as well because we can delete an ld check detecting "cannot move location counter backwards". Signed-off-by: Fangrui Song --- scripts/layoutrom.py | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index 4c55390..94d4

[SeaBIOS] [PATCH v2] Use readelf -WSrs instead of objdump -thr so that llvm-readelf can be used as a replacement

2020-04-01 Thread Fangrui Song
-by: Fangrui Song --- Makefile | 18 +++--- scripts/checkrom.py | 2 +- scripts/layoutrom.py | 143 --- 3 files changed, 78 insertions(+), 85 deletions(-) -- Changes v1->v2 * Deleted unrelated debug lines diff --git a/Makefile b/Makefile in

[SeaBIOS] [PATCH] vgaentry.S: Add missing SHF_ALLOC flag to .rom.header

2020-05-01 Thread Fangrui Song
the relocation. GNU ld allows it but lld will warn. Add the SHF_ALLOC flag. Signed-off-by: Fangrui Song --- vgasrc/vgaentry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vgasrc/vgaentry.S b/vgasrc/vgaentry.S index f9624fc..93f28f9 100644 --- a/vgasrc/vgaentry.S +++ b/vgasrc

[SeaBIOS] [PATCH v2] romlayout32flag.lds: Use `. +=` instead of `. =`

2020-03-18 Thread Fangrui Song
On 2020-03-17, Kevin O'Connor wrote: On Fri, Mar 13, 2020 at 10:17:09PM -0700, Fangrui Song wrote: This improves the portability of the linker script and allows lld to link rom.o We can thus delete an ld check detecting "cannot move location counter backwards". Dot assignment inside

[SeaBIOS] Re: [PATCH] build: use -fcf-protection=none when available

2020-03-19 Thread Fangrui Song
On 2020-03-19, Christian Ehrhardt wrote: Some hardened gcc v9 compilers (such as the one in Ubuntu) default this option which for seabios leads to emulation errors when running in KVM (does not trigger in TCG) on older intel chips of the Penryn generation (~2006-2008). Symptom in KVM looks

[SeaBIOS] Re: recent ld built for x86_64 fails to accept 16bit code as input (seabios build)

2020-07-13 Thread Fangrui Song
On 2020-07-10, Nick Clifton via Binutils wrote: Hi Guys, I have just updated PR 26047 with a suggested patch which I think could resolve this situation. (Patch attached here as well in order to save time). It adds a new linker command line option: -z allowexec which will disable the

[SeaBIOS] Re: recent ld built for x86_64 fails to accept 16bit code as input (seabios build)

2020-07-10 Thread Fangrui Song
On 2020-07-10, Kevin O'Connor wrote: On Fri, Jul 10, 2020 at 11:58:06AM +0100, Nick Clifton wrote: Hi Guys, I have just updated PR 26047 with a suggested patch which I think could resolve this situation. (Patch attached here as well in order to save time). It adds a new linker command

[SeaBIOS] Re: [PATCH v3 0/5] Make seabios linkable with lld

2020-06-25 Thread Fangrui Song
On 2020-04-21, Fāng-ruì Sòng wrote: On 2020-04-21, Gerd Hoffmann wrote: Hi, Hi Gerd, thank you for your comments. You mean "Makefile: Change ET_EXEC to ET_REL so that lld can link bios.bin.elf" Let me add more descriptions. I am a maintainer of lld ELF (I contributed most features and

[SeaBIOS] [PATCH v4 3/4] romlayout32flag.lds: Use `. +=` instead of `. =`

2022-07-12 Thread Fangrui Song via SeaBIOS
as well because we can delete an ld check detecting "cannot move location counter backwards". Signed-off-by: Fangrui Song --- scripts/layoutrom.py | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index fa270ef..7bc4

[SeaBIOS] [PATCH v4 2/4] Make rom16.o linkable with lld

2022-07-12 Thread Fangrui Song via SeaBIOS
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 --- scripts/layoutrom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/layoutrom.p

[SeaBIOS] [PATCH v4 4/4] test-build.sh: Delete unneeded LD capability test

2022-07-12 Thread Fangrui Song via SeaBIOS
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 --- scripts/test-build.sh | 42 +- 1 file

[SeaBIOS] [PATCH v4 1/4] romlayout.S: Add missing SHF_ALLOC flag to .fixedaddr.\addr

2022-07-12 Thread Fangrui Song via SeaBIOS
the relocation. GNU ld allows it but lld will warn. Add the SHF_ALLOC flag. Signed-off-by: Fangrui Song --- 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

[SeaBIOS] [PATCH v4 0/4] Make seabios linkable with lld

2022-07-12 Thread Fangrui Song via SeaBIOS
ess 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 `. +

[SeaBIOS] [PATCH v3] Replace $(OBJDUMP) -thr with $(READELF) -WSrs

2022-07-12 Thread Fangrui Song via SeaBIOS
objdump when dumping ELF section/symbol information. Signed-off-by: Fangrui Song --- Changes from v2 (https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/message/4AZCP2KR63YAURID5FFXOWMPIOB4BNRJ/) * Change an objdump comment to mention readelf * For your convenience, this patch is available

[SeaBIOS] Re: [PATCH v3] Replace $(OBJDUMP) -thr with $(READELF) -WSrs

2022-07-13 Thread Fangrui Song via SeaBIOS
On Wed, Jul 13, 2022 at 10:01 PM Paul Menzel wrote: > > Dear Fangrui, > > > Thank you for the patch. > > Am 13.07.22 um 04:37 schrieb Fangrui Song via SeaBIOS: > > objdump -h relies heavily on BFD internals and the BFD flags. The output > > is difficult to emula