diff options
Diffstat (limited to 'arch/riscv/kernel/module-sections.c')
-rw-r--r-- | arch/riscv/kernel/module-sections.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/arch/riscv/kernel/module-sections.c b/arch/riscv/kernel/module-sections.c index bbbd26e19bfd..c9ae48333114 100644 --- a/arch/riscv/kernel/module-sections.c +++ b/arch/riscv/kernel/module-sections.c | |||
@@ -9,14 +9,14 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | 11 | ||
12 | u64 module_emit_got_entry(struct module *mod, u64 val) | 12 | unsigned long module_emit_got_entry(struct module *mod, unsigned long val) |
13 | { | 13 | { |
14 | struct mod_section *got_sec = &mod->arch.got; | 14 | struct mod_section *got_sec = &mod->arch.got; |
15 | int i = got_sec->num_entries; | 15 | int i = got_sec->num_entries; |
16 | struct got_entry *got = get_got_entry(val, got_sec); | 16 | struct got_entry *got = get_got_entry(val, got_sec); |
17 | 17 | ||
18 | if (got) | 18 | if (got) |
19 | return (u64)got; | 19 | return (unsigned long)got; |
20 | 20 | ||
21 | /* There is no duplicate entry, create a new one */ | 21 | /* There is no duplicate entry, create a new one */ |
22 | got = (struct got_entry *)got_sec->shdr->sh_addr; | 22 | got = (struct got_entry *)got_sec->shdr->sh_addr; |
@@ -25,10 +25,10 @@ u64 module_emit_got_entry(struct module *mod, u64 val) | |||
25 | got_sec->num_entries++; | 25 | got_sec->num_entries++; |
26 | BUG_ON(got_sec->num_entries > got_sec->max_entries); | 26 | BUG_ON(got_sec->num_entries > got_sec->max_entries); |
27 | 27 | ||
28 | return (u64)&got[i]; | 28 | return (unsigned long)&got[i]; |
29 | } | 29 | } |
30 | 30 | ||
31 | u64 module_emit_plt_entry(struct module *mod, u64 val) | 31 | unsigned long module_emit_plt_entry(struct module *mod, unsigned long val) |
32 | { | 32 | { |
33 | struct mod_section *got_plt_sec = &mod->arch.got_plt; | 33 | struct mod_section *got_plt_sec = &mod->arch.got_plt; |
34 | struct got_entry *got_plt; | 34 | struct got_entry *got_plt; |
@@ -37,27 +37,29 @@ u64 module_emit_plt_entry(struct module *mod, u64 val) | |||
37 | int i = plt_sec->num_entries; | 37 | int i = plt_sec->num_entries; |
38 | 38 | ||
39 | if (plt) | 39 | if (plt) |
40 | return (u64)plt; | 40 | return (unsigned long)plt; |
41 | 41 | ||
42 | /* There is no duplicate entry, create a new one */ | 42 | /* There is no duplicate entry, create a new one */ |
43 | got_plt = (struct got_entry *)got_plt_sec->shdr->sh_addr; | 43 | got_plt = (struct got_entry *)got_plt_sec->shdr->sh_addr; |
44 | got_plt[i] = emit_got_entry(val); | 44 | got_plt[i] = emit_got_entry(val); |
45 | plt = (struct plt_entry *)plt_sec->shdr->sh_addr; | 45 | plt = (struct plt_entry *)plt_sec->shdr->sh_addr; |
46 | plt[i] = emit_plt_entry(val, (u64)&plt[i], (u64)&got_plt[i]); | 46 | plt[i] = emit_plt_entry(val, |
47 | (unsigned long)&plt[i], | ||
48 | (unsigned long)&got_plt[i]); | ||
47 | 49 | ||
48 | plt_sec->num_entries++; | 50 | plt_sec->num_entries++; |
49 | got_plt_sec->num_entries++; | 51 | got_plt_sec->num_entries++; |
50 | BUG_ON(plt_sec->num_entries > plt_sec->max_entries); | 52 | BUG_ON(plt_sec->num_entries > plt_sec->max_entries); |
51 | 53 | ||
52 | return (u64)&plt[i]; | 54 | return (unsigned long)&plt[i]; |
53 | } | 55 | } |
54 | 56 | ||
55 | static int is_rela_equal(const Elf64_Rela *x, const Elf64_Rela *y) | 57 | static int is_rela_equal(const Elf_Rela *x, const Elf_Rela *y) |
56 | { | 58 | { |
57 | return x->r_info == y->r_info && x->r_addend == y->r_addend; | 59 | return x->r_info == y->r_info && x->r_addend == y->r_addend; |
58 | } | 60 | } |
59 | 61 | ||
60 | static bool duplicate_rela(const Elf64_Rela *rela, int idx) | 62 | static bool duplicate_rela(const Elf_Rela *rela, int idx) |
61 | { | 63 | { |
62 | int i; | 64 | int i; |
63 | for (i = 0; i < idx; i++) { | 65 | for (i = 0; i < idx; i++) { |
@@ -67,13 +69,13 @@ static bool duplicate_rela(const Elf64_Rela *rela, int idx) | |||
67 | return false; | 69 | return false; |
68 | } | 70 | } |
69 | 71 | ||
70 | static void count_max_entries(Elf64_Rela *relas, int num, | 72 | static void count_max_entries(Elf_Rela *relas, int num, |
71 | unsigned int *plts, unsigned int *gots) | 73 | unsigned int *plts, unsigned int *gots) |
72 | { | 74 | { |
73 | unsigned int type, i; | 75 | unsigned int type, i; |
74 | 76 | ||
75 | for (i = 0; i < num; i++) { | 77 | for (i = 0; i < num; i++) { |
76 | type = ELF64_R_TYPE(relas[i].r_info); | 78 | type = ELF_RISCV_R_TYPE(relas[i].r_info); |
77 | if (type == R_RISCV_CALL_PLT) { | 79 | if (type == R_RISCV_CALL_PLT) { |
78 | if (!duplicate_rela(relas, i)) | 80 | if (!duplicate_rela(relas, i)) |
79 | (*plts)++; | 81 | (*plts)++; |
@@ -118,9 +120,9 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, | |||
118 | 120 | ||
119 | /* Calculate the maxinum number of entries */ | 121 | /* Calculate the maxinum number of entries */ |
120 | for (i = 0; i < ehdr->e_shnum; i++) { | 122 | for (i = 0; i < ehdr->e_shnum; i++) { |
121 | Elf64_Rela *relas = (void *)ehdr + sechdrs[i].sh_offset; | 123 | Elf_Rela *relas = (void *)ehdr + sechdrs[i].sh_offset; |
122 | int num_rela = sechdrs[i].sh_size / sizeof(Elf64_Rela); | 124 | int num_rela = sechdrs[i].sh_size / sizeof(Elf_Rela); |
123 | Elf64_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info; | 125 | Elf_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info; |
124 | 126 | ||
125 | if (sechdrs[i].sh_type != SHT_RELA) | 127 | if (sechdrs[i].sh_type != SHT_RELA) |
126 | continue; | 128 | continue; |