]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non...
authorSerhei Makarov <serhei@serhei.io>
Fri, 13 Mar 2026 15:06:03 +0000 (11:06 -0400)
committerSerhei Makarov <serhei@serhei.io>
Thu, 19 Mar 2026 20:58:30 +0000 (16:58 -0400)
libdwfl_stacktrace uses __libdwfl_set_initial_registers_thread but it
is wrapped by #ifdef __linux__, causing build errors on non-Linux
platforms.

* linux-pid-attach.c (__libdwfl_set_initial_registers_thread):
  Remove from inside the '#ifdef __linux__'.
* dwfl_frame_regs.c (__libdwfl_set_initial_registers_thread):
  Move here.

Tested-by: Sam James <sam@gentoo.org>
Signed-off-by: Serhei Makarov <serhei@serhei.io>
libdwfl/dwfl_frame_regs.c
libdwfl/linux-pid-attach.c

index 572ac6761ea8b50476e0b5bf2734450feaf67cd5..99de3c229cf14c88a04139924120155dd53fb5ec 100644 (file)
@@ -77,3 +77,30 @@ dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val)
   return res;
 }
 INTDEF(dwfl_frame_reg)
+
+/* Implement the ebl_set_initial_registers_tid setfunc callback.  */
+
+bool
+/* Not internal_function, since that allows calling-convention changes
+   e.g. on i386, and stable ABI is needed to use this as an
+   ebl_tid_registers_t * callback in linux-pid-attach.c and
+   libdwfl_stacktrace.  */
+__libdwfl_set_initial_registers_thread (int firstreg, unsigned nregs,
+                                  const Dwarf_Word *regs, void *arg)
+{
+  Dwfl_Thread *thread = (Dwfl_Thread *) arg;
+  if (firstreg == -1)
+    {
+      assert (nregs == 1);
+      INTUSE(dwfl_thread_state_register_pc) (thread, *regs);
+      return true;
+    }
+  else if (firstreg == -2)
+    {
+      assert (nregs == 1);
+      INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
+      return true;
+     }
+  assert (nregs > 0);
+  return INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
+}
index a6e4e41ad3f491df70514877779a3cd00eecbac6..9472b04114187ba24e3a23884539a2cff4805188 100644 (file)
@@ -302,31 +302,6 @@ pid_getthread (Dwfl *dwfl __attribute__ ((unused)), pid_t tid,
   return true;
 }
 
-/* Implement the ebl_set_initial_registers_tid setfunc callback.  */
-
-bool
-/* XXX No internal_function annotation,
-   as this function gets passed as ebl_tid_registers_t *.  */
-__libdwfl_set_initial_registers_thread (int firstreg, unsigned nregs,
-                                  const Dwarf_Word *regs, void *arg)
-{
-  Dwfl_Thread *thread = (Dwfl_Thread *) arg;
-  if (firstreg == -1)
-    {
-      assert (nregs == 1);
-      INTUSE(dwfl_thread_state_register_pc) (thread, *regs);
-      return true;
-    }
-  else if (firstreg == -2)
-    {
-      assert (nregs == 1);
-      INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
-      return true;
-     }
-  assert (nregs > 0);
-  return INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
-}
-
 static bool
 pid_set_initial_registers (Dwfl_Thread *thread, void *thread_arg)
 {