Fixing IRIX/GCC structure passing bug (Was: RE: DD'ing IRIX Disks (was Re: [geeks] Apple vs. Sun))

Corda Albert J DLVA CordaAJ at NSWC.NAVY.MIL
Fri Nov 8 17:11:55 CST 2002


I ran into this some time ago... If I remember, it had to do with the
way GCC passed very small structures as parameters, as opposed to the way
MIPSpro passed them.  Structures over a certain byte size were OK, and
passed in the same manner. The problem only occured when calling a library
routine compiled with MIPSpro from code compiled with GCC and passing
a structure (Not a pointer, but the struture itself) to the library routine.
There are only a couple of places this is done, most notably in some of the
inet_* calls, and some of the systems semaphore calls (I _think_)

I remember I cludged a fix by simply defining a union of the actual
passed system parameter structure, and another locally defined "dummy"
structure of 10 or so bytes in length. (I _think_ it was 10... I don't
quite remember.)  I wrote a silly little test program to see what the
minimum size of the dummy structure needed to be to fool GCC into using
the non-optimized structure passing method). Passing the union, rather
than the system-defined parameter structure fixed the problem. (Messy,
but quick and workable)

-al-


> -----Original Message-----
> From: Joshua D Boyd [mailto:jdboyd at cs.millersville.edu]
> Sent: Friday, November 08, 2002 1:19 AM
> To: geeks at sunhelp.org
> Subject: Re: DD'ing IRIX Disks (was Re: [geeks] Apple vs. Sun)
> 
> 
> On Thu, Nov 07, 2002 at 01:48:42PM -0600, Jonathan C Patschke wrote:
> 
> > >It also sounds like it should be simple for someone to 
> make a wrapper
> > >library to fix most of the problems.
> > 
> > You're not going to be able to fix the semaphore bugs with 
> a wrapper, I 
> > think.  The bugs are in the function-calling mechanism, and the 
> > semaphore calls go into the kernel and back out.  By that time, the 
> > data is already corrupt.  The only way you could wrap 
> around it would 
> > be an inline-assembly routine that did the function call by 
> hand.  I 
> > suppose it would work, but it would be messy, and you'd 
> still need to 
> > modify the source for each dependent source file to make it work.
> 
> It seems to me there should be a better way.  Well, of course 
> there is,
> fix the compiler.  But barring that there still seems like 
> there should
> be a better way.  I don't have the time to fiddle with it though.
> 
> -- 
> Joshua D. Boyd
> _______________________________________________
> GEEKS:  http://www.sunhelp.org/mailman/listinfo/geeks



More information about the geeks mailing list