-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[BOLT] Gadget scanner: factor out utility code #131895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
atrosinenko
merged 3 commits into
main
from
users/atrosinenko/bolt-gs-factor-out-utility-code
Mar 20, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
bolt/test/binary-analysis/AArch64/gs-pauth-debug-output.s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// REQUIRES: asserts | ||
// | ||
// RUN: %clang %cflags -march=armv8.3-a %s -o %t.exe | ||
// RUN: llvm-bolt-binary-analysis --scanners=pacret -no-threads \ | ||
// RUN: -debug-only bolt-nonpacprotectedret %t.exe 2>&1 | FileCheck %s | ||
|
||
// Check the debug output generated by PAuth gadget scanner to make sure the | ||
// that output is kept meaningful and to provide an overview of what happens | ||
// inside the scanner. | ||
|
||
.globl simple | ||
.type simple,@function | ||
simple: | ||
paciasp | ||
b 1f | ||
1: | ||
autiasp | ||
ret | ||
.size simple, .-simple | ||
|
||
// CHECK-LABEL:Analyzing in function simple, AllocatorId 1 | ||
// CHECK-NEXT: Binary Function "simple" { | ||
// CHECK-NEXT: Number : 1 | ||
// CHECK-NEXT: State : CFG constructed | ||
// ... | ||
// CHECK: BB Layout : [[BB0:[0-9a-zA-Z.]+]], [[BB1:[0-9a-zA-Z.]+]] | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: [[BB0]] (2 instructions, align : 1) | ||
// CHECK-NEXT: Entry Point | ||
// CHECK-NEXT: 00000000: paciasp | ||
// CHECK-NEXT: 00000004: b [[BB1]] | ||
// CHECK-NEXT: Successors: [[BB1]] | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: [[BB1]] (2 instructions, align : 1) | ||
// CHECK-NEXT: Predecessors: [[BB0]] | ||
// CHECK-NEXT: 00000008: autiasp | ||
// CHECK-NEXT: 0000000c: ret | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: DWARF CFI Instructions: | ||
// CHECK-NEXT: <empty> | ||
// CHECK-NEXT: End of Function "simple" | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( hint #25, pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: >) | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( b [[BB1]], pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: >) | ||
// CHECK-NEXT: PacRetAnalysis::Confluence( | ||
// CHECK-NEXT: State 1: pacret-state<NonAutClobRegs: , Insts: > | ||
// CHECK-NEXT: State 2: pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: >) | ||
// CHECK-NEXT: merged state: pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: > | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( hint #29, pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( ret x30, pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: PacRetAnalysis::Confluence( | ||
// CHECK-NEXT: State 1: pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: > | ||
// CHECK-NEXT: State 2: pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: >) | ||
// CHECK-NEXT: merged state: pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: > | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( hint #29, pacret-state<NonAutClobRegs: LR W30 W30_HI , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( ret x30, pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: After PacRetAnalysis: | ||
// CHECK-NEXT: Binary Function "simple" { | ||
// CHECK-NEXT: Number : 1 | ||
// CHECK-NEXT: State : CFG constructed | ||
// ... | ||
// CHECK: BB Layout : [[BB0]], [[BB1]] | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: [[BB0]] (2 instructions, align : 1) | ||
// CHECK-NEXT: Entry Point | ||
// CHECK-NEXT: 00000000: paciasp # PacRetAnalysis: pacret-state<NonAutClobRegs: BitVector, Insts: > | ||
// CHECK-NEXT: 00000004: b [[BB1]] # PacRetAnalysis: pacret-state<NonAutClobRegs: BitVector, Insts: > | ||
// CHECK-NEXT: Successors: [[BB1]] | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: [[BB1]] (2 instructions, align : 1) | ||
// CHECK-NEXT: Predecessors: [[BB0]] | ||
// CHECK-NEXT: 00000008: autiasp # PacRetAnalysis: pacret-state<NonAutClobRegs: BitVector, Insts: > | ||
// CHECK-NEXT: 0000000c: ret # PacRetAnalysis: pacret-state<NonAutClobRegs: BitVector, Insts: > | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: DWARF CFI Instructions: | ||
// CHECK-NEXT: <empty> | ||
// CHECK-NEXT: End of Function "simple" | ||
// CHECK-EMPTY: | ||
// CHECK-NEXT: Found RET inst: 00000000: ret # PacRetAnalysis: pacret-state<NonAutClobRegs: BitVector, Insts: > | ||
// CHECK-NEXT: RetReg: LR | ||
// CHECK-NEXT: Authenticated reg: (none) | ||
// CHECK-NEXT: NonAutClobRegs at Ret:{{[ \t]*$}} | ||
// CHECK-NEXT: Intersection with RetReg:{{[ \t]*$}} | ||
|
||
.globl clobber | ||
.type clobber,@function | ||
clobber: | ||
mov w30, #0 | ||
ret | ||
.size clobber, .-clobber | ||
|
||
// CHECK-LABEL:Analyzing in function clobber, AllocatorId 1 | ||
// ... | ||
// CHECK: PacRetAnalysis::ComputeNext( mov w30, #0x0, pacret-state<NonAutClobRegs: , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: W30 , Insts: >) | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( ret x30, pacret-state<NonAutClobRegs: W30 , Insts: >) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: W30 , Insts: >) | ||
// CHECK-NEXT: After PacRetAnalysis: | ||
// CHECK-NEXT: Binary Function "clobber" { | ||
// ... | ||
// CHECK: End of Function "clobber" | ||
|
||
// The above output was printed after first run of analysis | ||
|
||
// CHECK-EMPTY: | ||
// CHECK-NEXT: Found RET inst: 00000000: ret # PacRetAnalysis: pacret-state<NonAutClobRegs: BitVector, Insts: > | ||
// CHECK-NEXT: RetReg: LR | ||
// CHECK-NEXT: Authenticated reg: (none) | ||
// CHECK-NEXT: NonAutClobRegs at Ret: W30 | ||
// CHECK-NEXT: Intersection with RetReg: W30 | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( mov w30, #0x0, pacret-state<NonAutClobRegs: , Insts: [0]()>) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: W30 , Insts: [0](0x{{[0-9a-f]+}} )>) | ||
// CHECK-NEXT: PacRetAnalysis::ComputeNext( ret x30, pacret-state<NonAutClobRegs: W30 , Insts: [0](0x{{[0-9a-f]+}} )>) | ||
// CHECK-NEXT: .. result: (pacret-state<NonAutClobRegs: W30 , Insts: [0](0x{{[0-9a-f]+}} )>) | ||
// CHECK-NEXT: After PacRetAnalysis: | ||
// CHECK-NEXT: Binary Function "clobber" { | ||
// ... | ||
// CHECK: End of Function "clobber" | ||
|
||
// The analysis was re-computed with register tracking, as an issue was found in this function. | ||
// Re-checking the instructions: | ||
|
||
// CHECK-EMPTY: | ||
// CHECK-NEXT: Found RET inst: 00000000: ret # PacRetAnalysis: pacret-state<NonAutClobRegs: BitVector, Insts: [0](0x{{[0-9a-f]+}} )> | ||
// CHECK-NEXT: RetReg: LR | ||
// CHECK-NEXT: Authenticated reg: (none) | ||
// CHECK-NEXT: NonAutClobRegs at Ret: W30 | ||
// CHECK-NEXT: Intersection with RetReg: W30 | ||
|
||
|
||
// CHECK-LABEL:Analyzing in function main, AllocatorId 1 | ||
.globl main | ||
.type main,@function | ||
main: | ||
ret | ||
.size main, .-main |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.