bug-binutils
[Top][All Lists]
Advanced

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

[Bug gas/16202] New: ABS8 and ABS16 get wrong addend on ARM-ELF (big end


From: ma.jiang at zte dot com.cn
Subject: [Bug gas/16202] New: ABS8 and ABS16 get wrong addend on ARM-ELF (big endian)
Date: Fri, 22 Nov 2013 02:49:36 +0000

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

            Bug ID: 16202
           Summary: ABS8 and ABS16 get wrong addend on ARM-ELF (big
                    endian)
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gas
          Assignee: unassigned at sourceware dot org
          Reporter: ma.jiang at zte dot com.cn

on ARM-ELF , in function elf32_arm_final_link_relocate, addend is get from :
      addend = bfd_get_32 (input_bfd, hit_data) & howto->src_mask;
.There is a little problem, becasue howto->scr_mask is a constant that designed
for little endian.
for example , in the testcase in gas testsuit:
.syntax unified
        .byte   x -128
        .byte   x +255
        .short  y -32768
        .short  y +65535

the first ABS8 reloc for x should get a addend -128.But on big endian ARM,
"bfd_get_32 (input_bfd, hit_data)" get a  0x80ff8000, and with a
howto->src_mask=0xff, the final addend is 0.

in the ABS8 branch, the addend is used directly.
    case R_ARM_ABS8:
      value += addend;

      /* There is no way to tell whether the user intended to use a signed or
     unsigned addend.  When checking for overflow we accept either,
     as specified by the AAELF.  */
      if ((long) value > 0xff || (long) value < -0x80)
    return bfd_reloc_overflow;

      bfd_put_8 (input_bfd, value, hit_data);
      return bfd_reloc_ok;

Finally, a 0 is put into the object file, which of course is totally wrong.
ABS16 has the same problem.
============================================================================
Fix for this problem is quite strait-forward. IN ABS8/ABS16 branch, we can
fetch addend once more using correct bfd_get_8/bfd_get_16, as following codes :

    case R_ARM_ABS8:
      addend = bfd_get_8 (input_bfd, hit_data); /*fectch addend again with
bfd_get_8 */

      value += addend;

      /* There is no way to tell whether the user intended to use a signed or
     unsigned addend.  When checking for overflow we accept either,
     as specified by the AAELF.  */
      if ((long) value > 0xff || (long) value < -0x80)
    return bfd_reloc_overflow;

      bfd_put_8 (input_bfd, value, hit_data);
      return bfd_reloc_ok;
.

-- 
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]