[libc-commits] [libc] [libc] Fix dladdr stub (PR #230227)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Thu Oct 8 10:52:03 PDT 2026
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/230227
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
>From b5955a45cd4f64403f70134166b0c2ee718e9318 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Thu, 8 Oct 2026 17:50:59 +0000
Subject: [PATCH] [libc] Fix dladdr stub
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
---
libc/src/dlfcn/dladdr.cpp | 9 +++++++--
libc/src/dlfcn/dladdr.h | 7 ++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/libc/src/dlfcn/dladdr.cpp b/libc/src/dlfcn/dladdr.cpp
index 7e2a1544ada74..e61f72c3e8640 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 1fabe8163902a..1f9fcd502ce73 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
More information about the libc-commits
mailing list