From: Aaron Merey Date: Fri, 24 Oct 2025 16:17:57 +0000 (-0400) Subject: backends: Guard x86_sample_* function calls behind HAVE_X86_INITREG_SAMPLE X-Git-Tag: elfutils-0.194~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cde995de0ae996fc68e4a983a48f8d027e11a472;p=thirdparty%2Felfutils.git 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 --- diff --git a/backends/i386_initreg_sample.c b/backends/i386_initreg_sample.c index 94955191..d7d312b0 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,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 } diff --git a/backends/x86_64_initreg_sample.c b/backends/x86_64_initreg_sample.c index 9dd708c9..200a94a1 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,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 } diff --git a/backends/x86_initreg_sample.c b/backends/x86_initreg_sample.c index 47cd91c2..6f99bf53 100644 --- a/backends/x86_initreg_sample.c +++ b/backends/x86_initreg_sample.c @@ -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