[libc-commits] [libc] [libc] Populate _r_debug in startup code and expose it through <link.h> (PR #215649)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Wed Aug 12 08:27:04 PDT 2026


================
@@ -41,11 +44,18 @@ extern uintptr_t __fini_array_end[];
 // on how the program is loaded exactly.
 [[gnu::weak,
   gnu::visibility("hidden")]] extern const ElfW(Dyn) _DYNAMIC[]; // NOLINT
+
+// Debuggers look for this function by name. Carefully consider any changes.
+void _r_debug_state() { // NOLINT
+  asm volatile("");
----------------
labath wrote:

I'm reluctant to use the word "contract", but yes, that is how it works right now. There's no point in notifying the debugger of the main binary as the debugger can find its location via the auxiliary vector (also, it kind of needs to do that anyway in order to find our where to set the breakpoint).

https://github.com/llvm/llvm-project/pull/215649


More information about the libc-commits mailing list