NetBSD Problem Report #10582

Received: (qmail 15402 invoked from network); 14 Jul 2000 06:03:35 -0000
Message-Id: <200007140602.PAA07339@icnmp9.icg.tnr.sharp.co.jp>
Date: Fri, 14 Jul 2000 15:02:36 +0900 (JST)
From: itohy@netbsd.org
Reply-To: itohy@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: namespace pollution in profiled libc (symbol "mcount")
X-Send-Pr-Version: 3.95

>Number:         10582
>Category:       port-alpha
>Synopsis:       namespace pollution in profiled libc (symbol "mcount")
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    thorpej
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 14 06:04:00 +0000 2000
>Closed-Date:    
>Last-Modified:  Fri May 21 23:20:01 +0000 2021
>Originator:     ITOH Yasufumi
>Release:        1.5B (July 14, 2000)
>Organization:

>Environment:
	Broke down (;_;)


>Description:
	Profiled (cc -pg) libc has global symbol "mcount",
	which pollutes user namespace.

>How-To-Repeat:
	Look at sys/arch/alpha/include/profile.h.

>Fix:
--- sys/arch/alpha/include/profile.h.orig	Sat Aug 30 17:40:33 1997
+++ sys/arch/alpha/include/profile.h	Fri Jul 14 14:54:56 2000
@@ -27,7 +27,7 @@
  * rights to redistribute these changes.
  */

-#define	_MCOUNT_DECL	void mcount
+#define	_MCOUNT_DECL	static void mcount

 #if 0
 /*
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: port-alpha-maintainer->thorpej
Responsible-Changed-By: thorpej@NetBSD.org
Responsible-Changed-When: Tue, 13 Oct 2020 15:35:11 +0000
Responsible-Changed-Why:
Take.


From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-alpha/10582: namespace pollution in profiled libc (symbol
 "mcount")
Date: Fri, 21 May 2021 23:16:30 +0000

 The existing patch from 2000 won't work; on alpha the function named
 by _MCOUNT_DECL needs to be global (it is called from
 common/lib/libc/arch/alpha/gmon/_mcount.S, but lives in
 common/lib/libc/gmon/mcount.c) so the correct change is:

 Index: arch/alpha/include/profile.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/alpha/include/profile.h,v
 retrieving revision 1.11
 diff -u -r1.11 profile.h
 --- arch/alpha/include/profile.h	6 Feb 2012 02:14:13 -0000	1.11
 +++ arch/alpha/include/profile.h	21 May 2021 23:10:41 -0000
 @@ -41,5 +41,5 @@
  	(void)_alpha_pal_swpipl(s);
  #endif /* _KERNEL */

 -#define	_MCOUNT_DECL	void mcount
 -#define	_MCOUNT_FUNC	mcount
 +#define	_MCOUNT_DECL	void __mcount
 +#define	_MCOUNT_FUNC	__mcount


 Note that the compiler calls _mcount, which is the code in _mcount.S
 and is responsible for saving registers; that in turn calls
 _MCOUNT_FUNC, which is MI C code that does the real work. It is
 possible to make _MCOUNT_FUNC static if _mcount is provided in
 machine/profile.h (in the macro MCOUNT) so it gets inserted in
 mcount.c, but alpha doesn't do this and changing it is probably not
 worthwhile.

 Note that there are no libc compat issues because profiling
 executables are always statically linked.

 -- 
 David A. Holland
 dholland@netbsd.org

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.