linker file

Keith Wright
Mon Jun 18 12:51:00 GMT 2001

> From: Vermeulen Jan <>
> Using a gcc cross compiler on i686-mandrake for a 68040 target, i
> was wondering what the actual steps are for making a test program.
> The first few bytes of the flashrom should be interrupt vectors, so how do i
> make the compiler know where the start adress is in the rom (if not 0x0)?

The compiler will decide the start address relative to the start of
the .text (program).  The linker (ld) will put the program wherever
you say.  You need the info files for 'ld', the man pages are too
little.  I found them in /usr/info/ where they had been
placed by Redhat package binutils- (long out of date
no doubt).  If they are already installed then 'info ld'.

Also try to find
<!-- This HTML file has been created by texi2html 1.51
     from porting.texi on 4 March 1998 -->
<TITLE>Embed with GNU - Libgloss</TITLE>
<p> Copyright (C) 1993, 1994, 1995 Cygnus Support

There are rumors that it can be found on the redhat site now.

Getting the program started depends upon what is already running.  If
nothing is running, then the reset interrupt vector must point to the
start of the program when the power comes on, otherwise read the
manual for your boot loader to find out how to call a user program.

> I know i have to do something with a linker-file which says where
> the compiler should adress uninitialized data, and where to copy
> initialized data from rom.  But i don't know where that file is or
> how to make it.

Call it what you like, *.ld is traditional.  Tell the loader where
it is with 
  LDFLAGS = -s -n -T$(LINKER_SCRIPT) -Map=$(basename $@).map
  $(LD) $(LDFLAGS) -o boot.srec $(OBJS)

> (is the copying from rom->ram done automatically by gcc or do
> i have to do it myself?).

You had better do it, gcc is sitting back on your Mandrake
machine and doesn't know how to read the ROM.  If your program
is in Flash, then the data segment must be somewhere else,
and will be uninitialized when the power comes on.  You can
write your program to work with uninitialized data, or you can
put a block copy very early in the startup code.  If a boot
loader is downloading the program, then it will probably
download the initialized data segment at the same time.

> Do i have to make it before making a crossgcc compiler, because it
> is used when making the crossgcc; or is it more dynamic and can be
> invoked at link time?

The load script for your test program is not used to make gcc.

> And what should it look like ?

It should look something like this:

OUTPUT_ARCH(m68k)   /* Specify the output machine architecture to be m68k. */
OUTPUT_FORMAT(srec) /* Output format. Should be srec (S-records).*/
                    /* Same as the --oformat command-line option.       */ 


__sram_origin = 0x20000000;
__sram_length = 8K;

__dram_origin = 0x40000000;
__dram_length = 512K;

__flash_length = 128K;
__flash_origin = 0x0;

  /* Flash; Read-only, execute     */
  flash (rx): ORIGIN = 0x0,         LENGTH = 128K
  /* Internal SRAM; RW, no execute */
  sram  (w):  ORIGIN = 0x20000000,  LENGTH = 8K
  dram (rwx): ORIGIN = 0x40000000, LENGTH = 512K
  hidram (rwx): ORIGIN = 0x40004000, LENGTH = 496K


  .text __vector_table_origin : 
    { bootinit.o(.text)
    } > flash
  .data :
    { bootinit.o(.data)
    } > flash
  .bss __sram_origin :
    { boot.o(.bss)
      end = ALIGN(0x8);
    } > sram

     -- Keith Wright  <>

Programmer in Chief, Free Computer Shop < >
         ---  Food, Shelter, Source code.  ---

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list