/*
 * Copyright 2007 Freescale Semiconductor, Inc.
 *
 * 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)

SECTIONS
{

  /* Read-only sections, merged into text segment: */
  .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 :
  {
    arch/powerpc/cpu/mpc86xx/start.o	(.text)
    arch/powerpc/cpu/mpc86xx/traps.o (.text)
    arch/powerpc/cpu/mpc86xx/interrupts.o (.text)
    arch/powerpc/cpu/mpc86xx/cpu_init.o (.text)
    arch/powerpc/cpu/mpc86xx/cpu.o (.text)
    arch/powerpc/cpu/mpc86xx/speed.o (.text)
    common/dlmalloc.o (.text)
    lib/crc32.o (.text)
    arch/powerpc/lib/extable.o (.text)
    lib/zlib.o (.text)
    *(.text)
    *(.got1)
   }
    _etext = .;
    PROVIDE (etext = .);
    .rodata    :
   {
    *(.eh_frame)
    *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
  }
  .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 (NOLOAD)	     :
  {
   *(.sbss) *(.scommon)
   *(.dynbss)
   *(.bss)
   *(COMMON)
   . = ALIGN(4);
  }
  _end = . ;
  PROVIDE (end = .);
}
