at commit 19ed235c
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _LINUX_INSTRUCTION_POINTER_H |
| 3 | #define _LINUX_INSTRUCTION_POINTER_H |
| 4 | |
| 5 | #include <asm/linkage.h> |
| 6 | |
| 7 | #define _RET_IP_ (unsigned long)__builtin_return_address(0) |
| 8 | |
| 9 | #ifndef _THIS_IP_ |
| 10 | #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) |
| 11 | /* |
| 12 | * The current generic definition of _THIS_IP_ is considered broken by GCC [1] |
| 13 | * and Clang [2]. In particular, the address of a label is only expected to be |
| 14 | * used with a computed goto. |
| 15 | * |
| 16 | * [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120071 |
| 17 | * [2] https://github.com/llvm/llvm-project/issues/138272 |
| 18 | * |
| 19 | * Mark it as broken, so that appropriate fallback options can be implemented |
| 20 | * for architectures that do not define their own _THIS_IP_. |
| 21 | */ |
| 22 | #define HAS_BROKEN_THIS_IP |
| 23 | #endif |
| 24 | |
| 25 | /* |
| 26 | * _CODE_LOCATION_ provides a unique identifier for the current code location. |
| 27 | * When _THIS_IP_ is broken (generic version), we fall back to a static marker |
| 28 | * which guarantees uniqueness and resolves to a constant address at link time, |
| 29 | * avoiding runtime overhead and compiler optimizations breaking it. |
| 30 | */ |
| 31 | #ifdef HAS_BROKEN_THIS_IP |
| 32 | #define _CODE_LOCATION_ ({ static const char __here; (unsigned long)&__here; }) |
| 33 | #else |
| 34 | #define _CODE_LOCATION_ _THIS_IP_ |
| 35 | #endif |
| 36 | |
| 37 | #endif /* _LINUX_INSTRUCTION_POINTER_H */ |