From 3d168fac149a5b0e7c66fbb526a2803eb2e2a7f5 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Tue, 10 Jan 2023 12:26:49 +0000 Subject: [PATCH] zipl/boot: declare that no executable stack is required MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Normally, `gcc` takes care of adding the `GNU_STACK` marking except for assembly code. Therefore, let's add the marking manually. Discard the `.note.GNU-stack` section in the linker script since it's just a "message" from the compiler to the linker. This fixes the linker warning: ld: warning: entry.o: missing .note.GNU-stack section implies executable stack Acked-by: Eduard Shishkin Reviewed-by: Stefan Haberland Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- zipl/boot/entry.S | 5 +++++ zipl/boot/head.S | 5 +++++ zipl/boot/stage2.lds.S | 1 + zipl/boot/stage3.lds.S | 1 + 4 files changed, 12 insertions(+) diff --git a/zipl/boot/entry.S b/zipl/boot/entry.S index 3ee786f1..d888a53a 100644 --- a/zipl/boot/entry.S +++ b/zipl/boot/entry.S @@ -18,3 +18,8 @@ pgm_check_handler: basr %r14,%r14 lmg %r0,%r15,__LC_SAVE_AREA_SYNC lpswe __LC_PGM_OLD_PSW(%r0) + +/* The code doesn't require an executable stack */ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/zipl/boot/head.S b/zipl/boot/head.S index f2395f6d..58515012 100644 --- a/zipl/boot/head.S +++ b/zipl/boot/head.S @@ -28,3 +28,8 @@ _start: brasl %r14,initialize .Lstack: .long 0x10000-160 .previous + +/* The code doesn't require an executable stack */ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/zipl/boot/stage2.lds.S b/zipl/boot/stage2.lds.S index eee1d3c2..2204dd56 100644 --- a/zipl/boot/stage2.lds.S +++ b/zipl/boot/stage2.lds.S @@ -94,5 +94,6 @@ SECTIONS /DISCARD/ : { *(.eh_frame) *(.interp) + *(.note.GNU-stack) } } diff --git a/zipl/boot/stage3.lds.S b/zipl/boot/stage3.lds.S index 9cea19b8..1150fea4 100644 --- a/zipl/boot/stage3.lds.S +++ b/zipl/boot/stage3.lds.S @@ -79,5 +79,6 @@ SECTIONS /DISCARD/ : { *(.eh_frame) *(.interp) + *(.note.GNU-stack) } }