Skip to content

Commit 0ebb756

Browse files
committed
[hwasan] Add __hwasan_init constructor to runtime lib.
Found by an Android toolchain upgrade, inherited module constructors (like init_have_lse_atomics from the builtins) can sneak into the hwasan runtime. If these inherited constructors call hwasanified libc functions, then the HWASan runtime isn't setup enough, and the code crashes. Mark the initialized as a high-priority initializer to fix this. Reviewed By: pcc, yabinc Differential Revision: https://reviews.llvm.org/D107391
1 parent 440d971 commit 0ebb756

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler-rt/lib/hwasan/hwasan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void __hwasan_init_static() {
319319
InitializeSingleGlobal(global);
320320
}
321321

322-
void __hwasan_init() {
322+
__attribute__((constructor(0))) void __hwasan_init() {
323323
CHECK(!hwasan_init_is_running);
324324
if (hwasan_inited) return;
325325
hwasan_init_is_running = 1;

0 commit comments

Comments
 (0)