linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Brendan Gregg <brendan.d.gregg@gmail.com>,
	Hemant Kumar <hemant@linux.vnet.ibm.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 04/16] perf build: Add feature detection for libelf's elf_getshdrstrndx()
Date: Mon,  4 Jul 2016 21:38:23 -0300	[thread overview]
Message-ID: <1467679115-20496-5-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1467679115-20496-1-git-send-email-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

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>
---
 tools/build/Makefile.feature                    | 1 +
 tools/build/feature/Makefile                    | 4 ++++
 tools/build/feature/test-all.c                  | 5 +++++
 tools/build/feature/test-libelf-getshdrstrndx.c | 8 ++++++++
 tools/perf/config/Makefile                      | 4 ++++
 tools/perf/util/symbol-elf.c                    | 8 ++++++++
 6 files changed, 30 insertions(+)
 create mode 100644 tools/build/feature/test-libelf-getshdrstrndx.c

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 :=			\
 	libbfd				\
 	libelf				\
 	libelf-getphdrnum		\
+	libelf-getshdrstrndx		\
 	libelf-mmap			\
 	libnuma				\
 	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=					\
 	test-cplus-demangle.bin		\
 	test-libelf.bin			\
 	test-libelf-getphdrnum.bin	\
+	test-libelf-getshdrstrndx.bin	\
 	test-libelf-mmap.bin		\
 	test-libnuma.bin		\
 	test-numa_num_possible_cpus.bin	\
@@ -98,6 +99,9 @@ $(OUTPUT)test-libelf-mmap.bin:
 $(OUTPUT)test-libelf-getphdrnum.bin:
 	$(BUILD) -lelf
 
+$(OUTPUT)test-libelf-getshdrstrndx.bin:
+	$(BUILD) -lelf
+
 $(OUTPUT)test-libnuma.bin:
 	$(BUILD) -lnuma
 
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 @@
 # include "test-libelf-getphdrnum.c"
 #undef main
 
+#define main main_test_libelf_getshdrstrndx
+# include "test-libelf-getshdrstrndx.c"
+#undef main
+
 #define main main_test_libunwind
 # include "test-libunwind.c"
 #undef main
@@ -149,6 +153,7 @@ int main(int argc, char *argv[])
 	main_test_dwarf();
 	main_test_dwarf_getlocations();
 	main_test_libelf_getphdrnum();
+	main_test_libelf_getshdrstrndx();
 	main_test_libunwind();
 	main_test_libaudit();
 	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 @@
+#include <libelf.h>
+
+int main(void)
+{
+	size_t dst;
+
+	return elf_getshdrstrndx(0, &dst);
+}
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
     CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
   endif
 
+  ifeq ($(feature-libelf-getshdrstrndx), 1)
+    CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
+  endif
+
   ifndef NO_DWARF
     ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
       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)
 }
 #endif
 
+#ifndef HAVE_ELF_GETSHDRSTRNDX_SUPPORT
+static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused)
+{
+	pr_err("%s: update your libelf to > 0.140, this one lacks elf_getshdrstrndx().\n", __func__);
+	return -1;
+}
+#endif
+
 #ifndef NT_GNU_BUILD_ID
 #define NT_GNU_BUILD_ID 3
 #endif
-- 
2.7.4

  parent reply	other threads:[~2016-07-05  0:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05  0:38 [GIT PULL 00/16] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 01/16] perf probe: Use cache entry if possible Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 02/16] perf probe: Show all cached probes Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 03/16] perf probe: Remove caches when --cache is given Arnaldo Carvalho de Melo
2016-07-05  0:38 ` Arnaldo Carvalho de Melo [this message]
2016-07-05  0:38 ` [PATCH 05/16] perf sdt: ELF support for SDT Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 06/16] perf probe: Add group name support Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 07/16] perf buildid-cache: Scan and import user SDT events to probe cache Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 08/16] perf header: Transform nodes string info to struct Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 09/16] perf tests: Fix hist accumulation test Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 10/16] perf unwind: Add initialized arg into unwind__prepare_access Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 11/16] perf unwind: Call unwind__prepare_access for forked thread Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 12/16] tools lib bpf: Add license header Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 13/16] tools lib api: Respect WERROR=0 for build Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 14/16] tools lib subcmd: " Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 15/16] perf tools: Update android build documentation Arnaldo Carvalho de Melo
2016-07-05  0:38 ` [PATCH 16/16] perf tools: Sync copy of syscall_64.tbl with the kernel Arnaldo Carvalho de Melo
2016-07-05 10:14 ` [GIT PULL 00/16] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467679115-20496-5-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=brendan.d.gregg@gmail.com \
    --cc=hemant@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).