Skip to content

Commit 08bbdf1

Browse files
committed
Fix duplicated cookies
1 parent 4d58c25 commit 08bbdf1

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "signalCookie.h"
2+
3+
namespace SignalCookie {
4+
namespace detail {
5+
// Place tags in a named section on Linux to prevent LTO from merging
6+
// or reordering them across TUs (their addresses must be unique per DSO).
7+
#ifdef __linux__
8+
[[gnu::section(".data.signal_cookie")]] char cpu_tag;
9+
[[gnu::section(".data.signal_cookie")]] char wallclock_tag;
10+
#else
11+
char cpu_tag;
12+
char wallclock_tag;
13+
#endif
14+
}
15+
void* cpu() { return &detail::cpu_tag; }
16+
void* wallclock() { return &detail::wallclock_tag; }
17+
}

ddprof-lib/src/main/cpp/signalCookie.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,8 @@
2121
// forged by an unrelated in-process sender without reading our symbols, and
2222
// never collide with legitimate user-space pointers in third-party code.
2323
namespace SignalCookie {
24-
namespace detail {
25-
// Place tags in a named section on Linux to prevent LTO from merging
26-
// or reordering them across TUs (their addresses must be unique per DSO).
27-
#ifdef __linux__
28-
[[gnu::section(".data.signal_cookie")]] inline char cpu_tag;
29-
[[gnu::section(".data.signal_cookie")]] inline char wallclock_tag;
30-
#else
31-
inline char cpu_tag;
32-
inline char wallclock_tag;
33-
#endif
34-
}
35-
inline void* cpu() { return &detail::cpu_tag; }
36-
inline void* wallclock() { return &detail::wallclock_tag; }
24+
void* cpu();
25+
void* wallclock();
3726
}
3827

3928
#endif // SIGNAL_COOKIE_H

0 commit comments

Comments
 (0)