13 #include <linux/elf.h>
15 #include <linux/kernel.h>
20 long ep = (
long)ip & ~31;
22 long mask = (1 << maskbits) - 1;
24 if ((delta >> (maskbits - 1)) == 0 ||
25 (delta >> (maskbits - 1)) == -1) {
27 opcode &= ~(mask << shift);
28 opcode |= ((delta &
mask) << shift);
31 pr_debug(
"REL PCR_S%d[%p] dest[%p] opcode[%08x]\n",
32 maskbits, ip, (
void *)dest, opcode);
36 pr_err(
"PCR_S%d reloc %p -> %p out of range!\n",
37 maskbits, ip, (
void *)dest);
47 unsigned int symindex,
51 Elf32_Rela *rel = (
void *) sechdrs[relsec].sh_addr;
58 pr_debug(
"Applying relocate section %u to %u with offset 0x%x\n",
59 relsec, sechdrs[relsec].sh_info, offset);
61 for (i = 0; i < sechdrs[relsec].
sh_size /
sizeof(*rel); i++) {
63 location = (
void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
68 sym = (
Elf_Sym *)sechdrs[symindex].sh_addr
76 pr_debug(
"RELA ABS32: [%p] = 0x%x\n", location, v);
80 pr_debug(
"RELA ABS16: [%p] = 0x%x\n", location, v);
84 pr_debug(
"RELA ABS8: [%p] = 0x%x\n", location, v);
90 opcode |= ((v & 0xffff) << 7);
91 pr_debug(
"RELA ABS_L16[%p] v[0x%x] opcode[0x%x]\n",
98 opcode |= ((v >> 9) & 0x7fff80);
99 pr_debug(
"RELA ABS_H16[%p] v[0x%x] opcode[0x%x]\n",
100 location, v, opcode);
104 if (fixup_pcr(location, v, 21, 7))
108 if (fixup_pcr(location, v, 12, 16))
112 if (fixup_pcr(location, v, 10, 13))
116 pr_err(
"module %s: Unknown RELA relocation: %u\n",