Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c1a3a47 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c8a3f7de
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ FEATURE_TESTS_BASIC := \
	libbfd				\
	libelf				\
	libelf-getphdrnum		\
	libelf-gelf_getnote		\
	libelf-getshdrstrndx		\
	libelf-mmap			\
	libnuma				\
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ FILES= \
	test-cplus-demangle.bin		\
	test-libelf.bin			\
	test-libelf-getphdrnum.bin	\
	test-libelf-gelf_getnote.bin	\
	test-libelf-getshdrstrndx.bin	\
	test-libelf-mmap.bin		\
	test-libnuma.bin		\
@@ -99,6 +100,9 @@ $(OUTPUT)test-libelf-mmap.bin:
$(OUTPUT)test-libelf-getphdrnum.bin:
	$(BUILD) -lelf

$(OUTPUT)test-libelf-gelf_getnote.bin:
	$(BUILD) -lelf

$(OUTPUT)test-libelf-getshdrstrndx.bin:
	$(BUILD) -lelf

+5 −0
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@
# include "test-libelf-getphdrnum.c"
#undef main

#define main main_test_libelf_gelf_getnote
# include "test-libelf-gelf_getnote.c"
#undef main

#define main main_test_libelf_getshdrstrndx
# include "test-libelf-getshdrstrndx.c"
#undef main
@@ -153,6 +157,7 @@ int main(int argc, char *argv[])
	main_test_dwarf();
	main_test_dwarf_getlocations();
	main_test_libelf_getphdrnum();
	main_test_libelf_gelf_getnote();
	main_test_libelf_getshdrstrndx();
	main_test_libunwind();
	main_test_libaudit();
+7 −0
Original line number Diff line number Diff line
#include <stdlib.h>
#include <gelf.h>

int main(void)
{
	return gelf_getnote(NULL, 0, NULL, NULL, NULL);
}
+6 −0
Original line number Diff line number Diff line
@@ -309,6 +309,12 @@ ifndef NO_LIBELF
    CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
  endif

  ifeq ($(feature-libelf-gelf_getnote), 1)
    CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT
  else
    msg := $(warning gelf_getnote() not found on libelf, SDT support disabled);
  endif

  ifeq ($(feature-libelf-getshdrstrndx), 1)
    CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
  endif
Loading