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

相关文章
|
机器学习/深度学习 数据采集 人工智能
【AIGC】人工智能生成的漫画
【AIGC】人工智能生成的漫画
578 0
|
API 语音技术 开发者
基于开源技术的数字人实时对话:形象可自定义,支持语音输入,对话首包延迟可低至3s
魔搭社区最近上线了基于开源技术的数字人实时对话demo,无需预训练即可使用自定义的数字人形象进行实时对话,支持语音输入和实时对话。
|
机器学习/深度学习 资源调度 数据挖掘
深度学习原理篇 第五章:YOLOv8
简要介绍yolov8的原理和代码实现。
2834 0
ES自定义插件-elasticsearch-analysis-hanlp
ES自定义插件-elasticsearch-analysis-hanlp
ES自定义插件-elasticsearch-analysis-hanlp
|
运维 监控 负载均衡
项目一----IDC的功能和运维要求
项目一----IDC的功能和运维要求
1084 0
项目一----IDC的功能和运维要求
|
Java 应用服务中间件 网络安全
【ssh系列一】——框架搭建
建立项目(SpringMVC+Spring+hibernate的maven项目)
|
Oracle 关系型数据库 机器学习/深度学习
|
TensorFlow 算法框架/工具 C++
IOS平台TensorFlow实践:实际应用教程(附源码)(二)
本文是《从零到一:IOS平台TensorFlow入门及应用》系列二,介绍IOS平台TensorFlow的安装,以及将系列一中开发的模型在IOS app上的实际应用
14239 0
|
2天前
|
人工智能 自然语言处理 JavaScript
2026年Windows+Ollama本地部署OpenClaw保姆级教程:本地AI Agent+阿里云上快速搭建
2026年OpenClaw凭借本地部署、私有化运行的特性,成为打造个人智能体的核心工具,而Ollama作为轻量级本地大模型管理工具,能让OpenClaw摆脱对云端大模型的依赖,实现**本地推理、数据不泄露、全流程私有化**的智能体验。本文基于Windows 11系统,从硬件环境准备、Ollama安装与模型定制、OpenClaw部署配置、技能扩展到常见问题排查,打造保姆级本地部署教程,同时补充阿里云OpenClaw(Clawdbot)快速部署步骤,兼顾本地私有化需求与云端7×24小时运行需求,文中所有代码命令均可直接复制执行,确保零基础用户也能快速搭建属于自己的本地智能体。
4168 18

热门文章

最新文章