Daily bump.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_dl.cpp
blobe957d529c2fe1f552b14dbe8ad9ea49d480131d9
1 //===-- sanitizer_dl.cpp --------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file has helper functions that depend on libc's dynamic loading
10 // introspection.
12 //===----------------------------------------------------------------------===//
14 #include "sanitizer_dl.h"
16 #include "sanitizer_common/sanitizer_platform.h"
18 #if SANITIZER_GLIBC
19 # include <dlfcn.h>
20 #endif
22 namespace __sanitizer {
23 extern const char *SanitizerToolName;
25 const char *DladdrSelfFName(void) {
26 #if SANITIZER_GLIBC
27 Dl_info info;
28 int ret = dladdr((void *)&SanitizerToolName, &info);
29 if (ret) {
30 return info.dli_fname;
32 #endif
34 return nullptr;
37 } // namespace __sanitizer