From 675dae36c7c7e93be1be8d574c923a2738905e4f Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 24 Apr 2006 22:11:51 +0930 Subject: [PATCH] --- yaml --- r: 26310 b: refs/heads/master c: f749edae5ebd339eaf22508572233600f717424f h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/arch/powerpc/kernel/module_64.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 876b97b432ed..13326113f7b3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d882995c054ff90706cc339321bfb04b15c5581f +refs/heads/master: f749edae5ebd339eaf22508572233600f717424f diff --git a/trunk/arch/powerpc/kernel/module_64.c b/trunk/arch/powerpc/kernel/module_64.c index 928b8581fcb0..ba34001fca8e 100644 --- a/trunk/arch/powerpc/kernel/module_64.c +++ b/trunk/arch/powerpc/kernel/module_64.c @@ -191,11 +191,19 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr, (void *)hdr + sechdrs[sechdrs[i].sh_link].sh_offset); } - if (!me->arch.stubs_section || !me->arch.toc_section) { - printk("%s: doesn't contain .toc or .stubs.\n", me->name); + + if (!me->arch.stubs_section) { + printk("%s: doesn't contain .stubs.\n", me->name); return -ENOEXEC; } + /* If we don't have a .toc, just use .stubs. We need to set r2 + to some reasonable value in case the module calls out to + other functions via a stub, or if a function pointer escapes + the module by some means. */ + if (!me->arch.toc_section) + me->arch.toc_section = me->arch.stubs_section; + /* Override the stubs size */ sechdrs[me->arch.stubs_section].sh_size = get_stubs_size(hdr, sechdrs); return 0; @@ -342,7 +350,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, break; case R_PPC64_TOC16: - /* Subtact TOC pointer */ + /* Subtract TOC pointer */ value -= my_r2(sechdrs, me); if (value + 0x8000 > 0xffff) { printk("%s: bad TOC16 relocation (%lu)\n", @@ -355,7 +363,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, break; case R_PPC64_TOC16_DS: - /* Subtact TOC pointer */ + /* Subtract TOC pointer */ value -= my_r2(sechdrs, me); if ((value & 3) != 0 || value + 0x8000 > 0xffff) { printk("%s: bad TOC16_DS relocation (%lu)\n",