]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
vmlinux.lds.h: Have ORC lookup cover entire _etext - _stext
authorKristen Carlson Accardi <kristen@linux.intel.com>
Wed, 13 Oct 2021 17:57:42 +0000 (10:57 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 27 Oct 2021 09:07:59 +0000 (11:07 +0200)
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
include/asm-generic/vmlinux.lds.h

index f2984af2b85bd54383453e5f4e96f645db769ef4..e8234911dc18b63bae3517a431bc26577ec2b67e 100644 (file)
                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 = .;                                     \
        }