cross-compiler for PowerPC without operating system

Duszczak, Richard richd@enikia.com
Wed Jun 23 10:10:00 GMT 1999


Hi Erik,

I can't answer all of your questions but I have just built a PowerPC
cross-compiler myself and thought I'd share my results.

>I'm trying to build a cross-compiler for PowerPC using the following:
>
>- gcc-2.8.1
>- binutils-2.9.1
>- newlib-1.8.1

This configuration may also work, but I used

- egcs-1.1.2
- binutils-2.9.1
- newlib-1.8.1

Also, check out http://www.users.surfaid.org/~fiddes/coldfire/ .  Granted
this page is geared towards ColdFire, but if you substitute PowerPC for
ColdFire the instructions are very good.  I have successfully built a
compiler using them.

>I'm building the cross-compiler with the option "powerpc-motorola-eabi" and
there are a few questions that I have:

>1:  Is "powerpc-motorola-eabi" the right option to build a compiler for
PowerPC that runs native code (there is no >Operating System on the PowerPC
board) or should I use another build option?

I have never tried powerpc-motorola-eabi, but powerpc-elf definitely works.
I had built another version of the compiler previously using powerpc-eabi
but the compiler/linker generated incorrect code.  I am not sure what caused
it, though.

>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?

Sorry, I know very little about EABI.  I probably should though....

>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?

If everything goes right, the code in crt0.S should do that for you.  Just
make sure to edit the linker file (eg ads.ld) to specify where the stack
should go and your memory regions.  It should look something like this:

OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
	      "elf32-powerpc")
OUTPUT_ARCH(powerpc)
ENTRY(_start)
/* Do we need any of these for elf?
   __DYNAMIC = 0;    */

PROVIDE (__stack = 0x400000);

MEMORY
{
  ram (rwx) : ORIGIN = 0x10000, LENGTH = 0x400000
}

SECTIONS
{
  /* Read-only sections, merged into text segment: */
  . = 0x10000 + SIZEOF_HEADERS;
  .interp   : { *(.interp) }
  .hash		  : { *(.hash)		}


More information about the crossgcc mailing list