Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kobj_reloc: unexpected relocation type 10



Hi,

On Thu, Dec 04, 2008 at 02:28:22PM +0100, Nicolas Joly wrote:

> I just tested kernel modules loading on my main developpement amd64
> machine (Tyan S2885, 2 Opterons 246, 2GB RAM); and noticed that both
> auto and manual module loading failed ...
> 
> kobj_reloc: unexpected relocation type 10
> WARNING: module error: Cannot load kernel object `compat_linux32' error=2
> 
> The main problem is that i compile the whole userland with debugging
> enabled (in mk.conf) :
> 
> .if !defined(KERNEL_BUILD)
> COPTS+=        -g
> STRIPFLAG=     -S -d
> .endif 
> 
> Without it, all is fine.
> 
> Do we support such options for building kernel modules ? And, if yes,
> can someone with appropriate knowledge add R_X86_64_32 relocation
> support to kobj_reloc() ?

Can you try this patch? If it works, please check it in.

Thanks,
Andrew

Index: kobj_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/kobj_machdep.c,v
retrieving revision 1.4
diff -p -u -r1.4 kobj_machdep.c
--- kobj_machdep.c      12 Nov 2008 12:35:56 -0000      1.4
+++ kobj_machdep.c      7 Dec 2008 09:52:45 -0000
@@ -95,6 +95,7 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
                /* Addend is 32 bit on 32 bit relocs */
                switch (rtype) {
                case R_X86_64_PC32:
+               case R_X86_64_32:
                case R_X86_64_32S:
                        addend = *(Elf32_Addr *)where;
                        break;
@@ -110,27 +111,28 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
 
        case R_X86_64_64:               /* S + A */
                addr = kobj_sym_lookup(ko, symidx);
-               val = addr + addend;
                if (addr == 0)
                        return -1;
+               val = addr + addend;
                *where = val;
                break;
 
        case R_X86_64_PC32:     /* S + A - P */
                addr = kobj_sym_lookup(ko, symidx);
-               where32 = (Elf32_Addr *)where;
-               val32 = (Elf32_Addr)(addr + addend - (Elf64_Addr)where);
                if (addr == 0)
                        return -1;
+               where32 = (Elf32_Addr *)where;
+               val32 = (Elf32_Addr)(addr + addend - (Elf64_Addr)where);
                *where32 = val32;
                break;
 
+       case R_X86_64_32:       /* S + A */
        case R_X86_64_32S:      /* S + A sign extend */
                addr = kobj_sym_lookup(ko, symidx);
-               val32 = (Elf32_Addr)(addr + addend);
-               where32 = (Elf32_Addr *)where;
                if (addr == 0)
                        return -1;
+               val32 = (Elf32_Addr)(addr + addend);
+               where32 = (Elf32_Addr *)where;
                *where32 = val32;
                break;
 


Home | Main Index | Thread Index | Old Index