* position independent executable using shared libraries on arm
@ 2007-12-15 16:26 mathias palmqvist
2007-12-21 17:35 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: mathias palmqvist @ 2007-12-15 16:26 UTC (permalink / raw)
To: binutils
Hey
When I compile simple test code with -fPIC and no pie link parameter
or shared libs I can see
prologue code similar to this in each function setting up R10 and adding PC.
.text:0000804C MOV R12, SP
.text:00008050 STMFD SP!, {R10-R12,LR,PC}
.text:00008054 SUB R11, R12, #4
.text:00008058 LDR R10, =0x3D8
.text:0000805C ADD R10, PC, R10
.text:00008060 LDR R3, =0xC
If I add -pie as a link parameter, or link the executable with a
shared library, the
ADD R10,PC,R10
instruction is replaced with a NOP, and the code looks like this:
.text:0000034C MOV R12, SP
.text:00000350 STMFD SP!, {R10-R12,LR,PC}
.text:00000354 SUB R11, R12, #4
.text:00000358 LDR R10, =_GLOBAL_OFFSET_TABLE_ ; PIC mode
.text:0000035C NOP
.text:00000360 LDR R3, =0xC
The object file generated by gcc is the same. Only link parameters change.
Am I missing something here? What should I do to get ld to position
GOT at a relative
offset instead of at the absolute address when linking with shared libs?
We are currently implementing dynamic linking support for elf and
simple so:s on our embedded
platform, so we have complete control of the loading, but want to use
gcc/ld for building.
Using: ld 2.16.1 with gcc 4.1.0. Building for armv5.
Thanks in advance
/Mathias
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-12-21 17:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-15 16:26 position independent executable using shared libraries on arm mathias palmqvist
2007-12-21 17:35 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).