This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Add __hwasan_init constructor to runtime lib.
ClosedPublic

Authored by hctim on Aug 3 2021, 12:54 PM.

Details

Summary

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.

Diff Detail

Event Timeline

hctim created this revision.Aug 3 2021, 12:54 PM
hctim requested review of this revision.Aug 3 2021, 12:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2021, 12:54 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
srhines added a subscriber: srhines.Aug 3 2021, 1:10 PM
yabinc accepted this revision.Aug 3 2021, 3:34 PM

LGTM. I have verified that it solves the problem of booting hwasan Android build.

This revision is now accepted and ready to land.Aug 3 2021, 3:34 PM
pcc accepted this revision.Aug 4 2021, 10:49 AM

LGTM

This revision was automatically updated to reflect the committed changes.