templates.sifive/sections.ld: local arch & device

/*
 * Default linker script.
 *
 * Static constructors/destructors use the new .init_array/.fini_array
 * definitions; the old .init/.fini are no longer used.
 *
 * The heap starts immediately after the last statically allocated
 * .bss/.noinit section (the _end symbol), and extends up to the stack.
 *
 * To make use of the multi-region initialisations, define
 * OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS for the _startup.cpp file.
 */

/*
 * Explicitly define the RISC-V architecture.
 */
OUTPUT_ARCH( "riscv" )

/*
 * The entry point is informative, for debuggers and simulators, the
 * hardware has its own notion of the startup address.
 */
ENTRY(_start)

/*
 * The '__stack' definition is required by newlib crt0; do not remove it.
 * The stack is located at the very end of the RAM region.
 */
__stack = ORIGIN(RAM) + LENGTH(RAM);
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;

/*
 * The ELF object file format uses program headers, also knows as segments.
 * The program headers describe how the program should be loaded into memory.
 * You can print them out by using the objdump program with the ‘-p’ option.
 */
PHDRS
{
  phdr_flash PT_LOAD;
  phdr_ram_init PT_LOAD;
  phdr_ram PT_NULL;
}

SECTIONS
{
    /*
     * On RISC-V devices the startup address is a regular address, so this
     * must be the very first section.
     * Apart from the assembly code used to initialise the stack,
     * do not place anything else into this section.
     */
    .reset_entry : ALIGN(4)
    {
        KEEP(*(SORT_NONE(.reset_entry) SORT_NONE(.reset_entry.*)))
    } >FLASH AT>FLASH :phdr_flash

    /*
     * Dynamic Run Time Metadata.
     * Normally the debugger reaches this section by resolving a symbol,
     * but in case it should scan memory for the magic, better place this
     * section as early as possible.
     */
    .drtm : ALIGN(4)
    {
        KEEP(*(.drtm .drtm.*))
    } >FLASH AT>FLASH :phdr_flash

    /*
     * For convenience, place the trap code early.
     */
    .trap_entry : ALIGN(4)
    {
        *(.exceptions_array .exceptions_array.*)
        *(.interrupts_local_arch_array .interrupts_local_arch_array.*)
        *(.interrupts_local_device_array .interrupts_local_device_array.*)
        *(.interrupts_global_array .interrupts_global_array.*)
        *(.trap_entry .trap_entry.*)
        *(.traps_handlers .traps_handlers.*)
    } >FLASH AT>FLASH :phdr_flash

    /*
     * Memory regions initialization arrays.
     *
     * There are two kinds of arrays for each RAM region, one for
     * data and one for bss. Each is iterated at startup and the
     * region initialization is performed.
     *
     * The data array includes:
     * - from (LOADADDR())
     * - region_begin (ADDR())
     * - region_end (ADDR()+SIZEOF())
     *
     * The bss array includes:
     * - region_begin (ADDR())
     * - region_end (ADDR()+SIZEOF())
     *
     * WARNING: It is mandatory that the regions are word aligned,
     * since the initialization code works only on words.
     */
    .mem_inits : ALIGN(4)
    {
        PROVIDE_HIDDEN(__data_regions_array_begin__ = .); /* µOS++ specific. */

        LONG(LOADADDR(.data));
        LONG(ADDR(.data));
        LONG(ADDR(.data)+SIZEOF(.data));

        /* If more DATA regions are needed, add more such records. */

        PROVIDE_HIDDEN(__data_regions_array_end__ = .); /* µOS++ specific. */

        PROVIDE_HIDDEN(__bss_regions_array_begin__ = .); /* µOS++ specific. */

        LONG(ADDR(.bss));
        LONG(ADDR(.bss)+SIZEOF(.bss));

        /* If more BSS regions are needed, add more such records. */

        PROVIDE_HIDDEN(__bss_regions_array_end__ = .); /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The preinit code, i.e. an array of pointers to initialization
     * functions to be performed before constructors.
     */
    .preinit_array : ALIGN(4)
    {
        /*
         * PROVIDE not used intentionally,
         * this symbol must not be used for other purposes.
         */
        __preinit_array_begin__ = .;    /* µOS++ specific. */

        /*
         * Used to run the system inits before anything else.
         */
        KEEP(*(.preinit_array_sysinit .preinit_array_sysinit.*))

        /*
         * Used for other platform inits.
         */
        KEEP(*(.preinit_array_platform .preinit_array_platform.*))

        /*
         * The application inits. If you need to enforce some order in
         * execution, create new sections, as before.
         */
        KEEP(*(.preinit_array .preinit_array.*))

        __preinit_array_end__ = .;     /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The init code, i.e. an array of pointers to static constructors.
     */
    .init_array : ALIGN(4)
    {
        /* PROVIDE not used intentionally, this symbol must not be used. */
        __init_array_start = .;        /* Standard newlib definition. */
        __init_array_begin__ = .;    /* µOS++ specific. */
        KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
        KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
        __init_array_end = .;        /* Standard newlib definition. */
        __init_array_end__ = .;        /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The fini code, i.e. an array of pointers to static destructors.
     */
    .fini_array : ALIGN(4)
    {
        /* PROVIDE not used intentionally, this symbol must not be used. */
        __fini_array_start = .;        /* Standard newlib definition. */
        __fini_array_begin__ = .;    /* µOS++ specific. */
        KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
        KEEP(*(.fini_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
        __fini_array_end = .;        /* Standard newlib definition. */
        __fini_array_end__ = .;        /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The program code.
     */
    .text : ALIGN(4)
    {
        *(.text.unlikely .text.unlikely.*)
        *(.text.startup .text.startup.*)
        *(.text .text.*)
           *(.gnu.linkonce.t.*)
    } >FLASH AT>FLASH :phdr_flash

    . = ALIGN(4);
      PROVIDE(__etext = .);
      PROVIDE(_etext = .);
      PROVIDE(etext = .);

    /*
     * C++ virtual tables.
     */
    .vtable : ALIGN(4)
    {
        KEEP(*(vtable))
    } >FLASH AT>FLASH :phdr_flash

    /*
     * Exception frames.
     */
    .exceptions : ALIGN(4)
    {
        KEEP(*(.eh_frame*))
        *(.gcc_except_table)
    } >FLASH AT>FLASH :phdr_flash

     /*
      * Read-only data (constants)
      */
    .rodata : ALIGN(4)
    {
        *(.rodata .rodata.*)
        *(.constdata .constdata.*)
        *(.gnu.linkonce.r.*)
    } >FLASH AT>FLASH :phdr_flash

    . = ALIGN(4);
    PROVIDE( _data = . );

    /*
     * The initialised data section.
     *
     * The program executes knowing that the data is in RAM
     * but the loader puts the initial values in FLASH.
     * The startup will copy the initial values from FLASH to RAM.
     */
    .data : ALIGN(4)
    {
        FILL(0xFF)

        __data_start__ = . ;            /* Standard newlib definition. */
        __data_begin__ = . ;            /* µOS++ specific */
        *(.data_begin .data_begin.*)    /* µOS++ __data_begin_guard */

        *(.data .data.*)
        *(.gnu.linkonce.d.*)

        . = ALIGN(8);
        /*
         * RISC-V specific; the compiler optimises memory accesses
         * in the +/- 2K range around __global_pointer$ to GP relative.
         * For this to work, GP must be loaded during startup with the
         * address of __global_pointer$.
         * This optimisation favours a 4K range. Newlib places
         * several impure and malloc pointers in the .sdata section.
         */
        PROVIDE( __global_pointer$ = . + (4K / 2) );

        *(.sdata .sdata.*)
        *(.gnu.linkonce.s.*)

        /* RISC-V specific; not sure if needed. */
        . = ALIGN(8);
        *(.srodata.cst16)
        *(.srodata.cst8)
        *(.srodata.cst4)
        *(.srodata.cst2)
        *(.srodata .srodata.*)

        *(.data_end .data_end.*)        /* µOS++ __data_end_guard; must be last */
        . = ALIGN(4);
        __data_end__ = . ;                /* Standard newlib definition. */
    } >RAM AT>FLASH :phdr_ram_init

    /*
     * This address is used by the µOS++ startup code to
     * initialise the .data section.
     */
    __data_load_addr__ = LOADADDR(.data);

      . = ALIGN(4);
      PROVIDE( __edata = . );
      PROVIDE( _edata = . );
      PROVIDE( edata = . );

    /*
     * The uninitialised data sections. NOLOAD is used to avoid
     * the "section `.bss' type changed to PROGBITS" warning
     */

    /* The primary uninitialised data section. */
    .bss (NOLOAD) : ALIGN(4)
    {
        __bss_start = .;                 /* Standard newlib definition. */
        __bss_start__ = .;                 /* Standard newlib definition. */
           __bss_begin__ = .;                 /* µOS++ specific */
         *(.bss_begin .bss_begin.*)     /* µOS++ __bss_begin_guard */

        *(.sbss .sbss.*)
        *(.gnu.linkonce.sb.*)

        *(.bss .bss.*)
        *(.gnu.linkonce.b.*)
        *(COMMON)

        *(.bss_end .bss_end.*)             /* µOS++ __bss_end_guard; must be last */
        . = ALIGN(4);
        __bss_end__ = .;                /* Standard newlib definition. */
        __bss_end = .;                    /* Standard newlib definition. */
     } >RAM AT>RAM :phdr_ram

    /*
     * Similar to .bss, but not initialised to zero. µOS++ extension.
     */
    .noinit (NOLOAD) : ALIGN(4)
    {
        __noinit_begin__ = .;            /* µOS++ extension. */

        *(.noinit .noinit.*)

         . = ALIGN(4) ;
        __noinit_end__ = .;               /* µOS++ extension. */
    } >RAM AT>RAM :phdr_ram

    /* _sbrk() expects at least word alignment. */
      . = ALIGN(8);
    PROVIDE( __end = . );
    PROVIDE( _end = . );
    PROVIDE( end = . );

    PROVIDE( __heap_begin__ = . );        /* µOS++ extension. */

      .stack __stack - __stack_size :
      {
        PROVIDE( _heap_end = . );        /* Standard newlib definition. */
        PROVIDE( __heap_end__ = . );    /* µOS++ extension. */
        . += __stack_size;
      } >RAM AT>RAM :phdr_ram

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

/*
 * Default linker script.
 *
 * Static constructors/destructors use the new .init_array/.fini_array
 * definitions; the old .init/.fini are no longer used.
 *
 * The heap starts immediately after the last statically allocated
 * .bss/.noinit section (the _end symbol), and extends up to the stack.
 *
 * To make use of the multi-region initialisations, define
 * OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS for the _startup.cpp file.
 */

/*
 * Explicitly define the RISC-V architecture.
 */
OUTPUT_ARCH( "riscv" )

/*
 * The entry point is informative, for debuggers and simulators, the
 * hardware has its own notion of the startup address.
 */
ENTRY(_start)

/*
 * The '__stack' definition is required by newlib crt0; do not remove it.
 * The stack is located at the very end of the RAM region.
 */
__stack = ORIGIN(RAM) + LENGTH(RAM);
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;

/*
 * The ELF object file format uses program headers, also knows as segments.
 * The program headers describe how the program should be loaded into memory.
 * You can print them out by using the objdump program with the ‘-p’ option.
 */
PHDRS
{
  phdr_flash PT_LOAD;
  phdr_ram_init PT_LOAD;
  phdr_ram PT_NULL;
}

SECTIONS
{
    /*
     * On RISC-V devices the startup address is a regular address, so this
     * must be the very first section.
     * Apart from the assembly code used to initialise the stack,
     * do not place anything else into this section.
     */
    .reset_entry : ALIGN(4)
    {
        KEEP(*(SORT_NONE(.reset_entry) SORT_NONE(.reset_entry.*)))
    } >FLASH AT>FLASH :phdr_flash

    /*
     * Dynamic Run Time Metadata.
     * Normally the debugger reaches this section by resolving a symbol,
     * but in case it should scan memory for the magic, better place this
     * section as early as possible.
     */
    .drtm : ALIGN(4)
    {
        KEEP(*(.drtm .drtm.*))
    } >FLASH AT>FLASH :phdr_flash

    /*
     * For convenience, place the trap code early.
     */
    .trap_entry : ALIGN(4)
    {
        *(.exceptions_array .exceptions_array.*)
        *(.local_interrupts_array .local_interrupts_array.*)
        *(.device_local_interrupts_array .device_local_interrupts_array.*)
        *(.global_interrupts_array .global_interrupts_array.*)
        *(.trap_entry .trap_entry.*)
        *(.traps_handlers .traps_handlers.*)
    } >FLASH AT>FLASH :phdr_flash

    /*
     * Memory regions initialisation arrays.
     *
     * There are two kinds of arrays for each RAM region, one for
     * data and one for bss. Each is iterrated at startup and the
     * region initialisation is performed.
     *
     * The data array includes:
     * - from (LOADADDR())
     * - region_begin (ADDR())
     * - region_end (ADDR()+SIZEOF())
     *
     * The bss array includes:
     * - region_begin (ADDR())
     * - region_end (ADDR()+SIZEOF())
     *
     * WARNING: It is mandatory that the regions are word aligned,
     * since the initialisation code works only on words.
     */
    .mem_inits : ALIGN(4)
    {
        PROVIDE_HIDDEN(__data_regions_array_begin__ = .); /* µOS++ specific. */

        LONG(LOADADDR(.data));
        LONG(ADDR(.data));
        LONG(ADDR(.data)+SIZEOF(.data));

        /* If more DATA regions are needed, add more such records. */

        PROVIDE_HIDDEN(__data_regions_array_end__ = .); /* µOS++ specific. */

        PROVIDE_HIDDEN(__bss_regions_array_begin__ = .); /* µOS++ specific. */

        LONG(ADDR(.bss));
        LONG(ADDR(.bss)+SIZEOF(.bss));

        /* If more BSS regions are needed, add more such records. */

        PROVIDE_HIDDEN(__bss_regions_array_end__ = .); /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The preinit code, i.e. an array of pointers to initialisation
     * functions to be performed before constructors.
     */
    .preinit_array : ALIGN(4)
    {
        /*
         * PROVIDE not used intentionally,
         * this symbol must not be used for other purposes.
         */
        __preinit_array_begin__ = .;    /* µOS++ specific. */

        /*
         * Used to run the system inits before anything else.
         */
        KEEP(*(.preinit_array_sysinit .preinit_array_sysinit.*))

        /*
         * Used for other platform inits.
         */
        KEEP(*(.preinit_array_platform .preinit_array_platform.*))

        /*
         * The application inits. If you need to enforce some order in
         * execution, create new sections, as before.
         */
        KEEP(*(.preinit_array .preinit_array.*))

        __preinit_array_end__ = .;     /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The init code, i.e. an array of pointers to static constructors.
     */
    .init_array : ALIGN(4)
    {
        /* PROVIDE not used intentionally, this symbol must not be used. */
        __init_array_start = .;        /* Standard newlib definition. */
        __init_array_begin__ = .;    /* µOS++ specific. */
        KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
        KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
        __init_array_end = .;        /* Standard newlib definition. */
        __init_array_end__ = .;        /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The fini code, i.e. an array of pointers to static destructors.
     */
    .fini_array : ALIGN(4)
    {
        /* PROVIDE not used intentionally, this symbol must not be used. */
        __fini_array_start = .;        /* Standard newlib definition. */
        __fini_array_begin__ = .;    /* µOS++ specific. */
        KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
        KEEP(*(.fini_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
        __fini_array_end = .;        /* Standard newlib definition. */
        __fini_array_end__ = .;        /* µOS++ specific. */
    } >FLASH AT>FLASH :phdr_flash

    /*
     * The program code.
     */
    .text : ALIGN(4)
    {
        *(.text.unlikely .text.unlikely.*)
        *(.text.startup .text.startup.*)
        *(.text .text.*)
           *(.gnu.linkonce.t.*)
    } >FLASH AT>FLASH :phdr_flash

    . = ALIGN(4);
      PROVIDE(__etext = .);
      PROVIDE(_etext = .);
      PROVIDE(etext = .);

    /*
     * C++ virtual tables.
     */
    .vtable : ALIGN(4)
    {
        KEEP(*(vtable))
    } >FLASH AT>FLASH :phdr_flash

    /*
     * Exception frames.
     */
    .exceptions : ALIGN(4)
    {
        KEEP(*(.eh_frame*))
        *(.gcc_except_table)
    } >FLASH AT>FLASH :phdr_flash

     /*
      * Read-only data (constants)
      */
    .rodata : ALIGN(4)
    {
        *(.rodata .rodata.*)
        *(.constdata .constdata.*)
        *(.gnu.linkonce.r.*)
    } >FLASH AT>FLASH :phdr_flash

    . = ALIGN(4);
    PROVIDE( _data = . );

    /*
     * The initialised data section.
     *
     * The program executes knowing that the data is in RAM
     * but the loader puts the initial values in FLASH.
     * The startup will copy the initial values from FLASH to RAM.
     */
    .data : ALIGN(4)
    {
        FILL(0xFF)

        __data_start__ = . ;            /* Standard newlib definition. */
        __data_begin__ = . ;            /* µOS++ specific */
        *(.data_begin .data_begin.*)    /* µOS++ __data_begin_guard */

        *(.data .data.*)
        *(.gnu.linkonce.d.*)

        . = ALIGN(8);
        /*
         * RISC-V specific; the compiler optimises memory accesses
         * in the +/- 2K range around __global_pointer$ to GP relative.
         * For this to work, GP must be loaded during startup with the
         * address of __global_pointer$.
         * This optimisation favours a 4K range. Newlib places
         * several impure and malloc pointers in the .sdata section.
         */
        PROVIDE( __global_pointer$ = . + (4K / 2) );

        *(.sdata .sdata.*)
        *(.gnu.linkonce.s.*)

        /* RISC-V specific; not sure if needed. */
        . = ALIGN(8);
        *(.srodata.cst16)
        *(.srodata.cst8)
        *(.srodata.cst4)
        *(.srodata.cst2)
        *(.srodata .srodata.*)

        *(.data_end .data_end.*)        /* µOS++ __data_end_guard; must be last */
        . = ALIGN(4);
        __data_end__ = . ;                /* Standard newlib definition. */
    } >RAM AT>FLASH :phdr_ram_init

    /*
     * This address is used by the µOS++ startup code to
     * initialise the .data section.
     */
    __data_load_addr__ = LOADADDR(.data);

      . = ALIGN(4);
      PROVIDE( __edata = . );
      PROVIDE( _edata = . );
      PROVIDE( edata = . );

    /*
     * The uninitialised data sections. NOLOAD is used to avoid
     * the "section `.bss' type changed to PROGBITS" warning
     */

    /* The primary uninitialised data section. */
    .bss (NOLOAD) : ALIGN(4)
    {
        __bss_start = .;                 /* Standard newlib definition. */
        __bss_start__ = .;                 /* Standard newlib definition. */
           __bss_begin__ = .;                 /* µOS++ specific */
         *(.bss_begin .bss_begin.*)     /* µOS++ __bss_begin_guard */

        *(.sbss .sbss.*)
        *(.gnu.linkonce.sb.*)

        *(.bss .bss.*)
        *(.gnu.linkonce.b.*)
        *(COMMON)

        *(.bss_end .bss_end.*)             /* µOS++ __bss_end_guard; must be last */
        . = ALIGN(4);
        __bss_end__ = .;                /* Standard newlib definition. */
        __bss_end = .;                    /* Standard newlib definition. */
     } >RAM AT>RAM :phdr_ram

    /*
     * Similar to .bss, but not initialised to zero. µOS++ extension.
     */
    .noinit (NOLOAD) : ALIGN(4)
    {
        __noinit_begin__ = .;            /* µOS++ extension. */

        *(.noinit .noinit.*)

         . = ALIGN(4) ;
        __noinit_end__ = .;               /* µOS++ extension. */
    } >RAM AT>RAM :phdr_ram

    /* _sbrk() expects at least word alignment. */
      . = ALIGN(8);
    PROVIDE( __end = . );
    PROVIDE( _end = . );
    PROVIDE( end = . );

    PROVIDE( __heap_begin__ = . );        /* µOS++ extension. */

      .stack __stack - __stack_size :
      {
        PROVIDE( _heap_end = . );        /* Standard newlib definition. */
        PROVIDE( __heap_end__ = . );    /* µOS++ extension. */
        . += __stack_size;
      } >RAM AT>RAM :phdr_ram

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


[PATCH] ppc64 boot: cleanup linker script

Remove userland related stuff from ld.script, they are not required for zImage
use wildcards for some sections.

Signed-off-by: Olaf Hering <9d781ea8292a2154c6ca4a89a79e3c0c69f1ae9f@suse.de>
Cc: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Cc: Anton Blanchard <14deb5e5e417133e888bf47bb6a3555c9bb7d81c@samba.org>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>

OUTPUT_ARCH(powerpc:common)
SECTIONS
{
  .text      :
  {
    *(.text)
    *(.fixup)
  }
  _etext = .;
  . = ALIGN(4096);
  .data    :
  {
    *(.rodata*)
    *(.data*)
    *(.sdata*)
    *(.got*)
  }

  . = ALIGN(4096);
  _vmlinux_start =  .;
  .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
  _vmlinux_end =  .;

  . = ALIGN(4096);
  _initrd_start =  .;
  .kernel:initrd : { *(.kernel:initrd) }
  _initrd_end =  .;

  . = ALIGN(4096);
  _edata  =  .;

  . = ALIGN(4096);
  __bss_start = .;
  .bss       :
  {
   *(.sbss)
   *(.bss)
  }
  . = ALIGN(4096);
  _end = . ;
}

OUTPUT_ARCH(powerpc:common)
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
{
  /* 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)      }
  .plt : { *(.plt) }
  .text      :
  {
    *(.text)
    *(.fixup)
    *(.got1)
  }
  . = ALIGN(4096);
  _etext = .;
  PROVIDE (etext = .);
  .rodata    :
  {
    *(.rodata)
    *(.rodata1)
  }
  .kstrtab   : { *(.kstrtab) }
  __vermagic : { *(__vermagic) }
  .fini      : { *(.fini)    } =0
  .ctors     : { *(.ctors)   }
  .dtors     : { *(.dtors)   }
  /* Read-write section, merged into data segment: */
  . = ALIGN(4096);
  .data    :
  {
    *(.data)
    *(.data1)
    *(.sdata)
    *(.sdata2)
    *(.got.plt) *(.got)
    *(.dynamic)
    CONSTRUCTORS
  }

  . = ALIGN(4096);
  _vmlinux_start =  .;
  .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
  _vmlinux_end =  .;

  . = ALIGN(4096);
  _initrd_start =  .;
  .kernel:initrd : { *(.kernel:initrd) }
  _initrd_end =  .;

  . = ALIGN(4096);
  _edata  =  .;
  PROVIDE (edata = .);

  .fixup   : { *(.fixup) }

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


Updated LD file to add preliminary bank switch support

OUTPUT_ARCH(m68k)
SEARCH_DIR(.)
/*GROUP(-lbcc -lc -lgcc)*/
__DYNAMIC  =  0;

/*
 * Setup the memory map of the SEGA Genesis.
 * stack grows down from high memory.
 *
 * The memory map look like this:
 * +--------------------+ <- low memory
 * | .text              |
 * |        _etext      |
 * |        ctor list   | the ctor and dtor lists are for
 * |        dtor list   | C++ support
 * +--------------------+
 * .                    .
 * .                    .
 * .                    .
 * +--------------------+ <- 0x00FF0000
 * | .data              | initialized data goes here
 * |        _data       |
 * |        _edata      |
 * +--------------------+
 * | .bss               |
 * |        _bstart     | start of bss, cleared by crt0
 * |        _bend       | start of heap, used by sbrk()
 * +--------------------+
 * .                    .
 * .                    .
 * .                    .
 * |        __stack     | top of stack
 * +--------------------+ <- 0x01000000
 */
MEMORY
{
	rom : ORIGIN = 0x00000000, LENGTH = 0x00A00000
	ram : ORIGIN = 0x00FF0000, LENGTH = 0x00010000
}

/*
 * allocate the stack to be at the top of memory, since the stack
 * grows down
 */

PROVIDE (__stack = 0x01000000);

SECTIONS
{
  .text 0x00000000:
  {
    KEEP(*(.text.keepboot)) *(.text.*) *(.text)
    . = ALIGN(0x4);
     __CTOR_LIST__ = .;
    LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
    *(.ctors)
    LONG(0)
    __CTOR_END__ = .;
    __DTOR_LIST__ = .;
    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
    *(.dtors)
     LONG(0)
    __DTOR_END__ = .;
    *(.gcc_except_table .gcc_except_table.*)

    . = ALIGN(0x4);
    __INIT_SECTION__ = . ;
    *(.init)
    SHORT (0x4E75)	/* rts */

    __FINI_SECTION__ = . ;
    *(.fini)
    SHORT (0x4E75)	/* rts */

    _etext = .;
    *(.lit)

    *(.rodata .rodata.*)
    *(.far_rodata .far_rodata.*)
  } > rom
  _stext = SIZEOF (.text);

  .data 0xFF0000 :
  AT ( ADDR (.text) + SIZEOF (.text) )
  {
    *(.got.plt) *(.got)
    *(.shdata)
    *(.data .data.*)
    _edata = .;
  } > ram
  _sdata = SIZEOF (.data);

  .bss 0xFF0000 + SIZEOF (.data) :
  {
    _start = . ;
    *(.shbss)
    *(.bss .bss.*)
    *(COMMON)
    _bend = . ;
  } > ram

  .stab 0 (NOLOAD) :
  {
    *(.stab)
  }

  .stabstr 0 (NOLOAD) :
  {
    *(.stabstr)
  }

  .eh_frame 0 (NOLOAD) :
  {
    *(.eh_frame)
  }
}

OUTPUT_ARCH(m68k)
SEARCH_DIR(.)
/*GROUP(-lbcc -lc -lgcc)*/
__DYNAMIC  =  0;

/*
 * Setup the memory map of the SEGA Genesis.
 * stack grows down from high memory.
 *
 * The memory map look like this:
 * +--------------------+ <- low memory
 * | .text              |
 * |        _etext      |
 * |        ctor list   | the ctor and dtor lists are for
 * |        dtor list   | C++ support
 * +--------------------+
 * .                    .
 * .                    .
 * .                    .
 * +--------------------+ <- 0x00FF0000
 * | .data              | initialized data goes here
 * |        _data       |
 * |        _edata      |
 * +--------------------+
 * | .bss               |
 * |        _bstart     | start of bss, cleared by crt0
 * |        _bend       | start of heap, used by sbrk()
 * +--------------------+
 * .                    .
 * .                    .
 * .                    .
 * |        __stack     | top of stack
 * +--------------------+ <- 0x01000000
 */
MEMORY
{
	rom : ORIGIN = 0x00000000, LENGTH = 0x00A00000
	ram : ORIGIN = 0x00FF0000, LENGTH = 0x00010000
}

/*
 * allocate the stack to be at the top of memory, since the stack
 * grows down
 */

PROVIDE (__stack = 0x01000000);

SECTIONS
{
  .text 0x00000000:
  {
    KEEP(*(.text.keepboot)) *(.text.*) *(.text)
    . = ALIGN(0x4);
     __CTOR_LIST__ = .;
    LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
    *(.ctors)
    LONG(0)
    __CTOR_END__ = .;
    __DTOR_LIST__ = .;
    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
    *(.dtors)
     LONG(0)
    __DTOR_END__ = .;
    *(.rodata .rodata.*)
    *(.gcc_except_table .gcc_except_table.*)

    . = ALIGN(0x4);
    __INIT_SECTION__ = . ;
    *(.init)
    SHORT (0x4E75)	/* rts */

    __FINI_SECTION__ = . ;
    *(.fini)
    SHORT (0x4E75)	/* rts */

    _etext = .;
    *(.lit)
  } > rom
  _stext = SIZEOF (.text);

  .data 0xFF0000 :
  AT ( ADDR (.text) + SIZEOF (.text) )
  {
    *(.got.plt) *(.got)
    *(.shdata)
    *(.data .data.*)
    _edata = .;
  } > ram
  _sdata = SIZEOF (.data);

  .bss 0xFF0000 + SIZEOF (.data) :
  {
    _start = . ;
    *(.shbss)
    *(.bss .bss.*)
    *(COMMON)
    _bend = . ;
  } > ram

  .stab 0 (NOLOAD) :
  {
    *(.stab)
  }

  .stabstr 0 (NOLOAD) :
  {
    *(.stabstr)
  }

  .eh_frame 0 (NOLOAD) :
  {
    *(.eh_frame)
  }
}


Updated stm32f373xc linker script

Updated stm32f373xc linker script

ENTRY(Reset_Handler)
MEMORY
{
    ROM   (rx): ORIGIN = 0x08000000, LENGTH = 256K
    RAM  (rwx): ORIGIN = 0x20000000, LENGTH = 32K
}

INCLUDE sections.ld

ENTRY(Reset_Handler)
MEMORY
{
    ROM   (rx): ORIGIN = 0x08000000, LENGTH = 256K
    RAM  (rwx): ORIGIN = 0x20000000, LENGTH = 32K
}
SECTIONS
{
    .text :
    {
        KEEP(*(.isr_vector))
        *(.text*)
        KEEP(*(.init))  KEEP(*(.fini))
        *crtbegin.o(.ctors)
        *crtbegin?.o(.ctors)
        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
        *(SORT(.ctors.*))
        *(.ctors)
        *crtbegin.o(.dtors)
        *crtbegin?.o(.dtors)
        *(EXCLUDE_FILE(*crtend?.o *crtend.o).dtors)
        *(SORT(.dtors.*))
        *(.dtors)
        *(.rodata*)
        KEEP(*(.eh_frame*))
    } > ROM
    .ARM.extab :
    {
        *(.ARM.extab* .gnu.linkonce.armextab.*)
    } > ROM
    __exidx_start = .;
    .ARM.exidx :
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > ROM
    __exidx_end = .;
    __etext = .;
    .data : AT (__etext)
    {
        __data_start__ = .;
        *(vtable)
        *(.data*)
        . = ALIGN(4);
        PROVIDE_HIDDEN (__preinit_array_start = .);
        KEEP(*(.preinit_array))
        PROVIDE_HIDDEN (__preinit_array_end = .);
        . = ALIGN(4);
        PROVIDE_HIDDEN (__init_array_start = .);
        KEEP(*(SORT(.init_array.*)))
        KEEP(*(.init_array))
        PROVIDE_HIDDEN (__init_array_end = .);
        . = ALIGN(4);
        PROVIDE_HIDDEN (__fini_array_start = .);
        KEEP(*(SORT(.fini_array.*)))
        KEEP(*(.fini_array))
        PROVIDE_HIDDEN (__fini_array_end = .);
        . = ALIGN(4);
        __data_end__ = .;
    } > RAM
    .bss (NOLOAD) :
    {
        __bss_start__ = .;
        *(.bss*)
        *(COMMON)
        __bss_end__ = .;
    } > RAM
    .heap (NOLOAD) :
    {
        __end__ = .;
        *(.heap*)
        __HeapLimit = .;
    } > RAM
    .stack_dummy (NOLOAD) :
    {
        *(.stack)
    } > RAM
    __StackTop = ORIGIN(RAM) + LENGTH(RAM);
    __StackLimit = __StackTop - SIZEOF(.stack_dummy);
    PROVIDE(__stack = __StackTop);
    ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
    PROVIDE(_estack = __stack);
    PROVIDE(_sidata = __etext);
    PROVIDE(_sdata = __data_start__);
    PROVIDE(_edata = __data_end__);
    PROVIDE(_sbss = __bss_start__);
    PROVIDE(_ebss = __bss_end__);
}


Linker for higher-half linking and lower setup sections

OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY (loader)
hhalf = 0xc0000000;
page_size = 4096;

SECTIONS
{
    . = 0x00100000;
    .setup :
    {
    __start_setup = .;
        *(.setup)
        *(.setup.data)
        boot/boot.o(.bss)
        boot/boot.o(COMMON)
    __end_setup = .;
    }

    /* Higher half */
    . += 0xc0000000;
    .text : AT(ADDR(.text) - hhalf)
    {
        *(.text)
    __start_cs_init = .;
        *(.init.text)
    __end_cs_init = .;
    }

    .rodata ALIGN(page_size) : AT(ADDR(.rodata) - hhalf)
    {
    __start_data_kernel = .;
        *(.rodata*)
    }

    .data ALIGN(page_size) : AT(ADDR(.data) - hhalf)
    {
        *(.data)
    }

    .bss ALIGN(page_size) : AT(ADDR(.bss) - hhalf)
    {
        sbss = .;
        *(COMMON)
        *(.bss)
        ebss = .;
    __end_data_kernel = .;
    }
}

OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY (loader)

SECTIONS
{
    . = 0x00100000;
    .setup ALIGN (0x1000) :
    {
        __start_setup = .;
        *(.setup)
        *(.setup.data)
        __end_setup = .;
    }

    /* Higher half */
    . += 0xc0000000;
    .text ALIGN (0x1000) :
    {
        *(.text)
    __start_cs_init = .;
        *(.init.text)
    __end_cs_init = .;
    }

    .rodata ALIGN (0x1000) :
    {
    __start_data_kernel = .;
        *(.rodata*)
    }

    .data ALIGN (0x1000) :
    {
        *(.data)
    }

    .bss :
    {
        sbss = .;
        *(COMMON)
        *(.bss)
        ebss = .;
    __end_data_kernel = .;
    }
}


popcorn: remove unused file

popcorn: remove unused file

ENTRY(_start)
SECTIONS
{
    __virtual_base = 0xFFFF000000000000;
    . = __virtual_base;
    __kernel_virtual_start = .;
    __kernel_physical_start = . - __virtual_base;

    /* Align to page (4 kb) boundary */
    .text ALIGN(0x1000) : AT(ADDR(.text) - __virtual_base) {
        *(.text)
    }
    .rodata ALIGN(0x1000) : AT(ADDR(.rodata) - __virtual_base) {
        *(.rodata)
    }

    .data ALIGN(0x1000) : AT(ADDR(.data) - __virtual_base) {
        *(.data)
    }

    __kernel_physical_bss_start = . - __virtual_base;
    .bss ALIGN(0x1000) : AT(ADDR(.bss) - __virtual_base) {
        *(.bss)
        *(.COMMON)
    }
    __kernel_physical_bss_end = . - __virtual_base;

    __kernel_virtual_end = .;
    __kernel_physical_end = . - __virtual_base;
}


Skip calling wrappers from a number of the ROM functions.

A number of the ROM functions were pointing to wrappers that saved and
restored the $a0 register, but the functions they called either did
not use $a0 or saved and restored $a0 as needed anyway.

/* Linker script containing Boot ROM functions for ESP8266

   For more information, see:

   http://esp8266-re.foogod.com/wiki/Boot_ROM
   https://github.com/jcmvbkbc/esp-elf-rom/
*/

PROVIDE ( SPI_sector_erase = 0x400040c0 );
PROVIDE ( SPI_page_program = 0x40004174 );
PROVIDE ( SPI_read_data = 0x400042ac );
PROVIDE ( SPI_read_status = 0x400043c8 );
PROVIDE ( SPI_write_status = 0x40004400 );
PROVIDE ( SPI_write_enable = 0x4000443c );
PROVIDE ( Wait_SPI_Idle = 0x4000448c );
PROVIDE ( Enable_QMode = 0x400044c0 );
PROVIDE ( Disable_QMode = 0x40004508 );

/* When using OTA, Cache_Read_Enable is defined in extras/rboot-ota so
   the ROM Cache_Read_Enable isn't picked up from here. However we
   also provide access to the ROM function in all cases, via the name
   rom_Cache_Read_Enable */
PROVIDE ( rom_Cache_Read_Enable = 0x40004678 );
PROVIDE ( Cache_Read_Enable = rom_Cache_Read_Enable );

PROVIDE ( Cache_Read_Disable = 0x400047f0 );

PROVIDE ( lldesc_build_chain = 0x40004f40 );
PROVIDE ( lldesc_num2link = 0x40005050 );
PROVIDE ( lldesc_set_owner = 0x4000507c );

/* TODO: Nearly everything below here is probably provided by the
   libc, so never linked in, and can therefore be removed. */

PROVIDE ( __adddf3 = 0x4000c538 );
PROVIDE ( __addsf3 = 0x4000c180 );
PROVIDE ( __divdf3 = 0x4000cb94 );
PROVIDE ( __divdi3 = 0x4000ce60 );
PROVIDE ( __divsi3 = 0x4000dc88 );
PROVIDE ( __extendsfdf2 = 0x4000cdfc );
PROVIDE ( __fixdfsi = 0x4000ccb8 );
PROVIDE ( __fixunsdfsi = 0x4000cd00 );
PROVIDE ( __fixunssfsi = 0x4000c4c4 );
PROVIDE ( __floatsidf = 0x4000e2f0 );
PROVIDE ( __floatsisf = 0x4000e2ac );
PROVIDE ( __floatunsidf = 0x4000e2e8 );
PROVIDE ( __floatunsisf = 0x4000e2a4 );
PROVIDE ( __muldf3 = 0x4000c8f0 );
PROVIDE ( __muldi3 = 0x40000650 );
PROVIDE ( __mulsf3 = 0x4000c3dc );
PROVIDE ( __subdf3 = 0x4000c688 );
PROVIDE ( __subsf3 = 0x4000c268 );
PROVIDE ( __truncdfsf2 = 0x4000cd5c );
PROVIDE ( __udivdi3 = 0x4000d310 );
PROVIDE ( __udivsi3 = 0x4000e21c );
PROVIDE ( __umoddi3 = 0x4000d770 );
PROVIDE ( __umodsi3 = 0x4000e268 );
PROVIDE ( __umulsidi3 = 0x4000dcf0 );

PROVIDE ( bzero = 0x4000de84 );
PROVIDE ( memcmp = 0x4000dea8 );
PROVIDE ( memcpy = 0x4000df48 );
PROVIDE ( memmove = 0x4000e04c );
PROVIDE ( memset = 0x4000e190 );

PROVIDE ( strcmp = 0x4000bdc8 );
PROVIDE ( strcpy = 0x4000bec8 );
PROVIDE ( strlen = 0x4000bf4c );
PROVIDE ( strncmp = 0x4000bfa8 );
PROVIDE ( strncpy = 0x4000c0a0 );
PROVIDE ( strstr = 0x4000e1e0 );

PROVIDE ( ETS_INTR_LOCK = 0x40000f74 );
PROVIDE ( ETS_INTR_UNLOCK = 0x40000f80 );

/* Linker script containing Boot ROM functions for ESP8266

   For more information, see:

   http://esp8266-re.foogod.com/wiki/Boot_ROM
   https://github.com/jcmvbkbc/esp-elf-rom/
*/

PROVIDE ( SPI_sector_erase = 0x400040c0 );
PROVIDE ( SPI_page_program = 0x40004174 );
PROVIDE ( SPI_read_data = 0x400042ac );
PROVIDE ( SPI_read_status = 0x400043c8 );
PROVIDE ( SPI_write_status = 0x40004400 );
PROVIDE ( SPI_write_enable = 0x4000443c );
PROVIDE ( Wait_SPI_Idle = 0x4000448c );
PROVIDE ( Enable_QMode = 0x400044c0 );
PROVIDE ( Disable_QMode = 0x40004508 );

/* When using OTA, Cache_Read_Enable is defined in extras/rboot-ota so
   the ROM Cache_Read_Enable isn't picked up from here. However we
   also provide access to the ROM function in all cases, via the name
   rom_Cache_Read_Enable */
PROVIDE ( rom_Cache_Read_Enable = 0x40004678 );
PROVIDE ( Cache_Read_Enable = rom_Cache_Read_Enable );

PROVIDE ( Cache_Read_Disable = 0x400047f0 );

PROVIDE ( lldesc_build_chain = 0x40004f40 );
PROVIDE ( lldesc_num2link = 0x40005050 );
PROVIDE ( lldesc_set_owner = 0x4000507c );

/* TODO: Nearly everything below here is probably provided by the
   libc, so never linked in, and can therefore be removed. */

PROVIDE ( __adddf3 = 0x4000c538 );
PROVIDE ( __addsf3 = 0x4000c180 );
PROVIDE ( __divdf3 = 0x4000cb94 );
PROVIDE ( __divdi3 = 0x4000ce60 );
PROVIDE ( __divsi3 = 0x4000dc88 );
PROVIDE ( __extendsfdf2 = 0x4000cdfc );
PROVIDE ( __fixdfsi = 0x4000ccb8 );
PROVIDE ( __fixunsdfsi = 0x4000cd00 );
PROVIDE ( __fixunssfsi = 0x4000c4c4 );
PROVIDE ( __floatsidf = 0x4000e2f0 );
PROVIDE ( __floatsisf = 0x4000e2ac );
PROVIDE ( __floatunsidf = 0x4000e2e8 );
PROVIDE ( __floatunsisf = 0x4000e2a4 );
PROVIDE ( __muldf3 = 0x4000c8f0 );
PROVIDE ( __muldi3 = 0x40000650 );
PROVIDE ( __mulsf3 = 0x4000c3dc );
PROVIDE ( __subdf3 = 0x4000c688 );
PROVIDE ( __subsf3 = 0x4000c268 );
PROVIDE ( __truncdfsf2 = 0x4000cd5c );
PROVIDE ( __udivdi3 = 0x4000d310 );
PROVIDE ( __udivsi3 = 0x4000e21c );
PROVIDE ( __umoddi3 = 0x4000d770 );
PROVIDE ( __umodsi3 = 0x4000e268 );
PROVIDE ( __umulsidi3 = 0x4000dcf0 );

PROVIDE ( bzero = 0x40002ae8 );
PROVIDE ( memcmp = 0x400018d4 );
PROVIDE ( memcpy = 0x400018b4 );
PROVIDE ( memmove = 0x400018c4 );
PROVIDE ( memset = 0x400018a4 );

PROVIDE ( strcmp = 0x40002aa8 );
PROVIDE ( strcpy = 0x40002a88 );
PROVIDE ( strlen = 0x40002ac8 );
PROVIDE ( strncmp = 0x40002ab8 );
PROVIDE ( strncpy = 0x40002a98 );
PROVIDE ( strstr = 0x40002ad8 );

PROVIDE ( ETS_INTR_LOCK = 0x40000f74 );
PROVIDE ( ETS_INTR_UNLOCK = 0x40000f80 );


Adapt flash location for NRF52

Adapt flash location for NRF52

This reverts commit 112544055854f5c3763de2e8613b840e2db8fdaa.

/* Userland Generic Layout
 *
 * This linker script is designed for Tock apps where the end microcontroller
 * is not known. Therefore, this script over provisions space on some platforms.
 */

/* Memory Spaces Definitions, 448K flash, 64K ram */
PROG_LENGTH = 0x00040000;
RAM_LENGTH  = 0x00010000;

ENTRY(_start)

/* Note: Because apps are relocated, the FLASH address here acts as a sentinel
 * value for relocation fixup routines. The application loader will select the
 * actual location in flash where the app is placed.
 */
MEMORY {
    FLASH (rx) : ORIGIN = 0x00020038, LENGTH = PROG_LENGTH
    SRAM (RWX) : ORIGIN = 0x00000000, LENGTH = RAM_LENGTH
}

SECTIONS {
/* Text section, Code! */
    .text :
    {
        _text = .;
        KEEP (*(.text._start))
        *(.text*)
        *(.rodata*)

        /* C++ exception unwinding information */
        *(.ARM.extab* .gnu.linkonce.armextab.*)
    } > FLASH =0xFF

/* ARM Exception support
 *
 * This contains compiler-generated support for unwinding the stack,
 * consisting of key-value pairs of function addresses and information on
 * how to unwind stack frames.
 * https://wiki.linaro.org/KenWerner/Sandbox/libunwind?action=AttachFile&do=get&target=libunwind-LDS.pdf
 *
 * .ARM.exidx is sorted, so has to go in its own output section.
 */
    PROVIDE_HIDDEN (__exidx_start = .);
    .ARM.exidx :
    {
      /* (C++) Index entries for section unwinding */
      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > FLASH
    PROVIDE_HIDDEN (__exidx_end = .);

/* Beginning of SRAM */
    _sram_start = .;

/* Global Offset Table */
    .got :
    {
        _got = .;
        *(.got*)
        _egot = .;
        _plt = .;
        *(.got.plt*)
        _eplt = .;
    } > SRAM AT > FLASH

/* Data section, static initialized variables
 *  Note: This is placed in Flash after the text section, but needs to be
 *  moved to SRAM at runtime
 */
    .data :
    {
        _data = .;
        KEEP(*(.data*))
        _edata = .;
    } > SRAM AT > FLASH

/* BSS section, static uninitialized variables */
    .bss :
    {
        _bss = .;
        KEEP(*(.bss*))
        *(COMMON)
        _ebss = .;
    } > SRAM

/*
 * __NOTE__: The following symbols are used only to pass information
 * through the elf -> tbf -> Tock kernel.
 *
 * The kernel will place the stack at the beginning of the SRAM section so
 * that stack overflows run off the end of the memory segment and trigger an
 * MPU violation instead of overwriting data/got/bss information. This means
 * the actual location of symbols in those sections in memory will be offset
 * by STACK_SIZE.
 */
    .stack :
    {
        _stack = .;
        . += 1024;
        _estack = .;
    } > SRAM

    .app_heap :
    {
        _app_heap = .;
        . += 1024;
        _eapp_heap = .;
    } > SRAM

    .kernel_heap :
    {
        _kernel_heap = .;
        . += 1024;
        _ekernel_heap = .;
    } > SRAM

    _sram_end = .;
}

/* Userland Generic Layout
 *
 * This linker script is designed for Tock apps where the end microcontroller
 * is not known. Therefore, this script over provisions space on some platforms.
 */

/* Memory Spaces Definitions, 448K flash, 64K ram */
PROG_LENGTH = 0x00040000;
RAM_LENGTH  = 0x00010000;

ENTRY(_start)

/* Note: Because apps are relocated, the FLASH address here acts as a sentinel
 * value for relocation fixup routines. The application loader will select the
 * actual location in flash where the app is placed.
 */
MEMORY {
    FLASH (rx) : ORIGIN = 0x00040030, LENGTH = PROG_LENGTH
    SRAM (RWX) : ORIGIN = 0x00000000, LENGTH = RAM_LENGTH
}

SECTIONS {
/* Text section, Code! */
    .text :
    {
        _text = .;
        KEEP (*(.text._start))
        *(.text*)
        *(.rodata*)

        /* C++ exception unwinding information */
        *(.ARM.extab* .gnu.linkonce.armextab.*)
    } > FLASH =0xFF

/* ARM Exception support
 *
 * This contains compiler-generated support for unwinding the stack,
 * consisting of key-value pairs of function addresses and information on
 * how to unwind stack frames.
 * https://wiki.linaro.org/KenWerner/Sandbox/libunwind?action=AttachFile&do=get&target=libunwind-LDS.pdf
 *
 * .ARM.exidx is sorted, so has to go in its own output section.
 */
    PROVIDE_HIDDEN (__exidx_start = .);
    .ARM.exidx :
    {
      /* (C++) Index entries for section unwinding */
      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > FLASH
    PROVIDE_HIDDEN (__exidx_end = .);

/* Beginning of SRAM */
    _sram_start = .;

/* Global Offset Table */
    .got :
    {
        _got = .;
        *(.got*)
        _egot = .;
        _plt = .;
        *(.got.plt*)
        _eplt = .;
    } > SRAM AT > FLASH

/* Data section, static initialized variables
 *  Note: This is placed in Flash after the text section, but needs to be
 *  moved to SRAM at runtime
 */
    .data :
    {
        _data = .;
        KEEP(*(.data*))
        _edata = .;
    } > SRAM AT > FLASH

/* BSS section, static uninitialized variables */
    .bss :
    {
        _bss = .;
        KEEP(*(.bss*))
        *(COMMON)
        _ebss = .;
    } > SRAM

/*
 * __NOTE__: The following symbols are used only to pass information
 * through the elf -> tbf -> Tock kernel.
 *
 * The kernel will place the stack at the beginning of the SRAM section so
 * that stack overflows run off the end of the memory segment and trigger an
 * MPU violation instead of overwriting data/got/bss information. This means
 * the actual location of symbols in those sections in memory will be offset
 * by STACK_SIZE.
 */
    .stack :
    {
        _stack = .;
        . += 1024;
        _estack = .;
    } > SRAM

    .app_heap :
    {
        _app_heap = .;
        . += 1024;
        _eapp_heap = .;
    } > SRAM

    .kernel_heap :
    {
        _kernel_heap = .;
        . += 1024;
        _ekernel_heap = .;
    } > SRAM

    _sram_end = .;
}


[os.ld] Removed unneeded padding

[os.ld] Removed unneeded padding

Signed-off-by: Dan Printzell <69f25cbe4b2608181d39803083cb5ee0c30f2794@gmail.com>

OUTPUT_FORMAT(elf64-x86-64)
ENTRY(lstart)
KERNEL_LMA = 1M;
KERNEL_VMA = 0xFFFFFFFF80000000;
lstart = start - KERNEL_VMA;
SECTIONS {
	. = KERNEL_LMA;

	.multiboot : AT(ADDR(.multiboot)) {
		LONG(0x0)
		*(.multiboot)
	}

	/*. += 0x100000;*/
	. += KERNEL_VMA;

	.text ALIGN(0x1000) : AT(ADDR(.text) - KERNEL_VMA) {
		*(.text .text.*)
	}

	.rodata ALIGN(0x1000) : AT(ADDR(.rodata) - KERNEL_VMA) {
		*(.initpd)
		*(.rodata .rodata.*)
		*(.rdata)
	}

	.minfo ALIGN(0x1000) : AT(ADDR(.minfo) - KERNEL_VMA) {
		*(.minfo)
	}

	.deh_eh ALIGN(0x1000) : AT(ADDR(.deh_eh) - KERNEL_VMA) {
		*(.deh_eh)
	}

	.dtors.d_dso_dtor ALIGN(0x1000) : AT(ADDR(.dtors.d_dso_dtor) - KERNEL_VMA) {
		*(.dtors .dtors.*)
		 *(.dtors.d_dso_dtor)
	}

	.ctors.d_dso_ctor ALIGN(0x1000) : AT(ADDR(.ctors.d_dso_ctor) - KERNEL_VMA) {
		*(.ctors .ctors.*)
		*(.ctors.d_dso_ctor)
	}

	.eh_frame ALIGN(0x1000) : AT(ADDR(.eh_frame) - KERNEL_VMA) {
		*(.eh_frame)
	}

	.data ALIGN(0x1000) : AT(ADDR(.data) - KERNEL_VMA) {
		*(.padata)
		*(.data .data.*)

		KERNEL_MODULES_START = .;
		*(.KMODULES)
		KERNEL_MODULES_END = .;
	}

	.symbols ALIGN(0x1000) : AT(ADDR(.symbols) - KERNEL_VMA) {
		KERNEL_SYMBOLS_START = .;
		*(.symbols .symbols.*)
		KERNEL_SYMBOLS_END = .;
	}

	.tdata ALIGN(0x1000) : AT(ADDR(.tdata) - KERNEL_VMA) {
		*(.tdata .tdata.*)
	}

	.got ALIGN(0x1000) : AT(ADDR(.got) - KERNEL_VMA) {
		*(.got)
		*(.got.plt)
	}

	.bss ALIGN(0x1000) : AT(ADDR(.bss) - KERNEL_VMA) {
		KERNEL_BSS_START = .;
		*(.COMMON)
		*(.bss)
	}

	.tbss : AT(ADDR(.tbss) - KERNEL_VMA) {
		*(.tbss .tbss.*)
	}

	KERNEL_END = (. + 0xFFF) & 0xFFFFFFFFFFFFF000;

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

OUTPUT_FORMAT(elf64-x86-64)
ENTRY(lstart)
KERNEL_LMA = 1M;
KERNEL_VMA = 0xFFFFFFFF80000000;
lstart = start - KERNEL_VMA;
SECTIONS {
	. = KERNEL_LMA;

	.multiboot : AT(ADDR(.multiboot)) {
		LONG(0x0)
		*(.multiboot)
	}

	. += KERNEL_VMA;

	.text ALIGN(0x1000) : AT(ADDR(.text) - KERNEL_VMA) {
		*(.text .text.*)
	}

	.rodata ALIGN(0x1000) : AT(ADDR(.rodata) - KERNEL_VMA) {
		*(.initpd)
		*(.rodata .rodata.*)
		*(.rdata)
	}

	.minfo ALIGN(0x1000) : AT(ADDR(.minfo) - KERNEL_VMA) {
		*(.minfo)
	}

	.deh_eh ALIGN(0x1000) : AT(ADDR(.deh_eh) - KERNEL_VMA) {
		*(.deh_eh)
	}

	.dtors.d_dso_dtor ALIGN(0x1000) : AT(ADDR(.dtors.d_dso_dtor) - KERNEL_VMA) {
		*(.dtors .dtors.*)
		 *(.dtors.d_dso_dtor)
	}

	.ctors.d_dso_ctor ALIGN(0x1000) : AT(ADDR(.ctors.d_dso_ctor) - KERNEL_VMA) {
		*(.ctors .ctors.*)
		*(.ctors.d_dso_ctor)
	}

	.eh_frame ALIGN(0x1000) : AT(ADDR(.eh_frame) - KERNEL_VMA) {
		*(.eh_frame)
	}

	.data ALIGN(0x1000) : AT(ADDR(.data) - KERNEL_VMA) {
		*(.padata)
		*(.data .data.*)

		KERNEL_MODULES_START = .;
		*(.KMODULES)
		KERNEL_MODULES_END = .;
	}

	.symbols ALIGN(0x1000) : AT(ADDR(.symbols) - KERNEL_VMA) {
		KERNEL_SYMBOLS_START = .;
		*(.symbols .symbols.*)
		KERNEL_SYMBOLS_END = .;
	}

	.tdata ALIGN(0x1000) : AT(ADDR(.tdata) - KERNEL_VMA) {
		*(.tdata .tdata.*)
	}

	.got ALIGN(0x1000) : AT(ADDR(.got) - KERNEL_VMA) {
		*(.got)
		*(.got.plt)
	}

	.bss ALIGN(0x1000) : AT(ADDR(.bss) - KERNEL_VMA) {
		KERNEL_BSS_START = .;
		*(.COMMON)
		*(.bss)
	}

	.tbss : AT(ADDR(.tbss) - KERNEL_VMA) {
		*(.tbss .tbss.*)
	}

	KERNEL_END = (. + 0xFFF) & 0xFFFFFFFFFFFFF000;

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


Update stm32_rom.ld

Update stm32_rom.ld

/*
 * linker script for STM32F10x with GNU ld
 * bernard.xiong 2009-10-14
 */

/* Program Entry, set to mark it as "used" and avoid gc */
MEMORY
{
    CODE (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */
    DATA (rw) : ORIGIN = 0x20000000, LENGTH =  128k /* 128K sram */
}
ENTRY(Reset_Handler)
_system_stack_size = 0x100;

SECTIONS
{
    .text :
    {
        . = ALIGN(4);
        _stext = .;
        KEEP(*(.isr_vector))            /* Startup code */
        . = ALIGN(4);
        *(.text)                        /* remaining code */
        *(.text.*)                      /* remaining code */
        *(.rodata)                      /* read-only data (constants) */
        *(.rodata*)
        *(.glue_7)
        *(.glue_7t)
        *(.gnu.linkonce.t*)

        /* section information for finsh shell */
        . = ALIGN(4);
        __fsymtab_start = .;
        KEEP(*(FSymTab))
        __fsymtab_end = .;
        . = ALIGN(4);
        __vsymtab_start = .;
        KEEP(*(VSymTab))
        __vsymtab_end = .;
        . = ALIGN(4);

        /* section information for initial. */
        . = ALIGN(4);
        __rt_init_start = .;
        KEEP(*(SORT(.rti_fn*)))
        __rt_init_end = .;
        . = ALIGN(4);

        . = ALIGN(4);
        _etext = .;
    } > CODE = 0

    /* .ARM.exidx is sorted, so has to go in its own output section.  */
    __exidx_start = .;
    .ARM.exidx :
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)

        /* This is used by the startup in order to initialize the .data secion */
        _sidata = .;
    } > CODE
    __exidx_end = .;

    /* .data section which is used for initialized data */

    .data : AT (_sidata)
    {
        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .data secion */
        _sdata = . ;

        *(.data)
        *(.data.*)
        *(.gnu.linkonce.d*)

        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .data secion */
        _edata = . ;
    } >DATA

    .stack :
    {
        . = . + _system_stack_size;
        . = ALIGN(4);
        _estack = .;
    } >DATA

    __bss_start = .;
    .bss :
    {
        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .bss secion */
        _sbss = .;

        *(.bss)
        *(.bss.*)
        *(COMMON)

        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .bss secion */
        _ebss = . ;

        *(.bss.init)
    } > DATA
    __bss_end = .;

    _end = .;

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

/*
 * linker script for STM32F10x with GNU ld
 * bernard.xiong 2009-10-14
 */

/* Program Entry, set to mark it as "used" and avoid gc */
MEMORY
{
    CODE (rx) : ORIGIN = 0x08000000, LENGTH = 512k /* 512KB flash */
    DATA (rw) : ORIGIN = 0x20000000, LENGTH =  64k /* 64K sram */
}
ENTRY(Reset_Handler)
_system_stack_size = 0x100;

SECTIONS
{
    .text :
    {
        . = ALIGN(4);
        _stext = .;
        KEEP(*(.isr_vector))            /* Startup code */
        . = ALIGN(4);
        *(.text)                        /* remaining code */
        *(.text.*)                      /* remaining code */
        *(.rodata)                      /* read-only data (constants) */
        *(.rodata*)
        *(.glue_7)
        *(.glue_7t)
        *(.gnu.linkonce.t*)

        /* section information for finsh shell */
        . = ALIGN(4);
        __fsymtab_start = .;
        KEEP(*(FSymTab))
        __fsymtab_end = .;
        . = ALIGN(4);
        __vsymtab_start = .;
        KEEP(*(VSymTab))
        __vsymtab_end = .;
        . = ALIGN(4);

        /* section information for initial. */
        . = ALIGN(4);
        __rt_init_start = .;
        KEEP(*(SORT(.rti_fn*)))
        __rt_init_end = .;
        . = ALIGN(4);

        . = ALIGN(4);
        _etext = .;
    } > CODE = 0

    /* .ARM.exidx is sorted, so has to go in its own output section.  */
    __exidx_start = .;
    .ARM.exidx :
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)

        /* This is used by the startup in order to initialize the .data secion */
        _sidata = .;
    } > CODE
    __exidx_end = .;

    /* .data section which is used for initialized data */

    .data : AT (_sidata)
    {
        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .data secion */
        _sdata = . ;

        *(.data)
        *(.data.*)
        *(.gnu.linkonce.d*)

        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .data secion */
        _edata = . ;
    } >DATA

    .stack :
    {
        . = . + _system_stack_size;
        . = ALIGN(4);
        _estack = .;
    } >DATA

    __bss_start = .;
    .bss :
    {
        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .bss secion */
        _sbss = .;

        *(.bss)
        *(.bss.*)
        *(COMMON)

        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .bss secion */
        _ebss = . ;

        *(.bss.init)
    } > DATA
    __bss_end = .;

    _end = .;

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


fix bss start address in ld file

fix bss start address in ld file

/*
 * COPYRIGHT (C) 2013-2014, Shanghai Real-Thread Technology Co., Ltd
 *
 *  This file is part of RT-Thread (http://www.rt-thread.org)
 *
 *  All rights reserved.
 *
 *  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.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
SECTIONS
{
    . = 0x1ff00000;
    __text_start = .;
    .text :
    {
        *(.vectors)
        /* make the ISRs close to vectors may be more cache-friendly */
        *(.text.isr)

        *(.text)
        *(.text.*)

        /* section information for finsh shell */
        . = ALIGN(4);
        __fsymtab_start = .;
        KEEP(*(FSymTab))
        __fsymtab_end = .;
        . = ALIGN(4);
        __vsymtab_start = .;
        KEEP(*(VSymTab))
        __vsymtab_end = .;
        . = ALIGN(4);

        /* section information for modules */
        . = ALIGN(4);
        __rtmsymtab_start = .;
        KEEP(*(RTMSymTab))
        __rtmsymtab_end = .;

        /* section information for initialization */
        . = ALIGN(4);
        __rt_init_start = .;
        KEEP(*(SORT(.rti_fn*)))
        __rt_init_end = .;
    } =0
    __text_end = .;

    __rodata_start = .;
    .rodata   : { *(.rodata) *(.rodata.*) }
    __rodata_end = .;

    . = ALIGN(4);
    .ctors :
    {
        PROVIDE(__ctors_start__ = .);
        KEEP(*(SORT(.ctors.*)))
        KEEP(*(.ctors))
        PROVIDE(__ctors_end__ = .);
    }

    .dtors :
    {
        PROVIDE(__dtors_start__ = .);
        KEEP(*(SORT(.dtors.*)))
        KEEP(*(.dtors))
        PROVIDE(__dtors_end__ = .);
    }

    __data_start = .;
    . = ALIGN(4);
    .data :
    {
        KEEP(*(.resource_table))
        *(.data)
        *(.data.*)
    }
    __data_end = .;

    . = ALIGN(4);
    __bss_start = __data_end;
    .bss       :
    {
    *(.bss)
    *(.bss.*)
    *(COMMON)
    . = ALIGN(4);
    }
    . = ALIGN(4);
    __bss_end = .;

    /* Stabs debugging sections.  */
    .stab 0 : { *(.stab) }
    .stabstr 0 : { *(.stabstr) }
    .stab.excl 0 : { *(.stab.excl) }
    .stab.exclstr 0 : { *(.stab.exclstr) }
    .stab.index 0 : { *(.stab.index) }
    .stab.indexstr 0 : { *(.stab.indexstr) }
    .comment 0 : { *(.comment) }

    _end = .;
}

/*
 * COPYRIGHT (C) 2013-2014, Shanghai Real-Thread Technology Co., Ltd
 *
 *  This file is part of RT-Thread (http://www.rt-thread.org)
 *
 *  All rights reserved.
 *
 *  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.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
SECTIONS
{
    . = 0x1ff00000;
    __text_start = .;
    .text :
    {
        *(.vectors)
        /* make the ISRs close to vectors may be more cache-friendly */
        *(.text.isr)

        *(.text)
        *(.text.*)

        /* section information for finsh shell */
        . = ALIGN(4);
        __fsymtab_start = .;
        KEEP(*(FSymTab))
        __fsymtab_end = .;
        . = ALIGN(4);
        __vsymtab_start = .;
        KEEP(*(VSymTab))
        __vsymtab_end = .;
        . = ALIGN(4);

        /* section information for modules */
        . = ALIGN(4);
        __rtmsymtab_start = .;
        KEEP(*(RTMSymTab))
        __rtmsymtab_end = .;

        /* section information for initialization */
        . = ALIGN(4);
        __rt_init_start = .;
        KEEP(*(SORT(.rti_fn*)))
        __rt_init_end = .;
    } =0
    __text_end = .;

    __rodata_start = .;
    .rodata   : { *(.rodata) *(.rodata.*) }
    __rodata_end = .;

    . = ALIGN(4);
    .ctors :
    {
        PROVIDE(__ctors_start__ = .);
        KEEP(*(SORT(.ctors.*)))
        KEEP(*(.ctors))
        PROVIDE(__ctors_end__ = .);
    }

    .dtors :
    {
        PROVIDE(__dtors_start__ = .);
        KEEP(*(SORT(.dtors.*)))
        KEEP(*(.dtors))
        PROVIDE(__dtors_end__ = .);
    }

    __data_start = .;
    . = ALIGN(4);
    .data :
    {
        KEEP(*(.resource_table))
        *(.data)
        *(.data.*)
    }
    __data_end = .;

    . = ALIGN(4);
    __bss_start = 0;
    .bss       :
    {
    *(.bss)
    *(.bss.*)
    *(COMMON)
    . = ALIGN(4);
    }
    . = ALIGN(4);
    __bss_end = .;

    /* Stabs debugging sections.  */
    .stab 0 : { *(.stab) }
    .stabstr 0 : { *(.stabstr) }
    .stab.excl 0 : { *(.stab.excl) }
    .stab.exclstr 0 : { *(.stab.exclstr) }
    .stab.index 0 : { *(.stab.index) }
    .stab.indexstr 0 : { *(.stab.indexstr) }
    .comment 0 : { *(.comment) }

    _end = .;
}


userland: add comment to linker file

userland: add comment to linker file

/* Userland Generic Layout
 *
 * This linker script is designed for Tock apps where the end microcontroller
 * is not known. Therefore, this script over provisions space on some platforms.
 */

/* Memory Spaces Definitions, 448K flash, 64K ram */
PROG_LENGTH = 0x00040000;
RAM_LENGTH  = 0x00010000;

ENTRY(_start)

/* Note: Because apps are relocated, the FLASH address here acts as a sentinel
 * value for relocation fixup routines. The application loader will select the
 * actual location in flash where the app is placed.
 */
MEMORY {
    FLASH (rx) : ORIGIN = 0x80000000, LENGTH = PROG_LENGTH
    SRAM (RWX) : ORIGIN = 0x00000000, LENGTH = RAM_LENGTH
}

SECTIONS {
    /* Section for just the app crt0 header.
     * This must be first so that the app can find it.
     */
    .crt0_header :
    {
        _beg = .; /* Start of the app in flash. */
        /**
         * Populate the header expected by `crt0`:
         *
         *  struct hdr {
         *    uint32_t got_sym_start;
         *    uint32_t got_start;
         *    uint32_t got_size;
         *    uint32_t data_sym_start;
         *    uint32_t data_start;
         *    uint32_t data_size;
         *    uint32_t bss_start;
         *    uint32_t bss_size;
         *    uint32_t reldata_start;
         *    uint32_t stack_size;
         *  };
         */
        /* Offset of GOT symbols in flash */
        LONG(LOADADDR(.got) - _beg);
        /* Offset of GOT section in memory */
        LONG(_got);
        /* Size of GOT section */
        LONG(SIZEOF(.got));
        /* Offset of data symbols in flash */
        LONG(LOADADDR(.data) - _beg);
        /* Offset of data section in memory */
        LONG(_data);
        /* Size of data section */
        LONG(SIZEOF(.data));
        /* Offset of BSS section in memory */
        LONG(_bss);
        /* Size of BSS section */
        LONG(SIZEOF(.bss));
        /* First address offset after program flash, where elf2tab places
         * .rel.data section */
        LONG(LOADADDR(.endflash) - _beg);
        /* The size of the stack requested by this application */
        LONG(STACK_SIZE);
    } > FLASH =0xFF

    /* App state section. Used for persistent app data.
     * We put this first so that if the app code changes but the persistent
     * data doesn't, the app_state can be preserved.
     */
    .wfr.app_state :
    {
        KEEP (*(.app_state))
        . = ALIGN(4); /* Make sure we're word-aligned here */
    } > FLASH =0xFF

    /* Text section, Code! */
    .text :
    {
        . = ALIGN(4);
        _text = .;
        KEEP (*(.start))
        *(.text*)
        *(.rodata*)
        KEEP (*(.syscalls))
        _etext = .;
        *(.ARM.extab*)
        . = ALIGN(4); /* Make sure we're word-aligned here */
    } > FLASH =0xFF

    /* Global Offset Table */
    .got :
    {
        . = ALIGN(4); /* Make sure we're word-aligned here */
        _got = .;
        *(.got*)
        *(.got.plt*)
        . = ALIGN(4);
    } > SRAM AT > FLASH

    /* Data section, static initialized variables
     *  Note: This is placed in Flash after the text section, but needs to be
     *  moved to SRAM at runtime
     */
    .data :
    {
        . = ALIGN(4); /* Make sure we're word-aligned here */
        _data = .;
        KEEP(*(.data*))
        . = ALIGN(4); /* Make sure we're word-aligned at the end of flash */
    } > SRAM AT > FLASH

    /* BSS section, static uninitialized variables */
    .bss :
    {
        . = ALIGN(4); /* Make sure we're word-aligned here */
        _bss = .;
        KEEP(*(.bss*))
        *(COMMON)
        . = ALIGN(4);
    } > SRAM

    /* End of flash. */
    .endflash :
    {
    } > FLASH

    /* ARM Exception support
     *
     * This contains compiler-generated support for unwinding the stack,
     * consisting of key-value pairs of function addresses and information on
     * how to unwind stack frames.
     * https://wiki.linaro.org/KenWerner/Sandbox/libunwind?action=AttachFile&do=get&target=libunwind-LDS.pdf
     *
     * .ARM.exidx is sorted, so has to go in its own output section.
     *
     * __NOTE__: It's at the end because we currently don't actually serialize
     * it to the binary in elf2tbf. If it was before the RAM sections, it would
     * through off our calculations of the header.
     */
    PROVIDE_HIDDEN (__exidx_start = .);
    .ARM.exidx :
    {
      /* (C++) Index entries for section unwinding */
      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > FLASH
    PROVIDE_HIDDEN (__exidx_end = .);
}

/* Userland Generic Layout
 *
 * This linker script is designed for Tock apps where the end microcontroller
 * is not known. Therefore, this script over provisions space on some platforms.
 */

/* Memory Spaces Definitions, 448K flash, 64K ram */
PROG_LENGTH = 0x00040000;
RAM_LENGTH  = 0x00010000;

ENTRY(_start)

/* Note: Because apps are relocated, the FLASH address here acts as a sentinel
 * value for relocation fixup routines. The application loader will select the
 * actual location in flash where the app is placed.
 */
MEMORY {
    FLASH (rx) : ORIGIN = 0x80000000, LENGTH = PROG_LENGTH
    SRAM (RWX) : ORIGIN = 0x00000000, LENGTH = RAM_LENGTH
}

SECTIONS {
    /* Section for just the app crt0 header.
     * This must be first so that the app can find it.
     */
    .crt0_header :
    {
        _beg = .; /* Start of the app in flash. */
        /**
         * Populate the header expected by `crt0`:
         *
         *  struct hdr {
         *    uint32_t got_sym_start;
         *    uint32_t got_start;
         *    uint32_t got_size;
         *    uint32_t data_sym_start;
         *    uint32_t data_start;
         *    uint32_t data_size;
         *    uint32_t bss_start;
         *    uint32_t bss_size;
         *    uint32_t reldata_start;
         *    uint32_t stack_size;
         *  };
         */
        /* Offset of GOT symbols in flash */
        LONG(LOADADDR(.got) - _beg);
        /* Offset of GOT section in memory */
        LONG(_got);
        /* Size of GOT section */
        LONG(SIZEOF(.got));
        /* Offset of data symbols in flash */
        LONG(LOADADDR(.data) - _beg);
        /* Offset of data section in memory */
        LONG(_data);
        /* Size of data section */
        LONG(SIZEOF(.data));
        /* Offset of BSS section in memory */
        LONG(_bss);
        /* Size of BSS section */
        LONG(SIZEOF(.bss));
        /* First address offset after program flash, where elf2tab places
         * .rel.data section */
        LONG(LOADADDR(.endflash) - _beg);
        /* The size of the stack requested by this application */
        LONG(STACK_SIZE);
    } > FLASH =0xFF

    /* App state section. Used for persistent app data.
     * We put this first so that if the app code changes but the persistent
     * data doesn't, the app_state can be preserved.
     */
    .wfr.app_state :
    {
        KEEP (*(.app_state))
        . = ALIGN(4); /* Make sure we're word-aligned here */
    } > FLASH =0xFF

    /* Text section, Code! */
    .text :
    {
        . = ALIGN(4);
        _text = .;
        KEEP (*(.start))
        *(.text*)
        *(.rodata*)
        KEEP (*(.syscalls))
        _etext = .;
        *(.ARM.extab*)
        . = ALIGN(4); /* Make sure we're word-aligned here */
    } > FLASH =0xFF

    /* Global Offset Table */
    .got :
    {
        . = ALIGN(4); /* Make sure we're word-aligned here */
        _got = .;
        *(.got*)
        *(.got.plt*)
        . = ALIGN(4);
    } > SRAM AT > FLASH

    /* Data section, static initialized variables
     *  Note: This is placed in Flash after the text section, but needs to be
     *  moved to SRAM at runtime
     */
    .data :
    {
        . = ALIGN(4); /* Make sure we're word-aligned here */
        _data = .;
        KEEP(*(.data*))
        . = ALIGN(4);
    } > SRAM AT > FLASH

    /* BSS section, static uninitialized variables */
    .bss :
    {
        . = ALIGN(4); /* Make sure we're word-aligned here */
        _bss = .;
        KEEP(*(.bss*))
        *(COMMON)
        . = ALIGN(4);
    } > SRAM

    /* End of flash. */
    .endflash :
    {
    } > FLASH

    /* ARM Exception support
     *
     * This contains compiler-generated support for unwinding the stack,
     * consisting of key-value pairs of function addresses and information on
     * how to unwind stack frames.
     * https://wiki.linaro.org/KenWerner/Sandbox/libunwind?action=AttachFile&do=get&target=libunwind-LDS.pdf
     *
     * .ARM.exidx is sorted, so has to go in its own output section.
     *
     * __NOTE__: It's at the end because we currently don't actually serialize
     * it to the binary in elf2tbf. If it was before the RAM sections, it would
     * through off our calculations of the header.
     */
    PROVIDE_HIDDEN (__exidx_start = .);
    .ARM.exidx :
    {
      /* (C++) Index entries for section unwinding */
      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > FLASH
    PROVIDE_HIDDEN (__exidx_end = .);
}