MEMORY
{
  Peripherals (wx) : ORIGIN = 0xe0000000, LENGTH = 0x20000000
  SRAM (wx) : ORIGIN = 0x40000000, LENGTH = 0x00010000
  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00020000
}

SECTIONS
{
  __Peripherals_segment_start__ = 0xe0000000;
  __Peripherals_segment_end__ = 0x00000000;
  __SRAM_segment_start__ = 0x40000000;
  __SRAM_segment_end__ = 0x40010000;
  __FLASH_segment_start__ = 0x00000000;
  __FLASH_segment_end__ = 0x00020000;
  .vectors_ram __SRAM_segment_start__ (NOLOAD) :
  {
    __vectors_ram_start__ = .;
    *(.vectors_ram)
    . = MAX(__vectors_ram_start__ + 60, .);
  }
  __vectors_ram_end__ = __vectors_ram_start__ + SIZEOF(.vectors_ram);

  . = ASSERT(__vectors_ram_end__ >= __SRAM_segment_start__ && __vectors_ram_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".vectors_ram is too large to fit in SRAM memory segment");

  .vectors __FLASH_segment_start__ :
  {
    __vectors_start__ = .;
    *(.vectors .vectors.*)
  }
  __vectors_end__ = __vectors_start__ + SIZEOF(.vectors);

  . = ASSERT(__vectors_end__ >= __FLASH_segment_start__ && __vectors_end__ <= (__FLASH_segment_start__ + 0x00020000) , ".vectors is too large to fit in FLASH memory segment");

  .init (__vectors_end__ + 3) / 4 * 4 :
  {
    __init_start__ = .;
    *(.init .init.*)
  }
  __init_end__ = __init_start__ + SIZEOF(.init);

  . = ASSERT(__init_end__ >= __FLASH_segment_start__ && __init_end__ <= (__FLASH_segment_start__ + 0x00020000) , ".init is too large to fit in FLASH memory segment");

  .text_load (__init_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __text_load_start__ = .;
    *(.text_load)
  }
  __text_load_end__ = __text_load_start__ + SIZEOF(.text_load);

  . = ASSERT(__text_load_end__ >= __FLASH_segment_start__ && __text_load_end__ <= (__FLASH_segment_start__ + 0x00020000) , ".text_load is too large to fit in FLASH memory segment");

  .text (__text_load_end__ + 3) / 4 * 4 :
  {
    __text_start__ = .;
    *(.text .text.* .glue_7t .glue_7 .gnu.linkonce.t.*)
  }
  __text_end__ = __text_start__ + SIZEOF(.text);

  . = ASSERT(__text_end__ >= __FLASH_segment_start__ && __text_end__ <= (__FLASH_segment_start__ + 0x00020000) , ".text is too large to fit in FLASH memory segment");

  .dtors (__text_end__ + 3) / 4 * 4 :
  {
    __dtors_start__ = .;
    KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors))
  }
  __dtors_end__ = __dtors_start__ + SIZEOF(.dtors);

  . = ASSERT(__dtors_end__ >= __FLASH_segment_start__ && __dtors_end__ <= (__FLASH_segment_start__ + 0x00020000) , ".dtors is too large to fit in FLASH memory segment");

  .ctors (__dtors_end__ + 3) / 4 * 4 :
  {
    __ctors_start__ = .;
    KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors))
  }
  __ctors_end__ = __ctors_start__ + SIZEOF(.ctors);

  . = ASSERT(__ctors_end__ >= __FLASH_segment_start__ && __ctors_end__ <= (__FLASH_segment_start__ + 0x00020000) , ".ctors is too large to fit in FLASH memory segment");

  .rodata (__ctors_end__ + 3) / 4 * 4 :
  {
    __rodata_start__ = .;
    *(.rodata .rodata.* .gnu.linkonce.r.*)
  }
  __rodata_end__ = __rodata_start__ + SIZEOF(.rodata);

  . = ASSERT(__rodata_end__ >= __FLASH_segment_start__ && __rodata_end__ <= (__FLASH_segment_start__ + 0x00020000) , ".rodata is too large to fit in FLASH memory segment");

  __fast_load_start__ = (__rodata_end__ + 3) / 4 * 4;
  .fast __vectors_ram_end__ : AT((__rodata_end__ + 3) / 4 * 4)
  {
    __fast_start__ = .;
    *(.fast .fast.*)
  }
  __fast_end__ = __fast_start__ + SIZEOF(.fast);

  . = ASSERT((__fast_load_start__ + SIZEOF(.fast)) >= __FLASH_segment_start__ && (__fast_load_start__ + SIZEOF(.fast)) <= (__FLASH_segment_start__ + 0x00020000) , ".fast is too large to fit in FLASH memory segment");

  .fast_run (__vectors_ram_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __fast_run_start__ = .;
    . = MAX(__fast_run_start__ + SIZEOF(.fast), .);
  }
  __fast_run_end__ = __fast_run_start__ + SIZEOF(.fast_run);

  . = ASSERT(__fast_run_end__ >= __SRAM_segment_start__ && __fast_run_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".fast_run is too large to fit in SRAM memory segment");

  __data_load_start__ = (__fast_load_start__ + SIZEOF(.fast) + 3) / 4 * 4;
  .data __fast_run_end__ : AT((__fast_load_start__ + SIZEOF(.fast) + 3) / 4 * 4)
  {
    __data_start__ = .;
    *(.data .data.* .gnu.linkonce.d.*)
  }
  __data_end__ = __data_start__ + SIZEOF(.data);

  . = ASSERT((__data_load_start__ + SIZEOF(.data)) >= __FLASH_segment_start__ && (__data_load_start__ + SIZEOF(.data)) <= (__FLASH_segment_start__ + 0x00020000) , ".data is too large to fit in FLASH memory segment");

  .data_run (__fast_run_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __data_run_start__ = .;
    . = MAX(__data_run_start__ + SIZEOF(.data), .);
  }
  __data_run_end__ = __data_run_start__ + SIZEOF(.data_run);

  . = ASSERT(__data_run_end__ >= __SRAM_segment_start__ && __data_run_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".data_run is too large to fit in SRAM memory segment");

  .bss (__data_run_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __bss_start__ = .;
    *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON)
  }
  __bss_end__ = __bss_start__ + SIZEOF(.bss);

  . = ASSERT(__bss_end__ >= __SRAM_segment_start__ && __bss_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".bss is too large to fit in SRAM memory segment");

  .heap (__bss_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __heap_start__ = .;
    *(.heap)
    . = MAX(__heap_start__ + 1024, .);
  }
  __heap_end__ = __heap_start__ + SIZEOF(.heap);

  . = ASSERT(__heap_end__ >= __SRAM_segment_start__ && __heap_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".heap is too large to fit in SRAM memory segment");

  .stack (__heap_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __stack_start__ = .;
    *(.stack)
    . = MAX(__stack_start__ + 1024, .);
  }
  __stack_end__ = __stack_start__ + SIZEOF(.stack);

  . = ASSERT(__stack_end__ >= __SRAM_segment_start__ && __stack_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".stack is too large to fit in SRAM memory segment");

  .stack_irq (__stack_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __stack_irq_start__ = .;
    *(.stack_irq)
    . = MAX(__stack_irq_start__ + 256, .);
  }
  __stack_irq_end__ = __stack_irq_start__ + SIZEOF(.stack_irq);

  . = ASSERT(__stack_irq_end__ >= __SRAM_segment_start__ && __stack_irq_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".stack_irq is too large to fit in SRAM memory segment");

  .stack_fiq (__stack_irq_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __stack_fiq_start__ = .;
    *(.stack_fiq)
    . = MAX(__stack_fiq_start__ + 256, .);
  }
  __stack_fiq_end__ = __stack_fiq_start__ + SIZEOF(.stack_fiq);

  . = ASSERT(__stack_fiq_end__ >= __SRAM_segment_start__ && __stack_fiq_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".stack_fiq is too large to fit in SRAM memory segment");

  .stack_svc (__stack_fiq_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __stack_svc_start__ = .;
    *(.stack_svc)
    . = MAX(__stack_svc_start__ + 0, .);
  }
  __stack_svc_end__ = __stack_svc_start__ + SIZEOF(.stack_svc);

  . = ASSERT(__stack_svc_end__ >= __SRAM_segment_start__ && __stack_svc_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".stack_svc is too large to fit in SRAM memory segment");

  .stack_abt (__stack_svc_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __stack_abt_start__ = .;
    *(.stack_abt)
    . = MAX(__stack_abt_start__ + 0, .);
  }
  __stack_abt_end__ = __stack_abt_start__ + SIZEOF(.stack_abt);

  . = ASSERT(__stack_abt_end__ >= __SRAM_segment_start__ && __stack_abt_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".stack_abt is too large to fit in SRAM memory segment");

  .stack_und (__stack_abt_end__ + 3) / 4 * 4 (NOLOAD) :
  {
    __stack_und_start__ = .;
    *(.stack_und)
    . = MAX(__stack_und_start__ + 0, .);
  }
  __stack_und_end__ = __stack_und_start__ + SIZEOF(.stack_und);

  . = ASSERT(__stack_und_end__ >= __SRAM_segment_start__ && __stack_und_end__ <= (__SRAM_segment_start__ + 0x00010000) , ".stack_und is too large to fit in SRAM memory segment");

}

