7 #define pr_fmt(fmt) "module %s: " fmt, mod->name
10 #include <linux/elf.h>
13 #include <linux/string.h>
14 #include <linux/kernel.h>
16 #include <asm/cacheflush.h>
17 #include <asm/uaccess.h>
31 Elf_Shdr *
s, *sechdrs_end = sechdrs + hdr->e_shnum;
34 for (s = sechdrs; s < sechdrs_end; ++
s) {
35 const char *shname = secstrings + s->sh_name;
40 if (!
strcmp(
".l1.text", shname) ||
41 (!
strcmp(
".text", shname) &&
45 mod->arch.text_l1 =
dest;
47 pr_err(
"L1 inst memory allocation failed\n");
50 dma_memcpy(dest, (
void *)s->sh_addr, s->sh_size);
52 }
else if (!
strcmp(
".l1.data", shname) ||
53 (!
strcmp(
".data", shname) &&
57 mod->arch.data_a_l1 =
dest;
59 pr_err(
"L1 data memory allocation failed\n");
62 memcpy(dest, (
void *)s->sh_addr, s->sh_size);
64 }
else if (!
strcmp(
".l1.bss", shname) ||
65 (!
strcmp(
".bss", shname) &&
69 mod->arch.bss_a_l1 =
dest;
71 pr_err(
"L1 data memory allocation failed\n");
75 }
else if (!
strcmp(
".l1.data.B", shname)) {
78 mod->arch.data_b_l1 =
dest;
80 pr_err(
"L1 data memory allocation failed\n");
83 memcpy(dest, (
void *)s->sh_addr, s->sh_size);
85 }
else if (!
strcmp(
".l1.bss.B", shname)) {
88 mod->arch.bss_b_l1 =
dest;
90 pr_err(
"L1 data memory allocation failed\n");
93 memset(dest, 0, s->sh_size);
95 }
else if (!
strcmp(
".l2.text", shname) ||
96 (!
strcmp(
".text", shname) &&
100 mod->arch.text_l2 =
dest;
102 pr_err(
"L2 SRAM allocation failed\n");
105 memcpy(dest, (
void *)s->sh_addr, s->sh_size);
107 }
else if (!
strcmp(
".l2.data", shname) ||
108 (!
strcmp(
".data", shname) &&
112 mod->arch.data_l2 =
dest;
114 pr_err(
"L2 SRAM allocation failed\n");
117 memcpy(dest, (
void *)s->sh_addr, s->sh_size);
119 }
else if (!
strcmp(
".l2.bss", shname) ||
120 (!
strcmp(
".bss", shname) &&
124 mod->arch.bss_l2 =
dest;
126 pr_err(
"L2 SRAM allocation failed\n");
134 s->sh_addr = (
unsigned long)dest;
152 unsigned int symindex,
unsigned int relsec,
156 Elf32_Rela *rel = (
void *)sechdrs[relsec].sh_addr;
160 pr_debug(
"applying relocate section %u to %u\n",
161 relsec, sechdrs[relsec].sh_info);
163 for (i = 0; i < sechdrs[relsec].sh_size /
sizeof(*rel); i++) {
165 location = sechdrs[sechdrs[relsec].sh_info].sh_addr +
170 sym = (
Elf32_Sym *) sechdrs[symindex].sh_addr
177 pr_err(
"cannot relocate in L1: %u (SMP kernel)\n",
183 pr_debug(
"location is %lx, value is %lx type is %d\n",
203 pr_err(
"unsupported relocation: %u (no -mlong-calls?)\n",
208 pr_err(
"unknown relocation: %u\n",
216 memcpy((
void *)location, &value, size);
225 pr_err(
"invalid relocation for %#lx\n", location);
237 unsigned int i, strindex = 0, symindex = 0;
241 secstrings = (
void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
243 for (i = 1; i < hdr->e_shnum; i++) {
247 strindex = sechdrs[
i].sh_link;
251 for (i = 1; i < hdr->e_shnum; i++) {
252 const char *strtab = (
char *)sechdrs[strindex].sh_addr;
253 unsigned int info = sechdrs[
i].sh_info;
254 const char *shname = secstrings + sechdrs[
i].sh_name;
257 if (info >= hdr->e_shnum)
264 if (!
strcmp(
".rela.l2.text", shname) ||
265 !
strcmp(
".rela.l1.text", shname) ||
266 (!
strcmp(
".rela.text", shname) &&