Keil中使用arm section进行绝对地址定位并进行O2等级代码优化时报错: Error: L6982E
?
2、當(dāng)選擇O2優(yōu)化時(shí),編譯會報(bào)錯(cuò)
?3、在motor_id.c文件中,使用arm section來將數(shù)據(jù)指定到特定位置
#pragma arm section rwdata = ".ARM.__at_0x1100CE00"
?
Parameter1???????????? _Parameter1 =
{
? ……
};
?
Parameter2???????????? _Parameter2=
{
? ……
};
Parameter3???????????? _Parameter3 =
{
? ……
};
?
Parameter4??????????? _Parameter4=
{
? ……
};
#pragma arm section
程序原意是將_Parameter1、_Parameter2、_Parameter3、_Parameter4四個(gè)結(jié)構(gòu)體中的數(shù)據(jù)都指定到0x1100CE00起始的位置,在O0優(yōu)化等級下程序這樣寫沒有問題,但在O2優(yōu)化等級下程序會報(bào)錯(cuò)。
錯(cuò)誤詳細(xì)信息如下:
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce04 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce13.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce04 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce0c.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce04 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce30.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce04 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce04 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce13 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce0c.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce13 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce30.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce13 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce13 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce0c overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce30.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce0c overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce0c overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce30 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce30 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
.\Objects\Test 9843_2QX.axf: Error: L6982E: AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28 overlaps address range with AT section motor_id.o(.ARM.__at_0x1100CE00) with base 0x1100ce00 limit 0x1100ce28.
?
分析編譯時(shí)的輸出log,可以大概看出是幾個(gè)結(jié)構(gòu)體的位置分配發(fā)生錯(cuò)亂,如果想在O0優(yōu)化等級下使用arm section將幾個(gè)結(jié)構(gòu)體指定到特定存儲地址,需要將程序進(jìn)行修改。
4、修改步驟3中的程序
#pragma arm section rwdata = ".ARM.__at_0x1100CE00"
?
Parameter1???????????? _Parameter1 =
{
? ……
};
?
#pragma arm section
?
#pragma arm section rwdata = ".ARM.__at_0x1100CE04" ?//04是_Parameter1結(jié)構(gòu)體的大小
?
?
Parameter2???????????? _Parameter2=
{
? ……
};
?
?
#pragma arm section
?
#pragma arm section rwdata = ".ARM.__at_0x1100CE08" ?//08是_Parameter1 + _Parameter2結(jié)構(gòu)體的大小
?
?
Parameter3???????????? _Parameter3 =
{
? ……
};
?
#pragma arm section
?
#pragma arm section rwdata = ".ARM.__at_0x1100CE0C" ?//0C是_Parameter1 + _Parameter2+ _Parameter3結(jié)構(gòu)體的大小
?
?
Parameter4??????????? _Parameter4=
{
? ……
};
#pragma arm section
?
此時(shí)再進(jìn)行編譯就會正常,而且程序大小也會變小。
?
5、Keil中幾個(gè)代碼優(yōu)化等級的說明
Keil中代碼優(yōu)化等級主要有四個(gè)O0、O1、O2、O3,默認(rèn)的優(yōu)化等級為O2
O0:使用最低優(yōu)化,多數(shù)優(yōu)化都被關(guān)閉,生成的代碼具有最多的調(diào)試信息。
O1:使用有限優(yōu)化,未使用的內(nèi)聯(lián)函數(shù)、未使用的靜態(tài)函數(shù)以及冗余代碼
????????? 都會被移除,指令會被重新排序以避免互鎖的情況。生成的代碼會被
????????? 適度優(yōu)化,并且比較適合調(diào)試。
O2:使用高度優(yōu)化,根據(jù)處理器的特定行為優(yōu)化程序代碼,生成的代碼為
???????? 高度優(yōu)化的,并且具有有限的調(diào)試信息。
O3:使用極端優(yōu)化,根據(jù)時(shí)間/空間選項(xiàng)進(jìn)行優(yōu)化,默認(rèn)為多文件編譯,它
????????? 可以提供最高等級的優(yōu)化,但編譯時(shí)間會稍微長些,軟件調(diào)試信息也
????????? 比較少。
一般情況下采用default即O2等級的代碼優(yōu)化即可,如果采用O1、O2,則代碼空間會變大,但會多很多調(diào)試信息,而使用O3的話有時(shí)候會對代碼業(yè)務(wù)邏輯產(chǎn)生影響,所以一般采用O2等級進(jìn)行優(yōu)化代碼。
總結(jié)
以上是生活随笔為你收集整理的Keil中使用arm section进行绝对地址定位并进行O2等级代码优化时报错: Error: L6982E的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab的clear函数,[转载]m
- 下一篇: 幻方修复