Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 162687
b: refs/heads/master
c: 459fec9
h: refs/heads/master
i:
  162685: 89de0cf
  162683: bf3a1cd
  162679: 19f8b26
  162671: 21c6c68
  162655: 2da55ea
  162623: 5d9bd3e
  162559: 8fce623
v: v3
  • Loading branch information
Mike Frysinger committed Sep 17, 2009
1 parent f389cdf commit 1958357
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 52 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 70deca9f9ca99e7a5fb88b9e4cb18e5eb1b79120
refs/heads/master: 459fec9073bca854badc1a719f7c12f5162d0edd
111 changes: 60 additions & 51 deletions trunk/arch/blackfin/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void module_free(struct module *mod, void *module_region)

/* Transfer the section to the L1 memory */
int
module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
char *secstrings, struct module *mod)
{
/*
Expand All @@ -64,12 +64,18 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
* NOTE: this breaks the semantic of mod->arch structure.
*/
Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
void *dest = NULL;
void *dest;

for (s = sechdrs; s < sechdrs_end; ++s) {
if ((strcmp(".l1.text", secstrings + s->sh_name) == 0) ||
((strcmp(".text", secstrings + s->sh_name) == 0) &&
(hdr->e_flags & EF_BFIN_CODE_IN_L1) && (s->sh_size > 0))) {
const char *shname = secstrings + s->sh_name;

if (s->sh_size == 0)
continue;

if (!strcmp(".l1.text", shname) ||
(!strcmp(".text", shname) &&
(hdr->e_flags & EF_BFIN_CODE_IN_L1))) {

dest = l1_inst_sram_alloc(s->sh_size);
mod->arch.text_l1 = dest;
if (dest == NULL) {
Expand All @@ -78,12 +84,11 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
return -1;
}
dma_memcpy(dest, (void *)s->sh_addr, s->sh_size);
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}
if ((strcmp(".l1.data", secstrings + s->sh_name) == 0) ||
((strcmp(".data", secstrings + s->sh_name) == 0) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L1) && (s->sh_size > 0))) {

} else if (!strcmp(".l1.data", shname) ||
(!strcmp(".data", shname) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L1))) {

dest = l1_data_sram_alloc(s->sh_size);
mod->arch.data_a_l1 = dest;
if (dest == NULL) {
Expand All @@ -92,23 +97,21 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
return -1;
}
memcpy(dest, (void *)s->sh_addr, s->sh_size);
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}
if (strcmp(".l1.bss", secstrings + s->sh_name) == 0 ||
((strcmp(".bss", secstrings + s->sh_name) == 0) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L1) && (s->sh_size > 0))) {

} else if (!strcmp(".l1.bss", shname) ||
(!strcmp(".bss", shname) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L1))) {

dest = l1_data_sram_zalloc(s->sh_size);
mod->arch.bss_a_l1 = dest;
if (dest == NULL) {
pr_err("L1 data memory allocation failed\n",
mod->name);
return -1;
}
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}
if (strcmp(".l1.data.B", secstrings + s->sh_name) == 0) {

} else if (!strcmp(".l1.data.B", shname)) {

dest = l1_data_B_sram_alloc(s->sh_size);
mod->arch.data_b_l1 = dest;
if (dest == NULL) {
Expand All @@ -117,10 +120,9 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
return -1;
}
memcpy(dest, (void *)s->sh_addr, s->sh_size);
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}
if (strcmp(".l1.bss.B", secstrings + s->sh_name) == 0) {

} else if (!strcmp(".l1.bss.B", shname)) {

dest = l1_data_B_sram_alloc(s->sh_size);
mod->arch.bss_b_l1 = dest;
if (dest == NULL) {
Expand All @@ -129,12 +131,11 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
return -1;
}
memset(dest, 0, s->sh_size);
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}
if ((strcmp(".l2.text", secstrings + s->sh_name) == 0) ||
((strcmp(".text", secstrings + s->sh_name) == 0) &&
(hdr->e_flags & EF_BFIN_CODE_IN_L2) && (s->sh_size > 0))) {

} else if (!strcmp(".l2.text", shname) ||
(!strcmp(".text", shname) &&
(hdr->e_flags & EF_BFIN_CODE_IN_L2))) {

dest = l2_sram_alloc(s->sh_size);
mod->arch.text_l2 = dest;
if (dest == NULL) {
Expand All @@ -143,12 +144,11 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
return -1;
}
memcpy(dest, (void *)s->sh_addr, s->sh_size);
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}
if ((strcmp(".l2.data", secstrings + s->sh_name) == 0) ||
((strcmp(".data", secstrings + s->sh_name) == 0) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L2) && (s->sh_size > 0))) {

} else if (!strcmp(".l2.data", shname) ||
(!strcmp(".data", shname) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L2))) {

dest = l2_sram_alloc(s->sh_size);
mod->arch.data_l2 = dest;
if (dest == NULL) {
Expand All @@ -157,23 +157,26 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
return -1;
}
memcpy(dest, (void *)s->sh_addr, s->sh_size);
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}
if (strcmp(".l2.bss", secstrings + s->sh_name) == 0 ||
((strcmp(".bss", secstrings + s->sh_name) == 0) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L2) && (s->sh_size > 0))) {

} else if (!strcmp(".l2.bss", shname) ||
(!strcmp(".bss", shname) &&
(hdr->e_flags & EF_BFIN_DATA_IN_L2))) {

dest = l2_sram_zalloc(s->sh_size);
mod->arch.bss_l2 = dest;
if (dest == NULL) {
pr_err("L2 SRAM allocation failed\n",
mod->name);
return -1;
}
s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}

} else
continue;

s->sh_flags &= ~SHF_ALLOC;
s->sh_addr = (unsigned long)dest;
}

return 0;
}

Expand Down Expand Up @@ -295,22 +298,28 @@ module_finalize(const Elf_Ehdr * hdr,
for (i = 1; i < hdr->e_shnum; i++) {
const char *strtab = (char *)sechdrs[strindex].sh_addr;
unsigned int info = sechdrs[i].sh_info;
const char *shname = secstrings + sechdrs[i].sh_name;

/* Not a valid relocation section? */
if (info >= hdr->e_shnum)
continue;

if ((sechdrs[i].sh_type == SHT_RELA) &&
((strcmp(".rela.l2.text", secstrings + sechdrs[i].sh_name) == 0) ||
(strcmp(".rela.l1.text", secstrings + sechdrs[i].sh_name) == 0) ||
((strcmp(".rela.text", secstrings + sechdrs[i].sh_name) == 0) &&
(hdr->e_flags & (EF_BFIN_CODE_IN_L1|EF_BFIN_CODE_IN_L2))))) {
/* Only support RELA relocation types */
if (sechdrs[i].sh_type != SHT_RELA)
continue;

if (!strcmp(".rela.l2.text", shname) ||
!strcmp(".rela.l1.text", shname) ||
(!strcmp(".rela.text", shname) &&
(hdr->e_flags & (EF_BFIN_CODE_IN_L1 | EF_BFIN_CODE_IN_L2)))) {

err = apply_relocate_add((Elf_Shdr *) sechdrs, strtab,
symindex, i, mod);
if (err < 0)
return -ENOEXEC;
}
}

return 0;
}

Expand Down

0 comments on commit 1958357

Please sign in to comment.