/* Link script for GCC-built titles: code at 0x82010000 (the first 64 KB
 * page holds the XEX headers), each kind of section on its own 64 KB pages
 * like xex-link's own script, plus what newlib/libstdc++ need:
 * .ctors, .eh_frame (kept, zero terminated), .gcc_except_table, .got2. */
ENTRY(_start)

SECTIONS {
    . = 0x82010000;
    .text : {
        *(.text._start)
        *(.text .text.* .gnu.linkonce.t.*)
    }
    . = ALIGN(4);
    .xthunks : { *(.xthunks .xthunks.*) }

    . = ALIGN(0x10000);
    .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) *(.sdata2 .sdata2.*) }
    . = ALIGN(4);
    .eh_frame : {
        PROVIDE(__eh_frame_start = .);
        KEEP(*(.eh_frame))
        LONG(0)
    }
    .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) }

    . = ALIGN(0x10000);
    .ctors : {
        __CTOR_LIST__ = .;
        KEEP(*(SORT(.ctors.*)))
        KEEP(*(.ctors))
        __CTOR_END__ = .;
    }
    .dtors : { KEEP(*(.dtors .dtors.*)) }
    .init_array : { KEEP(*(.init_array .init_array.*)) }
    .got2 : { *(.got2) }
    .got : { *(.got .got.plt) }
    .data : { *(.data .data.* .gnu.linkonce.d.*) *(.sdata .sdata.*) }
    .xvars : { *(.xvars .xvars.*) }

    . = ALIGN(0x10000);
    .bss : {
        __bss_start = .;
        *(.bss .bss.*) *(.sbss .sbss.*) *(COMMON)
        __bss_end = .;
    }
    . = ALIGN(8);
    _end = .;

    /DISCARD/ : { *(.comment) *(.note .note.*) *(.eh_frame_hdr) }
}
