From 803b49c40bb0b720b90d9c31d372911f1b946aa7 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 6 Aug 2022 11:16:29 +0100 Subject: [PATCH] */*.S: add non-executable GNU stack marking on ELF-linux binutils-2.39 enabed a few warning by default (https://sourceware.org/pipermail/binutils/2022-August/122246.html): > The ELF linker will now generate a warning message if the stack is made executable. Let's suppress the warnings in assembly files by adding non-executables stack markings. This fixes at least systemd build which uses '-Wl,--fatal-warnings': https://github.com/systemd/systemd/issues/24226 --- apps/trivial.S | 4 ++++ gnuefi/crt0-efi-aarch64.S | 4 ++++ gnuefi/crt0-efi-arm.S | 4 ++++ gnuefi/crt0-efi-ia32.S | 4 ++++ gnuefi/crt0-efi-ia64.S | 4 ++++ gnuefi/crt0-efi-mips64el.S | 4 ++++ gnuefi/crt0-efi-riscv64.S | 4 ++++ gnuefi/crt0-efi-x86_64.S | 3 +++ gnuefi/reloc_ia64.S | 4 ++++ lib/aarch64/efi_stub.S | 4 ++++ lib/aarch64/setjmp.S | 4 ++++ lib/arm/div.S | 4 ++++ lib/arm/efi_stub.S | 4 ++++ lib/arm/ldivmod.S | 5 +++-- lib/arm/llsl.S | 4 ++++ lib/arm/llsr.S | 4 ++++ lib/arm/mullu.S | 4 ++++ lib/arm/setjmp.S | 4 ++++ lib/arm/uldiv.S | 4 +++- lib/ia32/efi_stub.S | 4 ++++ lib/ia32/setjmp.S | 4 ++++ lib/ia64/palproc.S | 3 +++ lib/ia64/setjmp.S | 4 ++++ lib/mips64el/efi_stub.S | 4 ++++ lib/mips64el/setjmp.S | 4 ++++ lib/riscv64/setjmp.S | 4 ++++ lib/x86_64/efi_stub.S | 4 ++++ lib/x86_64/setjmp.S | 4 ++++ 28 files changed, 108 insertions(+), 3 deletions(-) diff --git a/apps/trivial.S b/apps/trivial.S index 40bc68f..3ec6562 100644 --- a/apps/trivial.S +++ b/apps/trivial.S @@ -41,3 +41,7 @@ _start: hello: .byte 'h',0,'e',0,'l',0,'l',0,'o',0,'\n',0,'\r',0,0,0 #endif + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/crt0-efi-aarch64.S b/gnuefi/crt0-efi-aarch64.S index d50e78d..a0687b1 100644 --- a/gnuefi/crt0-efi-aarch64.S +++ b/gnuefi/crt0-efi-aarch64.S @@ -128,3 +128,7 @@ _start: 0: ldp x29, x30, [sp], #32 ret + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/crt0-efi-arm.S b/gnuefi/crt0-efi-arm.S index e7e5905..ea3bbc4 100644 --- a/gnuefi/crt0-efi-arm.S +++ b/gnuefi/crt0-efi-arm.S @@ -143,3 +143,7 @@ _start: .L_DYNAMIC: .word _DYNAMIC - . + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/crt0-efi-ia32.S b/gnuefi/crt0-efi-ia32.S index b1c9610..9e9c865 100644 --- a/gnuefi/crt0-efi-ia32.S +++ b/gnuefi/crt0-efi-ia32.S @@ -75,3 +75,7 @@ dummy: .long 0 .long 12 // Block Size (2*4+2*2), must be aligned by 32 Bits .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/crt0-efi-ia64.S b/gnuefi/crt0-efi-ia64.S index cd00b8d..38af615 100644 --- a/gnuefi/crt0-efi-ia64.S +++ b/gnuefi/crt0-efi-ia64.S @@ -85,3 +85,7 @@ _start_plabel: data4 12 // Block Size (2*4+2*2), must be aligned by 32 Bits data2 (IMAGE_REL_BASED_DIR64<<12) + 0 // reloc for plabel's entry point data2 (IMAGE_REL_BASED_DIR64<<12) + 8 // reloc for plabel's global pointer + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/crt0-efi-mips64el.S b/gnuefi/crt0-efi-mips64el.S index 6d26f66..4b2c1b2 100644 --- a/gnuefi/crt0-efi-mips64el.S +++ b/gnuefi/crt0-efi-mips64el.S @@ -186,3 +186,7 @@ _pc: .end _start .set pop + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/crt0-efi-riscv64.S b/gnuefi/crt0-efi-riscv64.S index 1bc536b..0a5b7fc 100644 --- a/gnuefi/crt0-efi-riscv64.S +++ b/gnuefi/crt0-efi-riscv64.S @@ -134,3 +134,7 @@ _start: ld ra, 16(sp) 0: addi sp, sp, 24 ret + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/crt0-efi-x86_64.S b/gnuefi/crt0-efi-x86_64.S index 20bbaee..49f0a0d 100644 --- a/gnuefi/crt0-efi-x86_64.S +++ b/gnuefi/crt0-efi-x86_64.S @@ -75,3 +75,6 @@ label1: .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/gnuefi/reloc_ia64.S b/gnuefi/reloc_ia64.S index 40203bf..ce2bf6a 100644 --- a/gnuefi/reloc_ia64.S +++ b/gnuefi/reloc_ia64.S @@ -225,3 +225,7 @@ apply_FPTR64: fptr_mem_base: .space MAX_FUNCTION_DESCRIPTORS*16 fptr_mem_limit: + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/aarch64/efi_stub.S b/lib/aarch64/efi_stub.S index 464eae5..f84aaf2 100644 --- a/lib/aarch64/efi_stub.S +++ b/lib/aarch64/efi_stub.S @@ -1 +1,5 @@ /* This stub is a stub to make the build happy */ + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/aarch64/setjmp.S b/lib/aarch64/setjmp.S index 46c29b1..700af78 100644 --- a/lib/aarch64/setjmp.S +++ b/lib/aarch64/setjmp.S @@ -58,3 +58,7 @@ longjmp: mov w0, #1 csel w0, w1, w0, ne br x30 + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/div.S b/lib/arm/div.S index 71158b6..6371327 100644 --- a/lib/arm/div.S +++ b/lib/arm/div.S @@ -153,3 +153,7 @@ label1: @ What to do about division by zero? For now, just return. ASM_PFX(__aeabi_idiv0): bx r14 + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/efi_stub.S b/lib/arm/efi_stub.S index 464eae5..f84aaf2 100644 --- a/lib/arm/efi_stub.S +++ b/lib/arm/efi_stub.S @@ -1 +1,5 @@ /* This stub is a stub to make the build happy */ + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/ldivmod.S b/lib/arm/ldivmod.S index edbf89e..a0648cc 100644 --- a/lib/arm/ldivmod.S +++ b/lib/arm/ldivmod.S @@ -57,5 +57,6 @@ L_Test3: L_Exit: pop {r4,pc} - - +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/llsl.S b/lib/arm/llsl.S index 0f5c407..d89d3df 100644 --- a/lib/arm/llsl.S +++ b/lib/arm/llsl.S @@ -39,3 +39,7 @@ ASM_PFX(__aeabi_llsl): lsl r1,r0,r3 mov r0,#0 bx lr + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/llsr.S b/lib/arm/llsr.S index 432b27d..4ecf1e1 100644 --- a/lib/arm/llsr.S +++ b/lib/arm/llsr.S @@ -39,3 +39,7 @@ ASM_PFX(__aeabi_llsr): lsr r0,r1,r3 mov r1,#0 bx lr + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/mullu.S b/lib/arm/mullu.S index 39b9a80..70cea2d 100644 --- a/lib/arm/mullu.S +++ b/lib/arm/mullu.S @@ -31,3 +31,7 @@ ASM_PFX(__aeabi_lmul): mla r1, r2, r1, ip mla r1, r3, lr, r1 ldmia sp!, {pc} + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/setjmp.S b/lib/arm/setjmp.S index bd61a8d..24b709a 100644 --- a/lib/arm/setjmp.S +++ b/lib/arm/setjmp.S @@ -23,3 +23,7 @@ setjmp: .type longjmp, %function longjmp: ldmia r0, {r3-r12,r14} + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/arm/uldiv.S b/lib/arm/uldiv.S index f478898..d606476 100644 --- a/lib/arm/uldiv.S +++ b/lib/arm/uldiv.S @@ -264,4 +264,6 @@ ASM_PFX(_ll_div0): ASM_PFX(__aeabi_ldiv0): bx r14 - +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/ia32/efi_stub.S b/lib/ia32/efi_stub.S index 464eae5..f84aaf2 100644 --- a/lib/ia32/efi_stub.S +++ b/lib/ia32/efi_stub.S @@ -1 +1,5 @@ /* This stub is a stub to make the build happy */ + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/ia32/setjmp.S b/lib/ia32/setjmp.S index aa9c084..c768488 100644 --- a/lib/ia32/setjmp.S +++ b/lib/ia32/setjmp.S @@ -43,3 +43,7 @@ longjmp: movl (%edx), %ebx movl 4(%edx), %esi movl 8(%edx), %edi + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/ia64/palproc.S b/lib/ia64/palproc.S index c304a78..b778623 100644 --- a/lib/ia64/palproc.S +++ b/lib/ia64/palproc.S @@ -159,3 +159,6 @@ StackedComeBackFromPALCall: PROCEDURE_EXIT(MakeStackedPALCall) +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/ia64/setjmp.S b/lib/ia64/setjmp.S index bbb29d8..09d6862 100644 --- a/lib/ia64/setjmp.S +++ b/lib/ia64/setjmp.S @@ -197,3 +197,7 @@ _skip_flushrs: invala mov ar.rsc = r16 br.ret.sptk b0 + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/mips64el/efi_stub.S b/lib/mips64el/efi_stub.S index 464eae5..f84aaf2 100644 --- a/lib/mips64el/efi_stub.S +++ b/lib/mips64el/efi_stub.S @@ -1 +1,5 @@ /* This stub is a stub to make the build happy */ + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/mips64el/setjmp.S b/lib/mips64el/setjmp.S index 930aca4..2b60cdb 100644 --- a/lib/mips64el/setjmp.S +++ b/lib/mips64el/setjmp.S @@ -90,3 +90,7 @@ longjmp: li $v0, 1 movn $v0, $a1, $a1 jr $ra + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/riscv64/setjmp.S b/lib/riscv64/setjmp.S index fa187d1..f7928e5 100644 --- a/lib/riscv64/setjmp.S +++ b/lib/riscv64/setjmp.S @@ -67,3 +67,7 @@ longjmp: seqz a0, a1 add a0, a0, a1 ret + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/x86_64/efi_stub.S b/lib/x86_64/efi_stub.S index b431255..617a1dd 100644 --- a/lib/x86_64/efi_stub.S +++ b/lib/x86_64/efi_stub.S @@ -187,3 +187,7 @@ ENTRY(efi_call10) ret #endif + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/lib/x86_64/setjmp.S b/lib/x86_64/setjmp.S index e870aef..54efa67 100644 --- a/lib/x86_64/setjmp.S +++ b/lib/x86_64/setjmp.S @@ -39,3 +39,7 @@ longjmp: cmp %rax,%rdx cmove %rcx,%rax jmp *0x38(%rdi) + +#if defined(__ELF__) && defined(__linux__) + .section .note.GNU-stack,"",%progbits +#endif