Skip to content

Commit 003602a

Browse files
nivedita76suryasaimadhu
authored andcommitted
x86/*/Makefile: Use -fno-asynchronous-unwind-tables to suppress .eh_frame sections
While discussing a patch to discard .eh_frame from the compressed vmlinux using the linker script, Fangrui Song pointed out [1] that these sections shouldn't exist in the first place because arch/x86/Makefile uses -fno-asynchronous-unwind-tables. It turns out this is because the Makefiles used to build the compressed kernel redefine KBUILD_CFLAGS, dropping this flag. Add the flag to the Makefile for the compressed kernel, as well as the EFI stub Makefile to fix this. Also add the flag to boot/Makefile and realmode/rm/Makefile so that the kernel's boot code (boot/setup.elf) and realmode trampoline (realmode/rm/realmode.elf) won't be compiled with .eh_frame sections, since their linker scripts also just discard them. [1] https://lore.kernel.org/lkml/[email protected]/ Suggested-by: Fangrui Song <[email protected]> Signed-off-by: Arvind Sankar <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-by: Kees Cook <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 0eea39a commit 003602a

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

arch/x86/boot/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ clean-files += cpustr.h
6868
KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
6969
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
7070
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
71+
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
7172
GCOV_PROFILE := n
7273
UBSAN_SANITIZE := n
7374

arch/x86/boot/compressed/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
3939
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
4040
KBUILD_CFLAGS += -Wno-pointer-sign
4141
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
42+
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
4243

4344
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
4445
GCOV_PROFILE := n

arch/x86/realmode/rm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
7171
KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \
7272
-I$(srctree)/arch/x86/boot
7373
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
74+
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
7475
GCOV_PROFILE := n
7576
UBSAN_SANITIZE := n

drivers/firmware/efi/libstub/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \
1212
-mno-mmx -mno-sse -fshort-wchar \
1313
-Wno-pointer-sign \
1414
$(call cc-disable-warning, address-of-packed-member) \
15-
$(call cc-disable-warning, gnu)
15+
$(call cc-disable-warning, gnu) \
16+
-fno-asynchronous-unwind-tables
1617

1718
# arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly
1819
# disable the stackleak plugin

0 commit comments

Comments
 (0)