From: "mathias palmqvist" <mathiaspalm@gmail.com>
To: binutils@sourceware.org
Subject: position independent executable using shared libraries on arm
Date: Sat, 15 Dec 2007 16:26:00 -0000 [thread overview]
Message-ID: <a7a2ffb60712150826q789d4a49j7f9ad364c1081cd@mail.gmail.com> (raw)
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
next reply other threads:[~2007-12-15 16:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-15 16:26 mathias palmqvist [this message]
2007-12-21 17:35 ` Nick Clifton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7a2ffb60712150826q789d4a49j7f9ad364c1081cd@mail.gmail.com \
--to=mathiaspalm@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).