From dfe8a4f803398b75429404828d929964281f2b91 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Fri, 3 Feb 2023 19:07:52 +0100 Subject: [PATCH] genprotimg/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 Reviewed-by: Steffen Eiden Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- genprotimg/boot/head.S | 5 +++++ genprotimg/boot/stage3a.lds.S | 1 + genprotimg/boot/stage3a_init.S | 5 +++++ genprotimg/boot/stage3b.lds.S | 1 + genprotimg/boot/stage3b_reloc.S | 5 +++++ 5 files changed, 17 insertions(+) diff --git a/genprotimg/boot/head.S b/genprotimg/boot/head.S index bfa35f6e..2a459487 100644 --- a/genprotimg/boot/head.S +++ b/genprotimg/boot/head.S @@ -29,3 +29,8 @@ _start: brasl %r14, initialize .Lstack: .long STACK_ADDRESS + STACK_SIZE - STACK_FRAME_OVERHEAD .previous + +/* The code doesn't require an executable stack */ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/genprotimg/boot/stage3a.lds.S b/genprotimg/boot/stage3a.lds.S index eefb52c3..07062876 100644 --- a/genprotimg/boot/stage3a.lds.S +++ b/genprotimg/boot/stage3a.lds.S @@ -99,5 +99,6 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { *(.eh_frame) + *(.note.GNU-stack) } } diff --git a/genprotimg/boot/stage3a_init.S b/genprotimg/boot/stage3a_init.S index 43dd02b3..de5ebcf1 100644 --- a/genprotimg/boot/stage3a_init.S +++ b/genprotimg/boot/stage3a_init.S @@ -26,3 +26,8 @@ _init: br %r1 .Lstage3a_entry: .long STAGE3A_ENTRY .previous + +/* The code doesn't require an executable stack */ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/genprotimg/boot/stage3b.lds.S b/genprotimg/boot/stage3b.lds.S index 2711d84e..91d69375 100644 --- a/genprotimg/boot/stage3b.lds.S +++ b/genprotimg/boot/stage3b.lds.S @@ -83,5 +83,6 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { *(.eh_frame) + *(.note.GNU-stack) } } diff --git a/genprotimg/boot/stage3b_reloc.S b/genprotimg/boot/stage3b_reloc.S index a7c4cf50..2b024c50 100644 --- a/genprotimg/boot/stage3b_reloc.S +++ b/genprotimg/boot/stage3b_reloc.S @@ -53,3 +53,8 @@ stage3b_start: .incbin "stage3b.bin" stage3b_end: .previous + +/* The code doesn't require an executable stack */ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif