Subject: Re: GCC problems.
To: Anders Magnusson <ragge@ludd.luth.se>
From: Matt Thomas <matt@3am-software.com>
List: port-vax
Date: 09/08/1998 14:53:16
At 02:19 PM 9/8/98 , Anders Magnusson wrote:
>I started hunting a bug this evening that caused ld to dump core 
>sometimes; like when compiling rbootd or xsetroot. This turned out
>to be a bug generated by gcc; merely the way it handles bitfields:
>
>If there is a bitfield struct of size 4 bytes, and bit 22 is referenced
>gcc will generate something like "rotl $31,2(r0)" if the bitfield address
>is in r0. This will cause bytes 2-5 to be referenced but only byte 0-3
>is legal, so a segmentation fault will occur.
>
>If anyone like to teach gcc to DTRT i would be very happy :-) I think
>it looks like an odd way of doing this instead of using extzv.

I'll look at it eventually.  I've been having to hack at GCC anyways
so that it produces PIC code (for shared libraries).  Gcc sometimes
emits code like

	movl	_foo+356(r2), r3

thinking that _foo is at a fixed address.  That isn't true when
generating PIC code.  It should really generate:

	movab	_foo, r4
	movl	356(r4)[r2], r3

Then the assembler can move _foo into the global offset table and
change that first instruction to:

	movab	*_GLOBAL_OFFSET_TABLE+_foo_OFF, r4


-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt/
Sunnyvale, CA             Disclaimer: I avow all knowledge of this message