[compiler-rt] [compiler-rt] Expose shared DSO helpers for compiler-rt runtimes (PR #191098)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 19:06:16 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- compiler-rt/lib/interception/interception.h compiler-rt/lib/interception/interception_linux.cpp compiler-rt/lib/interception/interception_win.cpp compiler-rt/lib/interception/tests/interception_linux_test.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/compiler-rt/lib/interception/interception.h b/compiler-rt/lib/interception/interception.h
index 1ae5c0fec..71c59ed36 100644
--- a/compiler-rt/lib/interception/interception.h
+++ b/compiler-rt/lib/interception/interception.h
@@ -366,11 +366,11 @@ namespace __interception {
// Implemented in interception_linux.cpp on non-Windows targets and
// interception_win.cpp on Windows.
bool DynamicLoaderAvailable();
-void *OpenLibrary(const char *name);
-void *LookupSymbol(void *handle, const char *symbol);
-void *LookupSymbolDefault(const char *symbol);
-void *LookupSymbolNext(const char *symbol);
-void *LookupSymbolNextVersioned(const char *symbol, const char *version);
+void* OpenLibrary(const char* name);
+void* LookupSymbol(void* handle, const char* symbol);
+void* LookupSymbolDefault(const char* symbol);
+void* LookupSymbolNext(const char* symbol);
+void* LookupSymbolNextVersioned(const char* symbol, const char* version);
#if defined(__ELF__) && !SANITIZER_FUCHSIA
// The use of interceptors makes many sanitizers unusable for static linking.
diff --git a/compiler-rt/lib/interception/interception_linux.cpp b/compiler-rt/lib/interception/interception_linux.cpp
index 0d2c2be6c..9b9796f7c 100644
--- a/compiler-rt/lib/interception/interception_linux.cpp
+++ b/compiler-rt/lib/interception/interception_linux.cpp
@@ -28,35 +28,33 @@
namespace __interception {
-bool DynamicLoaderAvailable() {
- return dlopen != nullptr && dlsym != nullptr;
-}
+bool DynamicLoaderAvailable() { return dlopen != nullptr && dlsym != nullptr; }
-void *OpenLibrary(const char *name) {
+void* OpenLibrary(const char* name) {
if (!DynamicLoaderAvailable())
return nullptr;
return dlopen(name, RTLD_LAZY | RTLD_LOCAL);
}
-void *LookupSymbol(void *handle, const char *symbol) {
+void* LookupSymbol(void* handle, const char* symbol) {
if (!DynamicLoaderAvailable())
return nullptr;
return dlsym(handle, symbol);
}
-void *LookupSymbolDefault(const char *symbol) {
+void* LookupSymbolDefault(const char* symbol) {
if (!DynamicLoaderAvailable())
return nullptr;
return dlsym(RTLD_DEFAULT, symbol);
}
-void *LookupSymbolNext(const char *symbol) {
+void* LookupSymbolNext(const char* symbol) {
if (!DynamicLoaderAvailable())
return nullptr;
return dlsym(RTLD_NEXT, symbol);
}
-void *LookupSymbolNextVersioned(const char *symbol, const char *version) {
+void* LookupSymbolNextVersioned(const char* symbol, const char* version) {
if (!DynamicLoaderAvailable() || dlvsym == nullptr)
return nullptr;
return dlvsym(RTLD_NEXT, symbol, version);
@@ -90,7 +88,7 @@ static void *GetFuncAddr(const char *name, uptr trampoline) {
if (StrCmp(name, "sigaction"))
name = "__sigaction14";
#endif
- void *addr = LookupSymbolNext(name);
+ void* addr = LookupSymbolNext(name);
if (!addr) {
// If the lookup using RTLD_NEXT failed, the sanitizer runtime library is
// later in the library search order than the DSO that we are trying to
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index 6c3a7e9d0..8b95c5b90 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -136,27 +136,27 @@ namespace __interception {
bool DynamicLoaderAvailable() { return true; }
-void *OpenLibrary(const char *name) {
+void* OpenLibrary(const char* name) {
if (!name)
- return reinterpret_cast<void *>(GetModuleHandleA(nullptr));
- return reinterpret_cast<void *>(LoadLibraryA(name));
+ return reinterpret_cast<void*>(GetModuleHandleA(nullptr));
+ return reinterpret_cast<void*>(LoadLibraryA(name));
}
-void *LookupSymbol(void *handle, const char *symbol) {
+void* LookupSymbol(void* handle, const char* symbol) {
if (!handle)
return nullptr;
- return reinterpret_cast<void *>(reinterpret_cast<__sanitizer::uptr>(
+ return reinterpret_cast<void*>(reinterpret_cast<__sanitizer::uptr>(
GetProcAddress(reinterpret_cast<HMODULE>(handle), symbol)));
}
-void *LookupSymbolDefault(const char *symbol) {
- return LookupSymbol(reinterpret_cast<void *>(GetModuleHandleA(nullptr)),
+void* LookupSymbolDefault(const char* symbol) {
+ return LookupSymbol(reinterpret_cast<void*>(GetModuleHandleA(nullptr)),
symbol);
}
-void *LookupSymbolNext(const char *) { return nullptr; }
+void* LookupSymbolNext(const char*) { return nullptr; }
-void *LookupSymbolNextVersioned(const char *, const char *) { return nullptr; }
+void* LookupSymbolNextVersioned(const char*, const char*) { return nullptr; }
static const int kAddressLength = FIRST_32_SECOND_64(4, 8);
static const int kJumpInstructionLength = 5;
diff --git a/compiler-rt/lib/interception/tests/interception_linux_test.cpp b/compiler-rt/lib/interception/tests/interception_linux_test.cpp
index 515affb5f..0b61f499b 100644
--- a/compiler-rt/lib/interception/tests/interception_linux_test.cpp
+++ b/compiler-rt/lib/interception/tests/interception_linux_test.cpp
@@ -96,13 +96,12 @@ TEST(Interception, Basic) {
TEST(Interception, DsoHelpers) {
EXPECT_TRUE(DynamicLoaderAvailable());
- void *self = OpenLibrary(nullptr);
+ void* self = OpenLibrary(nullptr);
EXPECT_NE(nullptr, self);
EXPECT_NE(nullptr, LookupSymbol(self, "malloc"));
EXPECT_NE(nullptr, LookupSymbolDefault("malloc"));
EXPECT_NE(nullptr, LookupSymbolNext("malloc"));
- EXPECT_EQ(nullptr,
- LookupSymbol(self, "symbol_that_does_not_exist__"));
+ EXPECT_EQ(nullptr, LookupSymbol(self, "symbol_that_does_not_exist__"));
}
TEST(Interception, ForeignOverrideDirect) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/191098
More information about the llvm-commits
mailing list