]> 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 23:06:21 +0000 (19:06 -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
backends/x86_initreg_sample.c

index 94955191fd042338677a8935ec7a6846e46cdc02..d7d312b069032c97b7140f01bb9bdc5926f21486 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,20 @@ 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
+  (void) regs;
+  (void) n_regs;
+  (void) regs_mapping;
+  (void) n_regs_mapping;
+  (void) sp;
+  (void) pc;
+  return false;
+#endif
 }
 
 bool
@@ -61,6 +72,15 @@ 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
+  (void) ebl;
+  (void) perf_regs_mask;
+  (void) abi;
+  (void) regs_mapping;
+  (void) n_regs_mapping;
+  return false;
+#endif
 }
index 9dd708c96cd97c999ba3bf77c29fb27a6e290522..200a94a1faa2d0e93decf6c198408cf83136aaf4 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,20 @@ 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
+  (void) regs;
+  (void) n_regs;
+  (void) regs_mapping;
+  (void) n_regs_mapping;
+  (void) sp;
+  (void) pc;
+  return false;
+#endif
 }
 
 bool
@@ -61,6 +72,15 @@ 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
+  (void) ebl;
+  (void) perf_regs_mask;
+  (void) abi;
+  (void) regs_mapping;
+  (void) n_regs_mapping;
+  return false;
+#endif
 }
index 47cd91c238125152fdf1deba2444bf37107180e4..6f99bf5352cf9e1029edf43336703783cf19d2a6 100644 (file)
@@ -39,6 +39,10 @@ x86_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs,
   (void)n_regs;
   (void)regs_mapping;
   (void)n_regs_mapping;
+  (void)sp;
+  (void)sp_index;
+  (void)pc;
+  (void)pc_index;
   return false;
 #else /* __x86_64__ */
   /* TODO: Register locations could be cached and rechecked on a