This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] add stack frame descriptions.
ClosedPublic

Authored by kcc on Oct 12 2018, 4:37 PM.

Details

Summary

At compile-time, create an array of {PC,HumanReadableStackFrameDescription}
for every function that has an instrumented frame, and pass this array
to the run-time at the module-init time.
Similar to how we handle pc-table in SanitizerCoverage.
The run-time is dummy, will add the actual logic in later commits.

Diff Detail

Repository
rL LLVM

Event Timeline

kcc created this revision.Oct 12 2018, 4:37 PM
eugenis added inline comments.Oct 12 2018, 5:38 PM
lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
151 ↗(On Diff #169518)

s/_/-

217 ↗(On Diff #169518)

"fd" usually stands for file descriptor
Rename to __hwasan_frames?

319 ↗(On Diff #169518)

This section should be read-only so the (intrusive) linked list idea would not work.

I don't think this slot helps you avoid a module pass. You can create a call to __hwasan_init_fd regardless.

You are inserting multiple calls to __hwasan_init_fd to the ctor function. Just one would be enough.

Ctor function should be comdat'ed itself, but that's orthogonal.

742 ↗(On Diff #169518)

Why would F's name start with "hwasan"? Did you mean "__hwasan"?

kcc updated this revision to Diff 169529.Oct 12 2018, 6:00 PM

addressed review comments

lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
151 ↗(On Diff #169518)

done.

217 ↗(On Diff #169518)

renamed the section to hwasan_frames and the callback to hwasan_init_frames

319 ↗(On Diff #169518)

Ok, won't use the (intrusive) linked list.

You are inserting multiple calls to __hwasan_init_fd to the ctor function.

Nope. This code is in HWAddressSanitizer::doInitialization(Module &M)

Ctor function should be comdat'ed itself, but that's orthogonal.

Yep, will do separately.

742 ↗(On Diff #169518)

No, this one is for the CTOR (HwasanCtorFunction above)

morehouse added inline comments.Oct 17 2018, 10:32 AM
lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
318 ↗(On Diff #169529)

Why do we need a frame description for the ctor in order to call it?

kcc added inline comments.Oct 19 2018, 2:14 PM
lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
318 ↗(On Diff #169529)

We don't.
This call is here to ensure that the section is not empty and that we can create __start_SECTION for it.
Otherwise, we will need to refactor the code to make it a ModulePass instead of a FunctionPass (which is unwelcome).
I don't know any other way to handle this in a FunctionPass. :(

eugenis added inline comments.Oct 22 2018, 4:28 PM
lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
742 ↗(On Diff #169518)

Why not compare F with HwasanCtorFunction?

kcc updated this revision to Diff 170533.Oct 22 2018, 5:25 PM

address one more comment

lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
742 ↗(On Diff #169518)

Yep, done.

eugenis accepted this revision.Oct 22 2018, 5:36 PM

Please rename the remaining FD's.
LGTM then.

This revision is now accepted and ready to land.Oct 22 2018, 5:36 PM
This revision was automatically updated to reflect the committed changes.