Skip to content

Commit 2faf8ef

Browse files
Refactored, improved test, and addressed reviewers.
1 parent 7719e07 commit 2faf8ef

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,10 @@ class MCPlusBuilder {
20342034
return InstructionListType();
20352035
}
20362036

2037-
virtual InstructionListType createDummyReturnFunction(MCContext *Ctx) const {
2037+
/// Returns a function body that contains only a return instruction. An
2038+
/// example usage is a workaround for the '__bolt_fini_trampoline' of
2039+
// Instrumentation.
2040+
virtual InstructionListType createDummyReturn(MCContext *Ctx) const {
20382041
llvm_unreachable("not implemented");
20392042
return InstructionListType();
20402043
}

bolt/lib/Passes/Instrumentation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ void Instrumentation::createAuxiliaryFunctions(BinaryContext &BC) {
755755
// with unknown symbol in runtime library. E.g. for static PIE
756756
// executable
757757
createSimpleFunction("__bolt_fini_trampoline",
758-
BC.MIB->createDummyReturnFunction(BC.Ctx.get()));
758+
BC.MIB->createDummyReturn(BC.Ctx.get()));
759759
}
760760
}
761761
}

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
16071607
return Instrs;
16081608
}
16091609

1610-
InstructionListType createDummyReturnFunction(MCContext *Ctx) const override {
1610+
InstructionListType createDummyReturn(MCContext *Ctx) const override {
16111611
InstructionListType Insts(1);
16121612
createReturn(Insts[0]);
16131613
return Insts;

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3271,7 +3271,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
32713271
return Insts;
32723272
}
32733273

3274-
InstructionListType createDummyReturnFunction(MCContext *Ctx) const override {
3274+
InstructionListType createDummyReturn(MCContext *Ctx) const override {
32753275
InstructionListType Insts(1);
32763276
createReturn(Insts[0]);
32773277
return Insts;

bolt/test/AArch64/dummy-return.test

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
// Tests that AArch64 is able to instrument static binaries in relocation mode.
1+
// Tests that AArch64 is able to instrument static binaries in relocation mode,
2+
// by checking that '__bolt_fini_trampoline' is generated and contains a 'ret'
3+
// instruction.
24

35
REQUIRES: system-linux
46

57
RUN: %clang %p/../Inputs/main.c -o %t -Wl,-q -static
68
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
9+
RUN: llvm-objdump --disassemble-symbols=__bolt_fini_trampoline %t.instr -D | FileCheck %s -check-prefix=CHECK-ASM
810

911
CHECK: BOLT-INFO: output linked against instrumentation runtime library
10-
CHECK-SYM: __bolt_fini_trampoline
12+
CHECK-ASM: <__bolt_fini_trampoline>:
13+
CHECK-ASM-NEXT: ret

bolt/test/Inputs/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// dummy function just for emitting relocations to the linker.
1+
// dummy function just for emitting relocations to the linker.
22
int foo() { return 0; }
33
int main(int argc, char **argv) { return foo() + 1; }

0 commit comments

Comments
 (0)