perf build: Add feature detection for libelf's elf_getshdrstrndx()

That appeared after 0.140, and will be used in the SDT code, so, to
avoid bisection break on older systems, add a feature detection and
provide a stub with a pr_debug() to keep it building.

Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-80y0eldgweorqnwha9rvfxjr@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4a0f65c1
...@@ -40,6 +40,7 @@ FEATURE_TESTS_BASIC := \ ...@@ -40,6 +40,7 @@ FEATURE_TESTS_BASIC := \
libbfd \ libbfd \
libelf \ libelf \
libelf-getphdrnum \ libelf-getphdrnum \
libelf-getshdrstrndx \
libelf-mmap \ libelf-mmap \
libnuma \ libnuma \
numa_num_possible_cpus \ numa_num_possible_cpus \
......
...@@ -17,6 +17,7 @@ FILES= \ ...@@ -17,6 +17,7 @@ FILES= \
test-cplus-demangle.bin \ test-cplus-demangle.bin \
test-libelf.bin \ test-libelf.bin \
test-libelf-getphdrnum.bin \ test-libelf-getphdrnum.bin \
test-libelf-getshdrstrndx.bin \
test-libelf-mmap.bin \ test-libelf-mmap.bin \
test-libnuma.bin \ test-libnuma.bin \
test-numa_num_possible_cpus.bin \ test-numa_num_possible_cpus.bin \
...@@ -98,6 +99,9 @@ $(OUTPUT)test-libelf-mmap.bin: ...@@ -98,6 +99,9 @@ $(OUTPUT)test-libelf-mmap.bin:
$(OUTPUT)test-libelf-getphdrnum.bin: $(OUTPUT)test-libelf-getphdrnum.bin:
$(BUILD) -lelf $(BUILD) -lelf
$(OUTPUT)test-libelf-getshdrstrndx.bin:
$(BUILD) -lelf
$(OUTPUT)test-libnuma.bin: $(OUTPUT)test-libnuma.bin:
$(BUILD) -lnuma $(BUILD) -lnuma
......
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
# include "test-libelf-getphdrnum.c" # include "test-libelf-getphdrnum.c"
#undef main #undef main
#define main main_test_libelf_getshdrstrndx
# include "test-libelf-getshdrstrndx.c"
#undef main
#define main main_test_libunwind #define main main_test_libunwind
# include "test-libunwind.c" # include "test-libunwind.c"
#undef main #undef main
...@@ -149,6 +153,7 @@ int main(int argc, char *argv[]) ...@@ -149,6 +153,7 @@ int main(int argc, char *argv[])
main_test_dwarf(); main_test_dwarf();
main_test_dwarf_getlocations(); main_test_dwarf_getlocations();
main_test_libelf_getphdrnum(); main_test_libelf_getphdrnum();
main_test_libelf_getshdrstrndx();
main_test_libunwind(); main_test_libunwind();
main_test_libaudit(); main_test_libaudit();
main_test_libslang(); main_test_libslang();
......
#include <libelf.h>
int main(void)
{
size_t dst;
return elf_getshdrstrndx(0, &dst);
}
...@@ -309,6 +309,10 @@ ifndef NO_LIBELF ...@@ -309,6 +309,10 @@ ifndef NO_LIBELF
CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
endif endif
ifeq ($(feature-libelf-getshdrstrndx), 1)
CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
endif
ifndef NO_DWARF ifndef NO_DWARF
ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
......
...@@ -54,6 +54,14 @@ static int elf_getphdrnum(Elf *elf, size_t *dst) ...@@ -54,6 +54,14 @@ static int elf_getphdrnum(Elf *elf, size_t *dst)
} }
#endif #endif
#ifndef HAVE_ELF_GETSHDRSTRNDX_SUPPORT
static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused)
{
pr_err("%s: update your libelf to > 0.140, this one lacks elf_getshdrstrndx().\n", __func__);
return -1;
}
#endif
#ifndef NT_GNU_BUILD_ID #ifndef NT_GNU_BUILD_ID
#define NT_GNU_BUILD_ID 3 #define NT_GNU_BUILD_ID 3
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment