Commit 1c1a3a4729aae712c55e001e151ef008d030d4a7
1 parent
c8a3f7de76
Exists in
smarc_imx_lf-5.15.y
and in
27 other branches
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>
Showing 8 changed files with 28 additions and 1 deletions Side-by-side Diff
tools/build/Makefile.feature
tools/build/feature/Makefile
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | test-cplus-demangle.bin \ |
18 | 18 | test-libelf.bin \ |
19 | 19 | test-libelf-getphdrnum.bin \ |
20 | + test-libelf-gelf_getnote.bin \ | |
20 | 21 | test-libelf-getshdrstrndx.bin \ |
21 | 22 | test-libelf-mmap.bin \ |
22 | 23 | test-libnuma.bin \ |
... | ... | @@ -97,6 +98,9 @@ |
97 | 98 | $(BUILD) -lelf |
98 | 99 | |
99 | 100 | $(OUTPUT)test-libelf-getphdrnum.bin: |
101 | + $(BUILD) -lelf | |
102 | + | |
103 | +$(OUTPUT)test-libelf-gelf_getnote.bin: | |
100 | 104 | $(BUILD) -lelf |
101 | 105 | |
102 | 106 | $(OUTPUT)test-libelf-getshdrstrndx.bin: |
tools/build/feature/test-all.c
... | ... | @@ -49,6 +49,10 @@ |
49 | 49 | # include "test-libelf-getphdrnum.c" |
50 | 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 | 56 | #define main main_test_libelf_getshdrstrndx |
53 | 57 | # include "test-libelf-getshdrstrndx.c" |
54 | 58 | #undef main |
... | ... | @@ -153,6 +157,7 @@ |
153 | 157 | main_test_dwarf(); |
154 | 158 | main_test_dwarf_getlocations(); |
155 | 159 | main_test_libelf_getphdrnum(); |
160 | + main_test_libelf_gelf_getnote(); | |
156 | 161 | main_test_libelf_getshdrstrndx(); |
157 | 162 | main_test_libunwind(); |
158 | 163 | main_test_libaudit(); |
tools/build/feature/test-libelf-gelf_getnote.c
tools/perf/config/Makefile
... | ... | @@ -309,6 +309,12 @@ |
309 | 309 | CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT |
310 | 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 | 318 | ifeq ($(feature-libelf-getshdrstrndx), 1) |
313 | 319 | CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT |
314 | 320 | endif |
tools/perf/util/build-id.c
tools/perf/util/probe-file.c
... | ... | @@ -624,6 +624,7 @@ |
624 | 624 | return ret; |
625 | 625 | } |
626 | 626 | |
627 | +#ifdef HAVE_GELF_GETNOTE_SUPPORT | |
627 | 628 | static unsigned long long sdt_note__get_addr(struct sdt_note *note) |
628 | 629 | { |
629 | 630 | return note->bit32 ? (unsigned long long)note->addr.a32[0] |
... | ... | @@ -682,6 +683,7 @@ |
682 | 683 | cleanup_sdt_note_list(&sdtlist); |
683 | 684 | return ret; |
684 | 685 | } |
686 | +#endif | |
685 | 687 | |
686 | 688 | static int probe_cache_entry__write(struct probe_cache_entry *entry, int fd) |
687 | 689 | { |
tools/perf/util/symbol-elf.c
... | ... | @@ -1790,6 +1790,7 @@ |
1790 | 1790 | unlink(kce->extract_filename); |
1791 | 1791 | } |
1792 | 1792 | |
1793 | +#ifdef HAVE_GELF_GETNOTE_SUPPORT | |
1793 | 1794 | /** |
1794 | 1795 | * populate_sdt_note : Parse raw data and identify SDT note |
1795 | 1796 | * @elf: elf of the opened file |
... | ... | @@ -2041,6 +2042,7 @@ |
2041 | 2042 | count++; |
2042 | 2043 | return count; |
2043 | 2044 | } |
2045 | +#endif | |
2044 | 2046 | |
2045 | 2047 | void symbol__elf_init(void) |
2046 | 2048 | { |