本文主要是介绍vxWorks6.9动态加载程序时出现 Relocation value does not fit in 24/26 bits,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在vxworks中动态加载可执行程序,有时候会出现类似 Relocation value does not fit in 26 bits (offset: 0x10, type: 1) 的错误提示,从而导致程序加载失败。
出错原因:
Some architectures have instructions that use less than 32 bits to reference a nearby position in memory. Using these instructions can be more efficient than always using 32 bits to refer to nearby places in memory.
The problem arises when the compiler has produced such a reference to something that lies farther away in memory than the range that can be accessed with the reduced number of bits. For instance, if a call to printf( ) is encoded with one of these instructions, the load may succeed if the object code is loaded near the kernel code, but fail if the object code is loaded farther away from the kernel image.
以上是官方文档解释,概述来说就是:有些架构的处理器使用少于32bit的指令来引用临近的内存,比如例子中使用26bit来访问,这样可以使访问更快、更有效率。但是万事万物的利和弊都是并存的,如果引用的内容位于内存中比26bit所能表示的地址更远时,就会出错了。
直白打比方,这个错误就好比:以北京为核心,你买的车票只能到郑州,但是你要访问的内容在南京,所以就出错了。
解决方案:
Recompile the object file using -Xcode-absolute-far for the Wind River compilers, and for GNU compilers, the appropriate long call option, -mlongcall (for PPC architecture).
官方给出的方案简单明了:对于diab编译器,添加 -Xcode-absolute-far 配置; 对于GNU编译器,添加 -mlongcall 配置即可。
如下图:
diab编译器处理如下,gnu的类似。
这篇关于vxWorks6.9动态加载程序时出现 Relocation value does not fit in 24/26 bits的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!