summaryrefslogtreecommitdiff
path: root/lib/lsan
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2017-10-05 22:53:17 +0000
committerAlex Shlyapnikov <alekseys@google.com>2017-10-05 22:53:17 +0000
commit2d21e8df3faee7f35589618ac36ad71d2c20908a (patch)
tree48bddbd5f6919e36019db92efc22e7e07b4e8bde /lib/lsan
parent590a32da41f486f5d834ccc9af1d337565b6a675 (diff)
Revert "[LSan] Detect dynamic loader by its base address."
This reverts commit r315024. Breaks sysconf_interceptor_bypass_test.cc git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/lsan')
-rw-r--r--lib/lsan/lsan_common.cc5
-rw-r--r--lib/lsan/lsan_common_linux.cc23
2 files changed, 8 insertions, 20 deletions
diff --git a/lib/lsan/lsan_common.cc b/lib/lsan/lsan_common.cc
index 651bbe1f3..622aae734 100644
--- a/lib/lsan/lsan_common.cc
+++ b/lib/lsan/lsan_common.cc
@@ -411,9 +411,8 @@ static void MarkInvalidPCCb(uptr chunk, void *arg) {
}
}
-// On Linux, treats all chunks allocated from ld-linux.so as reachable, which
-// covers dynamically allocated TLS blocks, internal dynamic loader's loaded
-// modules accounting etc.
+// On Linux, handles dynamically allocated TLS blocks by treating all chunks
+// allocated from ld-linux.so as reachable.
// Dynamic TLS blocks contain the TLS variables of dynamically loaded modules.
// They are allocated with a __libc_memalign() call in allocate_and_init()
// (elf/dl-tls.c). Glibc won't tell us the address ranges occupied by those
diff --git a/lib/lsan/lsan_common_linux.cc b/lib/lsan/lsan_common_linux.cc
index 5acff0b2d..5042c7b3a 100644
--- a/lib/lsan/lsan_common_linux.cc
+++ b/lib/lsan/lsan_common_linux.cc
@@ -23,10 +23,6 @@
#include "sanitizer_common/sanitizer_linux.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
-#if SANITIZER_USE_GETAUXVAL
-#include <sys/auxv.h>
-#endif // SANITIZER_USE_GETAUXVAL
-
namespace __lsan {
static const char kLinkerName[] = "ld";
@@ -34,12 +30,8 @@ static const char kLinkerName[] = "ld";
static char linker_placeholder[sizeof(LoadedModule)] ALIGNED(64);
static LoadedModule *linker = nullptr;
-static bool IsLinker(const LoadedModule& module) {
-#if SANITIZER_USE_GETAUXVAL
- return module.base_address() == getauxval(AT_BASE);
-#else
- return LibraryNameIs(module.full_name(), kLinkerName);
-#endif // SANITIZER_USE_GETAUXVAL
+static bool IsLinker(const char* full_name) {
+ return LibraryNameIs(full_name, kLinkerName);
}
__attribute__((tls_model("initial-exec")))
@@ -57,25 +49,22 @@ void InitializePlatformSpecificModules() {
ListOfModules modules;
modules.init();
for (LoadedModule &module : modules) {
- if (!IsLinker(module))
- continue;
+ if (!IsLinker(module.full_name())) continue;
if (linker == nullptr) {
linker = reinterpret_cast<LoadedModule *>(linker_placeholder);
*linker = module;
module = LoadedModule();
} else {
VReport(1, "LeakSanitizer: Multiple modules match \"%s\". "
- "TLS and other allocations originating from linker might be "
- "falsely reported as leaks.\n", kLinkerName);
+ "TLS will not be handled correctly.\n", kLinkerName);
linker->clear();
linker = nullptr;
return;
}
}
if (linker == nullptr) {
- VReport(1, "LeakSanitizer: Dynamic linker not found. TLS and other "
- "allocations originating from linker might be falsely reported "
- "as leaks.\n");
+ VReport(1, "LeakSanitizer: Dynamic linker not found. "
+ "TLS will not be handled correctly.\n");
}
}