解决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,如需转载请自行联系原作者

相关文章
|
编解码 C++ Python
成功解决LINK : fatal error LNK1181: 无法打开输入文件“avdevice.lib” error: command 'D:\\Program Files (x86)\\Micr
成功解决LINK : fatal error LNK1181: 无法打开输入文件“avdevice.lib” error: command 'D:\\Program Files (x86)\\Micr
成功解决LINK : fatal error LNK1181: 无法打开输入文件“avdevice.lib” error: command 'D:\\Program Files (x86)\\Micr
|
Java 开发工具 Android开发
Android Studio 解决:error adding symbols: File in wrong format clang++.exe: error: linker command...
错误日志: Error:FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:externalNativeBuildDebug'.
6566 0
|
Android开发
Failed to obtain GLES 2.x extensions striProcess finished with exit code -1073741819 (0xC0000005)
android studio打开虚拟机时报错信息,解决办法之一(我成功的办法,其他方法试了没用), 打开 设备管理器然后找到你的独显,然后禁用设备,然后再次启动设备就行了,最后再启动你的虚拟机就行了。
171 0
|
Java
Error: A JNI error has occurred, please check your installation and try again
Error: A JNI error has occurred, please check your installation and try again
198 0
configure: line syntax error near unexpected token `win32-dll'
configure: line syntax error near unexpected token `win32-dll'
351 0
|
Perl
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1
705 0
|
数据库 C++
VS错误的解决解决:LINK fatal error LNK1000: Internal error during IncrBuildImage
VS错误的解决解决:LINK fatal error LNK1000: Internal error during IncrBuildImage
242 0
|
开发工具 Windows
“basetsd.h”: No such file or directory,LINK : fatal error LNK1158: 无法运行“rc.exe”报错
无法打开包括文件: “basetsd.h”: No such file or directory 解决方案
“basetsd.h”: No such file or directory,LINK : fatal error LNK1158: 无法运行“rc.exe”报错