【ARM】為堆和棧保留空的記憶體塊
阿新 • • 發佈:2022-01-15
此示例演示如何使用分散載入描述為堆疊和堆保留和清空記憶體塊。它還顯示連結器生成的相關符號。
在以下示例中,執行區域定義STACK 0x800000 EMPTY -0x10000
定義了一個名為STACK 的區域
。該區域從地址0x7F0000
開始,到地址0x800000
結束:
LR_1 0x80000 ; load region starts at 0x80000
{
STACK 0x800000 EMPTY -0x10000 ; region ends at 0x800000 because of the
; negative length. The start of the region
; is calculated using the length.
{
; Empty region for placing the stack
}
HEAP +0 EMPTY 0x10000 ; region starts at the end of previous
; region. End of region calculated using
; positive length
{
; Empty region for placing the heap
}
... ; rest of scatter-loading description
}
注意
為EMPTY
執行區域建立的虛擬 ZI 區域在執行時不會初始化為零。
如果地址是相對 (+偏移量
) 形式,並且長度為負,則連結器將生成錯誤。
下圖顯示了此示例的圖示表示形式。
圖 1.為堆疊預留區域在此示例中,連結器生成以下符號:
Image$$STACK$$ZI$$Base = 0x7f0000 Image$$STACK$$ZI$$Limit = 0x800000 Image$$STACK$$ZI$$Length = 0x10000 Image$$HEAP$$ZI$$Base = 0x800000 Image$$HEAP$$ZI$$Limit = 0x810000 Image$$HEAP$$ZI$$Length = 0x10000
注意
EMPTY
屬性僅適用於執行區域。連結器將生成警告並忽略載入區域定義中使用的EMPTY
屬性。連結器檢查用於
EMPTY
區域的地址空間是否不與任何其他執行區域重疊。
【來源】
再牛逼的夢想也架不住傻逼似的堅持