21 #include <asm/module.h>
22 #include <linux/elf.h>
23 #include <linux/module.h>
30 #define DEBUGP(fmt , ...)
48 for (i = 0; i < hdr->e_shnum; i++) {
49 DEBUGP(
"Section %d is %s\n", i,
50 secstrings + sechdrs[i].sh_name);
51 if (
strcmp(secstrings + sechdrs[i].sh_name,
".plt") == 0)
53 if (
strcmp(secstrings + sechdrs[i].sh_name,
".got.plt") == 0)
55 if (
strcmp(secstrings + sechdrs[i].sh_name,
".rela.plt") == 0)
62 "Module '%s' contains unexpected .plt/.got sections.\n",
81 unsigned int symindex,
unsigned int relsec,
88 unsigned int nrelocs = sechdrs[relsec].sh_size /
sizeof(
Elf32_Rela);
89 Elf32_Rela *rela = (
void *)sechdrs[relsec].sh_addr;
92 void *loc_base = (
void *) sechdrs[sym_info].sh_addr;
94 DEBUGP(
"Applying relocations in section %u to section %u base=%p\n",
95 relsec, sym_info, loc_base);
97 for (i = 0; i < nrelocs; i++) {
108 DEBUGP(
"%d: value=%08x loc=%p reloc=%d symbol=%s\n",
111 &strtab[sym->
st_name] :
"(anonymous)");
116 if ((dist < -0x00800000) ||
117 (dist >= 0x00800000)) {
119 "%s: %s: %08x=%08x-%08x %s\n",
121 "R_HEXAGON_B22_PCREL reloc out of range",
124 &strtab[sym->
st_name] :
"(anonymous)");
127 DEBUGP(
"B22_PCREL contents: %08X.\n", *location);
128 *location &= ~0x01ff3fff;
129 *location |= 0x00003fff &
dist;
130 *location |= 0x01ff0000 & (dist<<2);
131 DEBUGP(
"Contents after reloc: %08x\n", *location);
135 value = (value>>16) & 0xffff;
138 *location &= ~0x00c03fff;
139 *location |= value & 0x3fff;
140 *location |= (value & 0xc000) << 8;
146 *location = value - (
uint32_t)location;