Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Make most arch asm/module.h files use asm-generic/module.h

Use the mapping of Elf_[SPE]hdr, Elf_Addr, Elf_Sym, Elf_Dyn, Elf_Rel/Rela,
ELF_R_TYPE() and ELF_R_SYM() to either the 32-bit version or the 64-bit version
into asm-generic/module.h for all arches bar MIPS.

Also, use the generic definition mod_arch_specific where possible.

To this end, I've defined three new config bools:

(*) HAVE_MOD_ARCH_SPECIFIC

Arches define this if they don't want to use the empty generic
mod_arch_specific struct.

(*) MODULES_USE_ELF_RELA

Arches define this if their modules can contain RELA records. This causes
the Elf_Rela mapping to be emitted and allows apply_relocate_add() to be
defined by the arch rather than have the core emit an error message.

(*) MODULES_USE_ELF_REL

Arches define this if their modules can contain REL records. This causes
the Elf_Rel mapping to be emitted and allows apply_relocate() to be
defined by the arch rather than have the core emit an error message.

Note that it is possible to allow both REL and RELA records: m68k and mips are
two arches that do this.

With this, some arch asm/module.h files can be deleted entirely and replaced
with a generic-y marker in the arch Kbuild file.

Additionally, I have removed the bits from m32r and score that handle the
unsupported type of relocation record as that's now handled centrally.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

David Howells and committed by
Rusty Russell
786d35d4 6ede8123

+168 -224
+19
arch/Kconfig
··· 281 281 282 282 See Documentation/prctl/seccomp_filter.txt for details. 283 283 284 + config HAVE_MOD_ARCH_SPECIFIC 285 + bool 286 + help 287 + The arch uses struct mod_arch_specific to store data. Many arches 288 + just need a simple module loader without arch specific data - those 289 + should not enable this. 290 + 291 + config MODULES_USE_ELF_RELA 292 + bool 293 + help 294 + Modules only use ELF RELA relocations. Modules with ELF REL 295 + relocations will give an error. 296 + 297 + config MODULES_USE_ELF_REL 298 + bool 299 + help 300 + Modules only use ELF REL relocations. Modules with ELF RELA 301 + relocations will give an error. 302 + 284 303 source "kernel/gcov/Kconfig"
+2
arch/alpha/Kconfig
··· 20 20 select GENERIC_CMOS_UPDATE 21 21 select GENERIC_STRNCPY_FROM_USER 22 22 select GENERIC_STRNLEN_USER 23 + select HAVE_MOD_ARCH_SPECIFIC 24 + select MODULES_USE_ELF_RELA 23 25 help 24 26 The Alpha is a 64-bit general-purpose processor designed and 25 27 marketed by the Digital Equipment Corporation of blessed memory,
+2 -8
arch/alpha/include/asm/module.h
··· 1 1 #ifndef _ALPHA_MODULE_H 2 2 #define _ALPHA_MODULE_H 3 3 4 + #include <asm-generic/module.h> 5 + 4 6 struct mod_arch_specific 5 7 { 6 8 unsigned int gotsecindex; 7 9 }; 8 - 9 - #define Elf_Sym Elf64_Sym 10 - #define Elf_Shdr Elf64_Shdr 11 - #define Elf_Ehdr Elf64_Ehdr 12 - #define Elf_Phdr Elf64_Phdr 13 - #define Elf_Dyn Elf64_Dyn 14 - #define Elf_Rel Elf64_Rel 15 - #define Elf_Rela Elf64_Rela 16 10 17 11 #define ARCH_SHF_SMALL SHF_ALPHA_GPREL 18 12
+2
arch/arm/Kconfig
··· 49 49 select GENERIC_STRNCPY_FROM_USER 50 50 select GENERIC_STRNLEN_USER 51 51 select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN 52 + select HAVE_MOD_ARCH_SPECIFIC if ARM_UNWIND 53 + select MODULES_USE_ELF_REL 52 54 help 53 55 The ARM series is a line of low-power-consumption RISC chip designs 54 56 licensed by ARM Ltd and targeted at embedded applications and
+2 -6
arch/arm/include/asm/module.h
··· 1 1 #ifndef _ASM_ARM_MODULE_H 2 2 #define _ASM_ARM_MODULE_H 3 3 4 - #define Elf_Shdr Elf32_Shdr 5 - #define Elf_Sym Elf32_Sym 6 - #define Elf_Ehdr Elf32_Ehdr 4 + #include <asm-generic/module.h> 7 5 8 6 struct unwind_table; 9 7 ··· 14 16 ARM_SEC_DEVEXIT, 15 17 ARM_SEC_MAX, 16 18 }; 17 - #endif 18 19 19 20 struct mod_arch_specific { 20 - #ifdef CONFIG_ARM_UNWIND 21 21 struct unwind_table *unwind[ARM_SEC_MAX]; 22 - #endif 23 22 }; 23 + #endif 24 24 25 25 /* 26 26 * Add the ARM architecture version to the version magic string
+2
arch/avr32/Kconfig
··· 15 15 select ARCH_WANT_IPC_PARSE_VERSION 16 16 select ARCH_HAVE_NMI_SAFE_CMPXCHG 17 17 select GENERIC_CLOCKEVENTS 18 + select HAVE_MOD_ARCH_SPECIFIC 19 + select MODULES_USE_ELF_RELA 18 20 help 19 21 AVR32 is a high-performance 32-bit RISC microprocessor core, 20 22 designed for cost-sensitive embedded applications, with particular
+2 -4
arch/avr32/include/asm/module.h
··· 1 1 #ifndef __ASM_AVR32_MODULE_H 2 2 #define __ASM_AVR32_MODULE_H 3 3 4 + #include <asm-generic/module.h> 5 + 4 6 struct mod_arch_syminfo { 5 7 unsigned long got_offset; 6 8 int got_initialized; ··· 18 16 /* Additional symbol information (got offsets). */ 19 17 struct mod_arch_syminfo *syminfo; 20 18 }; 21 - 22 - #define Elf_Shdr Elf32_Shdr 23 - #define Elf_Sym Elf32_Sym 24 - #define Elf_Ehdr Elf32_Ehdr 25 19 26 20 #define MODULE_PROC_FAMILY "AVR32v1" 27 21
+2
arch/blackfin/Kconfig
··· 42 42 select HAVE_NMI_WATCHDOG if NMI_WATCHDOG 43 43 select GENERIC_SMP_IDLE_THREAD 44 44 select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS 45 + select HAVE_MOD_ARCH_SPECIFIC 46 + select MODULES_USE_ELF_RELA 45 47 46 48 config GENERIC_CSUM 47 49 def_bool y
+1 -3
arch/blackfin/include/asm/module.h
··· 7 7 #ifndef _ASM_BFIN_MODULE_H 8 8 #define _ASM_BFIN_MODULE_H 9 9 10 - #define Elf_Shdr Elf32_Shdr 11 - #define Elf_Sym Elf32_Sym 12 - #define Elf_Ehdr Elf32_Ehdr 10 + #include <asm-generic/module.h> 13 11 14 12 struct mod_arch_specific { 15 13 Elf_Shdr *text_l1;
+1
arch/c6x/Kconfig
··· 17 17 select OF 18 18 select OF_EARLY_FLATTREE 19 19 select GENERIC_CLOCKEVENTS 20 + select MODULES_USE_ELF_RELA 20 21 21 22 config MMU 22 23 def_bool n
+1 -11
arch/c6x/include/asm/module.h
··· 13 13 #ifndef _ASM_C6X_MODULE_H 14 14 #define _ASM_C6X_MODULE_H 15 15 16 - #define Elf_Shdr Elf32_Shdr 17 - #define Elf_Sym Elf32_Sym 18 - #define Elf_Ehdr Elf32_Ehdr 19 - #define Elf_Addr Elf32_Addr 20 - #define Elf_Word Elf32_Word 21 - 22 - /* 23 - * This file contains the C6x architecture specific module code. 24 - */ 25 - struct mod_arch_specific { 26 - }; 16 + #include <asm-generic/module.h> 27 17 28 18 struct loaded_sections { 29 19 unsigned int new_vaddr;
+1
arch/cris/Kconfig
··· 47 47 select GENERIC_IOMAP 48 48 select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32 49 49 select GENERIC_CMOS_UPDATE 50 + select MODULES_USE_ELF_RELA 50 51 51 52 config HZ 52 53 int
+2
arch/cris/include/asm/Kbuild
··· 7 7 header-y += etraxgpio.h 8 8 header-y += rs485.h 9 9 header-y += sync_serial.h 10 + 11 + generic-y += module.h
-9
arch/cris/include/asm/module.h
··· 1 - #ifndef _ASM_CRIS_MODULE_H 2 - #define _ASM_CRIS_MODULE_H 3 - /* cris is simple */ 4 - struct mod_arch_specific { }; 5 - 6 - #define Elf_Shdr Elf32_Shdr 7 - #define Elf_Sym Elf32_Sym 8 - #define Elf_Ehdr Elf32_Ehdr 9 - #endif /* _ASM_CRIS_MODULE_H */
+1 -7
arch/frv/include/asm/module.h
··· 11 11 #ifndef _ASM_MODULE_H 12 12 #define _ASM_MODULE_H 13 13 14 - struct mod_arch_specific 15 - { 16 - }; 17 - 18 - #define Elf_Shdr Elf32_Shdr 19 - #define Elf_Sym Elf32_Sym 20 - #define Elf_Ehdr Elf32_Ehdr 14 + #include <asm-generic/module.h> 21 15 22 16 /* 23 17 * Include the architecture version.
+1
arch/h8300/Kconfig
··· 6 6 select ARCH_WANT_IPC_PARSE_VERSION 7 7 select GENERIC_IRQ_SHOW 8 8 select GENERIC_CPU_DEVICES 9 + select MODULES_USE_ELF_RELA 9 10 10 11 config SYMBOL_PREFIX 11 12 string
+2
arch/h8300/include/asm/Kbuild
··· 1 1 include include/asm-generic/Kbuild.asm 2 + 3 + generic-y += module.h
-11
arch/h8300/include/asm/module.h
··· 1 - #ifndef _ASM_H8300_MODULE_H 2 - #define _ASM_H8300_MODULE_H 3 - /* 4 - * This file contains the H8/300 architecture specific module code. 5 - */ 6 - struct mod_arch_specific { }; 7 - #define Elf_Shdr Elf32_Shdr 8 - #define Elf_Sym Elf32_Sym 9 - #define Elf_Ehdr Elf32_Ehdr 10 - 11 - #endif /* _ASM_H8/300_MODULE_H */
+1
arch/hexagon/Kconfig
··· 30 30 select KTIME_SCALAR 31 31 select GENERIC_CLOCKEVENTS 32 32 select GENERIC_CLOCKEVENTS_BROADCAST 33 + select MODULES_USE_ELF_RELA 33 34 ---help--- 34 35 Qualcomm Hexagon is a processor architecture designed for high 35 36 performance and low power across a wide variety of applications.
+2
arch/ia64/Kconfig
··· 39 39 select ARCH_THREAD_INFO_ALLOCATOR 40 40 select ARCH_CLOCKSOURCE_DATA 41 41 select GENERIC_TIME_VSYSCALL 42 + select HAVE_MOD_ARCH_SPECIFIC 43 + select MODULES_USE_ELF_RELA 42 44 default y 43 45 help 44 46 The Itanium Processor Family is Intel's 64-bit successor to
+2 -4
arch/ia64/include/asm/module.h
··· 1 1 #ifndef _ASM_IA64_MODULE_H 2 2 #define _ASM_IA64_MODULE_H 3 3 4 + #include <asm-generic/module.h> 5 + 4 6 /* 5 7 * IA-64-specific support for kernel module loader. 6 8 * ··· 30 28 void *init_unw_table; /* init unwind-table cookie returned by unwinder */ 31 29 unsigned int next_got_entry; /* index of next available got entry */ 32 30 }; 33 - 34 - #define Elf_Shdr Elf64_Shdr 35 - #define Elf_Sym Elf64_Sym 36 - #define Elf_Ehdr Elf64_Ehdr 37 31 38 32 #define MODULE_PROC_FAMILY "ia64" 39 33 #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY \
+1
arch/m32r/Kconfig
··· 13 13 select GENERIC_IRQ_SHOW 14 14 select GENERIC_ATOMIC64 15 15 select ARCH_USES_GETTIMEOFFSET 16 + select MODULES_USE_ELF_RELA 16 17 17 18 config SBUS 18 19 bool
+2
arch/m32r/include/asm/Kbuild
··· 1 1 include include/asm-generic/Kbuild.asm 2 + 3 + generic-y += module.h
-10
arch/m32r/include/asm/module.h
··· 1 - #ifndef _ASM_M32R_MODULE_H 2 - #define _ASM_M32R_MODULE_H 3 - 4 - struct mod_arch_specific { }; 5 - 6 - #define Elf_Shdr Elf32_Shdr 7 - #define Elf_Sym Elf32_Sym 8 - #define Elf_Ehdr Elf32_Ehdr 9 - 10 - #endif /* _ASM_M32R_MODULE_H */
-15
arch/m32r/kernel/module.c
··· 201 201 } 202 202 return 0; 203 203 } 204 - 205 - int apply_relocate(Elf32_Shdr *sechdrs, 206 - const char *strtab, 207 - unsigned int symindex, 208 - unsigned int relsec, 209 - struct module *me) 210 - { 211 - #if 0 212 - printk(KERN_ERR "module %s: REL RELOCATION unsupported\n", 213 - me->name); 214 - return -ENOEXEC; 215 - #endif 216 - return 0; 217 - 218 - }
+3
arch/m68k/Kconfig
··· 13 13 select FPU if MMU 14 14 select ARCH_WANT_IPC_PARSE_VERSION 15 15 select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE 16 + select HAVE_MOD_ARCH_SPECIFIC 17 + select MODULES_USE_ELF_REL 18 + select MODULES_USE_ELF_RELA 16 19 17 20 config RWSEM_GENERIC_SPINLOCK 18 21 bool
+2 -4
arch/m68k/include/asm/module.h
··· 1 1 #ifndef _ASM_M68K_MODULE_H 2 2 #define _ASM_M68K_MODULE_H 3 3 4 + #include <asm-generic/module.h> 5 + 4 6 enum m68k_fixup_type { 5 7 m68k_fixup_memoffset, 6 8 m68k_fixup_vnode_shift, ··· 37 35 struct module; 38 36 extern void module_fixup(struct module *mod, struct m68k_fixup_info *start, 39 37 struct m68k_fixup_info *end); 40 - 41 - #define Elf_Shdr Elf32_Shdr 42 - #define Elf_Sym Elf32_Sym 43 - #define Elf_Ehdr Elf32_Ehdr 44 38 45 39 #endif /* _ASM_M68K_MODULE_H */
+1
arch/microblaze/Kconfig
··· 24 24 select GENERIC_CPU_DEVICES 25 25 select GENERIC_ATOMIC64 26 26 select GENERIC_CLOCKEVENTS 27 + select MODULES_USE_ELF_RELA 27 28 28 29 config SWAP 29 30 def_bool n
+3
arch/mips/Kconfig
··· 36 36 select BUILDTIME_EXTABLE_SORT 37 37 select GENERIC_CLOCKEVENTS 38 38 select GENERIC_CMOS_UPDATE 39 + select HAVE_MOD_ARCH_SPECIFIC 40 + select MODULES_USE_ELF_REL 41 + select MODULES_USE_ELF_RELA if 64BIT 39 42 40 43 menu "Machine selection" 41 44
+8 -2
arch/mips/include/asm/module.h
··· 35 35 } Elf64_Mips_Rela; 36 36 37 37 #ifdef CONFIG_32BIT 38 - 39 38 #define Elf_Shdr Elf32_Shdr 40 39 #define Elf_Sym Elf32_Sym 41 40 #define Elf_Ehdr Elf32_Ehdr 42 41 #define Elf_Addr Elf32_Addr 42 + #define Elf_Rel Elf32_Rel 43 + #define Elf_Rela Elf32_Rela 44 + #define ELF_R_TYPE(X) ELF32_R_TYPE(X) 45 + #define ELF_R_SYM(X) ELF32_R_SYM(X) 43 46 44 47 #define Elf_Mips_Rel Elf32_Rel 45 48 #define Elf_Mips_Rela Elf32_Rela ··· 53 50 #endif 54 51 55 52 #ifdef CONFIG_64BIT 56 - 57 53 #define Elf_Shdr Elf64_Shdr 58 54 #define Elf_Sym Elf64_Sym 59 55 #define Elf_Ehdr Elf64_Ehdr 60 56 #define Elf_Addr Elf64_Addr 57 + #define Elf_Rel Elf64_Rel 58 + #define Elf_Rela Elf64_Rela 59 + #define ELF_R_TYPE(X) ELF64_R_TYPE(X) 60 + #define ELF_R_SYM(X) ELF64_R_SYM(X) 61 61 62 62 #define Elf_Mips_Rel Elf64_Mips_Rel 63 63 #define Elf_Mips_Rela Elf64_Mips_Rela
+1 -1
arch/mips/kernel/Makefile
··· 31 31 32 32 obj-$(CONFIG_STACKTRACE) += stacktrace.o 33 33 obj-$(CONFIG_MODULES) += mips_ksyms.o module.o 34 - obj-$(CONFIG_MODULES) += module-rela.o 34 + obj-$(CONFIG_MODULES_USE_ELF_RELA) += module-rela.o 35 35 36 36 obj-$(CONFIG_FUNCTION_TRACER) += mcount.o ftrace.o 37 37
+1
arch/mn10300/Kconfig
··· 8 8 select HAVE_ARCH_KGDB 9 9 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER 10 10 select GENERIC_CLOCKEVENTS 11 + select MODULES_USE_ELF_RELA 11 12 12 13 config AM33_2 13 14 def_bool n
+1 -6
arch/mn10300/include/asm/module.h
··· 12 12 #ifndef _ASM_MODULE_H 13 13 #define _ASM_MODULE_H 14 14 15 - struct mod_arch_specific { 16 - }; 17 - 18 - #define Elf_Shdr Elf32_Shdr 19 - #define Elf_Sym Elf32_Sym 20 - #define Elf_Ehdr Elf32_Ehdr 15 + #include <asm-generic/module.h> 21 16 22 17 /* 23 18 * Include the MN10300 architecture version.
+1
arch/openrisc/Kconfig
··· 21 21 select GENERIC_CLOCKEVENTS 22 22 select GENERIC_STRNCPY_FROM_USER 23 23 select GENERIC_STRNLEN_USER 24 + select MODULES_USE_ELF_RELA 24 25 25 26 config MMU 26 27 def_bool y
+2
arch/parisc/Kconfig
··· 19 19 select ARCH_HAVE_NMI_SAFE_CMPXCHG 20 20 select GENERIC_SMP_IDLE_THREAD 21 21 select GENERIC_STRNCPY_FROM_USER 22 + select HAVE_MOD_ARCH_SPECIFIC 23 + select MODULES_USE_ELF_RELA 22 24 23 25 help 24 26 The PA-RISC microprocessor is designed by Hewlett-Packard and used
+3 -13
arch/parisc/include/asm/module.h
··· 1 1 #ifndef _ASM_PARISC_MODULE_H 2 2 #define _ASM_PARISC_MODULE_H 3 + 4 + #include <asm-generic/module.h> 5 + 3 6 /* 4 7 * This file contains the parisc architecture specific module code. 5 8 */ 6 - #ifdef CONFIG_64BIT 7 - #define Elf_Shdr Elf64_Shdr 8 - #define Elf_Sym Elf64_Sym 9 - #define Elf_Ehdr Elf64_Ehdr 10 - #define Elf_Addr Elf64_Addr 11 - #define Elf_Rela Elf64_Rela 12 - #else 13 - #define Elf_Shdr Elf32_Shdr 14 - #define Elf_Sym Elf32_Sym 15 - #define Elf_Ehdr Elf32_Ehdr 16 - #define Elf_Addr Elf32_Addr 17 - #define Elf_Rela Elf32_Rela 18 - #endif 19 9 20 10 struct unwind_table; 21 11
+2
arch/powerpc/Kconfig
··· 139 139 select GENERIC_CLOCKEVENTS 140 140 select GENERIC_STRNCPY_FROM_USER 141 141 select GENERIC_STRNLEN_USER 142 + select HAVE_MOD_ARCH_SPECIFIC 143 + select MODULES_USE_ELF_RELA 142 144 143 145 config EARLY_PRINTK 144 146 bool
+1 -6
arch/powerpc/include/asm/module.h
··· 11 11 12 12 #include <linux/list.h> 13 13 #include <asm/bug.h> 14 + #include <asm-generic/module.h> 14 15 15 16 16 17 #ifndef __powerpc64__ ··· 61 60 */ 62 61 63 62 #ifdef __powerpc64__ 64 - # define Elf_Shdr Elf64_Shdr 65 - # define Elf_Sym Elf64_Sym 66 - # define Elf_Ehdr Elf64_Ehdr 67 63 # ifdef MODULE 68 64 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous"); 69 65 # endif 70 66 #else 71 - # define Elf_Shdr Elf32_Shdr 72 - # define Elf_Sym Elf32_Sym 73 - # define Elf_Ehdr Elf32_Ehdr 74 67 # ifdef MODULE 75 68 asm(".section .plt,\"ax\",@nobits; .align 3; .previous"); 76 69 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
+2
arch/s390/Kconfig
··· 125 125 select GENERIC_CLOCKEVENTS 126 126 select KTIME_SCALAR if 32BIT 127 127 select HAVE_ARCH_SECCOMP_FILTER 128 + select HAVE_MOD_ARCH_SPECIFIC 129 + select MODULES_USE_ELF_RELA 128 130 129 131 config SCHED_OMIT_FRAME_POINTER 130 132 def_bool y
+3 -15
arch/s390/include/asm/module.h
··· 1 1 #ifndef _ASM_S390_MODULE_H 2 2 #define _ASM_S390_MODULE_H 3 + 4 + #include <asm-generic/module.h> 5 + 3 6 /* 4 7 * This file contains the s390 architecture specific module code. 5 8 */ ··· 31 28 struct mod_arch_syminfo *syminfo; 32 29 }; 33 30 34 - #ifdef CONFIG_64BIT 35 - #define ElfW(x) Elf64_ ## x 36 - #define ELFW(x) ELF64_ ## x 37 - #else 38 - #define ElfW(x) Elf32_ ## x 39 - #define ELFW(x) ELF32_ ## x 40 - #endif 41 - 42 - #define Elf_Addr ElfW(Addr) 43 - #define Elf_Rela ElfW(Rela) 44 - #define Elf_Shdr ElfW(Shdr) 45 - #define Elf_Sym ElfW(Sym) 46 - #define Elf_Ehdr ElfW(Ehdr) 47 - #define ELF_R_SYM ELFW(R_SYM) 48 - #define ELF_R_TYPE ELFW(R_TYPE) 49 31 #endif /* _ASM_S390_MODULE_H */
+2
arch/score/Kconfig
··· 10 10 select ARCH_DISCARD_MEMBLOCK 11 11 select GENERIC_CPU_DEVICES 12 12 select GENERIC_CLOCKEVENTS 13 + select HAVE_MOD_ARCH_SPECIFIC 14 + select MODULES_USE_ELF_REL 13 15 14 16 choice 15 17 prompt "System type"
+1 -5
arch/score/include/asm/module.h
··· 3 3 4 4 #include <linux/list.h> 5 5 #include <asm/uaccess.h> 6 + #include <asm-generic/module.h> 6 7 7 8 struct mod_arch_specific { 8 9 /* Data Bus Error exception tables */ ··· 13 12 }; 14 13 15 14 typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */ 16 - 17 - #define Elf_Shdr Elf32_Shdr 18 - #define Elf_Sym Elf32_Sym 19 - #define Elf_Ehdr Elf32_Ehdr 20 - #define Elf_Addr Elf32_Addr 21 15 22 16 /* Given an address, look for it in the exception tables. */ 23 17 #ifdef CONFIG_MODULES
-10
arch/score/kernel/module.c
··· 125 125 return 0; 126 126 } 127 127 128 - int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, 129 - unsigned int symindex, unsigned int relsec, 130 - struct module *me) 131 - { 132 - /* Non-standard return value... most other arch's return -ENOEXEC 133 - * for an unsupported relocation variant 134 - */ 135 - return 0; 136 - } 137 - 138 128 /* Given an address, look for it in the module exception tables. */ 139 129 const struct exception_table_entry *search_module_dbetables(unsigned long addr) 140 130 {
+2
arch/sh/Kconfig
··· 35 35 select GENERIC_CMOS_UPDATE if SH_SH03 || SH_DREAMCAST 36 36 select GENERIC_STRNCPY_FROM_USER 37 37 select GENERIC_STRNLEN_USER 38 + select HAVE_MOD_ARCH_SPECIFIC if DWARF_UNWINDER 39 + select MODULES_USE_ELF_RELA 38 40 help 39 41 The SuperH is a RISC processor targeted for use in embedded systems 40 42 and consumer electronics; it was also used in the Sega Dreamcast
+3 -11
arch/sh/include/asm/module.h
··· 1 1 #ifndef _ASM_SH_MODULE_H 2 2 #define _ASM_SH_MODULE_H 3 3 4 - struct mod_arch_specific { 4 + #include <asm-generic/module.h> 5 + 5 6 #ifdef CONFIG_DWARF_UNWINDER 7 + struct mod_arch_specific { 6 8 struct list_head fde_list; 7 9 struct list_head cie_list; 8 - #endif 9 10 }; 10 - 11 - #ifdef CONFIG_64BIT 12 - #define Elf_Shdr Elf64_Shdr 13 - #define Elf_Sym Elf64_Sym 14 - #define Elf_Ehdr Elf64_Ehdr 15 - #else 16 - #define Elf_Shdr Elf32_Shdr 17 - #define Elf_Sym Elf32_Sym 18 - #define Elf_Ehdr Elf32_Ehdr 19 11 #endif 20 12 21 13 #ifdef CONFIG_CPU_LITTLE_ENDIAN
+1
arch/sparc/Kconfig
··· 37 37 select GENERIC_CLOCKEVENTS 38 38 select GENERIC_STRNCPY_FROM_USER 39 39 select GENERIC_STRNLEN_USER 40 + select MODULES_USE_ELF_RELA 40 41 41 42 config SPARC32 42 43 def_bool !64BIT
+1
arch/sparc/include/asm/Kbuild
··· 21 21 generic-y += local64.h 22 22 generic-y += irq_regs.h 23 23 generic-y += local.h 24 + generic-y += module.h 24 25 generic-y += word-at-a-time.h
-24
arch/sparc/include/asm/module.h
··· 1 - #ifndef __SPARC_MODULE_H 2 - #define __SPARC_MODULE_H 3 - struct mod_arch_specific { }; 4 - 5 - /* 6 - * Use some preprocessor magic to define the correct symbol 7 - * for sparc32 and sparc64. 8 - * Elf_Addr becomes Elf32_Addr for sparc32 and Elf64_Addr for sparc64 9 - */ 10 - #define ___ELF(a, b, c) a##b##c 11 - #define __ELF(a, b, c) ___ELF(a, b, c) 12 - #define _Elf(t) __ELF(Elf, CONFIG_BITS, t) 13 - #define _ELF(t) __ELF(ELF, CONFIG_BITS, t) 14 - 15 - #define Elf_Shdr _Elf(_Shdr) 16 - #define Elf_Sym _Elf(_Sym) 17 - #define Elf_Ehdr _Elf(_Ehdr) 18 - #define Elf_Rela _Elf(_Rela) 19 - #define Elf_Addr _Elf(_Addr) 20 - 21 - #define ELF_R_SYM _ELF(_R_SYM) 22 - #define ELF_R_TYPE _ELF(_R_TYPE) 23 - 24 - #endif /* __SPARC_MODULE_H */
+1
arch/tile/Kconfig
··· 17 17 select SYS_HYPERVISOR 18 18 select ARCH_HAVE_NMI_SAFE_CMPXCHG 19 19 select GENERIC_CLOCKEVENTS 20 + select MODULES_USE_ELF_RELA 20 21 21 22 # FIXME: investigate whether we need/want these options. 22 23 # select HAVE_IOREMAP_PROT
+1
arch/unicore32/Kconfig
··· 14 14 select GENERIC_IRQ_SHOW 15 15 select ARCH_WANT_FRAME_POINTERS 16 16 select GENERIC_IOMAP 17 + select MODULES_USE_ELF_REL 17 18 help 18 19 UniCore-32 is 32-bit Instruction Set Architecture, 19 20 including a series of low-power-consumption RISC chip
+2
arch/x86/Kconfig
··· 97 97 select KTIME_SCALAR if X86_32 98 98 select GENERIC_STRNCPY_FROM_USER 99 99 select GENERIC_STRNLEN_USER 100 + select MODULES_USE_ELF_REL if X86_32 101 + select MODULES_USE_ELF_RELA if X86_64 100 102 101 103 config INSTRUCTION_DECODER 102 104 def_bool (KPROBES || PERF_EVENTS || UPROBES)
+2
arch/x86/um/Kconfig
··· 21 21 config X86_32 22 22 def_bool !64BIT 23 23 select HAVE_AOUT 24 + select MODULES_USE_ELF_REL 24 25 25 26 config X86_64 26 27 def_bool 64BIT 28 + select MODULES_USE_ELF_RELA 27 29 28 30 config RWSEM_XCHGADD_ALGORITHM 29 31 def_bool X86_XADD && 64BIT
+1
arch/xtensa/Kconfig
··· 11 11 select HAVE_GENERIC_HARDIRQS 12 12 select GENERIC_IRQ_SHOW 13 13 select GENERIC_CPU_DEVICES 14 + select MODULES_USE_ELF_RELA 14 15 help 15 16 Xtensa processors are 32-bit RISC machines designed by Tensilica 16 17 primarily for embedded systems. These processors are both
+1 -8
arch/xtensa/include/asm/module.h
··· 13 13 #ifndef _XTENSA_MODULE_H 14 14 #define _XTENSA_MODULE_H 15 15 16 - struct mod_arch_specific 17 - { 18 - /* No special elements, yet. */ 19 - }; 20 - 21 16 #define MODULE_ARCH_VERMAGIC "xtensa-" __stringify(XCHAL_CORE_ID) " " 22 17 23 - #define Elf_Shdr Elf32_Shdr 24 - #define Elf_Sym Elf32_Sym 25 - #define Elf_Ehdr Elf32_Ehdr 18 + #include <asm-generic/module.h> 26 19 27 20 #endif /* _XTENSA_MODULE_H */
+33 -7
include/asm-generic/module.h
··· 5 5 * Many architectures just need a simple module 6 6 * loader without arch specific data. 7 7 */ 8 + #ifndef CONFIG_HAVE_MOD_ARCH_SPECIFIC 8 9 struct mod_arch_specific 9 10 { 10 11 }; 12 + #endif 11 13 12 14 #ifdef CONFIG_64BIT 13 - #define Elf_Shdr Elf64_Shdr 14 - #define Elf_Sym Elf64_Sym 15 - #define Elf_Ehdr Elf64_Ehdr 16 - #else 17 - #define Elf_Shdr Elf32_Shdr 18 - #define Elf_Sym Elf32_Sym 19 - #define Elf_Ehdr Elf32_Ehdr 15 + #define Elf_Shdr Elf64_Shdr 16 + #define Elf_Phdr Elf64_Phdr 17 + #define Elf_Sym Elf64_Sym 18 + #define Elf_Dyn Elf64_Dyn 19 + #define Elf_Ehdr Elf64_Ehdr 20 + #define Elf_Addr Elf64_Addr 21 + #ifdef CONFIG_MODULES_USE_ELF_REL 22 + #define Elf_Rel Elf64_Rel 23 + #endif 24 + #ifdef CONFIG_MODULES_USE_ELF_RELA 25 + #define Elf_Rela Elf64_Rela 26 + #endif 27 + #define ELF_R_TYPE(X) ELF64_R_TYPE(X) 28 + #define ELF_R_SYM(X) ELF64_R_SYM(X) 29 + 30 + #else /* CONFIG_64BIT */ 31 + 32 + #define Elf_Shdr Elf32_Shdr 33 + #define Elf_Phdr Elf32_Phdr 34 + #define Elf_Sym Elf32_Sym 35 + #define Elf_Dyn Elf32_Dyn 36 + #define Elf_Ehdr Elf32_Ehdr 37 + #define Elf_Addr Elf32_Addr 38 + #ifdef CONFIG_MODULES_USE_ELF_REL 39 + #define Elf_Rel Elf32_Rel 40 + #endif 41 + #ifdef CONFIG_MODULES_USE_ELF_RELA 42 + #define Elf_Rela Elf32_Rela 43 + #endif 44 + #define ELF_R_TYPE(X) ELF32_R_TYPE(X) 45 + #define ELF_R_SYM(X) ELF32_R_SYM(X) 20 46 #endif 21 47 22 48 #endif /* __ASM_GENERIC_MODULE_H */
+32 -4
include/linux/moduleloader.h
··· 28 28 /* Free memory returned from module_alloc. */ 29 29 void module_free(struct module *mod, void *module_region); 30 30 31 - /* Apply the given relocation to the (simplified) ELF. Return -error 32 - or 0. */ 31 + /* 32 + * Apply the given relocation to the (simplified) ELF. Return -error 33 + * or 0. 34 + */ 35 + #ifdef CONFIG_MODULES_USE_ELF_REL 33 36 int apply_relocate(Elf_Shdr *sechdrs, 34 37 const char *strtab, 35 38 unsigned int symindex, 36 39 unsigned int relsec, 37 40 struct module *mod); 41 + #else 42 + static inline int apply_relocate(Elf_Shdr *sechdrs, 43 + const char *strtab, 44 + unsigned int symindex, 45 + unsigned int relsec, 46 + struct module *me) 47 + { 48 + printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name); 49 + return -ENOEXEC; 50 + } 51 + #endif 38 52 39 - /* Apply the given add relocation to the (simplified) ELF. Return 40 - -error or 0 */ 53 + /* 54 + * Apply the given add relocation to the (simplified) ELF. Return 55 + * -error or 0 56 + */ 57 + #ifdef CONFIG_MODULES_USE_ELF_RELA 41 58 int apply_relocate_add(Elf_Shdr *sechdrs, 42 59 const char *strtab, 43 60 unsigned int symindex, 44 61 unsigned int relsec, 45 62 struct module *mod); 63 + #else 64 + static inline int apply_relocate_add(Elf_Shdr *sechdrs, 65 + const char *strtab, 66 + unsigned int symindex, 67 + unsigned int relsec, 68 + struct module *me) 69 + { 70 + printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name); 71 + return -ENOEXEC; 72 + } 73 + #endif 46 74 47 75 /* Any final processing of module before access. Return -error or 0. */ 48 76 int module_finalize(const Elf_Ehdr *hdr,
-20
kernel/module.c
··· 1949 1949 return ret; 1950 1950 } 1951 1951 1952 - int __weak apply_relocate(Elf_Shdr *sechdrs, 1953 - const char *strtab, 1954 - unsigned int symindex, 1955 - unsigned int relsec, 1956 - struct module *me) 1957 - { 1958 - pr_err("module %s: REL relocation unsupported\n", me->name); 1959 - return -ENOEXEC; 1960 - } 1961 - 1962 - int __weak apply_relocate_add(Elf_Shdr *sechdrs, 1963 - const char *strtab, 1964 - unsigned int symindex, 1965 - unsigned int relsec, 1966 - struct module *me) 1967 - { 1968 - pr_err("module %s: RELA relocation unsupported\n", me->name); 1969 - return -ENOEXEC; 1970 - } 1971 - 1972 1952 static int apply_relocations(struct module *mod, const struct load_info *info) 1973 1953 { 1974 1954 unsigned int i;