Skip to content

Commit d1c0272

Browse files
keesingomolnar
authored andcommitted
x86/boot/compressed: Remove, discard, or assert for unwanted sections
In preparation for warning on orphan sections, stop the linker from generating the .eh_frame* sections, discard unwanted non-zero-sized generated sections, and enforce other expected-to-be-zero-sized sections (since discarding them might hide problems with them suddenly gaining unexpected entries). Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20200821194310.3089815-28-keescook@chromium.org
1 parent 7cf891a commit d1c0272

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

arch/x86/boot/compressed/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ GCOV_PROFILE := n
5050
UBSAN_SANITIZE :=n
5151

5252
KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
53+
KBUILD_LDFLAGS += $(call ld-option,--no-ld-generated-unwind-info)
5354
# Compressed kernel should be built as PIE since it may be loaded at any
5455
# address by the bootloader.
5556
LDFLAGS_vmlinux := -pie $(call ld-option, --no-dynamic-linker)

arch/x86/boot/compressed/vmlinux.lds.S

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ SECTIONS
7272
ELF_DETAILS
7373

7474
DISCARDS
75+
/DISCARD/ : {
76+
*(.dynamic) *(.dynsym) *(.dynstr) *(.dynbss)
77+
*(.hash) *(.gnu.hash)
78+
*(.note.*)
79+
}
7580

7681
.got.plt (INFO) : {
7782
*(.got.plt)
@@ -93,13 +98,18 @@ SECTIONS
9398
}
9499
ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
95100

101+
.plt : {
102+
*(.plt) *(.plt.*)
103+
}
104+
ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
105+
96106
.rel.dyn : {
97-
*(.rel.*)
107+
*(.rel.*) *(.rel_*)
98108
}
99109
ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!")
100110

101111
.rela.dyn : {
102-
*(.rela.*)
112+
*(.rela.*) *(.rela_*)
103113
}
104114
ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!")
105115
}

0 commit comments

Comments
 (0)