|
From: Steve W. <sc...@ne...> - 2003-03-21 12:40:02
|
Hi,
I've been playing around with SuperH's sh5 toolchain on NetBSD/sh5. (yeah,
this is a Linux list. Bite me... ;-).
At this point, I have it running natively under NetBSD/sh5 and have been
trying to get shared libraries working (don't ask; they're needed for
something else). In the course of this, I found a PIC bug. This may or
may not be a problem for a cross-sh5 compiler from the same sources; I
went straight in at the deep end and build it natively (bootstrapped using
an earlier native sh5 toolchain, before self-hosting it). Someone else can
verify if the cross compiler is similarly afflicted.
Anyhow, the following test case tickles the bug:
--8<--8<--
/*
* Compile with "cc -O2 -fPIC -c" (Note the -fPIC option)
*
* This will segfault in cc1:gen_movsi_const() for -O1 and -O2.
* Compiling with -O0 is fine.
*
* I suspect the problem is due to some interaction between the offset
* of 'wibble.bar' from 'wibble@GOTOFF' and a tail-call to
* 'some_function()' when optimisation is enabled.
*
* Interestingly, removing the 'static' storage class from 'wibble' also
* fixes the problem. So the problem does not affect 'wibble@GOT'. It is
* definately only triggered by 'wibble@GOTOFF'.
*
* As I have no native debugger (yet) on NetBSD/sh5, the only way to
* debug this problem is to catch the segfault in the kernel debugger
* and look at the registers. It's caused by a NULL de-reference in
* gen_movsi_const(). I can provide a few more details if required.
*/
static struct {
int foo;
int bar;
} wibble;
extern void some_function(void *);
void
wobble(void)
{
some_function(&wibble.bar);
#if 0
/* Enabling this statement fixes the problem */
wibble.foo = 0;
#endif
}
--8<--8<--
Of course, if no one else can repeat this, then I'll have to go looking at
a problem somewhere in NetBSD. :-/
Any ideas?
Cheers, Steve
|