Using newlib (was: [Efi332] Building newlib/libgloss for MPC555)

Gunter Magin gm
Tue Aug 16 19:47:38 UTC 2005


Hi David,

(have been out all day...)

On Mon, Aug 15, 2005 at 08:13:59PM -0700, David Eicher wrote:
> Making some progress. I've discovered that the __sfvwrite ( ) function
> accepts as input two parameters (fp and uio) as shown in this code snippet.
> 
> _DEFUN(__sfvwrite, (fp, uio),
>        register FILE *fp _AND
>        register struct __suio *uio)
> 
> It appears in the code that one of the parameters is passed to the function
> in register r3, which gets copied to r27. I put a breakpoint at the
> beginning of __sfvwrite (which is in file fvwrite.c) and discovered that r3
> is 0xFFFFFFFF at the beginning of execution. 

It is fp which has the wrong value.

Did you initialize in any way stdin/stdout? 

No, I don't know precisely how to do that, but plain printf() expands
the call to vfprintf (_stdout_r (_REENT), fmt, ap);

So it has to do with _stdout_r, which actually is a macro defined in
newlib-1.13.0/newlib/libc/include/stdio.h

It uses a parameter _REENT, but I haven't found out where this is
defined, and where and how it is initialized. I strongly guess this is
the key for getting further.

It can be as easy, as the implicit fopen() call for stdout is missing,
but it also can be more. I have to bail out here.

> So..., that is more background on why __sfvwrite is crashing. I have not
> been able to tell which parameter is passed in r3 yet (working on it). 

See above. Parameter passing is part of the PowerPC-EABI specification.
I think I have that in form of a .pdf from some IBM website, I forgot. But
it is not essential at this point.

gm




More information about the Efi332 mailing list