Skip to contentSkip to conversation

pc-bios/optionrom: Fix pvh.img ld build failure on fedora rawhide

PATCH Superseded Cole Robinson 3 participants 4 messages Nov 28, 2023 – Jan 21, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pc-bios/optionrom: Fix pvh.img ld build failure on fedora rawhide

binutils 2.39 shows some warnings when building pvh.img

/usr/bin/ld: warning: pvh.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: pvh.img has a LOAD segment with RWX permissions

The latter of which is fatal on Fedora rawhide for some reason.

Add linker options to suppress the errors

---
 pc-bios/optionrom/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
pc-bios/optionrom/Makefile +1 -1
index 30d07026c7..f54ed39b54 100644
@@ -36,7 +36,7 @@ config-cc.mak: Makefile
 	    $(call cc-option,-Wno-array-bounds)) 3> config-cc.mak
 -include config-cc.mak
 
-override LDFLAGS = -nostdlib -Wl,--build-id=none,-T,$(SRC_DIR)/flat.lds
+override LDFLAGS = -nostdlib -Wl,--build-id=none,-T,$(SRC_DIR)/flat.lds -Wl,--no-warn-rwx-segments -Wl,--no-warn-execstack
 
 pvh.img: pvh.o pvh_main.o
 
#1 lore raw
Quoted 9 lines · Cole Robinson

binutils 2.39 shows some warnings when building pvh.img

/usr/bin/ld: warning: pvh.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: pvh.img has a LOAD segment with RWX permissions

The latter of which is fatal on Fedora rawhide for some reason.

Add linker options to suppress the errors

This makes it silent, but I guess someone needs to confirm that this option ROM code genuinely does NOT need to have executable stack, otherwise the future change that is being warned about could impact it ?

Quoted 13 lines
---
 pc-bios/optionrom/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
pc-bios/optionrom/Makefile +0 -0
index 30d07026c7..f54ed39b54 100644

pc-bios/optionrom/Makefile config-cc.mak: Makefile · line 42

Quoted 8 lines
pc-bios/optionrom/Makefile +1 -1
@@ -36,7 +36,7 @@ config-cc.mak: Makefile
 	    $(call cc-option,-Wno-array-bounds)) 3> config-cc.mak
 -include config-cc.mak
 
-override LDFLAGS = -nostdlib -Wl,--build-id=none,-T,$(SRC_DIR)/flat.lds
+override LDFLAGS = -nostdlib -Wl,--build-id=none,-T,$(SRC_DIR)/flat.lds -Wl,--no-warn-rwx-segments -Wl,--no-warn-execstack
 
 pvh.img: pvh.o pvh_main.o
 

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Acked-by
#2 lore raw
Quoted 7 lines · Daniel P. Berrangé
Quoted 6 lines · Cole Robinson

binutils 2.39 shows some warnings when building pvh.img

/usr/bin/ld: warning: pvh.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: pvh.img has a LOAD segment with RWX permissions

Quoted 8 lines
Quoted 3 lines

The latter of which is fatal on Fedora rawhide for some reason.

Add linker options to suppress the errors

This makes it silent, but I guess someone needs to confirm that this option ROM code genuinely does NOT need to have executable stack, otherwise the future change that is being warned about could impact it ?

Skimming the code it does not look like it depends on a execute-able stack. Beside that the option rom will be loaded as raw binary by seabios and run without paging. There is nothing which could actually setup and enforce an NX stack ...

take care,
Gerd

#3 lore raw
Quoted 17 lines · Gerd Hoffmann
Quoted 7 lines · Daniel P. Berrangé
Quoted 6 lines · Cole Robinson

binutils 2.39 shows some warnings when building pvh.img

/usr/bin/ld: warning: pvh.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: pvh.img has a LOAD segment with RWX permissions

Quoted 8 lines
Quoted 3 lines

The latter of which is fatal on Fedora rawhide for some reason.

Add linker options to suppress the errors

This makes it silent, but I guess someone needs to confirm that this option ROM code genuinely does NOT need to have executable stack, otherwise the future change that is being warned about could impact it ?

Quoted 7 lines

Skimming the code it does not look like it depends on a execute-able stack. Beside that the option rom will be loaded as raw binary by seabios and run without paging. There is nothing which could actually setup and enforce an NX stack ...

I just realized this breaks the build on centos 9 with binutils 2.35.2-42.el9

make[1]: Leaving directory '/builddir/build/BUILD/qemu-8.2.0/qemu_kvm_build/pc-bios/optionrom' make[1]: Entering directory '/builddir/build/BUILD/qemu-8.2.0/qemu_kvm_build/pc-bios/optionrom' gcc -O2 -g -march=i486 -Wall -m32 -m16 -ffreestanding -I/builddir/build/BUILD/qemu-8.2.0/include -fcf-protection=none -fno-pie -no-pie -fno-stack-protector -Wno-array-bounds -nostdlib -Wl,--build-id=none,-T,/builddir/build/BUILD/qemu-8.2.0/pc-bios/optionrom/flat.lds -Wl,--no-warn-rwx-segments -Wl,--no-warn-execstack -s -o multiboot.img multiboot.o
/usr/bin/ld: unrecognized option '--no-warn-rwx-segments' /usr/bin/ld: use the --help option for usage information

This article has tips about how to fix these issues in the linker scripts, so maybe that's the better approach:

https://www.redhat.com/en/blog/linkers-warnings-about-executable-stacks-and-segments

Thanks,
Cole