19 #include <linux/elf.h>
22 #include <linux/string.h>
23 #include <linux/kernel.h>
28 #define DEBUGP(fmt...)
31 #define COPY_UNALIGNED_WORD(sw, tw, align) \
33 void *__s = &(sw), *__t = &(tw); \
34 unsigned short *__s2 = __s, *__t2 =__t; \
35 unsigned char *__s1 = __s, *__t1 =__t; \
39 *(unsigned long *) __t = *(unsigned long *) __s; \
54 #define COPY_UNALIGNED_HWORD(sw, tw, align) \
56 void *__s = &(sw), *__t = &(tw); \
57 unsigned short *__s2 = __s, *__t2 =__t; \
58 unsigned char *__s1 = __s, *__t1 =__t; \
73 unsigned int symindex,
78 Elf32_Rela *rel = (
void *)sechdrs[relsec].sh_addr;
83 unsigned short *hlocation;
84 unsigned short hvalue;
88 DEBUGP(
"Applying relocate section %u to %u\n", relsec,
89 sechdrs[relsec].sh_info);
90 for (i = 0; i < sechdrs[relsec].
sh_size /
sizeof(*rel); i++) {
92 location = (
void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
96 sym = (
Elf32_Sym *)sechdrs[symindex].sh_addr
99 align = (
int)location & 3;
109 relocation = (relocation >>16) & 0xffff;
116 if (relocation & 0x8000) relocation += 0x10000;
117 relocation = (relocation >>16) & 0xffff;
123 hlocation = (
unsigned short *)location;
124 relocation = relocation & 0xffff;
132 relocation = relocation & 0xffff;
139 relocation = relocation & 0xffffff;
145 relocation = (relocation - (
Elf32_Addr) location);
146 if (relocation < -0x20000 || 0x1fffc < relocation)
149 me->
name, relocation);
160 relocation = (relocation >> 2) & 0xffff;
165 hlocation = (
unsigned short *)location;
166 relocation = (relocation - (
Elf32_Addr) location);
168 svalue = (
int)hvalue;
169 svalue = (
signed char)svalue << 2;
170 relocation += svalue;
171 relocation = (relocation >> 2) & 0xff;
172 hvalue = hvalue & 0xff00;
173 hvalue += relocation;
177 relocation = (relocation - (
Elf32_Addr) location);
178 if (relocation < -0x2000000 || 0x1fffffc < relocation)
181 me->
name, relocation);
185 if (value & 0xffffff)
192 relocation = (relocation >> 2) & 0xffffff;