This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
How to use an R_ARM_GOT32 symbol in a S file?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Sun, 26 May 2019 17:35:38 -0400
- Subject: How to use an R_ARM_GOT32 symbol in a S file?
- Reply-to: noloader at gmail dot com
I'm having a heck of a time accessing a symbol in a project built with -fPIC.
The symbol of interest is in a.c:
extern "C" unsigned int my_symbol;
unsigned int my_symbol = 0;
Then, in b.S:
.extern my_symbol
...
ldr r12,=my_symbol
ldr r12,[r12]
Or:
.extern my_symbol
...
adr r12,my_symbol
ldr r12,[r12]
Or:
<other variations, including literal pool tricks>
I can provide a bunch of different variations in b.S. Some of the
failed attempts result in my_symbol as R_ARM_REL32 (which fails to
runtime link in a shared object), R_ARM_ABS32 (which lacks position
independence), or fails to compile/assemble.
I'm not sure if this is an AS issue, and LD issue, or a combination of
both (modulo the intersection of my ignorance).
How do I use my_symbol in b.S as a R_ARM_GOT32 symbol?