ENTRY(_start);

SEARCH_DIR(/lib);
SEARCH_DIR(/usr/lib);
SEARCH_DIR(/usr/local/lib);
SEARCH_DIR(/usr/i686-pc-linux-gnu/lib);

INTERP(/lib/ld-linux.so.2);

PAGESIZE(4k);

SEGMENT [RX]
{
#ifdef SHARED
  . = SIZEOF_HEADERS;
#else
  . = 0x08048000 + SIZEOF_HEADERS;
#endif

  .interp;
  .note.ABI-tag;
  .note.gnu.build-id;
  .hash;
  .gnu.hash;
  .dynsym;
  .dynstr;
  .gnu.version;
  .gnu.version_d;
  .gnu.version_r;
  .rel.dyn;
  .rel.plt;
  .init { KEEP (*(.init)) }
  .plt;
  .text
  {
    *(.text)
    *(.text.*)
    *(.stub)
    *(.gnu.warning)
    *(.gnu.linkonce.t.*)
  }
  .fini { KEEP (*(.fini)) }
  PROVIDE (__etext = .);
  PROVIDE (_etext = .);
  PROVIDE (etext = .);
  .rodata
    {
      *(.rodata)
      *(.rodata.*)
      *(.gnu.linkonce.r.*)
    }
  .rodata1;
  .eh_frame_hdr;
  . = ALIGN(32 / 8);
  PROVIDE (__preinit_array_start = .);
  .preinit_array
    {
      *(.preinit_array)
    }
  PROVIDE (__preinit_array_end = .);
  PROVIDE (__init_array_start = .);
  .init_array
    {
      *(.init_array)
    }
  PROVIDE (__init_array_end = .);
  PROVIDE (__fini_array_start = .);
  .fini_array
    {
      *(.fini_array)
    }
  PROVIDE (__fini_array_end = .);
}

SEGMENT [RW]
{
  .sdata2
    {
      *(.sdata2)
      *(.sdata2.*)
      *(.gnu.linkonce.s2.*)
    }
  .sbss2
    {
      *(.sbss2)
      *(.sbss2.*)
      *(.gnu.linkonce.sb2.*)
    }
  /* Adjust the address for the data segment.  We want to adjust up to
     the same address within the page on the next page up.  */
  . = ALIGN(PAGESIZE) + (. & (PAGESIZE - 1));
  .eh_frame
    {
      KEEP (*(.eh_frame))
    }
  .gcc_except_table;
  .tdata
    {
      *(.tdata)
      *(.tdata.*)
      *(.gnu.linkone.td.*)
    }
  .tbss
    {
      *(.tbss)
      *(.tbss.*)
      *(.gnu.linkone.tb.*)
      *(.tcommon)
    }
  .ctors
    {
      /* gcc uses crtbegin.o to find the start of
         the constructors, so we make sure it is
          first.  Because this is a wildcard, it
         doesn't matter if the user does not
         actually link against crtbegin.o; the
         linker won't look for a file to match a
         wildcard.  The wildcard also means that it
         doesn't matter which directory crtbegin.o
         is in.  */
      KEEP (*crtbegin.o(.ctors))
      /* We don't want to include the .ctor section from
         from the crtend.o file until after the sorted ctors.
         The .ctor section from the crtend file contains the
         end of ctors marker and it must be last */
      KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
      KEEP (*(SORT(.ctors.*)))
      KEEP (*(.ctors))
    }
  .dtors
    {
      KEEP (*crtbegin.o(.dtors))
      KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
      KEEP (*(SORT(.dtors.*)))
      KEEP (*(.dtors))
    }
  .jcr;
  .dynamic;
  .got;
  .got.plt;
  .data
    {
      *(.data)
      *(.data.*)
      *(.gnu.linkonce.d.*)
    }
  /* 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.  */
  .data1;
  .sdata
    {
      *(.sdata)
      *(.sdata.*)
      *(.gnu.linkonce.s.*)
    }
  _edata = .;
  PROVIDE (edata = .);
  __bss_start = .;
  .sbss
    {
      PROVIDE (__sbss_start = .);
      PROVIDE (___sbss_start = .);
      *(.dynsbss)
      *(.sbss)
      *(.sbss.*)
      *(.gnu.linkonce.sb.*)
      *(.scommon)
      PROVIDE (__sbss_end = .);
      PROVIDE (___sbss_end = .);
    }
  .bss
    {
      *(.dynbss)
      *(.bss)
      *(.bss.*)
      *(.gnu.linkonce.b.*)
      *(COMMON)
      /* Align here to ensure that the .bss section occupies space up to
	 _end.  Align after .bss to ensure correct alignment even if the
	 .bss section disappears because there are no input sections.  */
      . = ALIGN(32 / 8);
    }
  . = ALIGN(32 / 8);
  _end = .;
  PROVIDE (end = .);
}

SEGMENT []
{
  /* Stabs debugging sections.  */
  .stab;
  .stabstr;
  .stab.excl;
  .stab.exclstr;
  .stab.index;
  .stab.indexstr;
  .comment;
  /* 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;
  .line;
  /* GNU DWARF 1 extensions */
  .debug_srcinfo;
  .debug_sfnames;
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges;
  .debug_pubnames;
  /* DWARF 2 */
  .debug_info
    {
       *(.debug_info)
       *(.gnu.linkonce.wi.*)
    }
  .debug_abbrev;
  .debug_line;
  .debug_frame;
  .debug_str;
  .debug_loc;
  .debug_macinfo;
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames;
  .debug_funcnames;
  .debug_typenames;
  .debug_varnames;
  /* These must appear regardless of  .  */
}