File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ Error BinaryFunctionPassManager::runPasses() {
352
352
Error BinaryFunctionPassManager::runAllPasses (BinaryContext &BC) {
353
353
BinaryFunctionPassManager Manager (BC);
354
354
355
- if (BC.isAArch64 ())
355
+ if (BC.isAArch64 () && AllowPacret )
356
356
Manager.registerPass (std::make_unique<MarkRAStates>());
357
357
358
358
Manager.registerPass (
@@ -515,7 +515,8 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
515
515
// relocations out of range and crash during linking.
516
516
Manager.registerPass (std::make_unique<LongJmpPass>(PrintLongJmp));
517
517
518
- Manager.registerPass (std::make_unique<InsertNegateRAState>());
518
+ if (AllowPacret)
519
+ Manager.registerPass (std::make_unique<InsertNegateRAState>());
519
520
}
520
521
521
522
// This pass should always run last.*
Original file line number Diff line number Diff line change
1
+ // This test checks that BOLT refuses to optimize binaries
2
+ // compiled with -mbranch-protection=pac-ret, unless the
3
+ // --allow-experimental-pacret flag is set.
4
+
5
+ // REQUIRES: system-linux,bolt-runtime
6
+ // RUN: %clangxx --target=aarch64-unknown-linux-gnu \
7
+ // RUN: -mbranch-protection=pac-ret -Wl,-q %s -o %t.exe
8
+ // RUN: not --crash llvm-bolt %t.exe -o %t.bolt.exe 2>&1 | FileCheck %s
9
+
10
+ // CHECK: BOLT-ERROR: set --allow-experimental-pacret to allow processing
11
+
12
+ extern " C" int printf (const char *, ...);
13
+
14
+ void bar () { throw 10 ; }
15
+
16
+ void foo () {
17
+ try {
18
+ bar ();
19
+ } catch (int e) {
20
+ printf (" Exception caught: %d\n " , e);
21
+ }
22
+ }
23
+
24
+ int main () {
25
+ foo ();
26
+ return 0 ;
27
+ }
Original file line number Diff line number Diff line change 1
1
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
2
2
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
3
- # RUN: llvm-bolt %t.exe -o %t.exe.bolt | FileCheck %s
3
+ # RUN: llvm-bolt %t.exe -o %t.exe.bolt --allow-experimental-pacret \
4
+ # RUN: | FileCheck %s
4
5
5
6
# check that the output is listing foo as incorrect
6
7
# CHECK: BOLT-INFO: inconsistent RAStates in function foo
You can’t perform that action at this time.
0 commit comments