[sanitizer] Remove empty Symbolizer PrepareForSandboxing

Summary:
`Symbolizer::PrepareForSandboxing` is empty for all platforms and apparently
has been for a while (D10213). Remove it, and shuffle things around so that the
platform specific code is now in `PlatformPrepareForSandboxing`.

This allows to have one less symbolizer dependency in a common file, which
helps for the upcoming split.

Also remove `SymbolizerPrepareForSandboxing` in tsan_go which appears to not
be used anywhere.

Reviewers: alekseyshl, eugenis, dvyukov, mcgrathr

Reviewed By: alekseyshl

Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D44953

llvm-svn: 329094
This commit is contained in:
Kostya Kortchinsky 2018-04-03 18:07:22 +00:00
parent 4fad76ccde
commit 2c5f944015
10 changed files with 10 additions and 38 deletions

View File

@ -281,7 +281,7 @@ void SetStackSizeLimitInBytes(uptr limit);
bool AddressSpaceIsUnlimited();
void SetAddressSpaceUnlimited();
void AdjustStackSize(void *attr);
void PrepareForSandboxing(__sanitizer_sandbox_arguments *args);
void PlatformPrepareForSandboxing(__sanitizer_sandbox_arguments *args);
void SetSandboxingCallback(void (*f)());
void InitializeCoverage(bool enabled, const char *coverage_dir);

View File

@ -59,11 +59,6 @@ bool ColorizeReports() {
(internal_strcmp(flag, "auto") == 0 && ReportSupportsColors());
}
static void (*sandboxing_callback)();
void SetSandboxingCallback(void (*f)()) {
sandboxing_callback = f;
}
void ReportErrorSummary(const char *error_type, const StackTrace *stack,
const char *alt_tool_name) {
#if !SANITIZER_GO
@ -369,11 +364,16 @@ void ScopedErrorReportLock::CheckLocked() {
CommonSanitizerReportMutex.CheckLocked();
}
static void (*sandboxing_callback)();
void SetSandboxingCallback(void (*f)()) {
sandboxing_callback = f;
}
} // namespace __sanitizer
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_sandbox_on_notify,
__sanitizer_sandbox_arguments *args) {
__sanitizer::PrepareForSandboxing(args);
__sanitizer::PlatformPrepareForSandboxing(args);
if (__sanitizer::sandboxing_callback)
__sanitizer::sandboxing_callback();
}

View File

@ -89,7 +89,7 @@ void GetThreadStackTopAndBottom(bool, uptr *stack_top, uptr *stack_bottom) {
}
void MaybeReexec() {}
void PrepareForSandboxing(__sanitizer_sandbox_arguments *args) {}
void PlatformPrepareForSandboxing(__sanitizer_sandbox_arguments *args) {}
void DisableCoreDumperIfNecessary() {}
void InstallDeadlySignalHandlers(SignalHandlerType handler) {}
void StartReportDeadlySignal() {}

View File

@ -24,8 +24,6 @@
#include "sanitizer_platform_limits_solaris.h"
#include "sanitizer_posix.h"
#include "sanitizer_procmaps.h"
#include "sanitizer_stacktrace.h"
#include "sanitizer_symbolizer.h"
#include <errno.h>
#include <fcntl.h>
@ -292,16 +290,12 @@ bool IsAccessibleMemoryRange(uptr beg, uptr size) {
return result;
}
void PrepareForSandboxing(__sanitizer_sandbox_arguments *args) {
void PlatformPrepareForSandboxing(__sanitizer_sandbox_arguments *args) {
// Some kinds of sandboxes may forbid filesystem access, so we won't be able
// to read the file mappings from /proc/self/maps. Luckily, neither the
// process will be able to load additional libraries, so it's fine to use the
// cached mappings.
MemoryMappingLayout::CacheMemoryMappings();
// Same for /proc/self/exe in the symbolizer.
#if !SANITIZER_GO
Symbolizer::GetOrInit()->PrepareForSandboxing();
#endif
}
#if SANITIZER_ANDROID || SANITIZER_GO

View File

@ -107,7 +107,6 @@ class Symbolizer final {
void Flush();
// Attempts to demangle the provided C++ mangled name.
const char *Demangle(const char *name);
void PrepareForSandboxing();
// Allow user to install hooks that would be called before/after Symbolizer
// does the actual file/line info fetching. Specific sanitizers may need this
@ -158,7 +157,6 @@ class Symbolizer final {
// Platform-specific default demangler, must not return nullptr.
const char *PlatformDemangle(const char *name);
void PlatformPrepareForSandboxing();
static Symbolizer *symbolizer_;
static StaticSpinMutex init_mu_;

View File

@ -145,11 +145,6 @@ const char *Symbolizer::Demangle(const char *name) {
return PlatformDemangle(name);
}
void Symbolizer::PrepareForSandboxing() {
BlockingMutexLock l(&mu_);
PlatformPrepareForSandboxing();
}
bool Symbolizer::FindModuleNameAndOffsetForAddress(uptr address,
const char **module_name,
uptr *module_offset,

View File

@ -445,8 +445,6 @@ const char *Symbolizer::PlatformDemangle(const char *name) {
return DemangleSwiftAndCXX(name);
}
void Symbolizer::PlatformPrepareForSandboxing() {}
static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) {
const char *path = common_flags()->external_symbolizer_path;
const char *binary_name = path ? StripModuleName(path) : "";

View File

@ -176,10 +176,6 @@ const char *Symbolizer::PlatformDemangle(const char *name) {
return name;
}
void Symbolizer::PlatformPrepareForSandboxing() {
// Do nothing.
}
namespace {
struct ScopedHandle {
ScopedHandle() : h_(nullptr) {}

View File

@ -467,8 +467,7 @@ void ReExec() {
UNIMPLEMENTED();
}
void PrepareForSandboxing(__sanitizer_sandbox_arguments *args) {
}
void PlatformPrepareForSandboxing(__sanitizer_sandbox_arguments *args) {}
bool StackSizeIsUnlimited() {
UNIMPLEMENTED();

View File

@ -282,11 +282,3 @@ void __tsan_report_count(u64 *pn) {
} // extern "C"
} // namespace __tsan
namespace __sanitizer {
void SymbolizerPrepareForSandboxing() {
// Nothing to do here for Go.
}
} // namespace __sanitizer