Commit 04e9b59f authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] H8/300 module fix

From: Yoshinori Sato <ysato@users.sourceforge.jp>

- fix relocation
- define SYMBOL_PREFIX
parent 45577464
...@@ -40,6 +40,8 @@ EXPORT_SYMBOL(strncmp); ...@@ -40,6 +40,8 @@ EXPORT_SYMBOL(strncmp);
EXPORT_SYMBOL(ip_fast_csum); EXPORT_SYMBOL(ip_fast_csum);
EXPORT_SYMBOL(kernel_thread); EXPORT_SYMBOL(kernel_thread);
EXPORT_SYMBOL(enable_irq);
EXPORT_SYMBOL(disable_irq);
/* Networking helper routines. */ /* Networking helper routines. */
EXPORT_SYMBOL(csum_partial_copy); EXPORT_SYMBOL(csum_partial_copy);
......
...@@ -67,7 +67,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -67,7 +67,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
Elf32_Sym *sym = (Elf32_Sym *)sechdrs[symindex].sh_addr Elf32_Sym *sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
+ ELF32_R_SYM(rela[i].r_info); + ELF32_R_SYM(rela[i].r_info);
uint32_t v = sym->st_value + rela[i].r_addend; uint32_t v = sym->st_value + rela[i].r_addend;
uint32_t dot = sechdrs[symindex].sh_addr + rela[i].r_offset;
switch (ELF32_R_TYPE(rela[i].r_info)) { switch (ELF32_R_TYPE(rela[i].r_info)) {
case R_H8_DIR24R8: case R_H8_DIR24R8:
...@@ -75,14 +74,15 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -75,14 +74,15 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
*loc = (*loc & 0xff000000) | ((*loc & 0xffffff) + v); *loc = (*loc & 0xff000000) | ((*loc & 0xffffff) + v);
break; break;
case R_H8_DIR24A8: case R_H8_DIR24A8:
*loc += v; if (ELF32_R_SYM(rela[i].r_info))
*loc += v;
break; break;
case R_H8_DIR32: case R_H8_DIR32:
case R_H8_DIR32A16: case R_H8_DIR32A16:
*loc += v; *loc += v;
break; break;
case R_H8_PCREL16: case R_H8_PCREL16:
v -= dot + 2; v -= (unsigned long)loc + 2;
if ((Elf32_Sword)v > 0x7fff || if ((Elf32_Sword)v > 0x7fff ||
(Elf32_Sword)v < -(Elf32_Sword)0x8000) (Elf32_Sword)v < -(Elf32_Sword)0x8000)
goto overflow; goto overflow;
...@@ -90,7 +90,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -90,7 +90,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
*(unsigned short *)loc = v; *(unsigned short *)loc = v;
break; break;
case R_H8_PCREL8: case R_H8_PCREL8:
v -= dot + 1; v -= (unsigned long)loc + 1;
if ((Elf32_Sword)v > 0x7f || if ((Elf32_Sword)v > 0x7f ||
(Elf32_Sword)v < -(Elf32_Sword)0x80) (Elf32_Sword)v < -(Elf32_Sword)0x80)
goto overflow; goto overflow;
...@@ -105,7 +105,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, ...@@ -105,7 +105,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
} }
return 0; return 0;
overflow: overflow:
printk(KERN_ERR "module %s: relocation offset overflow: %p\n", printk(KERN_ERR "module %s: relocation offset overflow: %08x\n",
me->name, rela[i].r_offset); me->name, rela[i].r_offset);
return -ENOEXEC; return -ENOEXEC;
} }
......
...@@ -8,4 +8,6 @@ struct mod_arch_specific { }; ...@@ -8,4 +8,6 @@ struct mod_arch_specific { };
#define Elf_Sym Elf32_Sym #define Elf_Sym Elf32_Sym
#define Elf_Ehdr Elf32_Ehdr #define Elf_Ehdr Elf32_Ehdr
#define MODULE_SYMBOL_PREFIX "_"
#endif /* _ASM_H8/300_MODULE_H */ #endif /* _ASM_H8/300_MODULE_H */
...@@ -55,7 +55,7 @@ main(int argc, char **argv) ...@@ -55,7 +55,7 @@ main(int argc, char **argv)
else else
abort(); abort();
if (strcmp(argv[1], "v850") == 0) if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0))
printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
else else
printf("#define MODULE_SYMBOL_PREFIX \"\"\n"); printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment