Closed palmer-dabbelt closed 6 years ago
@jim-wilson I haven't even compiled this. Do you mind taking it over?
Patch added upstream. The testcase had to be modified slightly to demonstrate the problem. I added a .skip 64 so that the auipc did not have a 0 address in the object file. Also, in the riscv-dis.c file, I don't think it is safe to unconditionally set register 0 to 0 as a -1 value has a special meaning, so I moved the code inside the if statement that compares a register value against -1.
The RISC-V ISA defines a hardware-enforced zero register, denotated as either x0 or zero. Normal programs don't write to this register, but when playing around with how our assembler interprets awkward addresses I noticed that our disassembler doesn't know that x0 always has the value 0. For example, before this patch we produce the following output:
While I'm arithmatically challaged, I'm pretty sure that 0+0 isn't 0x10078. This isn't really a problem: it's just an incorrect disassembler hint and nobody should we writing to x0 anyway, but it's technically wrong.
opcodes/ChangeLog
2018-01-08 Palmer Dabbelt palmer@dabbelt.com
gas/ChangeLog
2018-01-08 Palmer Dabbelt palmer@dabbelt.com