Brian Silverman | 2bf644d | 2013-12-06 16:54:59 -0800 | [diff] [blame^] | 1 | /* Linker script to configure memory regions. */ |
| 2 | MEMORY |
| 3 | { |
| 4 | FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 /* 256k */ |
| 5 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x08000 /* 32k */ |
| 6 | } |
| 7 | |
| 8 | /* Library configurations */ |
| 9 | GROUP(libgcc.a libc.a libm.a libnosys.a) |
| 10 | |
| 11 | /* Linker script to place sections and symbol values. Should be used together |
| 12 | * with other linker script that defines memory regions FLASH and RAM. |
| 13 | * It references following symbols, which must be defined in code: |
| 14 | * Reset_Handler : Entry of reset handler |
| 15 | * |
| 16 | * It defines following symbols, which code can use without definition: |
| 17 | * __exidx_start |
| 18 | * __exidx_end |
| 19 | * __etext |
| 20 | * __data_start__ |
| 21 | * __preinit_array_start |
| 22 | * __preinit_array_end |
| 23 | * __init_array_start |
| 24 | * __init_array_end |
| 25 | * __fini_array_start |
| 26 | * __fini_array_end |
| 27 | * __data_end__ |
| 28 | * __bss_start__ |
| 29 | * __bss_end__ |
| 30 | * __end__ |
| 31 | * end |
| 32 | * __HeapLimit |
| 33 | * __StackLimit |
| 34 | * __StackTop |
| 35 | * __stack |
| 36 | */ |
| 37 | ENTRY(Reset_Handler) |
| 38 | |
| 39 | SECTIONS |
| 40 | { |
| 41 | .text : |
| 42 | { |
| 43 | KEEP(*(.isr_vector)) |
| 44 | *(.text*) |
| 45 | |
| 46 | KEEP(*(.init)) |
| 47 | KEEP(*(.fini)) |
| 48 | |
| 49 | /* .ctors */ |
| 50 | *crtbegin.o(.ctors) |
| 51 | *crtbegin?.o(.ctors) |
| 52 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) |
| 53 | *(SORT(.ctors.*)) |
| 54 | *(.ctors) |
| 55 | |
| 56 | /* .dtors */ |
| 57 | *crtbegin.o(.dtors) |
| 58 | *crtbegin?.o(.dtors) |
| 59 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) |
| 60 | *(SORT(.dtors.*)) |
| 61 | *(.dtors) |
| 62 | |
| 63 | *(.rodata*) |
| 64 | |
| 65 | KEEP(*(.eh_frame*)) |
| 66 | } > FLASH |
| 67 | |
| 68 | .ARM.extab : |
| 69 | { |
| 70 | *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 71 | } > FLASH |
| 72 | |
| 73 | __exidx_start = .; |
| 74 | .ARM.exidx : |
| 75 | { |
| 76 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
| 77 | } > FLASH |
| 78 | __exidx_end = .; |
| 79 | |
| 80 | __etext = .; |
| 81 | |
| 82 | .data : AT (__etext) |
| 83 | { |
| 84 | __data_start__ = .; |
| 85 | *(vtable) |
| 86 | *(.data*) |
| 87 | |
| 88 | . = ALIGN(4); |
| 89 | /* preinit data */ |
| 90 | PROVIDE_HIDDEN (__preinit_array_start = .); |
| 91 | KEEP(*(.preinit_array)) |
| 92 | PROVIDE_HIDDEN (__preinit_array_end = .); |
| 93 | |
| 94 | . = ALIGN(4); |
| 95 | /* init data */ |
| 96 | PROVIDE_HIDDEN (__init_array_start = .); |
| 97 | KEEP(*(SORT(.init_array.*))) |
| 98 | KEEP(*(.init_array)) |
| 99 | PROVIDE_HIDDEN (__init_array_end = .); |
| 100 | |
| 101 | |
| 102 | . = ALIGN(4); |
| 103 | /* finit data */ |
| 104 | PROVIDE_HIDDEN (__fini_array_start = .); |
| 105 | KEEP(*(SORT(.fini_array.*))) |
| 106 | KEEP(*(.fini_array)) |
| 107 | PROVIDE_HIDDEN (__fini_array_end = .); |
| 108 | |
| 109 | KEEP(*(.jcr*)) |
| 110 | . = ALIGN(4); |
| 111 | /* All data end */ |
| 112 | __data_end__ = .; |
| 113 | |
| 114 | } > RAM |
| 115 | |
| 116 | .bss : |
| 117 | { |
| 118 | . = ALIGN(4); |
| 119 | __bss_start__ = .; |
| 120 | *(.bss*) |
| 121 | *(COMMON) |
| 122 | . = ALIGN(4); |
| 123 | __bss_end__ = .; |
| 124 | } > RAM |
| 125 | |
| 126 | .heap (COPY): |
| 127 | { |
| 128 | __end__ = .; |
| 129 | end = __end__; |
| 130 | *(.heap*) |
| 131 | __HeapLimit = .; |
| 132 | } > RAM |
| 133 | |
| 134 | /* .stack_dummy section doesn't contains any symbols. It is only |
| 135 | * used for linker to calculate size of stack sections, and assign |
| 136 | * values to stack symbols later */ |
| 137 | .stack_dummy (COPY): |
| 138 | { |
| 139 | *(.stack*) |
| 140 | } > RAM |
| 141 | |
| 142 | /* Set stack top to end of RAM, and stack limit move down by |
| 143 | * size of stack_dummy section */ |
| 144 | __StackTop = ORIGIN(RAM) + LENGTH(RAM); |
| 145 | __StackLimit = __StackTop - SIZEOF(.stack_dummy); |
| 146 | PROVIDE(__stack = __StackTop); |
| 147 | |
| 148 | /* Check if data + heap + stack exceeds RAM limit */ |
| 149 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") |
| 150 | } |