Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_ARM_MODULE_H
3#define _ASM_ARM_MODULE_H
4
5#include <asm-generic/module.h>
6#include <asm/unwind.h>
7
8#ifdef CONFIG_ARM_UNWIND
9#define ELF_SECTION_UNWIND 0x70000001
10#endif
11
12#define PLT_ENT_STRIDE L1_CACHE_BYTES
13#define PLT_ENT_COUNT (PLT_ENT_STRIDE / sizeof(u32))
14#define PLT_ENT_SIZE (sizeof(struct plt_entries) / PLT_ENT_COUNT)
15
16struct plt_entries {
17 u32 ldr[PLT_ENT_COUNT];
18 u32 lit[PLT_ENT_COUNT];
19};
20
21struct mod_plt_sec {
22 struct elf32_shdr *plt;
23 struct plt_entries *plt_ent;
24 int plt_count;
25};
26
27struct mod_arch_specific {
28#ifdef CONFIG_ARM_UNWIND
29 struct list_head unwind_list;
30 struct unwind_table *init_table;
31#endif
32#ifdef CONFIG_ARM_MODULE_PLTS
33 struct mod_plt_sec core;
34 struct mod_plt_sec init;
35#endif
36};
37
38struct module;
39u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val);
40#ifdef CONFIG_ARM_MODULE_PLTS
41bool in_module_plt(unsigned long loc);
42#else
43static inline bool in_module_plt(unsigned long loc) { return false; }
44#endif
45
46#ifdef CONFIG_THUMB2_KERNEL
47#define HAVE_ARCH_KALLSYMS_SYMBOL_VALUE
48static inline unsigned long kallsyms_symbol_value(const Elf_Sym *sym)
49{
50 if (ELF_ST_TYPE(sym->st_info) == STT_FUNC)
51 return sym->st_value & ~1;
52
53 return sym->st_value;
54}
55#endif
56
57#endif /* _ASM_ARM_MODULE_H */
1#ifndef _ASM_ARM_MODULE_H
2#define _ASM_ARM_MODULE_H
3
4#include <asm-generic/module.h>
5
6struct unwind_table;
7
8#ifdef CONFIG_ARM_UNWIND
9enum {
10 ARM_SEC_INIT,
11 ARM_SEC_DEVINIT,
12 ARM_SEC_CORE,
13 ARM_SEC_EXIT,
14 ARM_SEC_DEVEXIT,
15 ARM_SEC_HOT,
16 ARM_SEC_UNLIKELY,
17 ARM_SEC_MAX,
18};
19#endif
20
21struct mod_arch_specific {
22#ifdef CONFIG_ARM_UNWIND
23 struct unwind_table *unwind[ARM_SEC_MAX];
24#endif
25#ifdef CONFIG_ARM_MODULE_PLTS
26 struct elf32_shdr *core_plt;
27 struct elf32_shdr *init_plt;
28 int core_plt_count;
29 int init_plt_count;
30#endif
31};
32
33u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val);
34
35/*
36 * Add the ARM architecture version to the version magic string
37 */
38#define MODULE_ARCH_VERMAGIC_ARMVSN "ARMv" __stringify(__LINUX_ARM_ARCH__) " "
39
40/* Add __virt_to_phys patching state as well */
41#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
42#define MODULE_ARCH_VERMAGIC_P2V "p2v8 "
43#else
44#define MODULE_ARCH_VERMAGIC_P2V ""
45#endif
46
47/* Add instruction set architecture tag to distinguish ARM/Thumb kernels */
48#ifdef CONFIG_THUMB2_KERNEL
49#define MODULE_ARCH_VERMAGIC_ARMTHUMB "thumb2 "
50#else
51#define MODULE_ARCH_VERMAGIC_ARMTHUMB ""
52#endif
53
54#define MODULE_ARCH_VERMAGIC \
55 MODULE_ARCH_VERMAGIC_ARMVSN \
56 MODULE_ARCH_VERMAGIC_ARMTHUMB \
57 MODULE_ARCH_VERMAGIC_P2V
58
59#endif /* _ASM_ARM_MODULE_H */