| 1 | #include <stdint.h> |
|---|---|
| 2 | |
| 3 | void foo(void) {} |
| 4 | typedef void (*FooPtr)(void); |
| 5 | |
| 6 | int main() { |
| 7 | FooPtr fnptr = foo; |
| 8 | // Set top byte. |
| 9 | fnptr = (FooPtr)((uintptr_t)fnptr | (uintptr_t)0xff << 56); |
| 10 | // Then apply a PAuth signature to it. |
| 11 | __asm__ __volatile__("pacdza %0": "=r"(fnptr) : "r"(fnptr)); |
| 12 | // fnptr is now: |
| 13 | // <8 bit top byte tag><pointer signature><virtual address> |
| 14 | |
| 15 | foo(); // Set break point at this line. |
| 16 | |
| 17 | return 0; |
| 18 | } |
| 19 |
