1/* 2 * linker script for GD32F10x with GNU ld 3 * BruceOu 2021-12-18 4 */ 5 6/* Program Entry, set to mark it as "used" and avoid gc */ 7MEMORY 8{ 9 CODE (rx) : ORIGIN = 0x08000000, LENGTH = 256k /* 256KB flash */ 10 DATA (rw) : ORIGIN = 0x20000000, LENGTH = 48k /* 48KB sram */ 11} 12ENTRY(Reset_Handler) 13_system_stack_size = 0x200; 14 15SECTIONS 16{ 17 .text : 18 { 19 . = ALIGN(4); 20 _stext = .; 21 KEEP(*(.isr_vector)) /* Startup code */ 22 . = ALIGN(4); 23 *(.text) /* remaining code */ 24 *(.text.*) /* remaining code */ 25 *(.rodata) /* read-only data (constants) */ 26 *(.rodata*) 27 *(.glue_7) 28 *(.glue_7t) 29 *(.gnu.linkonce.t*) 30 31 /* section information for finsh shell */ 32 . = ALIGN(4); 33 __fsymtab_start = .; 34 KEEP(*(FSymTab)) 35 __fsymtab_end = .; 36 . = ALIGN(4); 37 __vsymtab_start = .; 38 KEEP(*(VSymTab)) 39 __vsymtab_end = .; 40 . = ALIGN(4); 41 42 /* section information for initial. */ 43 . = ALIGN(4); 44 __rt_init_start = .; 45 KEEP(*(SORT(.rti_fn*))) 46 __rt_init_end = .; 47 . = ALIGN(4); 48 49 . = ALIGN(4); 50 _etext = .; 51 } > CODE = 0 52 53 /* .ARM.exidx is sorted, so has to go in its own output section. */ 54 __exidx_start = .; 55 .ARM.exidx : 56 { 57 *(.ARM.exidx* .gnu.linkonce.armexidx.*) 58 59 /* This is used by the startup in order to initialize the .data secion */ 60 _sidata = .; 61 } > CODE 62 __exidx_end = .; 63 64 /* .data section which is used for initialized data */ 65 66 .data : AT (_sidata) 67 { 68 . = ALIGN(4); 69 /* This is used by the startup in order to initialize the .data secion */ 70 _sdata = . ; 71 72 *(.data) 73 *(.data.*) 74 *(.gnu.linkonce.d*) 75 76 . = ALIGN(4); 77 /* This is used by the startup in order to initialize the .data secion */ 78 _edata = . ; 79 } >DATA 80 81 .stack : 82 { 83 . = . + _system_stack_size; 84 . = ALIGN(4); 85 _estack = .; 86 } >DATA 87 88 __bss_start = .; 89 .bss : 90 { 91 . = ALIGN(4); 92 /* This is used by the startup in order to initialize the .bss secion */ 93 _sbss = .; 94 95 *(.bss) 96 *(.bss.*) 97 *(COMMON) 98 99 . = ALIGN(4); 100 /* This is used by the startup in order to initialize the .bss secion */ 101 _ebss = . ; 102 103 *(.bss.init) 104 } > DATA 105 __bss_end = .; 106 107 _end = .; 108 109 /* Stabs debugging sections. */ 110 .stab 0 : { *(.stab) } 111 .stabstr 0 : { *(.stabstr) } 112 .stab.excl 0 : { *(.stab.excl) } 113 .stab.exclstr 0 : { *(.stab.exclstr) } 114 .stab.index 0 : { *(.stab.index) } 115 .stab.indexstr 0 : { *(.stab.indexstr) } 116 .comment 0 : { *(.comment) } 117 /* DWARF debug sections. 118 * Symbols in the DWARF debugging sections are relative to the beginning 119 * of the section so we begin them at 0. */ 120 /* DWARF 1 */ 121 .debug 0 : { *(.debug) } 122 .line 0 : { *(.line) } 123 /* GNU DWARF 1 extensions */ 124 .debug_srcinfo 0 : { *(.debug_srcinfo) } 125 .debug_sfnames 0 : { *(.debug_sfnames) } 126 /* DWARF 1.1 and DWARF 2 */ 127 .debug_aranges 0 : { *(.debug_aranges) } 128 .debug_pubnames 0 : { *(.debug_pubnames) } 129 /* DWARF 2 */ 130 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 131 .debug_abbrev 0 : { *(.debug_abbrev) } 132 .debug_line 0 : { *(.debug_line) } 133 .debug_frame 0 : { *(.debug_frame) } 134 .debug_str 0 : { *(.debug_str) } 135 .debug_loc 0 : { *(.debug_loc) } 136 .debug_macinfo 0 : { *(.debug_macinfo) } 137 /* SGI/MIPS DWARF 2 extensions */ 138 .debug_weaknames 0 : { *(.debug_weaknames) } 139 .debug_funcnames 0 : { *(.debug_funcnames) } 140 .debug_typenames 0 : { *(.debug_typenames) } 141 .debug_varnames 0 : { *(.debug_varnames) } 142} 143