<div id="msgcns!53844A66ACD5698B!1120" class="bvMsg"><div>'.' which is location counter </div> <div>ex: </div> <div>. = 0x100000 (location 0x100000)</div> <div> </div> <div> </div> <div> </div></div>
如果沒有設default 是 0x00
定義一個output section ex: output section : {input section } .text : {*(.text)}
*(.text) : 表示(*)所有檔案中, 有.text的區段 所以.text : {*(.text)}的意思是 設定一個output section .text , 他是包含所有檔案的 .text區段
設定一個全域變數的值 _etext = .;
PROVIDE(etext = .); 表示linker 會優先使用程式中的定義, 若程式中沒有定義就用script中的定義
當然你可以用萬用字元來說明你要所有的檔案的.data都進去這一個output setion 你也可以指定, 哪一個檔案的data段要進去這一個output section ex: data.o(.data)
當然你更可以指定一個檔案, 進入output section ex : data.o
text 後面接address ex: .text . : { *(.text) } : 表示text的VM address 是location counter
. = ALIGN (0x8) 表示對齊0x8 bytes boundry
例如: location address 0x62d81 .=ALING(8) 的意思就是0x62d81 + 0x7 = 0x62d88 讓location adress 對齊 8 bytes boundry
這裡ALING指的是VM
LMA的default 值等同於VMA 若不想一樣, 可用AT ex: .mdata 0x2000 : AT ( ADDR (.text) + SIZEOF (.text) ) 表示雖然VMA是在0x2000, 但是LMA卻是放在.text之後 還有一點要注意的location counter指的是VMA不是LMA
MEMORY { rom : ORIGIN = 0x1000, LENGTH = 0x1000 } SECTIONS { ROM : { *(.text) } >rom } 這個表示ROM這個section 放到rom這個memory
MEMORY { rom (rx) : ORIGIN = 0, LENGTH = 256K ram (!rx) : org = 0x40000000, l = 4M } 表示memory 有rom, ram, rom 可讀可執行, ram 可寫可執行