This is an archive of the discontinued LLVM Phabricator instance.

SanitizerCoverage: Support sanitizer guard section on darwin
ClosedPublic

Authored by bogner on Jan 31 2017, 3:36 PM.

Details

Summary

MachO's sections need a segment as well as a section name, and the section start and end symbols are spelled differently than on ELF.

Diff Detail

Event Timeline

bogner created this revision.Jan 31 2017, 3:36 PM
kcc added inline comments.Jan 31 2017, 3:39 PM
lib/Transforms/Instrumentation/SanitizerCoverage.cpp
141

no macros please.

kubamracek edited edge metadata.Jan 31 2017, 3:51 PM

Looks sane. Can you please re-upload the patch with more context?

Agree with @kcc, I don't think we need the prefix abstraction macro and we can just have strings with the full section/symbol name. E.g. in AddressSanitizer.cpp we have:

StringRef AddressSanitizerModule::getGlobalMetadataSection() const {
  switch (TargetTriple.getObjectFormat()) {
  case Triple::COFF:  return ".ASAN$GL";
  case Triple::ELF:   return "asan_globals";
  case Triple::MachO: return "__DATA,__asan_globals,regular";
  default: break;
  }
  llvm_unreachable("unsupported object format");
}
bogner updated this revision to Diff 86525.Jan 31 2017, 4:57 PM

Get rid of the pointless string-abstraction macro. As Kostya and Kuba pointed out, it isn't really doing anything (and it's actually longer than just writing out the string).

Also note we'll need to un-xfail a test in compiler-rt when this is committed:

diff --git a/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc b/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc
index 1b787f143..e54993c5a 100644

  • a/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc

+++ b/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc
@@ -1,7 +1,7 @@
Tests trace pc guard coverage collection.

REQUIRES: has_sancovcc,stable-runtime
-
XFAIL: tsan,darwin,powerpc64,s390x
+ XFAIL: tsan,powerpc64,s390x

RUN: DIR=%t_workdir
RUN: rm -rf $DIR

kcc accepted this revision.Jan 31 2017, 5:01 PM

LGTM

This revision is now accepted and ready to land.Jan 31 2017, 5:01 PM
bogner closed this revision.Jan 31 2017, 6:51 PM

Committed in r293733, and the compiler-rt test update is r293734