Some notes about how to write linker script.
Linker Script
Linker script is used to instruct the linker to generate the final objective file.
here is an example:
see this for whole example.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| SECTIONS { . = 0x50;
.data : { *.o(.data) BYTE(0xcc) }
v1 = .; .sec2 : AT(0x70) { LONG(.) BYTE(0xcf) LONG(.) LONG(ABSOLUTE(.)) LONG(v1) BYTE(0xcf) *.o(.sec2) BYTE(0xcc) }
v2 = .; .text : AT(0x90) { BYTE(0xcc) sample.o(.text) BYTE(0xcc) }
.text : AT(0x110) { sample2.o(.text) BYTE(0xcc) } .rodata : { . = ALIGN(16); BYTE(0xcf) . = . + 50; BYTE(0xcf) } }
|
Note
VMA : virtual memory address
LMA : load memroy address
. = xxx sets VMA
AT(xxx) sets LMA
Done.