21 #include <linux/elf.h>
23 #include <linux/errno.h>
38 pr_err(
"module %s: dangerous R_MIPS_26 RELArelocation\n",
43 if ((v & 0xf0000000) != (((
unsigned long)location + 4) & 0xf0000000)) {
45 "module %s: relocation overflow\n",
50 *location = (*location & ~0x03ffffff) | ((v >> 2) & 0x03ffffff);
57 *location = (*location & 0xffff0000) |
58 ((((
long long) v + 0x8000LL) >> 16) & 0xffff);
65 *location = (*location & 0xffff0000) | (v & 0xffff);
77 static int apply_r_mips_higher_rela(
struct module *me,
u32 *location,
80 *location = (*location & 0xffff0000) |
81 ((((
long long) v + 0x80008000LL) >> 32) & 0xffff);
86 static int apply_r_mips_highest_rela(
struct module *me,
u32 *location,
89 *location = (*location & 0xffff0000) |
90 ((((
long long) v + 0x800080008000LL) >> 48) & 0xffff);
108 unsigned int symindex,
unsigned int relsec,
111 Elf_Mips_Rela *rel = (
void *) sechdrs[relsec].sh_addr;
118 pr_debug(
"Applying relocate section %u to %u\n", relsec,
119 sechdrs[relsec].sh_info);
121 for (i = 0; i < sechdrs[relsec].sh_size /
sizeof(*rel); i++) {
123 location = (
void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
126 sym = (
Elf_Sym *)sechdrs[symindex].sh_addr
127 + ELF_MIPS_R_SYM(rel[i]);
133 me->
name, strtab + sym->st_name);
137 v = sym->st_value + rel[
i].r_addend;
139 res = reloc_handlers_rela[ELF_MIPS_R_TYPE(rel[i])](me,
location,
v);