|
| 1 | +SEARCH_DIR(.); |
| 2 | + |
| 3 | +/* |
| 4 | +Format configurations |
| 5 | +*/ |
| 6 | +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm"); |
| 7 | +OUTPUT_ARCH(arm); |
| 8 | + |
| 9 | + |
| 10 | +/* |
| 11 | +The stack size used by the application. NOTE: you need to adjust according to your application. |
| 12 | +*/ |
| 13 | +STACK_SIZE = 0x100; |
| 14 | + |
| 15 | +/* |
| 16 | +Memories definitions |
| 17 | +*/ |
| 18 | +MEMORY |
| 19 | +{ |
| 20 | + ram (rwx) : org = 0x20000000, len = 32k |
| 21 | +} |
| 22 | + |
| 23 | +/* |
| 24 | +Entry point |
| 25 | +*/ |
| 26 | +ENTRY( __reset_handler ); |
| 27 | + |
| 28 | +/* |
| 29 | +Sections |
| 30 | +*/ |
| 31 | +SECTIONS |
| 32 | +{ |
| 33 | + /* Flash os information */ |
| 34 | + PrgCode : |
| 35 | + { |
| 36 | + . = ALIGN(4); |
| 37 | + KEEP(*(PrgCode PrgCode.*)); |
| 38 | + . = ALIGN(4); |
| 39 | + } > ram |
| 40 | + |
| 41 | + /* Vector table. Has the initial stack pointer and the initial |
| 42 | + structure for the arm interrupts */ |
| 43 | + .vectors : |
| 44 | + { |
| 45 | + . = ALIGN(128); |
| 46 | + /* vector table */ |
| 47 | + KEEP(*(.vectors .vectors.*)); |
| 48 | + . = ALIGN(4); |
| 49 | + } > ram |
| 50 | + |
| 51 | + /* Text segment, stores all user code */ |
| 52 | + .text : |
| 53 | + { |
| 54 | + . = ALIGN(4); |
| 55 | + /* text segment */ |
| 56 | + *(.text .text.* .gnu.linkonce.t.*); |
| 57 | + /* glue arm to thumb code, glue thumb to arm code*/ |
| 58 | + *(.glue_7t .glue_7); |
| 59 | + /* c++ exceptions */ |
| 60 | + *(.eh_frame .eh_frame_hdr) |
| 61 | + /* exception unwinding information */ |
| 62 | + |
| 63 | + . = ALIGN(4); |
| 64 | + *(.ARM.extab* .gnu.linkonce.armextab.*); |
| 65 | + *(.ARM.exidx*) |
| 66 | + |
| 67 | + . = ALIGN(4); |
| 68 | + KEEP(*(.init)); |
| 69 | + . = ALIGN(4); |
| 70 | + KEEP(*(.fini)); |
| 71 | + |
| 72 | + . = ALIGN(4); |
| 73 | + } > ram |
| 74 | + |
| 75 | + /* Read only data */ |
| 76 | + .rodata : |
| 77 | + { |
| 78 | + . = ALIGN(4); |
| 79 | + |
| 80 | + /* Constands, strings, etc */ |
| 81 | + *(.rodata .rodata.* .gnu.linkonce.r.*); |
| 82 | + |
| 83 | + . = ALIGN(4); |
| 84 | + } > ram |
| 85 | + |
| 86 | + /* Support C constructors, and C destructors in both user code |
| 87 | + and the C library. This also provides support for C++ code. */ |
| 88 | + .preinit_array : |
| 89 | + { |
| 90 | + . = ALIGN(4); |
| 91 | + PROVIDE(__preinit_array_start = .); |
| 92 | + |
| 93 | + KEEP(*(.preinit_array)) |
| 94 | + |
| 95 | + PROVIDE(__preinit_array_end = .); |
| 96 | + } > ram |
| 97 | + |
| 98 | + .init_array : |
| 99 | + { |
| 100 | + . = ALIGN(4); |
| 101 | + PROVIDE(__init_array_start = .); |
| 102 | + |
| 103 | + KEEP(*(SORT(.init_array.*))) |
| 104 | + KEEP(*(.init_array)) |
| 105 | + |
| 106 | + PROVIDE(__init_array_end = .); |
| 107 | + } > ram |
| 108 | + |
| 109 | + .fini_array : |
| 110 | + { |
| 111 | + . = ALIGN(4); |
| 112 | + PROVIDE(__fini_array_start = .); |
| 113 | + |
| 114 | + KEEP(*(SORT(.fini_array.*))) |
| 115 | + KEEP(*(.fini_array)) |
| 116 | + |
| 117 | + PROVIDE(__fini_array_end = .); |
| 118 | + } > ram |
| 119 | + |
| 120 | + PrgData : |
| 121 | + { |
| 122 | + . = ALIGN(4); |
| 123 | + KEEP(*(PrgData PrgData.*)) |
| 124 | + . = ALIGN(4); |
| 125 | + } > ram |
| 126 | + |
| 127 | + /* Data that needs to be initialized to a value different than 0 */ |
| 128 | + .data : |
| 129 | + { |
| 130 | + . = ALIGN(4); |
| 131 | + PROVIDE(__data_init_start = LOADADDR(.data)); |
| 132 | + PROVIDE(__data_start = .); |
| 133 | + |
| 134 | + . = ALIGN(4); |
| 135 | + *(.data .data.* .gnu.linkonce.d.*) |
| 136 | + . = ALIGN(4); |
| 137 | + |
| 138 | + PROVIDE(__data_end = .); |
| 139 | + PROVIDE(__data_init_end = LOADADDR(.data)); |
| 140 | + } > ram |
| 141 | + |
| 142 | + /* Data that needs to be initialized to 0 */ |
| 143 | + .bss (NOLOAD) : |
| 144 | + { |
| 145 | + . = ALIGN(4); |
| 146 | + PROVIDE(__bss_start = .); |
| 147 | + |
| 148 | + *(.bss .bss.* .gnu.linkonce.b.*) |
| 149 | + *(COMMON); |
| 150 | + . = ALIGN(4); |
| 151 | + |
| 152 | + PROVIDE(__bss_end = .); |
| 153 | + } > ram |
| 154 | + |
| 155 | + /* Stack segment */ |
| 156 | + .stack (NOLOAD) : |
| 157 | + { |
| 158 | + . = ALIGN(8); |
| 159 | + PROVIDE(__stack_start = .); |
| 160 | + |
| 161 | + . = . + STACK_SIZE; |
| 162 | + PROVIDE(__stack_end = .); |
| 163 | + } > ram |
| 164 | + |
| 165 | + /* Heap segment */ |
| 166 | + .heap (NOLOAD) : |
| 167 | + { |
| 168 | + . = ALIGN(4); |
| 169 | + PROVIDE(__heap_start = .); |
| 170 | + PROVIDE(__heap_end = (ORIGIN(ram) + LENGTH(ram))); |
| 171 | + } > ram |
| 172 | + |
| 173 | + /* Flash device information */ |
| 174 | + DevDscr : |
| 175 | + { |
| 176 | + . = ALIGN(4); |
| 177 | + KEEP(*(DevDscr DevDscr.*)); |
| 178 | + . = ALIGN(4); |
| 179 | + } > ram |
| 180 | + |
| 181 | + /* Remove information from the standard libraries */ |
| 182 | + /DISCARD/ : |
| 183 | + { |
| 184 | + libc.a ( * ) |
| 185 | + libm.a ( * ) |
| 186 | + libgcc.a ( * ) |
| 187 | + *(.note.GNU-stack) |
| 188 | + } |
| 189 | + |
| 190 | + .ARM.attributes 0 : { KEEP(*(.ARM.attributes)) } |
| 191 | +} |
0 commit comments