perf tools: fix compile with libelf without get_phdrnum
Adrian Hunter
reviewerPATCH 1/1 perf tools: fix compile with libelf without get_phdrnum
Add a feature check for get_phdrnum() and implement a replacement if it is not present.
Signed-off-by Adrian Hunter <[email protected]>
--- tools/perf/config/Makefile | 3 +++ tools/perf/config/feature-tests.mak | 9 +++++++++ tools/perf/util/symbol-elf.c | 16 ++++++++++++++++ 3 files changed, 28 insertions(+)
tools/perf/config/Makefile +3 -0
@@ -180,6 +180,9 @@ FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) CFLAGS += -DLIBELF_MMAP endif +ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM),y) + CFLAGS += -DHAVE_ELF_GETPHDRNUM +endif # include ARCH specific config -include $(src-perf)/arch/$(ARCH)/Makefile
tools/perf/config/feature-tests.mak +9 -0
@@ -61,6 +61,15 @@ int main(void) } endef +define SOURCE_ELF_GETPHDRNUM +#include <libelf.h> +int main(void) +{ + size_t dst; + return elf_getphdrnum(0, &dst); +} +endef + ifndef NO_SLANG define SOURCE_SLANG #include <slang.h>
tools/perf/util/symbol-elf.c +16 -0
@@ -8,6 +8,22 @@#include "symbol.h" #include "debug.h" +#ifndef HAVE_ELF_GETPHDRNUM +static int elf_getphdrnum (Elf *elf,size_t *dst) +{ +GElf_Ehdr gehdr; +GElf_Ehdr *ehdr; + + ehdr =gelf_getehdr (elf, &gehdr); +if (!ehdr) +return -1 ; + + *dst = ehdr->e_phnum; + +return 0 ; +} +#endif +#ifndef NT_GNU_BUILD_ID #define NT_GNU_BUILD_ID 3#endif
Signature · 1 line
1.7.11.7
tip-bot for Adrian Hunter
merge bot[tip:perf/urgent] perf tools: Fix compile with libelf without get_phdrnum
perf tools: Fix compile with libelf without get_phdrnum
Commit-ID: e955d5c434009b661dbb200c601254b0c2d9940a Gitweb: http://git.kernel.org/tip/e955d5c434009b661dbb200c601254b0c2d9940a Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 13 Sep 2013 16:49:30 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 19 Sep 2013 11:32:17 -0300
perf tools: Fix compile with libelf without get_phdrnum
Add a feature check for get_phdrnum() and implement a replacement if it is not present.
Signed-off-by Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/config/Makefile | 3 +++ tools/perf/config/feature-tests.mak | 9 +++++++++ tools/perf/util/symbol-elf.c | 16 ++++++++++++++++ 3 files changed, 28 insertions(+)
tools/perf/config/Makefile +3 -0
@@ -180,6 +180,9 @@ FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) CFLAGS += -DLIBELF_MMAP endif +ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM),y) + CFLAGS += -DHAVE_ELF_GETPHDRNUM +endif # include ARCH specific config -include $(src-perf)/arch/$(ARCH)/Makefile
tools/perf/config/feature-tests.mak +9 -0
@@ -61,6 +61,15 @@ int main(void) } endef +define SOURCE_ELF_GETPHDRNUM +#include <libelf.h> +int main(void) +{ + size_t dst; + return elf_getphdrnum(0, &dst); +} +endef + ifndef NO_SLANG define SOURCE_SLANG #include <slang.h>
tools/perf/util/symbol-elf.c +16 -0
@@ -8,6 +8,22 @@#include "symbol.h" #include "debug.h" +#ifndef HAVE_ELF_GETPHDRNUM +static int elf_getphdrnum (Elf *elf,size_t *dst) +{ +GElf_Ehdr gehdr; +GElf_Ehdr *ehdr; + + ehdr =gelf_getehdr (elf, &gehdr); +if (!ehdr) +return -1 ; + + *dst = ehdr->e_phnum; + +return 0 ; +} +#endif +#ifndef NT_GNU_BUILD_ID #define NT_GNU_BUILD_ID 3#endif