[arm64] Fix disassembler for ADR with negative offsets.

Change-Id: I8b50ff0d53787fb19604644a71f091837a8dcbde
Reviewed-on: https://chromium-review.googlesource.com/c/1292062
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com>
Cr-Commit-Position: refs/heads/master@{#56861}
This commit is contained in:
Georgia Kouveli 2018-10-22 12:09:47 +01:00 committed by Commit Bot
parent 99dcc4cd94
commit 3b98c90e64
2 changed files with 8 additions and 2 deletions

View File

@ -3892,10 +3892,9 @@ int DisassemblingDecoder::SubstitutePCRelAddressField(Instruction* instr,
char sign = '+';
if (offset < 0) {
offset = -offset;
sign = '-';
}
AppendToOutput("#%c0x%x (addr %p)", sign, offset,
AppendToOutput("#%c0x%x (addr %p)", sign, Abs(offset),
instr->InstructionAtOffset(offset, Instruction::NO_CHECK));
return 13;
}

View File

@ -799,6 +799,13 @@ TEST_(dp_2_source) {
TEST_(adr) {
SET_UP_ASM();
char expected[100];
snprintf(expected, sizeof(expected), "adr x0, #+0x0 (addr %p)", buf);
COMPARE(adr(x0, 0), expected);
snprintf(expected, sizeof(expected), "adr x0, #+0x1 (addr %p)", buf + 1);
COMPARE(adr(x0, 1), expected);
snprintf(expected, sizeof(expected), "adr x0, #-0x1 (addr %p)", buf - 1);
COMPARE(adr(x0, -1), expected);
COMPARE_PREFIX(adr(x0, 0), "adr x0, #+0x0");
COMPARE_PREFIX(adr(x1, 1), "adr x1, #+0x1");
COMPARE_PREFIX(adr(x2, -1), "adr x2, #-0x1");