Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+30
+1
tools/build/Makefile.feature
··· 40 40 libbfd \ 41 41 libelf \ 42 42 libelf-getphdrnum \ 43 + libelf-getshdrstrndx \ 43 44 libelf-mmap \ 44 45 libnuma \ 45 46 numa_num_possible_cpus \
+4
tools/build/feature/Makefile
··· 17 17 test-cplus-demangle.bin \ 18 18 test-libelf.bin \ 19 19 test-libelf-getphdrnum.bin \ 20 + test-libelf-getshdrstrndx.bin \ 20 21 test-libelf-mmap.bin \ 21 22 test-libnuma.bin \ 22 23 test-numa_num_possible_cpus.bin \ ··· 97 96 $(BUILD) -lelf 98 97 99 98 $(OUTPUT)test-libelf-getphdrnum.bin: 99 + $(BUILD) -lelf 100 + 101 + $(OUTPUT)test-libelf-getshdrstrndx.bin: 100 102 $(BUILD) -lelf 101 103 102 104 $(OUTPUT)test-libnuma.bin:
+5
tools/build/feature/test-all.c
··· 49 49 # include "test-libelf-getphdrnum.c" 50 50 #undef main 51 51 52 + #define main main_test_libelf_getshdrstrndx 53 + # include "test-libelf-getshdrstrndx.c" 54 + #undef main 55 + 52 56 #define main main_test_libunwind 53 57 # include "test-libunwind.c" 54 58 #undef main ··· 153 149 main_test_dwarf(); 154 150 main_test_dwarf_getlocations(); 155 151 main_test_libelf_getphdrnum(); 152 + main_test_libelf_getshdrstrndx(); 156 153 main_test_libunwind(); 157 154 main_test_libaudit(); 158 155 main_test_libslang();
+8
tools/build/feature/test-libelf-getshdrstrndx.c
··· 1 + #include <libelf.h> 2 + 3 + int main(void) 4 + { 5 + size_t dst; 6 + 7 + return elf_getshdrstrndx(0, &dst); 8 + }
+4
tools/perf/config/Makefile
··· 309 309 CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT 310 310 endif 311 311 312 + ifeq ($(feature-libelf-getshdrstrndx), 1) 313 + CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT 314 + endif 315 + 312 316 ifndef NO_DWARF 313 317 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) 314 318 msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
+8
tools/perf/util/symbol-elf.c
··· 54 54 } 55 55 #endif 56 56 57 + #ifndef HAVE_ELF_GETSHDRSTRNDX_SUPPORT 58 + static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused) 59 + { 60 + pr_err("%s: update your libelf to > 0.140, this one lacks elf_getshdrstrndx().\n", __func__); 61 + return -1; 62 + } 63 + #endif 64 + 57 65 #ifndef NT_GNU_BUILD_ID 58 66 #define NT_GNU_BUILD_ID 3 59 67 #endif