Skip to content

Commit 0c918e7

Browse files
keesingomolnar
authored andcommitted
arm/build: Assert for unwanted sections
In preparation for warning on orphan sections, enforce 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> Cc: Russell King <linux@armlinux.org.uk> Link: https://lore.kernel.org/r/20200821194310.3089815-19-keescook@chromium.org
1 parent 512dd2e commit 0c918e7

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

arch/arm/include/asm/vmlinux.lds.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@
5252
ARM_MMU_DISCARD(*(__ex_table)) \
5353
COMMON_DISCARDS
5454

55+
/*
56+
* Sections that should stay zero sized, which is safer to explicitly
57+
* check instead of blindly discarding.
58+
*/
59+
#define ARM_ASSERTS \
60+
.plt : { \
61+
*(.iplt) *(.rel.iplt) *(.iplt) *(.igot.plt) \
62+
} \
63+
ASSERT(SIZEOF(.plt) == 0, \
64+
"Unexpected run-time procedure linkages detected!")
65+
5566
#define ARM_DETAILS \
5667
ELF_DETAILS \
5768
.ARM.attributes 0 : { *(.ARM.attributes) }

arch/arm/kernel/vmlinux-xip.lds.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ SECTIONS
152152
STABS_DEBUG
153153
DWARF_DEBUG
154154
ARM_DETAILS
155+
156+
ARM_ASSERTS
155157
}
156158

157159
/*

arch/arm/kernel/vmlinux.lds.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ SECTIONS
151151
STABS_DEBUG
152152
DWARF_DEBUG
153153
ARM_DETAILS
154+
155+
ARM_ASSERTS
154156
}
155157

156158
#ifdef CONFIG_STRICT_KERNEL_RWX

0 commit comments

Comments
 (0)