hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/riscv/kernel/module-sections.c
....@@ -8,15 +8,16 @@
88 #include <linux/elf.h>
99 #include <linux/kernel.h>
1010 #include <linux/module.h>
11
+#include <linux/moduleloader.h>
1112
12
-u64 module_emit_got_entry(struct module *mod, u64 val)
13
+unsigned long module_emit_got_entry(struct module *mod, unsigned long val)
1314 {
1415 struct mod_section *got_sec = &mod->arch.got;
1516 int i = got_sec->num_entries;
1617 struct got_entry *got = get_got_entry(val, got_sec);
1718
1819 if (got)
19
- return (u64)got;
20
+ return (unsigned long)got;
2021
2122 /* There is no duplicate entry, create a new one */
2223 got = (struct got_entry *)got_sec->shdr->sh_addr;
....@@ -25,10 +26,10 @@
2526 got_sec->num_entries++;
2627 BUG_ON(got_sec->num_entries > got_sec->max_entries);
2728
28
- return (u64)&got[i];
29
+ return (unsigned long)&got[i];
2930 }
3031
31
-u64 module_emit_plt_entry(struct module *mod, u64 val)
32
+unsigned long module_emit_plt_entry(struct module *mod, unsigned long val)
3233 {
3334 struct mod_section *got_plt_sec = &mod->arch.got_plt;
3435 struct got_entry *got_plt;
....@@ -37,27 +38,29 @@
3738 int i = plt_sec->num_entries;
3839
3940 if (plt)
40
- return (u64)plt;
41
+ return (unsigned long)plt;
4142
4243 /* There is no duplicate entry, create a new one */
4344 got_plt = (struct got_entry *)got_plt_sec->shdr->sh_addr;
4445 got_plt[i] = emit_got_entry(val);
4546 plt = (struct plt_entry *)plt_sec->shdr->sh_addr;
46
- plt[i] = emit_plt_entry(val, (u64)&plt[i], (u64)&got_plt[i]);
47
+ plt[i] = emit_plt_entry(val,
48
+ (unsigned long)&plt[i],
49
+ (unsigned long)&got_plt[i]);
4750
4851 plt_sec->num_entries++;
4952 got_plt_sec->num_entries++;
5053 BUG_ON(plt_sec->num_entries > plt_sec->max_entries);
5154
52
- return (u64)&plt[i];
55
+ return (unsigned long)&plt[i];
5356 }
5457
55
-static int is_rela_equal(const Elf64_Rela *x, const Elf64_Rela *y)
58
+static int is_rela_equal(const Elf_Rela *x, const Elf_Rela *y)
5659 {
5760 return x->r_info == y->r_info && x->r_addend == y->r_addend;
5861 }
5962
60
-static bool duplicate_rela(const Elf64_Rela *rela, int idx)
63
+static bool duplicate_rela(const Elf_Rela *rela, int idx)
6164 {
6265 int i;
6366 for (i = 0; i < idx; i++) {
....@@ -67,13 +70,13 @@
6770 return false;
6871 }
6972
70
-static void count_max_entries(Elf64_Rela *relas, int num,
73
+static void count_max_entries(Elf_Rela *relas, int num,
7174 unsigned int *plts, unsigned int *gots)
7275 {
7376 unsigned int type, i;
7477
7578 for (i = 0; i < num; i++) {
76
- type = ELF64_R_TYPE(relas[i].r_info);
79
+ type = ELF_RISCV_R_TYPE(relas[i].r_info);
7780 if (type == R_RISCV_CALL_PLT) {
7881 if (!duplicate_rela(relas, i))
7982 (*plts)++;
....@@ -118,9 +121,9 @@
118121
119122 /* Calculate the maxinum number of entries */
120123 for (i = 0; i < ehdr->e_shnum; i++) {
121
- Elf64_Rela *relas = (void *)ehdr + sechdrs[i].sh_offset;
122
- int num_rela = sechdrs[i].sh_size / sizeof(Elf64_Rela);
123
- Elf64_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info;
124
+ Elf_Rela *relas = (void *)ehdr + sechdrs[i].sh_offset;
125
+ int num_rela = sechdrs[i].sh_size / sizeof(Elf_Rela);
126
+ Elf_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info;
124127
125128 if (sechdrs[i].sh_type != SHT_RELA)
126129 continue;