This is an archive of the discontinued LLVM Phabricator instance.

[asan] Add OS X 10.11's new dyld interposition support
ClosedPublic

Authored by kubamracek on Jul 3 2015, 6:22 AM.

Details

Reviewers
glider
samsonov
Summary

On OS X 10.11 (which is currently a public beta), the dynamic linker has been improved so that it doesn't require the use of DYLD_INSERT_LIBRARIES in order for interposition/wrappers to work. This patch adds support of this behavior into ASan – we no longer need to re-exec in case the env. variable is not set.

Since on older OS versions (10.10 and lower) we still need to keep the old behavior, this patch adds a runtime check for the OS version via GetMacosVersion. This turns out to be a little more complicated for the iOS Simulator, where this method reports the host's version and not the simulator's. Proper version checking via iOS system API is problematic to do this early in the process runtime. Instead, the patch contains a hack that checks presence of a symbol which is known to be available only on the newer system.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 29012.Jul 3 2015, 6:22 AM
kubamracek retitled this revision from to [asan] Add OS X 10.11's new dyld interposition support.
kubamracek updated this object.
kubamracek added reviewers: samsonov, glider.
kubamracek added subscribers: glider, samsonov.
samsonov accepted this revision.Jul 6 2015, 9:31 AM
samsonov edited edge metadata.
samsonov added a subscriber: llvm-commits.

LGTM

This revision is now accepted and ready to land.Jul 6 2015, 9:33 AM
kubamracek closed this revision.Jul 7 2015, 2:21 AM

Landed in r241487.

glider edited edge metadata.Jul 7 2015, 2:27 AM

LGTM, sorry for the delay.

lib/asan/asan_mac.cc
104

This is great.

test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc
15

Don't we run Darwin tests on the iOS simulator?

kubamracek added inline comments.Jul 7 2015, 2:34 AM
test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc
15

I'm not aware of that. I don't think there is any easy (documented) way to execute command-line programs in iOS simulator.