PROVIDE(_stext = ORIGIN(REGION_TEXT));

SECTIONS {
    .text.dummy (NOLOAD) :
    {
        /*
         * If we use _stext somewhere before its first appearance below, we
         * need to define it as absolute here to avoid linker errors.
         */
        . = ABSOLUTE(_stext);

    } > REGION_TEXT

    .text _stext :
    {
        __stext = .;

        *(.text .text.*);

    } > REGION_TEXT

    __etext = .;

    .rodata : ALIGN(16)
    {
        __srodata = .;

        *(.rodata .rodata.*);

    } > REGION_RODATA

    __erodata = .;

    .data : ALIGN(16)
    {
        __sdata = .;

        *(.data .data.*);
        *(.got .got.plt);

    } > REGION_DATA

    __edata = .;

    .bss (NOLOAD) : ALIGN(16)
    {
        __sbss = .;

        *(.bss .bss.*);

        . = ALIGN(0x1000);
    } > REGION_BSS

    __ebss = .;

    .eh_frame : ALIGN(16)
    {
        __seh_frame = .;

        KEEP(*(.eh_frame .eh_frame*));

    } > REGION_EHFRAME

    . = ALIGN(0x1000);
    __eeh_frame = .;
}

SECTIONS {
    /* Stabs debugging sections.  */
    .stab          0 : { KEEP(*(.stab)); }
    .stabstr       0 : { KEEP(*(.stabstr)); }
    .stab.excl     0 : { KEEP(*(.stab.excl)); }
    .stab.exclstr  0 : { KEEP(*(.stab.exclstr)); }
    .stab.index    0 : { KEEP(*(.stab.index)); }
    .stab.indexstr 0 : { KEEP(*(.stab.indexstr)); }
    .comment       0 : { KEEP(*(.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          0 : { KEEP(*(.debug)); }
    .line           0 : { KEEP(*(.line)); }
    /* GNU DWARF 1 extensions */
    .debug_srcinfo  0 : { KEEP(*(.debug_srcinfo)); }
    .debug_sfnames  0 : { KEEP(*(.debug_sfnames)); }
    /* DWARF 1.1 and DWARF 2 */
    .debug_aranges  0 : { KEEP(*(.debug_aranges)); }
    .debug_pubnames 0 : { KEEP(*(.debug_pubnames)); }
    /* DWARF 2 */
    .debug_info     0 : { KEEP(*(.debug_info)); }
    .debug_abbrev   0 : { KEEP(*(.debug_abbrev)); }
    .debug_line     0 : { KEEP(*(.debug_line)); }
    .debug_frame    0 : { KEEP(*(.debug_frame)); }
    .debug_str      0 : { KEEP(*(.debug_str)); }
    .debug_loc      0 : { KEEP(*(.debug_loc)); }
    .debug_macinfo  0 : { KEEP(*(.debug_macinfo)); }
    /* SGI/MIPS DWARF 2 extensions */
    .debug_weaknames 0 : { KEEP(*(.debug_weaknames)); }
    .debug_funcnames 0 : { KEEP(*(.debug_funcnames)); }
    .debug_typenames 0 : { KEEP(*(.debug_typenames)); }
    .debug_varnames  0 : { KEEP(*(.debug_varnames)); }

    /* DWARF Other */
    .debug_ranges  0 : { KEEP(*(.debug_ranges)); }
    .debug_line_str 0 : { KEEP(*(.debug_line_str)); }

    /DISCARD/ :
    {
        *(.fini_array*)
        *(.note*)
        *(.dtors*)
        *(.debug_gdb_scripts*)
    }
}
