Date: Fri, 11 Oct 1996 19:17:11 +1000 From: Bruce Evans <bde@zeta.org.au> To: bugs@freebsd.org, jin@george.lbl.gov Subject: Re: compiler bug in 2.2-961006-SNAP release Message-ID: <199610110917.TAA20179@godzilla.zeta.org.au>
index | next in thread | raw e-mail
>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
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610110917.TAA20179>
