This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: How to use an R_ARM_GOT32 symbol in a S file?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sun, 26 May 2019 18:30:09 -0400
- Subject: Re: How to use an R_ARM_GOT32 symbol in a S file?
- References: <CAH8yC8=p-sGNwFFKzg1FfVgZGC_C90SJXenpFNoP17H7xJeaDg@mail.gmail.com> <CAH8yC8=ry+92HL8zxWbJRRNh0tQXKKR2RkVcR=cj0o0iYRDNcA@mail.gmail.com> <87pno4oogh.fsf@igel.home>
- Reply-to: noloader at gmail dot com
On Sun, May 26, 2019 at 6:12 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Mai 26 2019, Jeffrey Walton <noloader@gmail.com> wrote:
>
> > My bad, I should have provided this. This is the dominant use case
> > that has to work for users:
> >
> > gcc -fPIC -march=armv7-a a.c -c
> > gcc -fPIC -march=armv7-a b.S -c
> > gcc -shared -fPIC a.o b.o -o test.so
>
> Try looking at the gcc output.
Thanks Andreas. I haven't gotten that far due to compile/assembler errors.
According to the ARM manual on LDR [1], it _does not_ produce position
independent code. And according to the manual, ADR [2] does produce
position independent code and data. So I must use ADR or ADRL.
So, using ADR (and also ADRL):
.extern my_symbol
...
adr r12,my_symbol
ldr r12,[r12]
...
gcc -fPIC -march=armv7-a b.S -c
Results in:
b.S: Assembler messages:
b.S:98: Error: undefined symbol my_symbol used as an immediate value
So I am obviously doing something wrong.
The bigger problem I am finding is, there's little documentation on
position independent code. I bought two books on ARM assembly language
and neither treats the subject.
[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0068b/Babbfdih.html
[2] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0068b/Babcjaii.html