xref: /openbmc/linux/arch/mips/include/asm/module.h (revision d2f4a190)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_MODULE_H
3 #define _ASM_MODULE_H
4 
5 #include <linux/list.h>
6 #include <linux/elf.h>
7 #include <asm/extable.h>
8 
9 struct mod_arch_specific {
10 	/* Data Bus Error exception tables */
11 	struct list_head dbe_list;
12 	const struct exception_table_entry *dbe_start;
13 	const struct exception_table_entry *dbe_end;
14 	struct mips_hi16 *r_mips_hi16_list;
15 };
16 
17 typedef uint8_t Elf64_Byte;		/* Type for a 8-bit quantity.  */
18 
19 typedef struct {
20 	Elf64_Addr r_offset;			/* Address of relocation.  */
21 	Elf64_Word r_sym;			/* Symbol index.  */
22 	Elf64_Byte r_ssym;			/* Special symbol.  */
23 	Elf64_Byte r_type3;			/* Third relocation.  */
24 	Elf64_Byte r_type2;			/* Second relocation.  */
25 	Elf64_Byte r_type;			/* First relocation.  */
26 } Elf64_Mips_Rel;
27 
28 typedef struct {
29 	Elf64_Addr r_offset;			/* Address of relocation.  */
30 	Elf64_Word r_sym;			/* Symbol index.  */
31 	Elf64_Byte r_ssym;			/* Special symbol.  */
32 	Elf64_Byte r_type3;			/* Third relocation.  */
33 	Elf64_Byte r_type2;			/* Second relocation.  */
34 	Elf64_Byte r_type;			/* First relocation.  */
35 	Elf64_Sxword r_addend;			/* Addend.  */
36 } Elf64_Mips_Rela;
37 
38 #ifdef CONFIG_32BIT
39 #define Elf_Shdr	Elf32_Shdr
40 #define Elf_Sym		Elf32_Sym
41 #define Elf_Ehdr	Elf32_Ehdr
42 #define Elf_Addr	Elf32_Addr
43 #define Elf_Rel		Elf32_Rel
44 #define Elf_Rela	Elf32_Rela
45 #define ELF_R_TYPE(X)	ELF32_R_TYPE(X)
46 #define ELF_R_SYM(X)	ELF32_R_SYM(X)
47 
48 #define Elf_Mips_Rel	Elf32_Rel
49 #define Elf_Mips_Rela	Elf32_Rela
50 
51 #define ELF_MIPS_R_SYM(rel) ELF32_R_SYM((rel).r_info)
52 #define ELF_MIPS_R_TYPE(rel) ELF32_R_TYPE((rel).r_info)
53 
54 #endif
55 
56 #ifdef CONFIG_64BIT
57 #define Elf_Shdr	Elf64_Shdr
58 #define Elf_Sym		Elf64_Sym
59 #define Elf_Ehdr	Elf64_Ehdr
60 #define Elf_Addr	Elf64_Addr
61 #define Elf_Rel		Elf64_Rel
62 #define Elf_Rela	Elf64_Rela
63 #define ELF_R_TYPE(X)	ELF64_R_TYPE(X)
64 #define ELF_R_SYM(X)	ELF64_R_SYM(X)
65 
66 #define Elf_Mips_Rel	Elf64_Mips_Rel
67 #define Elf_Mips_Rela	Elf64_Mips_Rela
68 
69 #define ELF_MIPS_R_SYM(rel) ((rel).r_sym)
70 #define ELF_MIPS_R_TYPE(rel) ((rel).r_type)
71 
72 #endif
73 
74 #ifdef CONFIG_MODULES
75 /* Given an address, look for it in the exception tables. */
76 const struct exception_table_entry*search_module_dbetables(unsigned long addr);
77 #else
78 /* Given an address, look for it in the exception tables. */
79 static inline const struct exception_table_entry *
80 search_module_dbetables(unsigned long addr)
81 {
82 	return NULL;
83 }
84 #endif
85 
86 #endif /* _ASM_MODULE_H */
87