Skip to content

Commit be28818

Browse files
keesingomolnar
authored andcommitted
arm64/build: Assert for unwanted sections
In preparation for warning on orphan 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). Suggested-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20200821194310.3089815-14-keescook@chromium.org
1 parent 578d7f0 commit be28818

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

arch/arm64/kernel/vmlinux.lds.S

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ SECTIONS
121121
*(.got) /* Global offset table */
122122
}
123123

124+
/*
125+
* Make sure that the .got.plt is either completely empty or it
126+
* contains only the lazy dispatch entries.
127+
*/
128+
.got.plt : { *(.got.plt) }
129+
ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18,
130+
"Unexpected GOT/PLT entries detected!")
131+
124132
. = ALIGN(SEGMENT_ALIGN);
125133
_etext = .; /* End of text section */
126134

@@ -243,6 +251,18 @@ SECTIONS
243251
ELF_DETAILS
244252

245253
HEAD_SYMBOLS
254+
255+
/*
256+
* Sections that should stay zero sized, which is safer to
257+
* explicitly check instead of blindly discarding.
258+
*/
259+
.plt : {
260+
*(.plt) *(.plt.*) *(.iplt) *(.igot)
261+
}
262+
ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
263+
264+
.data.rel.ro : { *(.data.rel.ro) }
265+
ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
246266
}
247267

248268
#include "image-vars.h"

0 commit comments

Comments
 (0)