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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1348824728-14025-11-git-send-email-namhyung@kernel.org>
Date:	Fri, 28 Sep 2012 18:32:06 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...nel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Namhyung Kim <namhyung.kim@....com>,
	Markus Trippelsdorf <markus@...ppelsdorf.de>,
	Mike Frysinger <vapier@...too.org>
Subject: [PATCH 10/12] perf tools: Convert to DEMANGLE_SUPPORT

From: Namhyung Kim <namhyung.kim@....com>

For building perf without name demangling, we can set NO_DEMANGLE=1 as
a argument of make.  It then defines NO_DEMANGLE macro for C code to
do the proper handling.  However it usually used in a negative
semantics - e.g. #ifndef - so we saw double negations which can be
misleading.  Convert it to a positive form to make it more readable.

Also add _SUPPORT suffix for consistency and make PACKAGE variable has
a string value "perf".

Cc: Markus Trippelsdorf <markus@...ppelsdorf.de>
Cc: Mike Frysinger <vapier@...too.org>
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/Makefile      | 12 +++++++-----
 tools/perf/util/symbol.h | 19 +++++++++++--------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 45f8920bab2b..dd5b9a0507c7 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -696,36 +696,38 @@ else
   endif
 endif
 
-ifdef NO_DEMANGLE
-	BASIC_CFLAGS += -DNO_DEMANGLE
-else
+ifndef NO_DEMANGLE
         ifdef HAVE_CPLUS_DEMANGLE
 		EXTLIBS += -liberty
+		BASIC_CFLAGS += -DDEMANGLE_SUPPORT
 		BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
         else
-		FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
+		FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='"perf"' -lbfd
 		has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
 		ifeq ($(has_bfd),y)
 			EXTLIBS += -lbfd
+			BASIC_CFLAGS += -DDEMANGLE_SUPPORT
 		else
 			FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
 			has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY))
 			ifeq ($(has_bfd_iberty),y)
 				EXTLIBS += -lbfd -liberty
+				BASIC_CFLAGS += -DDEMANGLE_SUPPORT
 			else
 				FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
 				has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z))
 				ifeq ($(has_bfd_iberty_z),y)
 					EXTLIBS += -lbfd -liberty -lz
+					BASIC_CFLAGS += -DDEMANGLE_SUPPORT
 				else
 					FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty
 					has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE))
 					ifeq ($(has_cplus_demangle),y)
 						EXTLIBS += -liberty
+						BASIC_CFLAGS += -DDEMANGLE_SUPPORT
 						BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
 					else
 						msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
-						BASIC_CFLAGS += -DNO_DEMANGLE
 					endif
 				endif
 			endif
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 8b6ef7fac745..e1484bb080e6 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -18,26 +18,29 @@
 #include <elf.h>
 #endif
 
-#ifdef HAVE_CPLUS_DEMANGLE
+#ifdef DEMANGLE_SUPPORT
+
+# ifdef HAVE_CPLUS_DEMANGLE
 extern char *cplus_demangle(const char *, int);
 
 static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
 {
 	return cplus_demangle(c, i);
 }
-#else
-#ifdef NO_DEMANGLE
+# else /* HAVE_CPLUS_DEMANGLE */
+#  define PACKAGE "perf"
+#  include <bfd.h>
+# endif /* HAVE_CPLUS_DEMANGLE */
+
+#else /* DEMANGLE_SUPPORT */
+
 static inline char *bfd_demangle(void __maybe_unused *v,
 				 const char __maybe_unused *c,
 				 int __maybe_unused i)
 {
 	return NULL;
 }
-#else
-#define PACKAGE 'perf'
-#include <bfd.h>
-#endif
-#endif
+#endif /* DEMANGLE_SUPPORT */
 
 int hex2u64(const char *ptr, u64 *val);
 char *strxfrchar(char *s, char from, char to);
-- 
1.7.11.4

--
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