lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 23 Oct 2009 23:37:14 +0300
From:	Marti Raudsepp <marti@...fo.org>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	Marti Raudsepp <marti@...fo.org>,
	Paul Mackerras <paulus@...ba.org>, Ingo Molnar <mingo@...e.hu>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	Mike Galbraith <efault@....de>, linux-kernel@...r.kernel.org
Subject: [PATCH] perf tools: add compatibility with libelf 0.8 and autodetect

The Makefile now automatically defines LIBELF_NO_MMAP when libelf 0.8 is
detected. libelf 0.8 is still maintained and some distributions such as
Arch Linux use it instead of elfutils.

Signed-off-by: Marti Raudsepp <marti@...fo.org>
---
 tools/perf/Makefile      |    6 +++++-
 tools/perf/util/symbol.c |   12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 742a32e..46e877b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -422,7 +422,11 @@ ifeq ($(uname_S),Darwin)
 	PTHREAD_LIBS =
 endif
 
-ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
+ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
+	ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
+		BASIC_CFLAGS += -DLIBELF_NO_MMAP
+	endif
+else
 	msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
 endif
 
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 47ea060..8d1df1e 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -413,7 +413,11 @@ static int dso__synthesize_plt_symbols(struct  dso *self, int v)
 	if (fd < 0)
 		goto out;
 
+#ifdef LIBELF_NO_MMAP
+	elf = elf_begin(fd, ELF_C_READ, NULL);
+#else
 	elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
+#endif
 	if (elf == NULL)
 		goto out_close;
 
@@ -533,7 +537,11 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
 	Elf *elf;
 	int nr = 0, kernel = !strcmp("[kernel]", self->name);
 
+#ifdef LIBELF_NO_MMAP
+	elf = elf_begin(fd, ELF_C_READ, NULL);
+#else
 	elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
+#endif
 	if (elf == NULL) {
 		if (v)
 			fprintf(stderr, "%s: cannot read %s ELF file.\n",
@@ -675,7 +683,11 @@ static char *dso__read_build_id(struct dso *self, int v)
 	if (fd < 0)
 		goto out;
 
+#ifdef LIBELF_NO_MMAP
+	elf = elf_begin(fd, ELF_C_READ, NULL);
+#else
 	elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
+#endif
 	if (elf == NULL) {
 		if (v)
 			fprintf(stderr, "%s: cannot read %s ELF file.\n",
-- 
1.6.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ