Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
return false;
}

bool isBRA(const MCInst &Inst) const {
return (Inst.getOpcode() == AArch64::BRAA ||
Inst.getOpcode() == AArch64::BRAB ||
Inst.getOpcode() == AArch64::BRAAZ ||
Inst.getOpcode() == AArch64::BRABZ);
}

bool mayLoad(const MCInst &Inst) const override {
return isLDRB(Inst) || isLDRH(Inst) || isLDRW(Inst) || isLDRX(Inst) ||
isLDRQ(Inst) || isLDRD(Inst) || isLDRS(Inst);
Expand Down Expand Up @@ -941,6 +948,11 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
DenseMap<const MCInst *, SmallVector<MCInst *, 4>> &UDChain,
const MCExpr *&JumpTable, int64_t &Offset, int64_t &ScaleValue,
MCInst *&PCRelBase) const {
// The only kind of indirect branches we match is jump table, thus ignore
// authenticating branch instructions early.
if (isBRA(Inst))
return false;

// Expect AArch64 BR
assert(Inst.getOpcode() == AArch64::BR && "Unexpected opcode");

Expand Down
23 changes: 22 additions & 1 deletion bolt/test/AArch64/test-indirect-branch.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// REQUIRES: system-linux, asserts

// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown -mattr=+pauth %s -o %t.o
// RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q
// RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --strict --debug-only=mcplus \
// RUN: -v=1 2>&1 | FileCheck %s
Expand Down Expand Up @@ -73,6 +73,27 @@ test2_0:
test2_1:
ret

// Make sure BOLT does not crash trying to disassemble BRA* instructions.
.globl test_braa
.type test_braa, %function
test_braa:
braa x0, x1

.globl test_brab
.type test_brab, %function
test_brab:
brab x0, x1

.globl test_braaz
.type test_braaz, %function
test_braaz:
braaz x0

.globl test_brabz
.type test_brabz, %function
test_brabz:
brabz x0

.section .rodata,"a",@progbits
datatable:
.word test1_0-datatable
Expand Down