diff options
author | Robin Getz <robin.getz@analog.com> | 2009-06-25 11:49:38 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-09-16 21:28:46 -0400 |
commit | 22532578ee0f8725e0155e528c29ff992c1950c7 (patch) | |
tree | 28696c273cfcc8fba5475eba56d2ed0a9b8401a1 /arch/blackfin | |
parent | c014e15a2f667f91b5c2d08a90d77197a89d8065 (diff) |
Blackfin: reject outdated/unused/wrong relocation types
All kernel modules are required to be built with -mlong-calls and thus
should not generate any of these relocations. If they do, it means the
module has not been compiled properly, so rather than trying to handle
them (and running into random run time errors) just error out on module
load to force the module to be compiled correctly.
Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r-- | arch/blackfin/kernel/module.c | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/arch/blackfin/kernel/module.c b/arch/blackfin/kernel/module.c index d5aee3626688..bb940784cf2e 100644 --- a/arch/blackfin/kernel/module.c +++ b/arch/blackfin/kernel/module.c | |||
@@ -243,40 +243,6 @@ apply_relocate_add(Elf_Shdr * sechdrs, const char *strtab, | |||
243 | #endif | 243 | #endif |
244 | switch (ELF32_R_TYPE(rel[i].r_info)) { | 244 | switch (ELF32_R_TYPE(rel[i].r_info)) { |
245 | 245 | ||
246 | case R_BFIN_PCREL24: | ||
247 | case R_BFIN_PCREL24_JUMP_L: | ||
248 | /* Add the value, subtract its postition */ | ||
249 | location16 = | ||
250 | (uint16_t *) (sechdrs[sechdrs[relsec].sh_info]. | ||
251 | sh_addr + rel[i].r_offset - 2); | ||
252 | location32 = (uint32_t *) location16; | ||
253 | value -= (uint32_t) location32; | ||
254 | value >>= 1; | ||
255 | if ((value & 0xFF000000) != 0 && | ||
256 | (value & 0xFF000000) != 0xFF000000) { | ||
257 | printk(KERN_ERR "module %s: relocation overflow\n", | ||
258 | mod->name); | ||
259 | return -ENOEXEC; | ||
260 | } | ||
261 | pr_debug("value is %x, before %x-%x after %x-%x\n", value, | ||
262 | *location16, *(location16 + 1), | ||
263 | (*location16 & 0xff00) | (value >> 16 & 0x00ff), | ||
264 | value & 0xffff); | ||
265 | *location16 = | ||
266 | (*location16 & 0xff00) | (value >> 16 & 0x00ff); | ||
267 | *(location16 + 1) = value & 0xffff; | ||
268 | break; | ||
269 | case R_BFIN_PCREL12_JUMP: | ||
270 | case R_BFIN_PCREL12_JUMP_S: | ||
271 | value -= (uint32_t) location32; | ||
272 | value >>= 1; | ||
273 | *location16 = (value & 0xfff); | ||
274 | break; | ||
275 | case R_BFIN_PCREL10: | ||
276 | value -= (uint32_t) location32; | ||
277 | value >>= 1; | ||
278 | *location16 = (value & 0x3ff); | ||
279 | break; | ||
280 | case R_BFIN_LUIMM16: | 246 | case R_BFIN_LUIMM16: |
281 | pr_debug("before %x after %x\n", *location16, | 247 | pr_debug("before %x after %x\n", *location16, |
282 | (value & 0xffff)); | 248 | (value & 0xffff)); |
@@ -302,6 +268,14 @@ apply_relocate_add(Elf_Shdr * sechdrs, const char *strtab, | |||
302 | pr_debug("before %x after %x\n", *location32, value); | 268 | pr_debug("before %x after %x\n", *location32, value); |
303 | *location32 = value; | 269 | *location32 = value; |
304 | break; | 270 | break; |
271 | case R_BFIN_PCREL24: | ||
272 | case R_BFIN_PCREL24_JUMP_L: | ||
273 | case R_BFIN_PCREL12_JUMP: | ||
274 | case R_BFIN_PCREL12_JUMP_S: | ||
275 | case R_BFIN_PCREL10: | ||
276 | printk(KERN_ERR "module %s: Unsupported relocation: %u (no -mlong-calls?)\n" | ||
277 | mod->name, ELF32_R_TYPE(rel[i].r_info)); | ||
278 | return -ENOEXEC; | ||
305 | default: | 279 | default: |
306 | printk(KERN_ERR "module %s: Unknown relocation: %u\n", | 280 | printk(KERN_ERR "module %s: Unknown relocation: %u\n", |
307 | mod->name, ELF32_R_TYPE(rel[i].r_info)); | 281 | mod->name, ELF32_R_TYPE(rel[i].r_info)); |