This is an archive of the discontinued LLVM Phabricator instance.

[ASan] Introduce a flag -asan-constructor-kind to control the generation of the Asan module constructor.
ClosedPublic

Authored by usama54321 on Jan 24 2023, 2:00 PM.

Details

Summary

By default, ASan generates an asan.module_ctor function that initializes asan and
registers the globals in the module. This function is added to the
@llvm.global_ctors array. Previously, there was no way to control the
generation of this function.

This patch adds a way to control the generation of this function. The
flag -asan-constructor-kind has two options:

global: This is the default option and the default behavior of ASan. It generates an
asan.module_ctor function.
none: This skips the generation of the asan.module_ctor function.

rdar://104448572

Diff Detail

Event Timeline

usama54321 created this revision.Jan 24 2023, 2:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2023, 2:00 PM

Removing unnecessary lint changes

usama54321 published this revision for review.Jan 24 2023, 2:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2023, 2:05 PM

Minor bugfix

minor typo fix in comments

vitalybuka added inline comments.Jan 24 2023, 2:28 PM
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
355

why it's about destructors?

2480

Can you do something like this?

What is the point of instrumenting globals without constructors?

usama54321 added inline comments.Jan 24 2023, 2:47 PM
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
355

Ah that is a typo

2480

We will be calling asan_init and registering globals manually. I will refactor this

minor refactoring

usama54321 marked 2 inline comments as done.Jan 24 2023, 3:11 PM
vitalybuka accepted this revision.Jan 24 2023, 3:19 PM
This revision is now accepted and ready to land.Jan 24 2023, 3:19 PM
yln accepted this revision.Jan 24 2023, 3:32 PM
This revision was landed with ongoing or failed builds.Jan 24 2023, 3:37 PM
This revision was automatically updated to reflect the committed changes.