diff --git a/ddprof-lib/src/main/cpp/signalCookie.cpp b/ddprof-lib/src/main/cpp/signalCookie.cpp new file mode 100644 index 000000000..8536270b2 --- /dev/null +++ b/ddprof-lib/src/main/cpp/signalCookie.cpp @@ -0,0 +1,17 @@ +#include "signalCookie.h" + +namespace SignalCookie { + namespace detail { + // Place tags in a named section on Linux to prevent LTO from merging + // or reordering them across TUs (their addresses must be unique per DSO). +#ifdef __linux__ + [[gnu::section(".data.signal_cookie")]] char cpu_tag; + [[gnu::section(".data.signal_cookie")]] char wallclock_tag; +#else + char cpu_tag; + char wallclock_tag; +#endif + } + void* cpu() { return &detail::cpu_tag; } + void* wallclock() { return &detail::wallclock_tag; } +} diff --git a/ddprof-lib/src/main/cpp/signalCookie.h b/ddprof-lib/src/main/cpp/signalCookie.h index c448680fa..8744307b0 100644 --- a/ddprof-lib/src/main/cpp/signalCookie.h +++ b/ddprof-lib/src/main/cpp/signalCookie.h @@ -21,19 +21,8 @@ // forged by an unrelated in-process sender without reading our symbols, and // never collide with legitimate user-space pointers in third-party code. namespace SignalCookie { - namespace detail { - // Place tags in a named section on Linux to prevent LTO from merging - // or reordering them across TUs (their addresses must be unique per DSO). -#ifdef __linux__ - [[gnu::section(".data.signal_cookie")]] inline char cpu_tag; - [[gnu::section(".data.signal_cookie")]] inline char wallclock_tag; -#else - inline char cpu_tag; - inline char wallclock_tag; -#endif - } - inline void* cpu() { return &detail::cpu_tag; } - inline void* wallclock() { return &detail::wallclock_tag; } + void* cpu(); + void* wallclock(); } #endif // SIGNAL_COOKIE_H