[PATCH v9 3/6] module: use relative references for __ksymtab entries

Will Deacon will.deacon at arm.com
Thu Jun 28 01:13:39 AEST 2018


Hi Ard,

On Tue, Jun 26, 2018 at 08:27:58PM +0200, Ard Biesheuvel wrote:
> An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
> entries, each consisting of two 64-bit fields containing absolute
> references, to the symbol itself and to a char array containing
> its name, respectively.

[...]

> diff --git a/include/linux/export.h b/include/linux/export.h
> index ea7df303d68d..ae072bc5aacf 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -18,12 +18,6 @@
>  #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
>  
>  #ifndef __ASSEMBLY__
> -struct kernel_symbol
> -{
> -	unsigned long value;
> -	const char *name;
> -};
> -
>  #ifdef MODULE
>  extern struct module __this_module;
>  #define THIS_MODULE (&__this_module)
> @@ -54,17 +48,47 @@ extern struct module __this_module;
>  #define __CRC_SYMBOL(sym, sec)
>  #endif
>  
> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
> +#include <linux/compiler.h>
> +/*
> + * Emit the ksymtab entry as a pair of relative references: this reduces
> + * the size by half on 64-bit architectures, and eliminates the need for
> + * absolute relocations that require runtime processing on relocatable
> + * kernels.
> + */
> +#define __KSYMTAB_ENTRY(sym, sec)					\
> +	__ADDRESSABLE(sym)						\
> +	asm("	.section \"___ksymtab" sec "+" #sym "\", \"a\"	\n"	\
> +	    "	.balign	8					\n"	\

Can we use KSYM_ALIGN here instead of 8, or do we need the 8-byte alignment
even on 32-bit architectures?

Will


More information about the Linuxppc-dev mailing list