]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
backends: Guard x86_sample_* function calls behind HAVE_X86_INITREG_SAMPLE
authorAaron Merey <amerey@redhat.com>
Fri, 24 Oct 2025 16:17:57 +0000 (12:17 -0400)
committerAaron Merey <amerey@redhat.com>
Fri, 24 Oct 2025 16:23:56 +0000 (12:23 -0400)
Avoid "implicit declaration" compile errors on non-x86_64/i386 arches
by calling x86_sample_* functions only when x86_initreg_sample.c is
included in the build.

Signed-off-by: Aaron Merey <amerey@redhat.com>
backends/i386_initreg_sample.c
backends/x86_64_initreg_sample.c

index 94955191fd042338677a8935ec7a6846e46cdc02..113e5be5b696d3fd68c9558d178b649c608f2422 100644 (file)
@@ -42,6 +42,7 @@
 #include "libebl_PERF_FLAGS.h"
 #if (defined __i386__ || defined __x86_64__) && defined(__linux__)
 # include "x86_initreg_sample.c"
+# define HAVE_X86_INITREG_SAMPLE
 #endif
 
 bool
@@ -49,10 +50,14 @@ i386_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs,
                    const int *regs_mapping, uint32_t n_regs_mapping,
                    Dwarf_Word *sp, Dwarf_Word *pc)
 {
+#ifdef HAVE_X86_INITREG_SAMPLE
   /* XXX for dwarf_regs indices, compare i386_initreg.c */
   return x86_sample_sp_pc (regs, n_regs, regs_mapping, n_regs_mapping,
                           sp, 4 /* index of sp in dwarf_regs */,
                           pc, 8 /* index of pc in dwarf_regs */);
+#else
+  return false;
+#endif
 }
 
 bool
@@ -61,6 +66,10 @@ i386_sample_perf_regs_mapping (Ebl *ebl,
                               const int **regs_mapping,
                               size_t *n_regs_mapping)
 {
+#ifdef HAVE_X86_INITREG_SAMPLE
   return x86_sample_perf_regs_mapping (ebl, perf_regs_mask, abi,
                                       regs_mapping, n_regs_mapping);
+#else
+  return false;
+#endif
 }
index 9dd708c96cd97c999ba3bf77c29fb27a6e290522..f381eef29d180016dcccef34eb6d2edc20d2fe70 100644 (file)
@@ -42,6 +42,7 @@
 #include "libebl_PERF_FLAGS.h"
 #if defined(__x86_64__) && defined(__linux__)
 # include "x86_initreg_sample.c"
+# define HAVE_X86_INITREG_SAMPLE
 #endif
 
 bool
@@ -49,10 +50,14 @@ x86_64_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs,
                     const int *regs_mapping, uint32_t n_regs_mapping,
                     Dwarf_Word *sp, Dwarf_Word *pc)
 {
+#ifdef HAVE_X86_INITREG_SAMPLE
   /* XXX for dwarf_regs indices, compare x86_64_initreg.c */
   return x86_sample_sp_pc (regs, n_regs, regs_mapping, n_regs_mapping,
                           sp, 7 /* index of sp in dwarf_regs */,
                           pc, 16 /* index of pc in dwarf_regs */);
+#else
+  return false;
+#endif
 }
 
 bool
@@ -61,6 +66,10 @@ x86_64_sample_perf_regs_mapping (Ebl *ebl,
                                 const int **regs_mapping,
                                 size_t *n_regs_mapping)
 {
+#ifdef HAVE_X86_INITREG_SAMPLE
   return x86_sample_perf_regs_mapping (ebl, perf_regs_mask, abi,
                                       regs_mapping, n_regs_mapping);
+#else
+  return false;
+#endif
 }