专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VxWorks

编译链接时优化有关问题.

发布时间:2010-06-14 16:51:04 文章来源:www.iduyao.cn 采编人员:星星草
编译链接时优化问题求助....
环境为VxWorks,发现部分函数在map表里面找不到, 后来发现只要是c文件中的所有接口都没其他文件函数调用时,该文件生成的点O不会被链接。 makefile没问题,如果把该文件的函数在别的文件中调用一下,则整个文件中接口都会被链接.

麻烦热心的兄弟帮忙解释一下这问题的原因, 是不是由哪个编译选项和开关控制?

------解决方案--------------------
是这样的,有一个东西叫做 dead strip,
意思就是,在链接的时候,如果链接器发现 有 symbols 没有被使用,则linker负责把这部分内容 剔除掉,不会放在生成的输出文件中

可以从几方面去看看:

1. linker script 链接脚本中可以不可以,将你不想被删除的symbols 通过什么 命令定义一下,避免被删除
2. 通过编译连接选项,
3. 有没可能makefile中调用了 名为 strip(arch)的可执行程序,做了 dead strip 这个事情

第三点最有可能 ,我看了 VxWorks APPLICATION PROGRAMMER'S GUIDE 6.7

里边有提到

3.3.4 Reducing Executable File Size With the strip Facility 

For production systems, it may be useful to strip executables. The striparch utility 
can be used with the --strip-unneeded and --strip-debug (or -d) options for any 
RTP executables. 

The --strip-all (or -s) option should only be used with absolutely-linked 
executables. For more information in this regard, see Stripping Absolutely-Linked 
RTP Executables, p.36 and Caveat With Regard to Stripped Executables, p.54). For 
information about absolutely-linked RTP executables and the overlapped virtual 
memory model, see 2.5 About VxWorks RTP Virtual Memory Models, p.23 and 
2.6 Using the Overlapped RTP Virtual Memory Model, p.26
------解决方案--------------------
最好还是用LD来做

可以全部连接进去,Makefile写好就行
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: