render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone
Blob Blame History Raw
From 12cbd48e1e78f07b19df900b0f9ccdd633aa42ee Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Mon, 27 Nov 2023 12:51:25 -0500
Subject: [PATCH] pc-bios/optionrom: Fix pvh.img ld build failure on fedora
 rawhide
Content-type: text/plain

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 pc-bios/optionrom/Makefile | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
index 30d07026c7..87cfc484c7 100644
--- a/pc-bios/optionrom/Makefile
+++ b/pc-bios/optionrom/Makefile
@@ -38,6 +38,16 @@ config-cc.mak: Makefile
 
 override LDFLAGS = -nostdlib -Wl,--build-id=none,-T,$(SRC_DIR)/flat.lds
 
+ld-test = $(LD) -v $1 >/dev/null 2>/dev/null
+ld-option = if $(call ld-test, $1); then \
+    echo "$(TARGET_PREFIX)$1 detected" && echo "override LDFLAGS += -Wl,$1" >&3; else \
+    echo "$(TARGET_PREFIX)$1 not detected" $(if $2,&& echo "override LDFLAGS += $2" >&3); fi
+
+config-ld.mak: Makefile
+	$(quiet-@)($(call ld-option,--no-warn-rwx-segments); \
+	    $(call ld-option,--no-warn-execstack)) 3> config-ld.mak
+-include config-ld.mak
+
 pvh.img: pvh.o pvh_main.o
 
 %.o: %.S
@@ -61,7 +71,7 @@ clean:
 	rm -f *.o *.d *.raw *.img *.bin *~
 
 distclean:
-	rm -f config-cc.mak
+	rm -f config-cc.mak config-ld.mak
 
 # suppress auto-removal of intermediate files
 .SECONDARY: