From owner-freebsd-bugs Fri Oct 11 02:30:37 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id CAA02948 for bugs-outgoing; Fri, 11 Oct 1996 02:30:37 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id CAA02796 for ; Fri, 11 Oct 1996 02:25:51 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.7.6/8.6.9) id TAA20179; Fri, 11 Oct 1996 19:17:11 +1000 Date: Fri, 11 Oct 1996 19:17:11 +1000 From: Bruce Evans Message-Id: <199610110917.TAA20179@godzilla.zeta.org.au> To: bugs@freebsd.org, jin@george.lbl.gov Subject: Re: compiler bug in 2.2-961006-SNAP release Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >2.2-961006-SNAP introduces a bug in C compiler. The initialization uses >memset which is only available in user space. So, if kernel has such code >like: > >Mystruct V = {any#}; ^^^^all zeros > >It will causes kernel linking failure: > >loading kernel >znatm.Dro: Undefined symbol `_memset' referenced from text segment This is best fixed by not using auto initializers for structs. They tend to be inefficient, and for all-zero initializes, gcc-2.7-2 only handles ones of the following sizes efficiently: 1, 2, 4, 8. It calls memset() to for all other cases. gcc-2.7.2 handles small nonzero auto struct initializers better by copying a template using its builtin memcpy (except for -O0 it calls memcpy). I fixed this problem in ipx_usrreq.c. The initializer was redundant. Bruce RCS file: /a/ncvs/src/sys/netipx/ipx_usrreq.c,v ---------------------------- revision 1.6 date: 1996/04/13 14:37:22; author: jhay; state: Exp; lines: +6 -2 Don't use a newfangled auto initializer. Initialize everything by assignment to avoid one bug and several pessimizations. In the old version, gcc-2.6.3 (i386 version) generates 16 bytes of static data and copies it using 4 4-byte load-stores. gcc-2.7.2 generates 2 1-byte stores and calls memset() to zero 14 bytes. Linking fails because memset() doesn't exist in the kernel. In both versions, the 2 bytes stored directly are all that is actually used unless the null padding at the end is used, since the 3 4-byte words in the middle are initialized again by struct assignment. These words are misaligned. gcc generates misaligned load-stores for (small) misaligned struct copies. Submitted by: Bruce Evans