日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

解决warning LNK1166: cannot adjust code之掩耳盗铃版

發(fā)布時(shí)間:2025/5/22 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 解决warning LNK1166: cannot adjust code之掩耳盗铃版 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在EVC編譯CEBetaPlayer 0.0.25版時(shí),在wmv_decode files模塊的LINKING階段出了這樣一個(gè)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? 某個(gè)地址上的編譯結(jié)果不可識(shí)別?這EVC怎么混的,編譯出自己不能識(shí)別的結(jié)果?
關(guān)鍵字在WARNING LNK166上。在EVC4的HELP里面搜索LNK1166,有且僅有的說(shuō)明為:
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.

不知所云,而且最重要的是,沒(méi)給出解決方案。誰(shuí)寫(xiě)的文檔,揍他個(gè)半身不遂。

當(dāng)然像我這樣的SUPER GOOGLER是沒(méi)什么找不到的東東啦。答案在這里

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.

也就是說(shuō)在TI的ARM925系列CPU上存在一個(gè)缺陷,但是他們自己不去FIX掉,卻牛B哄哄地讓微軟給他們擦屁股:在EVC里增加了LINK時(shí)的一項(xiàng)PAD CODE功能來(lái)防止EVC編譯出來(lái)的程序在他們CPU里跑著跑著導(dǎo)致死機(jī)。微軟雖然給了TI一點(diǎn)面子,也不是很賣(mài)帳,就沒(méi)把這個(gè)功能做完美,在某些情況就PADDING不起來(lái)了,報(bào)出了這個(gè)WARNING。雖然如此, 文中建議大家還是保留這個(gè)功能以防止自己的程序哪天把TI的CPU跑死。

文中給出了兩種解決方法:
(1)科學(xué)的解決方法:在project settings -> C/C++ TAB -> Category: Customize 里面把 Enable function-level linking 這個(gè)復(fù)選項(xiàng)勾起來(lái)? //結(jié)果我發(fā)現(xiàn)我的wmv_decode settings這個(gè)項(xiàng)上是灰的,不可勾選,哭啊哭啊眼淚嘩嘩。讓我心理平衡的是文中說(shuō)即使這么操作也有可能WANRING仍然存在.
(2)眼不見(jiàn)為凈法:在project settings -> Link TAB -> Project Options 里面加入"/ARMPADCODE:NO"? 很堅(jiān)定地拒絕給TI擦屁股。幸運(yùn)的是我只盯著INTEL XSCALE,O~O~O~ONLY YOU~~~? 所以可以這么做

本文轉(zhuǎn)自Walzer博客園博客,原文鏈接:http://www.cnblogs.com/walzer/archive/2006/02/09/327834.html,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者

總結(jié)

以上是生活随笔為你收集整理的解决warning LNK1166: cannot adjust code之掩耳盗铃版的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。