解决warning LNK1166: cannot adjust code之掩耳盗铃版
在EVC編譯CEBetaPlayer 0.0.25版時,在wmv_decode files模塊的LINKING階段出了這樣一個WARNING:
Linking...
xilinke44 starting link
Creating library ARMV4IRel/wmv_decode.lib and object ARMV4IRel/wmv_decode.exp
Affine.obj :?warning LNK1166: cannot adjust code at offset=0x00001000, rva=0x00001E74
decolorconv_wmv.obj :?warning LNK1166: cannot adjust code at offset=0x00001000, rva=0x00029E38
看得我心驚肉跳,cannot adjust code? 某個地址上的編譯結果不可識別?這EVC怎么混的,編譯出自己不能識別的結果?
關鍵字在WARNING LNK166上。在EVC4的HELP里面搜索LNK1166,有且僅有的說明為:
LINK was unable to pad the code as required.
Certain instructions are not allowed to cross page boundaries on some processors. LINK attempts to add pads to correct this situation. In this case, LINK could not work around the problem.
不知所云,而且最重要的是,沒給出解決方案。誰寫的文檔,揍他個半身不遂。
當然像我這樣的SUPER GOOGLER是沒什么找不到的東東啦。答案在這里
Microsoft eMbedded Visual C++ 4.0 SP4? Readme (Online Version)
http://download.microsoft.com/download/a/7/3/a735c7fb-dcbd-429f-9090-d09b3b15d3fa/ReleaseNotes.htm
其中提到
5.2. Linker warning LNK1166: cannot adjust code at offset?
Texas Instruments has identified a defect in the ES1, ES2 and ES3 silicon steppings of the OMAP710. It’s also believed (but not yet confirmed) that the same issue will impact all ARM925-based offerings from TI, including the OMAP1510 and OMAP310. This defect can lead to incorrect instruction execution, resulting in an operating system crash. The problem results when a data abort occurs for an instruction at address 0xXXXX:XFF4 of any instruction page and the following page of instructions is not present in the instruction TLB. A data abort, instruction fetch and instruction TLB miss must occur simultaneously for the error to occur. The linker included with eVC compensates for this potential problem by padding the resulting executable to move the hazardous instruction from the specific address. However, in some cases the linker can not handle this automatically and will issue “warning LNK1166: cannot adjust code at offset. To fix those cases, do the following:
Recompile adding the /Gy option to separate functions for the linker and then relink. If any warnings still exists, then?
Rewrite the source code for the large function that generates code larger than a page into several that generate less than one page each.?
The automatic padding can be turned off via the /ARMPADCODE:NO linker switch. However the perf/size impact of the padding is minimal, and we do not recommend turning this off unless you are absolutely sure your application will never run on a chipset with this problem. For most developers, this should be left enabled.
也就是說在TI的ARM925系列CPU上存在一個缺陷,但是他們自己不去FIX掉,卻牛B哄哄地讓微軟給他們擦屁股:在EVC里增加了LINK時的一項PAD CODE功能來防止EVC編譯出來的程序在他們CPU里跑著跑著導致死機。微軟雖然給了TI一點面子,也不是很賣帳,就沒把這個功能做完美,在某些情況就PADDING不起來了,報出了這個WARNING。雖然如此, 文中建議大家還是保留這個功能以防止自己的程序哪天把TI的CPU跑死。
文中給出了兩種解決方法:
(1)科學的解決方法:在project settings -> C/C++ TAB -> Category: Customize 里面把 Enable function-level linking 這個復選項勾起來? //結果我發現我的wmv_decode settings這個項上是灰的,不可勾選,哭啊哭啊眼淚嘩嘩。讓我心理平衡的是文中說即使這么操作也有可能WANRING仍然存在.
(2)眼不見為凈法:在project settings -> Link TAB -> Project Options 里面加入"/ARMPADCODE:NO"? 很堅定地拒絕給TI擦屁股。幸運的是我只盯著INTEL XSCALE,O~O~O~ONLY YOU~~~? 所以可以這么做
本文轉自Walzer博客園博客,原文鏈接:http://www.cnblogs.com/walzer/archive/2006/02/09/327834.html,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的解决warning LNK1166: cannot adjust code之掩耳盗铃版的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 设置Adobe Air应用程序属性
- 下一篇: Android--解析XML之SAX