From: Kristen Carlson Accardi Date: Wed, 13 Oct 2021 17:57:42 +0000 (-0700) Subject: vmlinux.lds.h: Have ORC lookup cover entire _etext - _stext X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ca136cac37eb51649d52d5bc4271c55e30ed354c;p=linux.git 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 [ alobakin: move it to vmlinux.lds.h and make arch-indep ] Signed-off-by: Alexander Lobakin Signed-off-by: Kees Cook Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Tony Luck Reviewed-by: Kees Cook Acked-by: Josh Poimboeuf Tested-by: Tony Luck Link: https://lore.kernel.org/r/20211013175742.1197608-5-keescook@chromium.org --- diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index f2984af2b85bd..e8234911dc18b 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -869,10 +869,11 @@ KEEP(*(.orc_unwind)) \ __stop_orc_unwind = .; \ } \ + text_size = _etext - _stext; \ . = ALIGN(4); \ .orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \ orc_lookup = .; \ - . += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) / \ + . += (((text_size + LOOKUP_BLOCK_SIZE - 1) / \ LOOKUP_BLOCK_SIZE) + 1) * 4; \ orc_lookup_end = .; \ }