/*
 * Copyright (c) 2015-2021, Renesas Electronics Corporation
 * All rights reserved.
 */


OUTPUT_FORMAT("elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Startup)

MEMORY {
    RAM (rwxa): ORIGIN = 0xE6304000, LENGTH = 0x0002A800
}


SECTIONS
{
    ASSERT(. == ALIGN(4096),
        "CR7 Loader address is not aligned on a page boundary.")

    .loader_start : {
        __RO_START__ = .;
        loader/loader.o(.text*)
        . = NEXT(1024);
        *rcar_version.o(.version*)
        . = NEXT(16);
        *scif.o(".text*" ".rodata*")
        *cpsr_acc.o(".text*" ".rodata*")
        *report_exception.o(".text*" ".rodata*")
        *arm_gic.o(".text*" ".rodata*")
        *gic_v2.o(".text*" ".rodata*")
        *error_output.o(".text*" ".rodata*")
        *micro_wait.o(".text*" ".rodata*")
        *protection_setting.o(".text*" ".rodata*")
        *mem.o(".text*" ".rodata*")
        *rom_api.o(".text*" ".rodata*")
        *swdt.o(".text*" ".rodata*")
        *dma_driver.o(".text*" ".rodata*")
        *printf.o(".text*" ".rodata*")
        *rcar_pwrc.o(".text*" ".rodata*")
        *rpc_driver.o(".text*" ".rodata*")
        *auth.o(".text*" ".rodata*")
        *lifec_init.o(".text*" ".rodata*")
        *mfis_init.o(".text*" ".rodata*")
        *edc_init.o(".text*" ".rodata*")
        *axi_bus_timeout.o(".text*" ".rodata*")
    } >RAM

    .loader_ro : {
        *(.text*)
        *(.rodata*)
        __RO_END_UNALIGNED__ = .;
        /*
         * Memory page(s) mapped to this section will be marked as
         * read-only, executable.  No RW data from the next section must
         * creep in.  Ensure the rest of the current memory page is unused.
         */
        . = NEXT(4096);
        __RO_END__ = .;
        __DATA_COPY_START__ = .;
    } >RAM

    .data : {
        __DATA_START__ = .;
        *(.data*)
        __DATA_END__ = .;
    } >RAM

    __DATA_SIZE__ = SIZEOF(.data);

    stacks (NOLOAD) : ALIGN(16) {
        __STACKS_START__ = .;
        KEEP(*(cr7_loader_stack))
        __STACKS_END__ = .;
    } >RAM

    /*
     * The .bss section gets initialised to 0 at runtime.
     * Its base address must be 16-byte aligned.
     */
    .bss : ALIGN(16) {
        __BSS_START__ = .;
        *(SORT_BY_ALIGNMENT(.bss*))
        *(COMMON)
        __BSS_END__ = .;
    } >RAM

    __BSS_SIZE__ = SIZEOF(.bss);

    __CR7_END__ = .;
}
