File tree 6 files changed +46
-9
lines changed 6 files changed +46
-9
lines changed Original file line number Diff line number Diff line change @@ -1426,11 +1426,12 @@ class MCPlusBuilder {
1426
1426
}
1427
1427
1428
1428
// / Creates an indirect call to the function within the \p DirectCall PLT
1429
- // / stub. The function's memory location is pointed by the \p TargetLocation
1429
+ // / stub. The function's address location is pointed by the \p TargetLocation
1430
1430
// / symbol.
1431
+ // / Move instruction annotations from \p DirectCall to the indirect call.
1431
1432
virtual InstructionListType
1432
- createIndirectPltCall ( const MCInst &DirectCall,
1433
- const MCSymbol *TargetLocation, MCContext *Ctx) {
1433
+ createIndirectPLTCall ( MCInst && DirectCall, const MCSymbol *TargetLocation ,
1434
+ MCContext *Ctx) {
1434
1435
llvm_unreachable (" not implemented" );
1435
1436
return {};
1436
1437
}
Original file line number Diff line number Diff line change @@ -70,8 +70,8 @@ Error PLTCall::runOnFunctions(BinaryContext &BC) {
70
70
const BinaryFunction *CalleeBF = BC.getFunctionForSymbol (CallSymbol);
71
71
if (!CalleeBF || !CalleeBF->isPLTFunction ())
72
72
continue ;
73
- const InstructionListType NewCode = BC.MIB ->createIndirectPltCall (
74
- *II, CalleeBF->getPLTSymbol (), BC.Ctx .get ());
73
+ const InstructionListType NewCode = BC.MIB ->createIndirectPLTCall (
74
+ std::move ( *II) , CalleeBF->getPLTSymbol (), BC.Ctx .get ());
75
75
II = BB.replaceInstruction (II, NewCode);
76
76
assert (!NewCode.empty () && " PLT Call replacement must be non-empty" );
77
77
std::advance (II, NewCode.size () - 1 );
Original file line number Diff line number Diff line change @@ -1263,7 +1263,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
1263
1263
return true ;
1264
1264
}
1265
1265
1266
- InstructionListType createIndirectPltCall ( const MCInst &DirectCall,
1266
+ InstructionListType createIndirectPLTCall ( MCInst & &DirectCall,
1267
1267
const MCSymbol *TargetLocation,
1268
1268
MCContext *Ctx) override {
1269
1269
const bool IsTailCall = isTailCall (DirectCall);
@@ -1297,8 +1297,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
1297
1297
MCInst InstCall;
1298
1298
InstCall.setOpcode (IsTailCall ? AArch64::BR : AArch64::BLR);
1299
1299
InstCall.addOperand (MCOperand::createReg (AArch64::X17));
1300
- if (IsTailCall)
1301
- setTailCall (InstCall);
1300
+ moveAnnotations (std::move (DirectCall), InstCall);
1302
1301
Code.emplace_back (InstCall);
1303
1302
1304
1303
return Code;
Original file line number Diff line number Diff line change @@ -1605,7 +1605,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
1605
1605
return true ;
1606
1606
}
1607
1607
1608
- InstructionListType createIndirectPltCall ( const MCInst &DirectCall,
1608
+ InstructionListType createIndirectPLTCall ( MCInst & &DirectCall,
1609
1609
const MCSymbol *TargetLocation,
1610
1610
MCContext *Ctx) override {
1611
1611
assert ((DirectCall.getOpcode () == X86::CALL64pcrel32 ||
Original file line number Diff line number Diff line change
1
+ // Verify that PLT optimization in BOLT preserves exception-handling info.
2
+
3
+ // REQUIRES: system-linux
4
+
5
+ // RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s -o %t.exe
6
+ // RUN: llvm-bolt %t.exe -o %t.bolt.exe --plt=all --print-only=.*main.* \
7
+ // RUN: --print-finalized 2>&1 | FileCheck %s
8
+
9
+ // CHECK-LABEL: Binary Function
10
+ // CHECK: adrp {{.*}}__cxa_throw
11
+ // CHECK-NEXT: ldr {{.*}}__cxa_throw
12
+ // CHECK-NEXT: blr x17 {{.*}} handler: {{.*}} PLTCall:
13
+
14
+ int main () {
15
+ try {
16
+ throw new int ;
17
+ } catch (...) {
18
+ return 0 ;
19
+ }
20
+ return 1 ;
21
+ }
Original file line number Diff line number Diff line change
1
+ // Verify that PLT optimization in BOLT preserves exception-handling info.
2
+
3
+ // REQUIRES: system-linux
4
+
5
+ // RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s -o %t.exe
6
+ // RUN: llvm-bolt %t.exe -o %t.bolt.exe --plt=all
7
+ // RUN: %t.bolt.exe
8
+
9
+ int main () {
10
+ try {
11
+ throw new int ;
12
+ } catch (...) {
13
+ return 0 ;
14
+ }
15
+ return 1 ;
16
+ }
You can’t perform that action at this time.
0 commit comments