/*
 * (C) Copyright 2002,2003, Motorola,Inc.
 * Xianghua Xiao, X.Xiao@motorola.com.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

OUTPUT_ARCH(powerpc)
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
/* Do we need any of these for elf?
   __DYNAMIC = 0;    */
SECTIONS
{
  .resetvec 0xFFFFFFFC :
  {
    *(.resetvec)
  } = 0xffff

  .bootpg 0xFFFFF000 :
  {
    cpu/mpc85xx/start.o (.bootpg)
    board/tqm85xx/init.o (.bootpg)
  } = 0xffff

  /* Read-only sections, merged into text segment: */
  . = + SIZEOF_HEADERS;
  .interp : { *(.interp) }
  .hash		 : { *(.hash)		}
  .dynsym	 : { *(.dynsym)		}
  .dynstr	 : { *(.dynstr)		}
  .rel.text	 : { *(.rel.text)		}
  .rela.text	 : { *(.rela.text)	}
  .rel.data	 : { *(.rel.data)		}
  .rela.data	 : { *(.rela.data)	}
  .rel.rodata	 : { *(.rel.rodata)	}
  .rela.rodata	 : { *(.rela.rodata)	}
  .rel.got	 : { *(.rel.got)		}
  .rela.got	 : { *(.rela.got)		}
  .rel.ctors	 : { *(.rel.ctors)	}
  .rela.ctors	 : { *(.rela.ctors)	}
  .rel.dtors	 : { *(.rel.dtors)	}
  .rela.dtors	 : { *(.rela.dtors)	}
  .rel.bss	 : { *(.rel.bss)		}
  .rela.bss	 : { *(.rela.bss)		}
  .rel.plt	 : { *(.rel.plt)		}
  .rela.plt	 : { *(.rela.plt)		}
  .init		 : { *(.init)	}
  .plt : { *(.plt) }
  .text	     :
  {
    cpu/mpc85xx/start.o (.text)
    board/tqm85xx/init.o (.text)
    cpu/mpc85xx/traps.o (.text)
    cpu/mpc85xx/interrupts.o (.text)
    cpu/mpc85xx/cpu_init.o (.text)
    cpu/mpc85xx/cpu.o (.text)
    cpu/mpc85xx/speed.o (.text)
    cpu/mpc85xx/pci.o (.text)
    common/dlmalloc.o (.text)
    lib_generic/crc32.o (.text)
    lib_ppc/extable.o (.text)
    lib_generic/zlib.o (.text)
    *(.text)
    *(.fixup)
    *(.got1)
   }
    _etext = .;
    PROVIDE (etext = .);
    .rodata    :
   {
    *(.rodata)
    *(.rodata1)
    *(.rodata.str1.4)
  }
  .fini	     : { *(.fini)    } =0
  .ctors     : { *(.ctors)   }
  .dtors     : { *(.dtors)   }

  /* Read-write section, merged into data segment: */
  . = (. + 0x00FF) & 0xFFFFFF00;
  _erotext = .;
  PROVIDE (erotext = .);
  .reloc   :
  {
    *(.got)
    _GOT2_TABLE_ = .;
    *(.got2)
    _FIXUP_TABLE_ = .;
    *(.fixup)
  }
  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
  __fixup_entries = (. - _FIXUP_TABLE_) >> 2;

  .data	   :
  {
    *(.data)
    *(.data1)
    *(.sdata)
    *(.sdata2)
    *(.dynamic)
    CONSTRUCTORS
  }
  _edata  =  .;
  PROVIDE (edata = .);

  . = .;
  __u_boot_cmd_start = .;
  .u_boot_cmd : { *(.u_boot_cmd) }
  __u_boot_cmd_end = .;

  . = .;
  __start___ex_table = .;
  __ex_table : { *(__ex_table) }
  __stop___ex_table = .;

  . = ALIGN(256);
  __init_begin = .;
  .text.init : { *(.text.init) }
  .data.init : { *(.data.init) }
  . = ALIGN(256);
  __init_end = .;

  __bss_start = .;
  .bss	     :
  {
   *(.sbss) *(.scommon)
   *(.dynbss)
   *(.bss)
   *(COMMON)
  }
  _end = . ;
  PROVIDE (end = .);
}
