Skip to content

Commit 5354e84

Browse files
keesIngo Molnar
authored andcommitted
x86/build: Add asserts for unwanted sections
In preparation for warning on orphan sections, 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-25-keescook@chromium.org
1 parent 815d680 commit 5354e84

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

arch/x86/kernel/vmlinux.lds.S

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,30 @@ SECTIONS
427427
SIZEOF(.got.plt) == 0xc,
428428
#endif
429429
"Unexpected GOT/PLT entries detected!")
430+
431+
/*
432+
* Sections that should stay zero sized, which is safer to
433+
* explicitly check instead of blindly discarding.
434+
*/
435+
.got : {
436+
*(.got) *(.igot.*)
437+
}
438+
ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
439+
440+
.plt : {
441+
*(.plt) *(.plt.*) *(.iplt)
442+
}
443+
ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
444+
445+
.rel.dyn : {
446+
*(.rel.*) *(.rel_*)
447+
}
448+
ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!")
449+
450+
.rela.dyn : {
451+
*(.rela.*) *(.rela_*)
452+
}
453+
ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!")
430454
}
431455

432456
#ifdef CONFIG_X86_32

0 commit comments

Comments
 (0)