diff options
author | Alan Modra <amodra@bigpond.net.au> | 2006-04-24 08:41:51 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-04-28 07:04:49 -0400 |
commit | f749edae5ebd339eaf22508572233600f717424f (patch) | |
tree | f2118ec27b0682ae9bb3d6c0605d7ccd08313a71 /arch | |
parent | d882995c054ff90706cc339321bfb04b15c5581f (diff) |
[PATCH] powerpc64: Fix loading of modules without a .toc section
Normally, ppc64 module .ko files contain a table-of-contents (.toc)
section, but if the module doesn't reference any static or external
data or external procedures, it is possible for gcc/binutils to
generate a .ko that doesn't have a .toc. Currently the module
loader refuses to load such a module, since it needs the address
of the .toc section to use in relocations.
This patch fixes the problem by using the address of the .stubs
section instead, which is an acceptable substitute in this situation.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-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", |