diff options
Diffstat (limited to 'arch/powerpc/kernel/module_64.c')
-rw-r--r-- | arch/powerpc/kernel/module_64.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index 928b8581fcb0..ba34001fca8e 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c | |||
@@ -191,11 +191,19 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr, | |||
191 | (void *)hdr | 191 | (void *)hdr |
192 | + sechdrs[sechdrs[i].sh_link].sh_offset); | 192 | + sechdrs[sechdrs[i].sh_link].sh_offset); |
193 | } | 193 | } |
194 | if (!me->arch.stubs_section || !me->arch.toc_section) { | 194 | |
195 | printk("%s: doesn't contain .toc or .stubs.\n", me->name); | 195 | if (!me->arch.stubs_section) { |
196 | printk("%s: doesn't contain .stubs.\n", me->name); | ||
196 | return -ENOEXEC; | 197 | return -ENOEXEC; |
197 | } | 198 | } |
198 | 199 | ||
200 | /* If we don't have a .toc, just use .stubs. We need to set r2 | ||
201 | to some reasonable value in case the module calls out to | ||
202 | other functions via a stub, or if a function pointer escapes | ||
203 | the module by some means. */ | ||
204 | if (!me->arch.toc_section) | ||
205 | me->arch.toc_section = me->arch.stubs_section; | ||
206 | |||
199 | /* Override the stubs size */ | 207 | /* Override the stubs size */ |
200 | sechdrs[me->arch.stubs_section].sh_size = get_stubs_size(hdr, sechdrs); | 208 | sechdrs[me->arch.stubs_section].sh_size = get_stubs_size(hdr, sechdrs); |
201 | return 0; | 209 | return 0; |
@@ -342,7 +350,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, | |||
342 | break; | 350 | break; |
343 | 351 | ||
344 | case R_PPC64_TOC16: | 352 | case R_PPC64_TOC16: |
345 | /* Subtact TOC pointer */ | 353 | /* Subtract TOC pointer */ |
346 | value -= my_r2(sechdrs, me); | 354 | value -= my_r2(sechdrs, me); |
347 | if (value + 0x8000 > 0xffff) { | 355 | if (value + 0x8000 > 0xffff) { |
348 | printk("%s: bad TOC16 relocation (%lu)\n", | 356 | printk("%s: bad TOC16 relocation (%lu)\n", |
@@ -355,7 +363,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, | |||
355 | break; | 363 | break; |
356 | 364 | ||
357 | case R_PPC64_TOC16_DS: | 365 | case R_PPC64_TOC16_DS: |
358 | /* Subtact TOC pointer */ | 366 | /* Subtract TOC pointer */ |
359 | value -= my_r2(sechdrs, me); | 367 | value -= my_r2(sechdrs, me); |
360 | if ((value & 3) != 0 || value + 0x8000 > 0xffff) { | 368 | if ((value & 3) != 0 || value + 0x8000 > 0xffff) { |
361 | printk("%s: bad TOC16_DS relocation (%lu)\n", | 369 | printk("%s: bad TOC16_DS relocation (%lu)\n", |