ld.bfd: warning: /usr/lib64/crt0-efi-x86_64.o: missing .note.GNU-stack...
Brought to you by:
noxorc
Since the recent changes in binutils, I noticed the following linker warning:
[ 69s] /usr/bin/cc -o src/boot/efi/systemd_boot.so -fuse-ld=bfd -L /usr/lib64 -nostdlib -T /usr/lib64/elf_x86_64_efi.lds -Wl,--build-id=sha1 -Wl,--fatal-warnings -Wl,--no-undefined -Wl,--warn-common -Wl,-Bsymbolic -z nocombreloc /usr/lib64/crt0-efi-x86_64.o -pie -Wl,--no-dynamic-linker -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -fno-stack-protector -fno-strict-aliasing -fpic -fwide-exec-charset=UCS2 -Wall -Wextra -Wsign-compare -nostdlib -std=gnu99 -ffreestanding -fshort-wchar -fvisibility=hidden -isystem /usr/include/efi -isystem /usr/include/efi/x86_64 -I /home/abuild/rpmbuild/BUILD/systemd-v250.4+suse.54.g736db5a59f/src/fundamental -DSD_BOOT -DGNU_EFI_USE_MS_ABI -include src/boot/efi/efi_config.h -include version.h -mno-red-zone -mno-sse -mno-mmx -O3 -flto=auto src/boot/efi/bootspec-fundamental.c.o src/boot/efi/efivars-fundamental.c.o src/boot/efi/sha256.c.o src/boot/efi/string-util-fundamental.c.o src/boot/efi/assert.c.o src/boot/efi/devicetree.c.o src/boot/efi/disk.c.o src/boot/efi/graphics.c.o src/boot/efi/measure.c.o src/boot/efi/pe.c.o src/boot/efi/secure-boot.c.o src/boot/efi/util.c.o src/boot/efi/boot.c.o src/boot/efi/console.c.o src/boot/efi/drivers.c.o src/boot/efi/random-seed.c.o src/boot/efi/shim.c.o src/boot/efi/xbootldr.c.o src/boot/efi/bcd.c.o -lefi -lgnuefi -lgcc
[ 69s] /usr/bin/ld.bfd: warning: /usr/lib64/crt0-efi-x86_64.o: missing .note.GNU-stack section implies executable stack
[ 69s] /usr/bin/ld.bfd: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
It's caused by
./gnuefi/crt0-efi-mips64el.S
./gnuefi/crt0-efi-aarch64.S
./gnuefi/crt0-efi-riscv64.S
./gnuefi/crt0-efi-x86_64.S
./gnuefi/crt0-efi-arm.S
./gnuefi/crt0-efi-ia64.S
./gnuefi/crt0-efi-ia32.S
files that does not contain .note.GNU-stack section. Please fix that as I guess you don't need an executable stack.
FWIW, I've just submitted patch for this to the list: https://sourceforge.net/p/gnu-efi/mailman/message/37684742/
https://lore.kernel.org/lkml/CAMj1kXHvf8vWTL=6HzQGcUMK3Qwd9-s5qKAhJzGuk_cEa=cZkQ@mail.gmail.com/t/
I'm going with Ard comment and not implement this patch request.
"This annotation is pointless in the kernel, as we never load any code
as ELF executables. We only load raw binaries or partially linked
objects, which don't carry this annotation, and we never use an
executable stack anyway.
So instead of adding these annotations, can we please just find a way
to shut up the linker?"