From owner-freebsd-current Wed Mar 29 3:10:27 2000 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 7AFDF37C10A for ; Wed, 29 Mar 2000 03:10:21 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id VAA29925; Wed, 29 Mar 2000 21:15:56 +1000 Date: Wed, 29 Mar 2000 21:09:45 +1000 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: Matthew Dillon Cc: Gary Jennejohn , freebsd-current@FreeBSD.ORG Subject: Re: Very weird assembly failure (was Re: UP kernel performance and Matt Dillon's patches) In-Reply-To: <200003290348.TAA56657@apollo.backplane.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 28 Mar 2000, Matthew Dillon wrote: > I found a couple of minor nits, but only one real bug. In i386/swtch.s > I forgot to change out a WANT_RESCHED for AST_RESCHED: > > sw1a: > call _chooseproc /* trash ecx, edx, ret eax*/ > testl %eax,%eax > CROSSJUMP(je, _idle, jne) /* if no proc, idle */ > movl %eax,%ecx > > xorl %eax,%eax > andl $~WANT_RESCHED,_astpending > > The problem is that a kernel build is not reporting any errors! > WANT_RESCHED does not exist at all, anywhere. If I change it to > a garbage name the kernel still builds. I don't get it. It seems to be a gas bug. The error is detected if ~WANT_RESCHED is replaced by WANT_RESCHED. ~WANT_RESCHED is no a simple relocatable expression, so it isn't clear that gas or elf can handle it. They don't seem to for the following simpler case: $ echo "movl $~FOO,%eax" >z.s $ echo ".globl foo; .set FOO,0x55555555" >z1.s $ cc -c z.s z1.s $ ld -o z z.o z1.s $ objdump --disassemble z z: file format elf32-i386 Disassembly of section .text: 08048074 <.text>: 8048074: b8 ff ff ff ff movl $0xffffffff,%eax ^^^^^^^^ should be aaaaaaaa but still has best guess at time of assembly of z.s 8048079: 90 nop 804807a: 90 nop 804807b: 90 nop Everthing works right for "FOO" instead of ~FOO. The aout case gets this wrong in a more obvious way. Gas produces the same code for "movl $~FOO,%eax" as for "movl $FOO,%eax". Linking to z1.o then gives the right value for $FOO and the wrong value for $~FOO. Gas notices the problem for "movl $-FOO,%eax": z.s: Assembler messages: z.s:1: Error: Negative of non-absolute symbol FOO Similarly for the a.out case. Complementation is equivalent to negation on 2's complement machines, so gas should produce this error for $~FOO too. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message