Skip to content

Commit 7719e07

Browse files
[BOLT][AArch64] Implemented createDummyReturnFunction.
On AArch64, this method is needed when trying to instrument a static binary. Sample commands: ```bash clang -Wl,-q test.c -static -o out llvm-bolt -instrument -instrumentation-sleep-time=5 out -o out.instr ```
1 parent a0796e6 commit 7719e07

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,12 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
16071607
return Instrs;
16081608
}
16091609

1610+
InstructionListType createDummyReturnFunction(MCContext *Ctx) const override {
1611+
InstructionListType Insts(1);
1612+
createReturn(Insts[0]);
1613+
return Insts;
1614+
}
1615+
16101616
std::vector<MCInst> createSymbolTrampoline(const MCSymbol *TgtSym,
16111617
MCContext *Ctx) override {
16121618
std::vector<MCInst> Insts;

bolt/test/AArch64/dummy-return.test

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
// Tests that AArch64 is able to instrument static binaries in relocation mode.
2+
13
REQUIRES: system-linux
24

35
RUN: %clang %p/../Inputs/main.c -o %t -Wl,-q -static
4-
RUN: not llvm-bolt -instrument -instrumentation-sleep-time=1 %t -o %t.instr 2>&1 | FileCheck %s
6+
RUN: llvm-bolt -instrument -instrumentation-sleep-time=1 %t -o %t.instr 2>&1 | FileCheck %s
7+
RUN: llvm-nm -n %t.instr | FileCheck %s -check-prefix=CHECK-SYM
58

6-
CHECK: not implemented
9+
CHECK: BOLT-INFO: output linked against instrumentation runtime library
10+
CHECK-SYM: __bolt_fini_trampoline

0 commit comments

Comments
 (0)