网站重新上线,多谢朋友们的关心
Nov 11
[问题] 当一个大程序中,有一些函数从来没有被调用过,用GCC编译仍然会把他们保留在最终的输出elf中。怎样去除这些没有被调用过的函数呢?
[Question] Sometimes some functions are never used in one program, but gcc will retain them in the produced elf file even with -O2 option. How to remove these dead code?

[GCC Doc]
引用
In order to do this, it has to work with objects compiled with the following options: -ffunction-sections -fdata-sections. These options are usable with C and Ada files. They will place respectively each function or data in a separate section in the resulting object file.

Once the objects and static libraries are created with these options, the linker can perform the dead code elimination. You can do this by setting the -Wl,--gc-sections option to gcc command or in the -largs section of gnatmake. This will perform a garbage collection of code and data never referenced.

Tags:
Oct 9
问题:在EDK中为某个Project设置的Optimize Level都只针对这个Project下的C,而Library都默认以-O2编译。这对调试的情况有一些不便。怎样设置让LibGen以-O0编译库?

解决:Platform Settings --> Software Platform --> Microblaze_0 --> extra compiler flags = -g -O0 ".
Tags: , ,
Jul 11

malloc 不指定

RickySu , 09:47 , 技术经验 , 评论(0) , 引用(0) , 阅读(404) , Via 本站原创
1. 在EDK里怎么用malloc?要不要include什么头文件?
- 不需要include。直接用就可以了。malloc是包含在lib里的。

2. malloc格式?
double *p = malloc( sizeof *p ); /* 不推荐用 sizeof( double ) */
free(p);
//according to http://cpp.ga-la.com/html/3/3/0510/7.htm

3. 潜在问题?
Xilinx AR30878 - reset后malloc返回null
其实如果malloc后,如果已经free了,那么再怎么reset也无妨。问题只是malloc后没有free,导致.bss内容变化,但reset cpu不重写BRAM/DDR RAM中的.bss,因此需要一段代码在启动时重新加载.bss - 这样.bss就需要先存储到non-volatile中了。很麻烦吧:)
Tags: , ,
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]