/*
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id: linkcmds,v 1.24 2006/03/08 18:49:26 joel Exp $
 */

OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
	      "elf32-powerpc")
OUTPUT_ARCH(powerpc)
ENTRY(_start)
/* Do we need any of these for elf?
   __DYNAMIC = 0;    */
PROVIDE (PSIM_INSTRUCTIONS_PER_MICROSECOND = 10000);   /* 100); */
PROVIDE (CPU_PPC_CLICKS_PER_MS = 16667);
MEMORY
  {
        RAM : ORIGIN = 0, LENGTH = 8M
        EPROM : ORIGIN = 0xFFF00000, LENGTH = 0x20000
  }

SECTIONS
{
  .entry_point_section :
  {
	*(.entry_point_section)
  } > EPROM

  /* Read-only sections, merged into text segment: */
  /* . = 0x40000 + SIZEOF_HEADERS; */
  . = 0x4000;
  .interp         : { *(.interp) }
  .hash           : { *(.hash) }
  .dynsym         : { *(.dynsym) }
  .dynstr         : { *(.dynstr) }
  .gnu.version    : { *(.gnu.version) }
  .gnu.version_d  : { *(.gnu.version_d) }
  .gnu.version_r  : { *(.gnu.version_r) }
  .rel.init       : { *(.rel.init) }
  .rela.init      : { *(.rela.init) }
  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } >RAM
  .rel.fini       : { *(.rel.fini) }
  .rela.fini      : { *(.rela.fini) } >RAM
  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } >RAM
  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } >RAM
  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } >RAM
  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } >RAM
  .rel.ctors      : { *(.rel.ctors) }
  .rela.ctors     : { *(.rela.ctors) } >RAM
  .rel.dtors      : { *(.rel.dtors) }
  .rela.dtors     : { *(.rela.dtors) } >RAM
  .rel.got        : { *(.rel.got) }
  .rela.got       : { *(.rela.got) } >RAM
  .rela.got1           : { *(.rela.got1) } >RAM
  .rela.got2           : { *(.rela.got2) } >RAM
  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) } >RAM
  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) } >RAM
  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) } >RAM
  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) } >RAM
  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } >RAM
  .rel.plt        : { *(.rel.plt) }
  .rela.plt       : { *(.rela.plt) } >RAM
  .text      :
  {
    *(.text*)
    *(.gnu.linkonce.t.*)
    *(.descriptors)

    /*
     * Special FreeBSD sysctl sections.
     */
    . = ALIGN (16);
    __start_set_sysctl_set = .;
    *(set_sysctl_*);
    __stop_set_sysctl_set = ABSOLUTE(.);
    *(set_domain_*);
    *(set_pseudo_*);

    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
  } >RAM
  .init           :
  {
    KEEP (*(.init))
  } >RAM =0
  .fini           :
  {
    _fini = .;
    KEEP (*(.fini))
  } >RAM =0
  .rodata  	  : { *(.rodata*) *(.gnu.linkonce.r*) } >RAM
  .rodata1	  : { *(.rodata1) 	} >RAM
  PROVIDE (__FRAME_BEGIN__ = .);
  .eh_frame	  : { *.(eh_frame)		} >RAM
  PROVIDE (__FRAME_END__ = .);
  PROVIDE (_etext = .);
  PROVIDE (etext = .);
  PROVIDE (__SDATA2_START__ = .);
  .sdata2   	  : { *(.sdata2) *(.gnu.linkonce.s2.*)	} >RAM
  .sbss2   	  : { *(.sbss2) *(.gnu.linkonce.sb2.*)	} >RAM
  PROVIDE (__SBSS2_END__ = .);
  /* .eh_frame_hdr : { *(.eh_frame_hdr) } >RAM */
  /* Adjust the address for the data segment.  We want to adjust up to
     the same address within the page on the next page up.  It would
     be more correct to do this:
       . = ALIGN(0x40000) + (ALIGN(8) & (0x40000 - 1));
     The current expression does not correctly handle the case of a
     text segment ending precisely at the end of a page; it causes the
     data segment to skip a page.  The above expression does not have
     this problem, but it will currently (2/95) cause BFD to allocate
     a single segment, combining both text and data, for this case.
     This will prevent the text segment from being shared among
     multiple executions of the program; I think that is more
     important than losing a page of the virtual address space (note
     that no actual memory is lost; the page which is skipped can not
     be referenced).  */
  /* . =  ALIGN(8) + 0x40000; */
  .data    :
  {
    *(.data .data.* .gnu.linkonce.d.*)
    SORT(CONSTRUCTORS)
  } >RAM
  PROVIDE (__EXCEPT_START__ = .);
  .gcc_except_table   : { *(.gcc_except_table) } >RAM
  PROVIDE (__EXCEPT_END__ = .);

  .data1   	  : { *(.data1) 	} >RAM
  .got1		  : { *(.got1) 		} >RAM
  .dynamic	  : { *(.dynamic) 	} >RAM
  /* Put .ctors and .dtors next to the .got2 section, so that the pointers
     get relocated with -mrelocatable. Also put in the .fixup pointers.
     The current compiler no longer needs this, but keep it around for 2.7.2  */
   PROVIDE (__GOT2_START__ = .);
   PROVIDE (_GOT2_START_ = .);
  .got2		  :  { *(.got2) 	} >RAM
  PROVIDE (__GOT2_END__ = .);
  PROVIDE (_GOT2_END_ = .);

  PROVIDE (__CTOR_LIST__ = .);
  .ctors	  : { *(.ctors) 	} >RAM
  PROVIDE (__CTOR_END__ = .);

  PROVIDE (__DTOR_LIST__ = .);
  .dtors	  : { *(.dtors) 	} >RAM
  PROVIDE (__DTOR_END__ = .);

  PROVIDE (__FIXUP_START__ = .);
  PROVIDE (_FIXUP_START_ = .);
  .fixup	  : { *(.fixup) 	} >RAM
  PROVIDE (_FIXUP_END_ = .);
  PROVIDE (__FIXUP_END__ = .);

  .jcr            : { KEEP (*(.jcr))	} > RAM

  PROVIDE (__GOT_START__ = .);
  PROVIDE (_GOT_START_ = .);
  s.got = .;
  .got		  : { *(.got) 		} >RAM
  .got.plt	  : { *(.got.plt) 	} >RAM
  PROVIDE (_GOT_END_ = .);
  PROVIDE (__GOT_END__ = .);

  /* We want the small data sections together, so single-instruction offsets
     can access them all, and initialized data all before uninitialized, so
     we can shorten the on-disk segment size.  */
  PROVIDE (__SDATA_START__ = .);
  .sdata	  : { *(.sdata*) *(.gnu.linkonce.s.*)	} >RAM
  _edata  =  .;
  PROVIDE (edata = .);

  PROVIDE (RAM_END = 0x7f0000);
  .sbss      :
  {
    PROVIDE (__sbss_start = .);
    *(.dynsbss)
    *(.sbss* .gnu.linkonce.sb.*)
    PROVIDE (__sbss_end = .);
  } >RAM
  PROVIDE (__SBSS_END__ = .);

  .bss       :
  {
   PROVIDE (__bss_start = .);
   *(.dynbss)
   *(.bss .bss* .gnu.linkonce.b*)
   *(COMMON)
  } >RAM
  . =  ALIGN(8) + 0x8000;
  __rtems_end = . ;
  PROVIDE(__stack = .);
  PROVIDE(_end = .);
  PROVIDE(end = .);

  /* These are needed for ELF backends which have not yet been
     converted to the new style linker.  */
  .stab 0 : { *(.stab) }
  .stabstr 0 : { *(.stabstr) }
  /* DWARF debug sections.
     Symbols in the DWARF debugging sections are relative to the beginning
     of the section so we begin them at 0.  */
  /* DWARF 1 */
  .debug          0 : { *(.debug) }
  .line           0 : { *(.line) }
  /* GNU DWARF 1 extensions */
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
  .debug_sfnames  0 : { *(.debug_sfnames) }
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges  0 : { *(.debug_aranges) }
  .debug_pubnames 0 : { *(.debug_pubnames) }
  /* DWARF 2 */
  .debug_info     0 : { *(.debug_info) }
  .debug_abbrev   0 : { *(.debug_abbrev) }
  .debug_line     0 : { *(.debug_line) }
  .debug_frame    0 : { *(.debug_frame) }
  .debug_str      0 : { *(.debug_str) }
  .debug_loc      0 : { *(.debug_loc) }
  .debug_macinfo  0 : { *(.debug_macinfo) }
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames 0 : { *(.debug_weaknames) }
  .debug_funcnames 0 : { *(.debug_funcnames) }
  .debug_typenames 0 : { *(.debug_typenames) }
  .debug_varnames  0 : { *(.debug_varnames) }
  /* These must appear regardless of  .  */
}
