From: Geert Stappers <stappers@stappers.it>
Date: Fri, 30 Jun 2023 10:59:59 +0100
Subject: [build] Inhibit linker warnings about an implied executable stack
 (bsc#1219733, bsc#1219722)

Signed-off-by: Geert Stappers <stappers@stappers.it>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
(cherry picked from commit e17568ad0642490143d0c6b154c874b9b9e285bf)
References: bsc#1219733
References: bsc#1219722
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
 src/arch/arm64/core/setjmp.S                    | 1 +
 src/arch/i386/core/gdbidt.S                     | 1 +
 src/arch/i386/core/setjmp.S                     | 1 +
 src/arch/i386/tests/gdbstub_test.S              | 1 +
 src/arch/x86/core/patch_cf.S                    | 1 +
 src/arch/x86/core/stack.S                       | 1 +
 src/arch/x86/core/stack16.S                     | 1 +
 src/arch/x86/drivers/net/undiisr.S              | 1 +
 src/arch/x86/interface/pcbios/e820mangler.S     | 1 +
 src/arch/x86/interface/pxe/pxe_entry.S          | 1 +
 src/arch/x86/interface/syslinux/com32_wrapper.S | 1 +
 src/arch/x86/prefix/bootpart.S                  | 1 +
 src/arch/x86/prefix/dskprefix.S                 | 1 +
 src/arch/x86/prefix/exeprefix.S                 | 1 +
 src/arch/x86/prefix/hdprefix.S                  | 1 +
 src/arch/x86/prefix/libprefix.S                 | 1 +
 src/arch/x86/prefix/lkrnprefix.S                | 1 +
 src/arch/x86/prefix/mbr.S                       | 1 +
 src/arch/x86/prefix/mromprefix.S                | 1 +
 src/arch/x86/prefix/nbiprefix.S                 | 1 +
 src/arch/x86/prefix/nullprefix.S                | 1 +
 src/arch/x86/prefix/pxeprefix.S                 | 1 +
 src/arch/x86/prefix/rawprefix.S                 | 1 +
 src/arch/x86/prefix/romprefix.S                 | 1 +
 src/arch/x86/prefix/undiloader.S                | 1 +
 src/arch/x86/prefix/unlzma.S                    | 1 +
 src/arch/x86/transitions/liba20.S               | 1 +
 src/arch/x86/transitions/libkir.S               | 1 +
 src/arch/x86/transitions/librm.S                | 2 ++
 src/arch/x86_64/core/gdbidt.S                   | 1 +
 src/arch/x86_64/core/setjmp.S                   | 1 +
 31 files changed, 32 insertions(+)

diff --git a/roms/ipxe/src/arch/arm64/core/setjmp.S b/roms/ipxe/src/arch/arm64/core/setjmp.S
index fa47aa0afa088fcffc91358dbb17..c5c77c1fb9afd916d71b8a1f59c9 100644
--- a/roms/ipxe/src/arch/arm64/core/setjmp.S
+++ b/roms/ipxe/src/arch/arm64/core/setjmp.S
@@ -1,5 +1,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", %progbits
 	.text
 
 	/* Must match jmp_buf structure layout */
diff --git a/roms/ipxe/src/arch/i386/core/gdbidt.S b/roms/ipxe/src/arch/i386/core/gdbidt.S
index 666ecce3ca5eee7471ae498933c6..78945c62cf4059b9c3b178fa52d4 100644
--- a/roms/ipxe/src/arch/i386/core/gdbidt.S
+++ b/roms/ipxe/src/arch/i386/core/gdbidt.S
@@ -9,6 +9,7 @@
  * Interrupt handlers
  ****************************************************************************
  */
+	.section ".note.GNU-stack", "", @progbits
 	.section ".text", "ax", @progbits
 	.code32
 
diff --git a/roms/ipxe/src/arch/i386/core/setjmp.S b/roms/ipxe/src/arch/i386/core/setjmp.S
index 81d3b491153884a0171a0447c856..e0bbb7ef8518dc6de32b14604816 100644
--- a/roms/ipxe/src/arch/i386/core/setjmp.S
+++ b/roms/ipxe/src/arch/i386/core/setjmp.S
@@ -1,5 +1,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.code32
diff --git a/roms/ipxe/src/arch/i386/tests/gdbstub_test.S b/roms/ipxe/src/arch/i386/tests/gdbstub_test.S
index 739b0527abb4de16846a1a28e0c6..e0c9e6c9a513a9978dde6ac69e85 100644
--- a/roms/ipxe/src/arch/i386/tests/gdbstub_test.S
+++ b/roms/ipxe/src/arch/i386/tests/gdbstub_test.S
@@ -1,3 +1,4 @@
+	.section ".note.GNU-stack", "", @progbits
 	.arch i386
 
 	.section ".data", "aw", @progbits
diff --git a/roms/ipxe/src/arch/x86/core/patch_cf.S b/roms/ipxe/src/arch/x86/core/patch_cf.S
index 4365563fe67b3dc787a79048e1f3..63730c3fd6156f734a8c08fcd9d1 100644
--- a/roms/ipxe/src/arch/x86/core/patch_cf.S
+++ b/roms/ipxe/src/arch/x86/core/patch_cf.S
@@ -22,6 +22,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.code16
diff --git a/roms/ipxe/src/arch/x86/core/stack.S b/roms/ipxe/src/arch/x86/core/stack.S
index 995c397cad1e609f490eb51a1db1..5aabab58cbe047b2972148d4f3fb 100644
--- a/roms/ipxe/src/arch/x86/core/stack.S
+++ b/roms/ipxe/src/arch/x86/core/stack.S
@@ -1,5 +1,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.arch i386
 
 #ifdef __x86_64__
diff --git a/roms/ipxe/src/arch/x86/core/stack16.S b/roms/ipxe/src/arch/x86/core/stack16.S
index 4bc6f081a94dcd424a51ad887826..85b683bc5f13bfa6d3fa814d04b1 100644
--- a/roms/ipxe/src/arch/x86/core/stack16.S
+++ b/roms/ipxe/src/arch/x86/core/stack16.S
@@ -1,5 +1,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.arch i386
 
 /****************************************************************************
diff --git a/roms/ipxe/src/arch/x86/drivers/net/undiisr.S b/roms/ipxe/src/arch/x86/drivers/net/undiisr.S
index 2428d1f5d0a66f413500c7bc2bae..a1098b8396e130de1ac3d16a10d8 100644
--- a/roms/ipxe/src/arch/x86/drivers/net/undiisr.S
+++ b/roms/ipxe/src/arch/x86/drivers/net/undiisr.S
@@ -10,6 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER )
 #define PIC1_ICR 0x20
 #define PIC2_ICR 0xa0
 	
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.code16
diff --git a/roms/ipxe/src/arch/x86/interface/pcbios/e820mangler.S b/roms/ipxe/src/arch/x86/interface/pcbios/e820mangler.S
index d5d97b482e547983cc9b75d2613b..22dd3b15d4607c3c7213288a6b40 100644
--- a/roms/ipxe/src/arch/x86/interface/pcbios/e820mangler.S
+++ b/roms/ipxe/src/arch/x86/interface/pcbios/e820mangler.S
@@ -23,6 +23,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.code16
diff --git a/roms/ipxe/src/arch/x86/interface/pxe/pxe_entry.S b/roms/ipxe/src/arch/x86/interface/pxe/pxe_entry.S
index 663aa842e06932ae7bcf3dc5c2e0..15ae82069201cba1192150aa23cb 100644
--- a/roms/ipxe/src/arch/x86/interface/pxe/pxe_entry.S
+++ b/roms/ipxe/src/arch/x86/interface/pxe/pxe_entry.S
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
 #include <librm.h>
 
+	.section ".note.GNU-stack", "", @progbits
 	.arch i386
 
 /****************************************************************************
diff --git a/roms/ipxe/src/arch/x86/interface/syslinux/com32_wrapper.S b/roms/ipxe/src/arch/x86/interface/syslinux/com32_wrapper.S
index d59a3392c2cc4dfca75c1858780f..5019195653185e62ec76fcbf5507 100644
--- a/roms/ipxe/src/arch/x86/interface/syslinux/com32_wrapper.S
+++ b/roms/ipxe/src/arch/x86/interface/syslinux/com32_wrapper.S
@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER )
 
 #include "librm.h"
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 
 	.code32
diff --git a/roms/ipxe/src/arch/x86/prefix/bootpart.S b/roms/ipxe/src/arch/x86/prefix/bootpart.S
index 6d0c6034a459d2a3f76ff52a0c79..575cb1c07182ec690baca8d754eb 100644
--- a/roms/ipxe/src/arch/x86/prefix/bootpart.S
+++ b/roms/ipxe/src/arch/x86/prefix/bootpart.S
@@ -5,6 +5,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 #define STACK_SEG 	0x0200
 #define STACK_SIZE	0x2000
 	
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.section ".prefix", "awx", @progbits
diff --git a/roms/ipxe/src/arch/x86/prefix/dskprefix.S b/roms/ipxe/src/arch/x86/prefix/dskprefix.S
index 0503f113d0c574ddc83dc0d03aa1..bc19488798674d1be687bac1108b 100644
--- a/roms/ipxe/src/arch/x86/prefix/dskprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/dskprefix.S
@@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_ONLY )
 
 .equ	SYSSEG, 0x1000			/* system loaded at SYSSEG<<4 */
 
+	.section ".note.GNU-stack", "", @progbits
 	.org	0
 	.arch i386
 	.text
diff --git a/roms/ipxe/src/arch/x86/prefix/exeprefix.S b/roms/ipxe/src/arch/x86/prefix/exeprefix.S
index c351456e2ebedba7eb5a024e2fbf..e257ed1b5ccf849a208f61f7f5a5 100644
--- a/roms/ipxe/src/arch/x86/prefix/exeprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/exeprefix.S
@@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 #define PSP_CMDLINE_LEN 0x80
 #define PSP_CMDLINE_START 0x81
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.org 0
diff --git a/roms/ipxe/src/arch/x86/prefix/hdprefix.S b/roms/ipxe/src/arch/x86/prefix/hdprefix.S
index 28c8a532d2f9cfc2f61ebcada4ea..fbf8d2e47d855baf1b8d1827371c 100644
--- a/roms/ipxe/src/arch/x86/prefix/hdprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/hdprefix.S
@@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
 #include <librm.h>
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.section ".prefix", "awx", @progbits
diff --git a/roms/ipxe/src/arch/x86/prefix/libprefix.S b/roms/ipxe/src/arch/x86/prefix/libprefix.S
index ffb2110583508d26b9fcd4f37587..0445a35d75a50adcac7139135e3a 100644
--- a/roms/ipxe/src/arch/x86/prefix/libprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/libprefix.S
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
 #include <librm.h>
 
+	.section ".note.GNU-stack", "", @progbits
 	.arch i386
 
 /* Image compression enabled */
diff --git a/roms/ipxe/src/arch/x86/prefix/lkrnprefix.S b/roms/ipxe/src/arch/x86/prefix/lkrnprefix.S
index 922181f0e9918ffef66126c0167f..2c17f79df755b99d4e87422048b9 100644
--- a/roms/ipxe/src/arch/x86/prefix/lkrnprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/lkrnprefix.S
@@ -4,6 +4,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
 #define BZI_LOAD_HIGH_ADDR 0x100000
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.code16
diff --git a/roms/ipxe/src/arch/x86/prefix/mbr.S b/roms/ipxe/src/arch/x86/prefix/mbr.S
index 032c0e775f12021ad6772c219808..928bb338bcbbc6d84428941bb5b4 100644
--- a/roms/ipxe/src/arch/x86/prefix/mbr.S
+++ b/roms/ipxe/src/arch/x86/prefix/mbr.S
@@ -1,5 +1,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.section ".prefix", "awx", @progbits
diff --git a/roms/ipxe/src/arch/x86/prefix/mromprefix.S b/roms/ipxe/src/arch/x86/prefix/mromprefix.S
index 2b5c6bf64825c265bdfce7f0ca30..a3e0d69a05915dde9caa3ef00969 100644
--- a/roms/ipxe/src/arch/x86/prefix/mromprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/mromprefix.S
@@ -41,6 +41,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 #define _pcirom_start _mrom_start
 #include "pciromprefix.S"
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.code16
diff --git a/roms/ipxe/src/arch/x86/prefix/nbiprefix.S b/roms/ipxe/src/arch/x86/prefix/nbiprefix.S
index de38e4af6e1b87b9615b85e63fb6..cae1009b3e37e76a063ad3d04386 100644
--- a/roms/ipxe/src/arch/x86/prefix/nbiprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/nbiprefix.S
@@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
 #include <librm.h>
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.code16
diff --git a/roms/ipxe/src/arch/x86/prefix/nullprefix.S b/roms/ipxe/src/arch/x86/prefix/nullprefix.S
index bd0ff339e8d7e9250e06606927c1..1568188d0753bd070e892947f16d 100644
--- a/roms/ipxe/src/arch/x86/prefix/nullprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/nullprefix.S
@@ -1,5 +1,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.org	0
 	.text
 	.arch i386
diff --git a/roms/ipxe/src/arch/x86/prefix/pxeprefix.S b/roms/ipxe/src/arch/x86/prefix/pxeprefix.S
index 52ea18039279791bddc5a90d680c..494fbc138e970e1cecc902596b70 100644
--- a/roms/ipxe/src/arch/x86/prefix/pxeprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/pxeprefix.S
@@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
 #define PXE_HACK_EB54			0x0001
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.org 0
diff --git a/roms/ipxe/src/arch/x86/prefix/rawprefix.S b/roms/ipxe/src/arch/x86/prefix/rawprefix.S
index 4cf5f391e0d6f40e84209bc529cb..4a3d350423120f0301cb72401f65 100644
--- a/roms/ipxe/src/arch/x86/prefix/rawprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/rawprefix.S
@@ -8,6 +8,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.org 0
diff --git a/roms/ipxe/src/arch/x86/prefix/romprefix.S b/roms/ipxe/src/arch/x86/prefix/romprefix.S
index 3abef0eaf734f45303b9ca61f91e..48f417a5f11321231c51d41d1e4c 100644
--- a/roms/ipxe/src/arch/x86/prefix/romprefix.S
+++ b/roms/ipxe/src/arch/x86/prefix/romprefix.S
@@ -54,6 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 #define BUSTYPE "PCIR"
 #endif
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.code16
 	.arch i386
diff --git a/roms/ipxe/src/arch/x86/prefix/undiloader.S b/roms/ipxe/src/arch/x86/prefix/undiloader.S
index 1d77110e7cc3a62bb99217395458..e544d5048fd3abd8d498cb3f87ea 100644
--- a/roms/ipxe/src/arch/x86/prefix/undiloader.S
+++ b/roms/ipxe/src/arch/x86/prefix/undiloader.S
@@ -2,6 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
 #include <librm.h>
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.code16
 	.arch i386
diff --git a/roms/ipxe/src/arch/x86/prefix/unlzma.S b/roms/ipxe/src/arch/x86/prefix/unlzma.S
index 82d78c331dce9c8116c103d0c686..2a7cde130260562fdfdb77f44843 100644
--- a/roms/ipxe/src/arch/x86/prefix/unlzma.S
+++ b/roms/ipxe/src/arch/x86/prefix/unlzma.S
@@ -43,6 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  ****************************************************************************
  */
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i486
 	.section ".prefix.lib", "ax", @progbits
diff --git a/roms/ipxe/src/arch/x86/transitions/liba20.S b/roms/ipxe/src/arch/x86/transitions/liba20.S
index 6c1e1f62fb8e72cde63f9ec9a285..f7245e0baf3e985f18bab8c13128 100644
--- a/roms/ipxe/src/arch/x86/transitions/liba20.S
+++ b/roms/ipxe/src/arch/x86/transitions/liba20.S
@@ -24,6 +24,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.arch i386
 
 /****************************************************************************
diff --git a/roms/ipxe/src/arch/x86/transitions/libkir.S b/roms/ipxe/src/arch/x86/transitions/libkir.S
index fa9459d52f1bb281b40428be358b..af090b266083ad5b79819f9a5852 100644
--- a/roms/ipxe/src/arch/x86/transitions/libkir.S
+++ b/roms/ipxe/src/arch/x86/transitions/libkir.S
@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 /* Breakpoint for when debugging under bochs */
 #define BOCHSBP xchgw %bx, %bx
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.arch i386
 	.section ".text16", "awx", @progbits
diff --git a/roms/ipxe/src/arch/x86/transitions/librm.S b/roms/ipxe/src/arch/x86/transitions/librm.S
index 9d3eff954e39b47d1ea088e4733b..b36c8b6052c92a39f0e67d91e346 100644
--- a/roms/ipxe/src/arch/x86/transitions/librm.S
+++ b/roms/ipxe/src/arch/x86/transitions/librm.S
@@ -83,6 +83,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 #define if64 if 0
 #endif
 
+	.section ".note.GNU-stack", "", @progbits
+
 /****************************************************************************
  * Global descriptor table
  *
diff --git a/roms/ipxe/src/arch/x86_64/core/gdbidt.S b/roms/ipxe/src/arch/x86_64/core/gdbidt.S
index 89280bf8982c4be733e7de77aa00..477492b4729396778b2ab75f173c 100644
--- a/roms/ipxe/src/arch/x86_64/core/gdbidt.S
+++ b/roms/ipxe/src/arch/x86_64/core/gdbidt.S
@@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define SIGFPE 8
 #define SIGSTKFLT 16
 
+	.section ".note.GNU-stack", "", @progbits
 	.section ".text.gdbmach_interrupt", "ax", @progbits
 	.code64
 
diff --git a/roms/ipxe/src/arch/x86_64/core/setjmp.S b/roms/ipxe/src/arch/x86_64/core/setjmp.S
index e43200d7b6cfb757e25db1b908d2..5137a72c1dbfe147689edff4fde4 100644
--- a/roms/ipxe/src/arch/x86_64/core/setjmp.S
+++ b/roms/ipxe/src/arch/x86_64/core/setjmp.S
@@ -1,5 +1,6 @@
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
+	.section ".note.GNU-stack", "", @progbits
 	.text
 	.code64
 
