bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/25235] Forward-referencing ADR instructions generate wrong offs


From: dwelch at dwelch dot com
Subject: [Bug gas/25235] Forward-referencing ADR instructions generate wrong offsets in Thumb code
Date: Mon, 30 Dec 2019 10:24:17 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=25235

dwelch at dwelch dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dwelch at dwelch dot com

--- Comment #1 from dwelch at dwelch dot com ---
Both in do_adr and do_t_adr there are checks for S_IS_DEFINED and THUMB_IS_FUNC
before applying the required offset (to match the defined behavior of the tool
in its documentation).  But at the time of those checks a forward referenced
label is not yet defined so the correct offset is not computed.  Later when
handled as an add or subtract the implementation does not check for thumb nor
compute the correct offset.

do_t_adr for example:

  if (inst.relocs[0].exp.X_op == O_symbol
      && inst.relocs[0].exp.X_add_symbol != NULL
      && S_IS_DEFINED (inst.relocs[0].exp.X_add_symbol)   <---- here
      && THUMB_IS_FUNC (inst.relocs[0].exp.X_add_symbol)) <---- and here
    inst.relocs[0].exp.X_add_number += 1;  <---- make |= 1 for cleanliness

There are further ADR thumb issues with respect to T16 and subtraction even
though this pseudo instruction can be handled in the same number of bytes as a
T32 (add rd,pc,#0, sub rd,#offset) so no excuse there for this error in general
(if the range is too far for either A32, T16, T32 solutions then sure error
out).

        if (subtract || value & ~0x3fc)
          as_bad_where (fixP->fx_file, fixP->fx_line,
                _("invalid immediate for address calculation (value =
0x%08lX)"),
                (unsigned long) (subtract ? - value : value));

This is in the same area of code where the fix for this bug would want/need to
live.  If this needs to be filed as a separate bug to get this fixed then fine,
but might as well fix the whole ADR issue at once rather than in pieces, yes?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]