[libc-commits] [libc] [libc] Fix dladdr stub (PR #230227)
via libc-commits
libc-commits at lists.llvm.org
Thu Oct 8 10:52:47 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Michael Jones (michaelrj-google)
<details>
<summary>Changes</summary>
Previously the dladdr stub returned -1 on error, but dladdr should
return 0 on error, see: https://pubs.opengroup.org/onlinepubs/9799919799/functions/dladdr.html
---
Full diff: https://github.com/llvm/llvm-project/pull/230227.diff
2 Files Affected:
- (modified) libc/src/dlfcn/dladdr.cpp (+7-2)
- (modified) libc/src/dlfcn/dladdr.h (+6-1)
``````````diff
diff --git a/libc/src/dlfcn/dladdr.cpp b/libc/src/dlfcn/dladdr.cpp
index 7e2a1544ada743..e61f72c3e86403 100644
--- a/libc/src/dlfcn/dladdr.cpp
+++ b/libc/src/dlfcn/dladdr.cpp
@@ -1,10 +1,15 @@
-//===-- Implementation of dladdr ------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of dladdr
+///
+//===----------------------------------------------------------------------===//
#include "dladdr.h"
@@ -17,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, dladdr,
([[maybe_unused]] const void *__restrict addr,
[[maybe_unused]] Dl_info *__restrict info)) {
- return -1;
+ return 0; // Returns 0 on fail, nonzero on success.
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/dlfcn/dladdr.h b/libc/src/dlfcn/dladdr.h
index 1fabe8163902a4..1f9fcd502ce73a 100644
--- a/libc/src/dlfcn/dladdr.h
+++ b/libc/src/dlfcn/dladdr.h
@@ -1,10 +1,15 @@
-//===-- Implementation header of dladdr -------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation header of dladdr
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_DLFCN_DLADDR_H
#define LLVM_LIBC_SRC_DLFCN_DLADDR_H
``````````
</details>
https://github.com/llvm/llvm-project/pull/230227
More information about the libc-commits
mailing list