[committed, nios2] fix incorrect disassembly of signed fields

Sandra Loosemore sandra@codesourcery.com
Sun Sep 23 19:54:00 GMT 2018


I recently spotted some failures in the gas testsuite when running nios2 
tests on x86_64-w64-mingw32 host for the first time, which turned out to 
be a disassembler bug rather than an assembler bug.  This host has a 
32-bit long type and 64-bit bfd_vma type, and some sloppy type 
conversions from int to unsigned long and then to bfd_vma in the 
disassembler were causing the extension of signed instruction fields 
from 32 to 64 bits to happen as an unsigned conversion.  This 
particularly affected printing of branch target addresses -- in some 
cases it was printing the wrong symbol, even.

I've checked in the attached patch to clean this up.  I'm now explicitly 
using signed temporaries of the appropriate type (long or 
bfd_signed_vma) instead of unsigned long for the intermediate value, and 
I changed the casts on the bit field extraction to int32_t to make the 
size as well as the signedness more obvious.

-Sandra
-------------- next part --------------
A non-text attachment was scrubbed...
Name: disasm.patch
Type: text/x-patch
Size: 3859 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180923/917f3472/attachment.bin>


More information about the Binutils mailing list