linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] Fixing the __gcov_init problem
@ 2005-03-13  6:53 Jeff Dike
  2005-03-14 19:16 ` Blaisorblade
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Dike @ 2005-03-13  6:53 UTC (permalink / raw)
  To: Blaisorblade, Adrian Bunk; +Cc: user-mode-linux-devel

OK, below is my latest attempt at getting this right.  It provides a weak
definition of __gcov_init for gcc's that don't generate it, while gcc's that
do will have their's override this one.

The patch is against -bk8.

				Jeff

# Try to finally fix the __gcov_init thing corectly.
# This patch makes a weak definition of __gcov_init, which will be used if
# there is no other definition, and which will be overridden if there is a
# real definition.  Thus, if it is not used, then the weak definition will
# satisfy the EXPORT_SYMBOL, and if it is, then the real one will.
Index: linux-2.6.11/arch/um/kernel/gmon_syms.c
===================================================================
--- linux-2.6.11.orig/arch/um/kernel/gmon_syms.c	2005-03-12 18:59:48.000000000 -0500
+++ linux-2.6.11/arch/um/kernel/gmon_syms.c	2005-03-12 22:44:31.000000000 -0500
@@ -10,17 +10,13 @@
 extern void __gcov_init(void *);
 EXPORT_SYMBOL(__gcov_init);
 #else
+#endif
+
 extern void __bb_init_func(void *);
 EXPORT_SYMBOL(__bb_init_func);
-#endif
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+void  __attribute__((weak)) __gcov_init(void *arg)
+{
+}
+
+EXPORT_SYMBOL(__gcov_init);



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [uml-devel] Fixing the __gcov_init problem
  2005-03-13  6:53 [uml-devel] Fixing the __gcov_init problem Jeff Dike
@ 2005-03-14 19:16 ` Blaisorblade
  2005-03-14 22:19   ` Jeff Dike
  0 siblings, 1 reply; 3+ messages in thread
From: Blaisorblade @ 2005-03-14 19:16 UTC (permalink / raw)
  To: user-mode-linux-devel; +Cc: Jeff Dike, Adrian Bunk

[-- Attachment #1: Type: text/plain, Size: 618 bytes --]

On Sunday 13 March 2005 07:53, Jeff Dike wrote:
> OK, below is my latest attempt at getting this right.  It provides a weak
> definition of __gcov_init for gcc's that don't generate it, while gcc's
> that do will have their's override this one.
The obtained code by this patch is a bit of a mess... plus there is a bunch of 
other problems (I've posted another mail with the description of the 
problems).
The patch below is a partial solution to all them...
> The patch is against -bk8.
>
>     Jeff


-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade

[-- Attachment #2: uml-real-fix-gcov-symbols.patch --]
[-- Type: text/x-diff, Size: 5259 bytes --]


From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
CC: Anton Altaparmakov <aia21@cam.ac.uk>

Correctly export __gcov_init for cases where it's needed, by adding a weak
definition for the case when GCC does not define this symbol and letting it
being overriden by the real definition when GCC defines it (recent ones).

Can't be implemented as a test on GCC version because SuSE has a crippled GCC,
declared as 3.3.4 but having a lot of backported features.

Also, since gcc 3.4.3 requires profiling options even during linking, avoid
adding profiling options for compilation of userspace utilities (where they
are not needed). And add profiling options to final link stage.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 linux-2.6.11-paolo/arch/um/Makefile               |    6 +++++-
 linux-2.6.11-paolo/arch/um/Makefile-skas          |   10 ++++++----
 linux-2.6.11-paolo/arch/um/kernel/gmon_syms.c     |   17 +++++++++++------
 linux-2.6.11-paolo/arch/um/sys-i386/util/Makefile |    4 ++--
 linux-2.6.11-paolo/arch/um/util/Makefile          |    4 ++--
 5 files changed, 26 insertions(+), 15 deletions(-)

diff -puN arch/um/kernel/gmon_syms.c~uml-real-fix-gcov-symbols arch/um/kernel/gmon_syms.c
--- linux-2.6.11/arch/um/kernel/gmon_syms.c~uml-real-fix-gcov-symbols	2005-03-13 20:47:53.000000000 +0100
+++ linux-2.6.11-paolo/arch/um/kernel/gmon_syms.c	2005-03-13 20:47:53.000000000 +0100
@@ -5,14 +5,19 @@
 
 #include "linux/module.h"
 
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) || \
-	(__GNUC__ == 3 && __GNUC_MINOR__ == 3 && __GNUC_PATCHLEVEL__ >= 4)
-extern void __gcov_init(void *);
-EXPORT_SYMBOL(__gcov_init);
-#else
 extern void __bb_init_func(void *);
 EXPORT_SYMBOL(__bb_init_func);
-#endif
+
+/* This is defined (and referred to in profiling stub code) only by some GCC
+ * versions in libgcov.
+ *
+ * Since SuSE backported the fix, we cannot handle it depending on GCC version.
+ * So, unconditinally export it. But also give it a weak definition, which will
+ * be overriden by any other one.
+ */
+
+extern void __gcov_init(void *) __attribute__((weak));
+EXPORT_SYMBOL(__gcov_init);
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
diff -puN arch/um/util/Makefile~uml-real-fix-gcov-symbols arch/um/util/Makefile
--- linux-2.6.11/arch/um/util/Makefile~uml-real-fix-gcov-symbols	2005-03-13 20:47:53.000000000 +0100
+++ linux-2.6.11-paolo/arch/um/util/Makefile	2005-03-13 20:47:53.000000000 +0100
@@ -4,5 +4,5 @@ always			:= $(hostprogs-y)
 mk_task-objs		:= mk_task_user.o mk_task_kern.o
 mk_constants-objs	:= mk_constants_user.o mk_constants_kern.o
 
-HOSTCFLAGS_mk_task_kern.o	:= $(CFLAGS) $(CPPFLAGS)
-HOSTCFLAGS_mk_constants_kern.o	:= $(CFLAGS) $(CPPFLAGS)
+HOSTCFLAGS_mk_task_kern.o	:= $(CFLAGS_noprof) $(CPPFLAGS)
+HOSTCFLAGS_mk_constants_kern.o	:= $(CFLAGS_noprof) $(CPPFLAGS)
diff -puN arch/um/Makefile~uml-real-fix-gcov-symbols arch/um/Makefile
--- linux-2.6.11/arch/um/Makefile~uml-real-fix-gcov-symbols	2005-03-13 20:47:53.000000000 +0100
+++ linux-2.6.11-paolo/arch/um/Makefile	2005-03-13 20:47:53.000000000 +0100
@@ -65,6 +65,10 @@ USER_CFLAGS := $(patsubst -D__KERNEL__,,
 CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask
 CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
 
+#XXX: Avoid compiling userspace utilities with profiling. Kludgy, but going away soon.
+CFLAGS_noprof := $(patsubst -fprofile-arcs -ftest-coverage,,$(patsubst -pg,,$(CFLAGS)))
+USER_CFLAGS_noprof := $(patsubst -fprofile-arcs -ftest-coverage,,$(patsubst -pg,,$(USER_CFLAGS)))
+
 #This will adjust *FLAGS accordingly to the platform.
 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
 
@@ -199,4 +203,4 @@ $(ARCH_DIR)/util: scripts_basic $(SYS_DI
 $(ARCH_DIR)/kernel/skas/util: scripts_basic FORCE
 	$(Q)$(MAKE) $(build)=$@
 
-export SUBARCH USER_CFLAGS OS
+export SUBARCH USER_CFLAGS OS CFLAGS_noprof USER_CFLAGS_noprof
diff -puN arch/um/sys-i386/util/Makefile~uml-real-fix-gcov-symbols arch/um/sys-i386/util/Makefile
--- linux-2.6.11/arch/um/sys-i386/util/Makefile~uml-real-fix-gcov-symbols	2005-03-13 20:47:53.000000000 +0100
+++ linux-2.6.11-paolo/arch/um/sys-i386/util/Makefile	2005-03-13 20:47:53.000000000 +0100
@@ -4,5 +4,5 @@ always		:= $(hostprogs-y)
 
 mk_thread-objs	:= mk_thread_kern.o mk_thread_user.o
 
-HOSTCFLAGS_mk_thread_kern.o	:= $(CFLAGS) $(CPPFLAGS)
-HOSTCFLAGS_mk_thread_user.o	:= $(USER_CFLAGS)
+HOSTCFLAGS_mk_thread_kern.o	:= $(CFLAGS_noprof) $(CPPFLAGS)
+HOSTCFLAGS_mk_thread_user.o	:= $(USER_CFLAGS_noprof)
diff -puN arch/um/Makefile-skas~uml-real-fix-gcov-symbols arch/um/Makefile-skas
--- linux-2.6.11/arch/um/Makefile-skas~uml-real-fix-gcov-symbols	2005-03-13 20:48:03.000000000 +0100
+++ linux-2.6.11-paolo/arch/um/Makefile-skas	2005-03-13 20:50:36.000000000 +0100
@@ -3,10 +3,12 @@
 # Licensed under the GPL
 #
 
-PROFILE += -pg
+GPROF_OPT += -pg
+GCOV_OPT += -fprofile-arcs -ftest-coverage
 
-CFLAGS-$(CONFIG_GCOV) += -fprofile-arcs -ftest-coverage
-CFLAGS-$(CONFIG_GPROF) += $(PROFILE)
-LINK-$(CONFIG_GPROF) += $(PROFILE)
+CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
+CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
+LINK-$(CONFIG_GCOV) += $(GCOV_OPT)
+LINK-$(CONFIG_GPROF) += $(GPROF_OPT)
 
 GEN_HEADERS += $(ARCH_DIR)/include/skas_ptregs.h
_

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [uml-devel] Fixing the __gcov_init problem
  2005-03-14 19:16 ` Blaisorblade
@ 2005-03-14 22:19   ` Jeff Dike
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Dike @ 2005-03-14 22:19 UTC (permalink / raw)
  To: Blaisorblade; +Cc: user-mode-linux-devel, Adrian Bunk

blaisorblade@yahoo.it said:
> The obtained code by this patch is a bit of a mess... plus there is a
> bunch of  other problems (I've posted another mail with the
> description of the  problems). The patch below is a partial solution
> to all them... 

Sigh.  OK, I'll drop that in my tree for now in place of mine, but won't send
it anywhere until we think it is roughly right.

				Jeff



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-14 21:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-13  6:53 [uml-devel] Fixing the __gcov_init problem Jeff Dike
2005-03-14 19:16 ` Blaisorblade
2005-03-14 22:19   ` Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox