aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel2016-03-15 16:58:19 -0500
committerLinus Torvalds2016-03-15 18:55:16 -0500
commit2213e9a66bb87d8344a1256b4ef568220d9587fb (patch)
tree0729c7a1170f86b2f830024f12bf6a785f3b3e9e /init/Kconfig
parent8c996940b3be9c3ac40ce558c270817e1722a95b (diff)
downloadkernel-2213e9a66bb87d8344a1256b4ef568220d9587fb.tar.gz
kernel-2213e9a66bb87d8344a1256b4ef568220d9587fb.tar.xz
kernel-2213e9a66bb87d8344a1256b4ef568220d9587fb.zip
kallsyms: add support for relative offsets in kallsyms address table
Similar to how relative extables are implemented, it is possible to emit the kallsyms table in such a way that it contains offsets relative to some anchor point in the kernel image rather than absolute addresses. On 64-bit architectures, it cuts the size of the kallsyms address table in half, since offsets between kernel symbols can typically be expressed in 32 bits. This saves several hundreds of kilobytes of permanent .rodata on average. In addition, the kallsyms address table is no longer subject to dynamic relocation when CONFIG_RELOCATABLE is in effect, so the relocation work done after decompression now doesn't have to do relocation updates for all these values. This saves up to 24 bytes (i.e., the size of a ELF64 RELA relocation table entry) per value, which easily adds up to a couple of megabytes of uncompressed __init data on ppc64 or arm64. Even if these relocation entries typically compress well, the combined size reduction of 2.8 MB uncompressed for a ppc64_defconfig build (of which 2.4 MB is __init data) results in a ~500 KB space saving in the compressed image. Since it is useful for some architectures (like x86) to retain the ability to emit absolute values as well, this patch also adds support for capturing both absolute and relative values when KALLSYMS_ABSOLUTE_PERCPU is in effect, by emitting absolute per-cpu addresses as positive 32-bit values, and addresses relative to the lowest encountered relative symbol as negative values, which are subtracted from the runtime address of this base symbol to produce the actual address. Support for the above is enabled by default for all architectures except IA-64 and Tile-GX, whose symbols are too far apart to capture in this manner. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Kees Cook <keescook@chromium.org> Tested-by: Kees Cook <keescook@chromium.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Ingo Molnar <mingo@kernel.org> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Michal Marek <mmarek@suse.cz> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/Kconfig')
-rw-r--r--init/Kconfig18
1 files changed, 18 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig
index b17824a875fa..fd664b3ab99e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1424,6 +1424,24 @@ config KALLSYMS_ABSOLUTE_PERCPU
1424 bool 1424 bool
1425 default X86_64 && SMP 1425 default X86_64 && SMP
1426 1426
1427config KALLSYMS_BASE_RELATIVE
1428 bool
1429 depends on KALLSYMS
1430 default !IA64 && !(TILE && 64BIT)
1431 help
1432 Instead of emitting them as absolute values in the native word size,
1433 emit the symbol references in the kallsyms table as 32-bit entries,
1434 each containing a relative value in the range [base, base + U32_MAX]
1435 or, when KALLSYMS_ABSOLUTE_PERCPU is in effect, each containing either
1436 an absolute value in the range [0, S32_MAX] or a relative value in the
1437 range [base, base + S32_MAX], where base is the lowest relative symbol
1438 address encountered in the image.
1439
1440 On 64-bit builds, this reduces the size of the address table by 50%,
1441 but more importantly, it results in entries whose values are build
1442 time constants, and no relocation pass is required at runtime to fix
1443 up the entries based on the runtime load address of the kernel.
1444
1427config PRINTK 1445config PRINTK
1428 default y 1446 default y
1429 bool "Enable support for printk" if EXPERT 1447 bool "Enable support for printk" if EXPERT