Skip to content

Commit ca136ca

Browse files
kaccardiPeter Zijlstra
authored andcommitted
vmlinux.lds.h: Have ORC lookup cover entire _etext - _stext
When using -ffunction-sections to place each function in its own text section (so it can be randomized at load time in the future FGKASLR series), the linker will place most of the functions into separate .text.* sections. SIZEOF(.text) won't work here for calculating the ORC lookup table size, so the total text size must be calculated to include .text AND all .text.* sections. Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com> [ alobakin: move it to vmlinux.lds.h and make arch-indep ] Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Tested-by: Tony Luck <tony.luck@intel.com> Link: https://lore.kernel.org/r/20211013175742.1197608-5-keescook@chromium.org
1 parent 33f98a9 commit ca136ca

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

include/asm-generic/vmlinux.lds.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,11 @@
869869
KEEP(*(.orc_unwind)) \
870870
__stop_orc_unwind = .; \
871871
} \
872+
text_size = _etext - _stext; \
872873
. = ALIGN(4); \
873874
.orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \
874875
orc_lookup = .; \
875-
. += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) / \
876+
. += (((text_size + LOOKUP_BLOCK_SIZE - 1) / \
876877
LOOKUP_BLOCK_SIZE) + 1) * 4; \
877878
orc_lookup_end = .; \
878879
}

0 commit comments

Comments
 (0)