From owner-freebsd-current Wed Mar 29 8: 7:56 2000 Delivered-To: freebsd-current@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 4082D37C0CC for ; Wed, 29 Mar 2000 08:07:53 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id IAA63043; Wed, 29 Mar 2000 08:07:48 -0800 (PST) (envelope-from dillon) Date: Wed, 29 Mar 2000 08:07:48 -0800 (PST) From: Matthew Dillon Message-Id: <200003291607.IAA63043@apollo.backplane.com> To: Bruce Evans Cc: Gary Jennejohn , freebsd-current@FreeBSD.ORG Subject: Re: Very weird assembly failure (was Re: UP kernel performance and Matt Dillon's patches) References: Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :> 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 Ok, so who do we send your excellent analysis to at GNU-C? I think this is a rather serious bug myself since a programmer can make a simple labelname mistake and get incorrect code instead of an error. Also, probably a simple mistake but complement != negation. I think ~F = -F - 1; -0x0001 == 0xFFFF ~0x0001 == 0xFFFE -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message