From 6f2dafdd1681c7f27dd1b0b3d8bcead2dc01a260 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Fri, 24 Oct 2025 12:17:57 -0400 Subject: [PATCH] backends: Guard x86_sample_* function calls behind HAVE_X86_INITREG_SAMPLE 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 --- backends/i386_initreg_sample.c | 9 +++++++++ backends/x86_64_initreg_sample.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/backends/i386_initreg_sample.c b/backends/i386_initreg_sample.c index 94955191..113e5be5 100644 --- a/backends/i386_initreg_sample.c +++ b/backends/i386_initreg_sample.c @@ -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 } diff --git a/backends/x86_64_initreg_sample.c b/backends/x86_64_initreg_sample.c index 9dd708c9..f381eef2 100644 --- a/backends/x86_64_initreg_sample.c +++ b/backends/x86_64_initreg_sample.c @@ -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 } -- 2.47.3