[hwasan] Add __hwasan_init constructor to runtime lib.
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Wed, 4 Aug 2021 18:03:24 +0000 (11:03 -0700)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Wed, 4 Aug 2021 18:18:23 +0000 (11:18 -0700)
commit0ebb75608759cc1ee1016699e15d03e8e3f30d14
treeef88a27690e6b8bc051d077bd8f07ba565187a60
parent440d9712ebf6d5faa898daa68045ff0c10859db3
[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
compiler-rt/lib/hwasan/hwasan.cpp