Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 162685
b: refs/heads/master
c: dc6b1ac
h: refs/heads/master
i:
  162683: bf3a1cd
v: v3
  • Loading branch information
Mike Frysinger committed Sep 17, 2009
1 parent fd3a6c8 commit 89de0cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 35 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: 22532578ee0f8725e0155e528c29ff992c1950c7
refs/heads/master: dc6b1ac98434d2c39d86de19aec9cf701b588c81
59 changes: 25 additions & 34 deletions trunk/arch/blackfin/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#define pr_fmt(fmt) "module %s: " fmt

#include <linux/moduleloader.h>
#include <linux/elf.h>
Expand Down Expand Up @@ -72,9 +73,8 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l1_inst_sram_alloc(s->sh_size);
mod->arch.text_l1 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L1 instruction memory allocation failed\n",
mod->name);
pr_err("L1 inst memory allocation failed\n",
mod->name);
return -1;
}
dma_memcpy(dest, (void *)s->sh_addr, s->sh_size);
Expand All @@ -87,8 +87,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l1_data_sram_alloc(s->sh_size);
mod->arch.data_a_l1 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L1 data memory allocation failed\n",
pr_err("L1 data memory allocation failed\n",
mod->name);
return -1;
}
Expand All @@ -102,8 +101,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l1_data_sram_alloc(s->sh_size);
mod->arch.bss_a_l1 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L1 data memory allocation failed\n",
pr_err("L1 data memory allocation failed\n",
mod->name);
return -1;
}
Expand All @@ -115,8 +113,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l1_data_B_sram_alloc(s->sh_size);
mod->arch.data_b_l1 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L1 data memory allocation failed\n",
pr_err("L1 data memory allocation failed\n",
mod->name);
return -1;
}
Expand All @@ -128,8 +125,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l1_data_B_sram_alloc(s->sh_size);
mod->arch.bss_b_l1 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L1 data memory allocation failed\n",
pr_err("L1 data memory allocation failed\n",
mod->name);
return -1;
}
Expand All @@ -143,9 +139,8 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l2_sram_alloc(s->sh_size);
mod->arch.text_l2 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L2 SRAM allocation failed\n",
mod->name);
pr_err("L2 SRAM allocation failed\n",
mod->name);
return -1;
}
memcpy(dest, (void *)s->sh_addr, s->sh_size);
Expand All @@ -158,8 +153,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l2_sram_alloc(s->sh_size);
mod->arch.data_l2 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L2 SRAM allocation failed\n",
pr_err("L2 SRAM allocation failed\n",
mod->name);
return -1;
}
Expand All @@ -173,8 +167,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
dest = l2_sram_alloc(s->sh_size);
mod->arch.bss_l2 = dest;
if (dest == NULL) {
printk(KERN_ERR
"module %s: L2 SRAM allocation failed\n",
pr_err("L2 SRAM allocation failed\n",
mod->name);
return -1;
}
Expand All @@ -190,7 +183,7 @@ int
apply_relocate(Elf_Shdr * sechdrs, const char *strtab,
unsigned int symindex, unsigned int relsec, struct module *me)
{
printk(KERN_ERR "module %s: .rel unsupported\n", me->name);
pr_err(".rel unsupported\n", me->name);
return -ENOEXEC;
}

Expand All @@ -217,8 +210,8 @@ apply_relocate_add(Elf_Shdr * sechdrs, const char *strtab,
uint16_t *location16;
uint32_t value;

pr_debug("Applying relocate section %u to %u\n", relsec,
sechdrs[relsec].sh_info);
pr_debug("applying relocate section %u to %u\n", mod->name,
relsec, sechdrs[relsec].sh_info);
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
/* This is where to make the change */
location16 =
Expand All @@ -231,30 +224,29 @@ apply_relocate_add(Elf_Shdr * sechdrs, const char *strtab,
+ ELF32_R_SYM(rel[i].r_info);
value = sym->st_value;
value += rel[i].r_addend;
pr_debug("location is %x, value is %x type is %d \n",
(unsigned int) location32, value,
ELF32_R_TYPE(rel[i].r_info));

#ifdef CONFIG_SMP
if ((unsigned long)location16 >= COREB_L1_DATA_A_START) {
printk(KERN_ERR "module %s: cannot relocate in L1: %u (SMP kernel)",
mod->name, ELF32_R_TYPE(rel[i].r_info));
pr_err("cannot relocate in L1: %u (SMP kernel)",
mod->name, ELF32_R_TYPE(rel[i].r_info));
return -ENOEXEC;
}
#endif

pr_debug("location is %lx, value is %x type is %d\n",
mod->name, (unsigned long)location32, value,
ELF32_R_TYPE(rel[i].r_info));

switch (ELF32_R_TYPE(rel[i].r_info)) {

case R_BFIN_LUIMM16:
pr_debug("before %x after %x\n", *location16,
(value & 0xffff));
tmp = (value & 0xffff);
if ((unsigned long)location16 >= L1_CODE_START) {
dma_memcpy(location16, &tmp, 2);
} else
*location16 = tmp;
break;
case R_BFIN_HUIMM16:
pr_debug("before %x after %x\n", *location16,
((value >> 16) & 0xffff));
tmp = ((value >> 16) & 0xffff);
if ((unsigned long)location16 >= L1_CODE_START) {
dma_memcpy(location16, &tmp, 2);
Expand All @@ -265,20 +257,19 @@ apply_relocate_add(Elf_Shdr * sechdrs, const char *strtab,
*location16 = (value & 0xffff);
break;
case R_BFIN_BYTE4_DATA:
pr_debug("before %x after %x\n", *location32, value);
*location32 = value;
break;
case R_BFIN_PCREL24:
case R_BFIN_PCREL24_JUMP_L:
case R_BFIN_PCREL12_JUMP:
case R_BFIN_PCREL12_JUMP_S:
case R_BFIN_PCREL10:
printk(KERN_ERR "module %s: Unsupported relocation: %u (no -mlong-calls?)\n"
pr_err("unsupported relocation: %u (no -mlong-calls?)\n",
mod->name, ELF32_R_TYPE(rel[i].r_info));
return -ENOEXEC;
default:
printk(KERN_ERR "module %s: Unknown relocation: %u\n",
mod->name, ELF32_R_TYPE(rel[i].r_info));
pr_err("unknown relocation: %u\n", mod->name,
ELF32_R_TYPE(rel[i].r_info));
return -ENOEXEC;
}
}
Expand Down

0 comments on commit 89de0cf

Please sign in to comment.