GAS (ARM): Possible bug in relative/relocatable address detection

Alan Modra amodra@gmail.com
Thu May 30 08:31:00 GMT 2013


On Wed, May 29, 2013 at 04:39:43PM +0200, Jens Bauer wrote:
> Hi Alan.
> 
> Please forgive me for any possible misunderstandings in advance. ;)
> 
> > /* Force output of R_ARM_REL32 relocations against thumb function symbols.
> >    This is needed to ensure the low bit is handled correctly.  */
> 
> Question: *Is* the low bit actually handled correctly, or is this just the easiest way to fix the problem? :)
> 
> > #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)	\
> >   (THUMB_IS_FUNC ((FIX)->fx_addsy)		\
> >    || !SEG_NORMAL (SEG))
> > 
> > So the subtraction isn't allowed, the subtrahend is converted to a
> > pc-relative value
> 
> To me it smells a bit like a quickfix; is this because the linker does not know how to do a bitwise OR operation ?

The TC_FORCE_RELOCATION comment means that the *assembler* doesn't do
the right thing in some situations, but the linker does.  By emitting
a relocation you leave final resolution of the value to link time.
I'm no ARM expert, but I'd guess that what is "correct" handling for
the low bit of thumb symbols depends on context (the ARM ABI reloc
specs seem to indicate this).  The comment also mentions R_ARM_REL32
relocs (but doesn't test for them!) so your use case obviously wasn't
considered..

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list