aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-07-12 11:19:09 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-07-12 14:20:41 -0400
commit1c1a3a4729aae712c55e001e151ef008d030d4a7 (patch)
tree62fd90d09b08cf1a48eaa85ea8a21d7b2cc55b5d
parentc8a3f7de76717a994c208e137156c077b1e93092 (diff)
perf tools: Add feature detection for gelf_getnote()
That is not present on some libelf implementations, such as the one used in Alpine Linux: libelf-0.8.13. This ends up disabling the SDT code, that relies on this function. One alternative would be to provide an weak fallback implementation or the open coded variant used by the buildid sysfs notes reading code. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-82lh22ybedy9b9lych8xj12g@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/build/Makefile.feature1
-rw-r--r--tools/build/feature/Makefile4
-rw-r--r--tools/build/feature/test-all.c5
-rw-r--r--tools/build/feature/test-libelf-gelf_getnote.c7
-rw-r--r--tools/perf/config/Makefile6
-rw-r--r--tools/perf/util/build-id.c2
-rw-r--r--tools/perf/util/probe-file.c2
-rw-r--r--tools/perf/util/symbol-elf.c2
8 files changed, 28 insertions, 1 deletions
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 3dd529bb0604..fe12bee57418 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-gelf_getnote \
43 libelf-getshdrstrndx \ 44 libelf-getshdrstrndx \
44 libelf-mmap \ 45 libelf-mmap \
45 libnuma \ 46 libnuma \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 674711629ef0..d6017c1abdb0 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-gelf_getnote.bin \
20 test-libelf-getshdrstrndx.bin \ 21 test-libelf-getshdrstrndx.bin \
21 test-libelf-mmap.bin \ 22 test-libelf-mmap.bin \
22 test-libnuma.bin \ 23 test-libnuma.bin \
@@ -99,6 +100,9 @@ $(OUTPUT)test-libelf-mmap.bin:
99$(OUTPUT)test-libelf-getphdrnum.bin: 100$(OUTPUT)test-libelf-getphdrnum.bin:
100 $(BUILD) -lelf 101 $(BUILD) -lelf
101 102
103$(OUTPUT)test-libelf-gelf_getnote.bin:
104 $(BUILD) -lelf
105
102$(OUTPUT)test-libelf-getshdrstrndx.bin: 106$(OUTPUT)test-libelf-getshdrstrndx.bin:
103 $(BUILD) -lelf 107 $(BUILD) -lelf
104 108
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 7433cca33306..843aed024a3a 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_gelf_getnote
53# include "test-libelf-gelf_getnote.c"
54#undef main
55
52#define main main_test_libelf_getshdrstrndx 56#define main main_test_libelf_getshdrstrndx
53# include "test-libelf-getshdrstrndx.c" 57# include "test-libelf-getshdrstrndx.c"
54#undef main 58#undef main
@@ -153,6 +157,7 @@ int main(int argc, char *argv[])
153 main_test_dwarf(); 157 main_test_dwarf();
154 main_test_dwarf_getlocations(); 158 main_test_dwarf_getlocations();
155 main_test_libelf_getphdrnum(); 159 main_test_libelf_getphdrnum();
160 main_test_libelf_gelf_getnote();
156 main_test_libelf_getshdrstrndx(); 161 main_test_libelf_getshdrstrndx();
157 main_test_libunwind(); 162 main_test_libunwind();
158 main_test_libaudit(); 163 main_test_libaudit();
diff --git a/tools/build/feature/test-libelf-gelf_getnote.c b/tools/build/feature/test-libelf-gelf_getnote.c
new file mode 100644
index 000000000000..d78cf4d5271f
--- /dev/null
+++ b/tools/build/feature/test-libelf-gelf_getnote.c
@@ -0,0 +1,7 @@
1#include <stdlib.h>
2#include <gelf.h>
3
4int main(void)
5{
6 return gelf_getnote(NULL, 0, NULL, NULL, NULL);
7}
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 97d47140a637..5ac428060779 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -309,6 +309,12 @@ 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-gelf_getnote), 1)
313 CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
314 else
315 msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
316 endif
317
312 ifeq ($(feature-libelf-getshdrstrndx), 1) 318 ifeq ($(feature-libelf-getshdrstrndx), 1)
313 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT 319 CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
314 endif 320 endif
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index e1a16408da9c..1e504e40dac8 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -533,7 +533,7 @@ int build_id_cache__list_build_ids(const char *pathname,
533 return ret; 533 return ret;
534} 534}
535 535
536#ifdef HAVE_LIBELF_SUPPORT 536#if defined(HAVE_LIBELF_SUPPORT) && defined(HAVE_GELF_GETNOTE_SUPPORT)
537static int build_id_cache__add_sdt_cache(const char *sbuild_id, 537static int build_id_cache__add_sdt_cache(const char *sbuild_id,
538 const char *realname) 538 const char *realname)
539{ 539{
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 98398b55a03f..e705a742ee1e 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -624,6 +624,7 @@ out_err:
624 return ret; 624 return ret;
625} 625}
626 626
627#ifdef HAVE_GELF_GETNOTE_SUPPORT
627static unsigned long long sdt_note__get_addr(struct sdt_note *note) 628static unsigned long long sdt_note__get_addr(struct sdt_note *note)
628{ 629{
629 return note->bit32 ? (unsigned long long)note->addr.a32[0] 630 return note->bit32 ? (unsigned long long)note->addr.a32[0]
@@ -682,6 +683,7 @@ int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname)
682 cleanup_sdt_note_list(&sdtlist); 683 cleanup_sdt_note_list(&sdtlist);
683 return ret; 684 return ret;
684} 685}
686#endif
685 687
686static int probe_cache_entry__write(struct probe_cache_entry *entry, int fd) 688static int probe_cache_entry__write(struct probe_cache_entry *entry, int fd)
687{ 689{
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 79a6a190f41d..cebf98ec27bc 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1790,6 +1790,7 @@ void kcore_extract__delete(struct kcore_extract *kce)
1790 unlink(kce->extract_filename); 1790 unlink(kce->extract_filename);
1791} 1791}
1792 1792
1793#ifdef HAVE_GELF_GETNOTE_SUPPORT
1793/** 1794/**
1794 * populate_sdt_note : Parse raw data and identify SDT note 1795 * populate_sdt_note : Parse raw data and identify SDT note
1795 * @elf: elf of the opened file 1796 * @elf: elf of the opened file
@@ -2041,6 +2042,7 @@ int sdt_notes__get_count(struct list_head *start)
2041 count++; 2042 count++;
2042 return count; 2043 return count;
2043} 2044}
2045#endif
2044 2046
2045void symbol__elf_init(void) 2047void symbol__elf_init(void)
2046{ 2048{