aboutsummaryrefslogtreecommitdiffstats
path: root/arch/riscv/include/asm/module.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv/include/asm/module.h')
-rw-r--r--arch/riscv/include/asm/module.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/arch/riscv/include/asm/module.h b/arch/riscv/include/asm/module.h
index cd2af4b013e3..46202dad365d 100644
--- a/arch/riscv/include/asm/module.h
+++ b/arch/riscv/include/asm/module.h
@@ -9,12 +9,12 @@
9#define MODULE_ARCH_VERMAGIC "riscv" 9#define MODULE_ARCH_VERMAGIC "riscv"
10 10
11struct module; 11struct module;
12u64 module_emit_got_entry(struct module *mod, u64 val); 12unsigned long module_emit_got_entry(struct module *mod, unsigned long val);
13u64 module_emit_plt_entry(struct module *mod, u64 val); 13unsigned long module_emit_plt_entry(struct module *mod, unsigned long val);
14 14
15#ifdef CONFIG_MODULE_SECTIONS 15#ifdef CONFIG_MODULE_SECTIONS
16struct mod_section { 16struct mod_section {
17 struct elf64_shdr *shdr; 17 Elf_Shdr *shdr;
18 int num_entries; 18 int num_entries;
19 int max_entries; 19 int max_entries;
20}; 20};
@@ -26,18 +26,18 @@ struct mod_arch_specific {
26}; 26};
27 27
28struct got_entry { 28struct got_entry {
29 u64 symbol_addr; /* the real variable address */ 29 unsigned long symbol_addr; /* the real variable address */
30}; 30};
31 31
32static inline struct got_entry emit_got_entry(u64 val) 32static inline struct got_entry emit_got_entry(unsigned long val)
33{ 33{
34 return (struct got_entry) {val}; 34 return (struct got_entry) {val};
35} 35}
36 36
37static inline struct got_entry *get_got_entry(u64 val, 37static inline struct got_entry *get_got_entry(unsigned long val,
38 const struct mod_section *sec) 38 const struct mod_section *sec)
39{ 39{
40 struct got_entry *got = (struct got_entry *)sec->shdr->sh_addr; 40 struct got_entry *got = (struct got_entry *)(sec->shdr->sh_addr);
41 int i; 41 int i;
42 for (i = 0; i < sec->num_entries; i++) { 42 for (i = 0; i < sec->num_entries; i++) {
43 if (got[i].symbol_addr == val) 43 if (got[i].symbol_addr == val)
@@ -62,7 +62,9 @@ struct plt_entry {
62#define REG_T0 0x5 62#define REG_T0 0x5
63#define REG_T1 0x6 63#define REG_T1 0x6
64 64
65static inline struct plt_entry emit_plt_entry(u64 val, u64 plt, u64 got_plt) 65static inline struct plt_entry emit_plt_entry(unsigned long val,
66 unsigned long plt,
67 unsigned long got_plt)
66{ 68{
67 /* 69 /*
68 * U-Type encoding: 70 * U-Type encoding:
@@ -76,7 +78,7 @@ static inline struct plt_entry emit_plt_entry(u64 val, u64 plt, u64 got_plt)
76 * +------------+------------+--------+----------+----------+ 78 * +------------+------------+--------+----------+----------+
77 * 79 *
78 */ 80 */
79 u64 offset = got_plt - plt; 81 unsigned long offset = got_plt - plt;
80 u32 hi20 = (offset + 0x800) & 0xfffff000; 82 u32 hi20 = (offset + 0x800) & 0xfffff000;
81 u32 lo12 = (offset - hi20); 83 u32 lo12 = (offset - hi20);
82 return (struct plt_entry) { 84 return (struct plt_entry) {
@@ -86,7 +88,7 @@ static inline struct plt_entry emit_plt_entry(u64 val, u64 plt, u64 got_plt)
86 }; 88 };
87} 89}
88 90
89static inline int get_got_plt_idx(u64 val, const struct mod_section *sec) 91static inline int get_got_plt_idx(unsigned long val, const struct mod_section *sec)
90{ 92{
91 struct got_entry *got_plt = (struct got_entry *)sec->shdr->sh_addr; 93 struct got_entry *got_plt = (struct got_entry *)sec->shdr->sh_addr;
92 int i; 94 int i;
@@ -97,9 +99,9 @@ static inline int get_got_plt_idx(u64 val, const struct mod_section *sec)
97 return -1; 99 return -1;
98} 100}
99 101
100static inline struct plt_entry *get_plt_entry(u64 val, 102static inline struct plt_entry *get_plt_entry(unsigned long val,
101 const struct mod_section *sec_plt, 103 const struct mod_section *sec_plt,
102 const struct mod_section *sec_got_plt) 104 const struct mod_section *sec_got_plt)
103{ 105{
104 struct plt_entry *plt = (struct plt_entry *)sec_plt->shdr->sh_addr; 106 struct plt_entry *plt = (struct plt_entry *)sec_plt->shdr->sh_addr;
105 int got_plt_idx = get_got_plt_idx(val, sec_got_plt); 107 int got_plt_idx = get_got_plt_idx(val, sec_got_plt);