GAS (ARM): Possible bug in relative/relocatable address detection
Jens Bauer
jens-lists@gpio.dk
Mon May 27 22:40:00 GMT 2013
Hi list.
The GAS I'm using is from Binutils 2.23.1
I've written a macro to generate a table of relative offsets.
.macro IntTab nextVector:req,prologue
.ifnb \prologue
.hword (\prologue - tableBase)
.else
.hword (xHSyncStartInterrupt - tableBase)
.endif
;// .hword ((\nextVector - tableBase) | 0) /* this can be done, but not without the (... | 0) */
;// .hword ((\nextVector - tableBase)) /* fails */
.hword (\nextVector - tableBase) /* fails */
.endm
If I omit (... | 0), I get the following error:
Error: cannot represent BFD_RELOC_16_PCREL relocation in this object file format
I'm building for ARM, but this may apply to all platforms.
...But if I add (... | 0), the generated table appears to be correct.
You can also use...
(... >> 0)
(... << 0)
(... & ~0)
(... ^ 0)
(... * 1)
(... / 1)
...But you still get the error if you use (... + 0) or (... - 0).
As the parameters to the macro are all relocatable, and (relocatable - relocatable) = relative, this seems to be a bug.
Love
Jens
More information about the Binutils
mailing list