From dunstan@freebsd.czest.pl  Thu Jul 14 11:42:54 2005
Return-Path: <dunstan@freebsd.czest.pl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8F50416A41C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Jul 2005 11:42:54 +0000 (GMT)
	(envelope-from dunstan@freebsd.czest.pl)
Received: from freebsd.czest.pl (silver.iplus.pl [80.48.250.4])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CA5D243D46
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Jul 2005 11:42:50 +0000 (GMT)
	(envelope-from dunstan@freebsd.czest.pl)
Received: from freebsd.czest.pl (freebsd.czest.pl [80.48.250.4])
	by freebsd.czest.pl (8.12.10/8.12.9) with ESMTP id j6EBuJGW031587
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Jul 2005 11:56:20 GMT
	(envelope-from dunstan@freebsd.czest.pl)
Received: (from dunstan@localhost)
	by freebsd.czest.pl (8.12.10/8.12.9/Submit) id j6EBuIhU031586;
	Thu, 14 Jul 2005 11:56:19 GMT
	(envelope-from dunstan)
Message-Id: <200507141156.j6EBuIhU031586@freebsd.czest.pl>
Date: Thu, 14 Jul 2005 11:56:19 GMT
From: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
Reply-To: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] ndis won't compile with kernel profiling enabled
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         83445
>Category:       kern
>Synopsis:       [ndis] [patch] ndis won't compile with kernel profiling enabled
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 14 11:50:12 GMT 2005
>Closed-Date:    Tue Dec 20 13:48:32 GMT 2005
>Last-Modified:  Tue Dec 20 13:48:32 GMT 2005
>Originator:     Wojciech A. Koszek
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD laptop.freebsd.czest.pl 5.4-STABLE FreeBSD 5.4-STABLE #2: Tue Jul 5 22:56:49 CEST 2005 dunstan@laptop.freebsd.czest.pl:/usr/obj/usr/src/sys/LAPTOP2 i386


>Description:
With kernel profiling enabled (-p[p] in CONFIGARGS) I'm
not able to properly compile ndis(4). Build process 
stops on:
(src/sys/compat/ndis/winx32_wrap.S):
[..]
	ret	$0xFF
[..]	
After changing this instructions to their proper op-code:
	.byte	0xC2
	.byte	0xFF
	.byte	0x00
everything seems to be just fine (ndis compiles). Since
this change needs to be made in order to satisfy compiler,
I belive it doesn't touch typical behaviour.
>How-To-Repeat:
cd /usr/src/sys/modules/ndis
env CFLAGS=-DGPROF make
[..]
anding -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-p              
rototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions -std=c99 -c               
/usr/src/sys/modules/ndis/../../compat/ndis/winx32_wrap.S
/usr/src/sys/modules/ndis/../../compat/ndis/winx32_wrap.S: Assembler messages:
/usr/src/sys/modules/ndis/../../compat/ndis/winx32_wrap.S:127: Error: junk at en              
d of line, first unrecognized character is `$'
/usr/src/sys/modules/ndis/../../compat/ndis/winx32_wrap.S:198: Error: junk at en              
d of line, first unrecognized character is `$'
*** Error code 1
[..]

>Fix:
Patch [diff.0.winx32_wrap.S] corrects this problem.

--- ndis begins here ---
Patch against FreeBSD 5.4-STABLE, kern.osreldate: 504102.

diff -upr /usr/src/sys/compat/ndis/winx32_wrap.S src/sys/compat/ndis/winx32_wrap.S
--- /usr/src/sys/compat/ndis/winx32_wrap.S	Sun May 22 20:18:13 2005
+++ src/sys/compat/ndis/winx32_wrap.S	Thu Jul 14 12:43:13 2005
@@ -123,8 +123,15 @@ x86_stdcall_wrap_call:
 	mov	%esi,%eax	# restore return val
 	pop	%edi
 	pop	%esi
+
+/*
+ * In order to compile kernel with profiling enabled,
+ * 'ret $0xFF' needs to be placed here in binary form.
+ */
 x86_stdcall_wrap_arg:
-	ret	$0xFF
+	.byte	0xC2
+	.byte	0xFF
+	.byte	0x00
 x86_stdcall_wrap_end:
 
 
@@ -194,8 +201,15 @@ x86_fastcall_wrap_call:
 
 	pop	%eax		# restore return val
 	add	$12,%esp	# clean the stack
+
+/*
+ * In order to compile kernel with profiling enabled,
+ * 'ret $0xFF' needs to be placed here in binary form.
+ */
 x86_fastcall_wrap_arg:
-	ret	$0xFF
+	.byte	0xC2
+	.byte	0xFF
+	.byte	0x00
 x86_fastcall_wrap_end:
 
 /*
--- ndis ends here ---

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
Cc: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: kern/83445: [PATCH] ndis won't compile with kernel profiling
 enabled
Date: Thu, 14 Jul 2005 23:50:59 +1000 (EST)

 >> Description:
 > With kernel profiling enabled (-p[p] in CONFIGARGS) I'm
 > not able to properly compile ndis(4). Build process
 > stops on:
 > (src/sys/compat/ndis/winx32_wrap.S):
 > [..]
 > 	ret	$0xFF
 > [..]
 
 I think it would work with plain profiling (-p), but with high
 resolution profiling (-pp), it would neither compile nor work,
 since "ret" is a macro in that case in order to make it work.
 
 > After changing this instructions to their proper op-code:
 > 	.byte	0xC2
 > 	.byte	0xFF
 > 	.byte	0x00
 > everything seems to be just fine (ndis compiles). Since
 > this change needs to be made in order to satisfy compiler,
 > I belive it doesn't touch typical behaviour.
 
 This would make high resolution profiling compile but not work.
 There must be a call to mexitcount just before the return.
 The ENTRY() macro hides the corresponding complications for
 entry to functions and the ret macro handles most cases for
 exit.
 
 Large amounts of assembler code are likely to have other bugs
 in mcounting.  The templates are especially difficult to handle
 correctly -- gprof won't be able to find the addresses in code
 constructed at runtime, so the runtime-only addresses should
 somehow be mapped to compile-time addresses.
 
 This is mostly moot for ndis since binary-only modules can't
 support profiling.
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: flz 
State-Changed-When: Tue Dec 20 13:46:13 UTC 2005 
State-Changed-Why:  
Submitter asked the PR to be closed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83445 
>Unformatted:
