diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-04 18:35:47 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-04 18:38:59 -0400 |
commit | 2492c465ad3ae6860ebfff1c9032865017835e70 (patch) | |
tree | 3d90bb4516d8e7bfbff757a824954c8b91a046bd | |
parent | 4a0f65c102ec3a718b4a0b90981232b6cb019477 (diff) |
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>
-rw-r--r-- | tools/build/Makefile.feature | 1 | ||||
-rw-r--r-- | tools/build/feature/Makefile | 4 | ||||
-rw-r--r-- | tools/build/feature/test-all.c | 5 | ||||
-rw-r--r-- | tools/build/feature/test-libelf-getshdrstrndx.c | 8 | ||||
-rw-r--r-- | tools/perf/config/Makefile | 4 | ||||
-rw-r--r-- | tools/perf/util/symbol-elf.c | 8 |
6 files changed, 30 insertions, 0 deletions
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 57c8f98874e8..3dd529bb0604 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature | |||
@@ -40,6 +40,7 @@ FEATURE_TESTS_BASIC := \ | |||
40 | libbfd \ | 40 | libbfd \ |
41 | libelf \ | 41 | libelf \ |
42 | libelf-getphdrnum \ | 42 | libelf-getphdrnum \ |
43 | libelf-getshdrstrndx \ | ||
43 | libelf-mmap \ | 44 | libelf-mmap \ |
44 | libnuma \ | 45 | libnuma \ |
45 | numa_num_possible_cpus \ | 46 | numa_num_possible_cpus \ |
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 3d88f09e188b..674711629ef0 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile | |||
@@ -17,6 +17,7 @@ FILES= \ | |||
17 | test-cplus-demangle.bin \ | 17 | test-cplus-demangle.bin \ |
18 | test-libelf.bin \ | 18 | test-libelf.bin \ |
19 | test-libelf-getphdrnum.bin \ | 19 | test-libelf-getphdrnum.bin \ |
20 | test-libelf-getshdrstrndx.bin \ | ||
20 | test-libelf-mmap.bin \ | 21 | test-libelf-mmap.bin \ |
21 | test-libnuma.bin \ | 22 | test-libnuma.bin \ |
22 | test-numa_num_possible_cpus.bin \ | 23 | test-numa_num_possible_cpus.bin \ |
@@ -98,6 +99,9 @@ $(OUTPUT)test-libelf-mmap.bin: | |||
98 | $(OUTPUT)test-libelf-getphdrnum.bin: | 99 | $(OUTPUT)test-libelf-getphdrnum.bin: |
99 | $(BUILD) -lelf | 100 | $(BUILD) -lelf |
100 | 101 | ||
102 | $(OUTPUT)test-libelf-getshdrstrndx.bin: | ||
103 | $(BUILD) -lelf | ||
104 | |||
101 | $(OUTPUT)test-libnuma.bin: | 105 | $(OUTPUT)test-libnuma.bin: |
102 | $(BUILD) -lnuma | 106 | $(BUILD) -lnuma |
103 | 107 | ||
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index a282e8cb84f3..7433cca33306 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c | |||
@@ -49,6 +49,10 @@ | |||
49 | # include "test-libelf-getphdrnum.c" | 49 | # include "test-libelf-getphdrnum.c" |
50 | #undef main | 50 | #undef main |
51 | 51 | ||
52 | #define main main_test_libelf_getshdrstrndx | ||
53 | # include "test-libelf-getshdrstrndx.c" | ||
54 | #undef main | ||
55 | |||
52 | #define main main_test_libunwind | 56 | #define main main_test_libunwind |
53 | # include "test-libunwind.c" | 57 | # include "test-libunwind.c" |
54 | #undef main | 58 | #undef main |
@@ -149,6 +153,7 @@ int main(int argc, char *argv[]) | |||
149 | main_test_dwarf(); | 153 | main_test_dwarf(); |
150 | main_test_dwarf_getlocations(); | 154 | main_test_dwarf_getlocations(); |
151 | main_test_libelf_getphdrnum(); | 155 | main_test_libelf_getphdrnum(); |
156 | main_test_libelf_getshdrstrndx(); | ||
152 | main_test_libunwind(); | 157 | main_test_libunwind(); |
153 | main_test_libaudit(); | 158 | main_test_libaudit(); |
154 | main_test_libslang(); | 159 | main_test_libslang(); |
diff --git a/tools/build/feature/test-libelf-getshdrstrndx.c b/tools/build/feature/test-libelf-getshdrstrndx.c new file mode 100644 index 000000000000..f0c3b47cce28 --- /dev/null +++ b/tools/build/feature/test-libelf-getshdrstrndx.c | |||
@@ -0,0 +1,8 @@ | |||
1 | #include <libelf.h> | ||
2 | |||
3 | int main(void) | ||
4 | { | ||
5 | size_t dst; | ||
6 | |||
7 | return elf_getshdrstrndx(0, &dst); | ||
8 | } | ||
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index bf1a0a0dd0ad..c7e269a7ca37 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -309,6 +309,10 @@ ifndef NO_LIBELF | |||
309 | CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT | 309 | CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT |
310 | endif | 310 | endif |
311 | 311 | ||
312 | ifeq ($(feature-libelf-getshdrstrndx), 1) | ||
313 | CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT | ||
314 | endif | ||
315 | |||
312 | ifndef NO_DWARF | 316 | ifndef NO_DWARF |
313 | ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) | 317 | ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) |
314 | msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); | 318 | msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 87a297dd8901..b222552c7159 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -54,6 +54,14 @@ static int elf_getphdrnum(Elf *elf, size_t *dst) | |||
54 | } | 54 | } |
55 | #endif | 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 | #ifndef NT_GNU_BUILD_ID | 65 | #ifndef NT_GNU_BUILD_ID |
58 | #define NT_GNU_BUILD_ID 3 | 66 | #define NT_GNU_BUILD_ID 3 |
59 | #endif | 67 | #endif |