Re: in-kernel linking issues

From: Richard Henderson (rth@twiddle.net)
Date: Fri Nov 15 2002 - 17:30:45 EST


On Fri, Nov 15, 2002 at 01:16:45PM +0000, Russell King wrote:
> I'm slightly worried about this. For things like shared libraries to be
> relocatable on ARM on current toolchains, you need to build with -fPIC.

Err, no you don't. You only need that if you want to share pages,
which is clearly not an issue with kernel modules. There are no
restrictions of which I am aware that require ARM to build with -fpic.

My test case,

        int i;
        int foo() { return bar() + i; }
        int j __attribute__((section(".init.data")));
        int __attribute__((section(".init.text")))
        baz() { return i + j; }

works exactly as desired on ARM:

Disassembly of section .text:

00000000 <foo>:
   0: e52de004 str lr, [sp, -#4]!
   4: ebfffffe bl 4 <foo+0x4>
   8: e59f3008 ldr r3, [pc, #8] ; 18 <foo+0x18>
   c: e5933000 ldr r3, [r3]
  10: e0800003 add r0, r0, r3
  14: e49df004 ldr pc, [sp], #4

Disassembly of section .init.text:

00001000 <baz>:
    1000: e59f3010 ldr r3, [pc, #16] ; 1018 <baz+0x18>
    1004: e5930000 ldr r0, [r3]
    1008: e59f300c ldr r3, [pc, #12] ; 101c <baz+0x1c>
    100c: e5933000 ldr r3, [r3]
    1010: e0800003 add r0, r0, r3
    1014: e1a0f00e mov pc, lr

Relocation section '.rel.dyn' at offset 0x11258 contains 4 entries:
 Offset Info Type Sym.Value Sym. Name
00000004 00001501 R_ARM_PC24 00000000 bar
00000018 00001202 R_ARM_ABS32 00000040 i
00001018 00001202 R_ARM_ABS32 00000040 i
0000101c 00000f02 R_ARM_ABS32 00001020 j

r~
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Nov 15 2002 - 22:00:39 EST