cross-compiler for PowerPC without operating system

Michael Schwingen
Thu Jun 24 12:24:00 GMT 1999

On Wed, Jun 23, 1999 at 02:15:23PM +0200, wrote:
> 2:  What is EABI and in how far does it handle register usage of the
> powerpc, i.e. do I need to set the stack pointer myself or does EABI
> handle this?

EABI only defines object format, register usage etc. - on a system without
OS, you will have to provide your own startup code to intialize these
registers to an environment which matches the terms defined in EABI, so that
you are able to call EABI-compliant C code (ie. your main function).

This part is hardware dependant and usually done in assembler, since a C
function wants to save things in the stack frame that does not yet exist
after reset.

You might want to get and read the PPC EABI spec - sorry, the link was here
on the list and helped me a lot, but I don't remember where it was.

> 3:  How can I initialise the stack? I defined a memory section for the
> stack in the linker file, but how can i set the stackpointer to this
> region?

Use assembler code to set R1 to the end of that area (properly aligned, and
leave some room for the back chain on the first function call). When really
using the back chain for debugging, you might want to initialize it,
although the code does not require this to run.

> 4:  Do I need a crt0 function and what should be inside it?

You can call this whatever you want - you only have to tell the linker to
place this code in a way so that it is executed from the reset vector.

You can look in the ecos PPC HAL source for sample code.

> 5:  Executables generated by the compiler are in ELF-format. Is it
> possible to download such an executable in RAM memory and start it right
> at the base address or do i need to convert the executable to a binary
> format (using objcopy) and execute this?

Depends on your downloader. When eg. burning an EPROM, you need to convert -
the motorola mpc8bug can directly download ELF files (including symbol
names) without conversion.

Michael Schwingen, Ahornstrasse 36, 52074 Aachen
New CrossGCC FAQ:
To remove yourself from the crossgcc list, send
mail to with the
text 'unsubscribe' (without the quotes) in the
body of the message.

More information about the crossgcc mailing list