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