Skip to content

Commit

Permalink
arm64: set absolute (rather than relative) address B/BL. issue report…
Browse files Browse the repository at this point in the history
…ed by Pancake
  • Loading branch information
aquynh committed Dec 12, 2014
1 parent c2925e9 commit 03a1836
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions SStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ void printInt64Bang(SStream *O, int64_t val)
}
}

void printUInt64Bang(SStream *O, uint64_t val)
{
if (val > HEX_THRESHOLD)
SStream_concat(O, "#0x%"PRIx64, val);
else
SStream_concat(O, "#%"PRIu64, val);
}

// print number
void printInt64(SStream *O, int64_t val)
{
Expand Down
2 changes: 2 additions & 0 deletions SStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void SStream_concat0(SStream *ss, char *s);

void printInt64Bang(SStream *O, int64_t val);

void printUInt64Bang(SStream *O, uint64_t val);

void printInt64(SStream *O, int64_t val);

void printInt32Bang(SStream *O, int32_t val);
Expand Down
5 changes: 3 additions & 2 deletions arch/AArch64/AArch64InstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,10 +1238,11 @@ static void printAlignedLabel(MCInst *MI, unsigned OpNum, SStream *O)
// If the label has already been resolved to an immediate offset (say, when
// we're running the disassembler), just print the immediate.
if (MCOperand_isImm(Op)) {
printInt64Bang(O, MCOperand_getImm(Op) << 2);
uint64_t imm = (MCOperand_getImm(Op) << 2) + MI->address;
printUInt64Bang(O, imm);
if (MI->csh->detail) {
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_IMM;
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = (int)MCOperand_getImm(Op) << 2;
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = imm;
MI->flat_insn->detail->arm64.op_count++;
}
return;
Expand Down

0 comments on commit 03a1836

Please sign in to comment.