简体   繁体   English

lpcxpresso与Cortex-M3:什么是libc.a(lib_a-impure.o)为什么它使用1k的ram?

[英]lpcxpresso with Cortex-M3: what is libc.a(lib_a-impure.o) any why is it using 1k of ram?

I hope this is not to domain specific. 我希望这不是针对特定领域的。 I would like to know why libc.a is using 1K of the 8K of ram that I have on chip. 我想知道为什么libc.a使用1K的8K内存芯片。

I am not aware of any way that I am using libc other than it calling the constructors of my global objects in array_init. 除了在array_init中调用我的全局对象的构造函数之外,我不知道我使用libc的任何方式。 I think its involved in default copy construction too as far as I know. 据我所知,我认为它涉及默认的拷贝构造。 I use pool allocation so no heap related stuff (I do use placement new but that should not cause libc to use ram as far as I know). 我使用池分配所以没有堆相关的东西(我确实使用了新的放置,但据我所知,这不应该导致libc使用ram)。 If I leave out the library completely and use placement new as a hack to construct all my global objects in main my program runs fine, this is another hint that the 1k of ram used by libc is useless. 如果我完全省略了库并使用placement new作为hack来构建我的所有全局对象,我的程序运行正常,这是另一个提示,libc使用的1k ram是无用的。 Can anyone point me to further reading or explain how I can keep array_init and default copy construction of POD types but get rid of the RAM overhead? 任何人都可以指出我进一步阅读或解释如何保持array_init和POD类型的默认复制结构,但摆脱RAM开销?

Here is the offending entry in the .map file of my project: 这是我项目的.map文件中的违规条目:

 *(vtable)
 *(.data*)
 .data._ZN3CDC4CoreI5MyCDCE11depInEmpty_E
                0x10000000        0x1 ./src/Main.o
                0x10000000                CDC::Core<MyCDC>::depInEmpty_
 *fill*         0x10000001        0x3 00
 .data.SystemFrequency
                0x10000004        0x4 ./kvasir/system_LPC17xx.o
                0x10000004                SystemFrequency
 .data.impure_data
                0x10000008      0x428 c:/nxp/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-impure.o)
 .data          0x10000430        0x4 c:/nxp/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7-m\crtbegin.o
                0x10000430                __dso_handle
                0x10000434                . = ALIGN (0x4)
                0x10000434                _edata = .

.jcr            0x10000434        0x0 load address 0x00003ee8
 .jcr           0x10000434        0x0 c:/nxp/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/armv7-m\crtbegin.o

.bss            0x10000434     0x1600 load address 0x00003ee8
                0x10000434                _bss = .
 *(.bss*)
 .bss.inBuf     0x10000434       0x34 ./src/Main.o
                0x10000434                inBuf

Update 更新

after going through my code line by line I found a fix, I had an empty destructor defined in one of my classes 在逐行浏览我的代码后,我找到了一个修复程序,我在其中一个类中定义了一个空的析构函数

~MyClass(){}

commenting that out removed the 1K of ram. 评论说,删除了1K的ram。 Can anyone tell me why? 谁能告诉我为什么?

This isn't a direct solution to your problem, but perhaps a lead. 这不是您问题的直接解决方案,但可能是一个主角。 The impure_data section is part of the library's reentrancy support. impure_data部分是图书馆重入支持的一部分。 http://web.archive.org/web/20090106124055/http://venus.billgatliff.com/node/3 http://web.archive.org/web/20090106124055/http://venus.billgatliff.com/node/3

I wonder if you rebuild the library with -ffunction-sections -fdata-sections if that section goes away? 我想知道如果该部分消失,你是否用-ffunction-sections -fdata-sections重建库? It sounds like you call precious little from the library, so that may be effective. 这听起来像你从图书馆那里称之为珍贵,所以这可能是有效的。 Otherwise, you might be stuck hacking on newlib or just borrowing the pieces you really want. 否则,你可能会被黑客攻击newlib或只是借用你真正想要的东西。

After reading a bit into the newLib code it seems to me that this is being caused by some multithreadding stuff being loaded. 在读入newLib代码后,在我看来,这是由一些多线程的东西被加载引起的。 I solved the problem by not declaring any non default destructors. 我通过不声明任何非默认析构函数来解决问题。 I have read that the newLib nano will solve this problem but I haven't tested because my IDE does not support it yet out of the box. 我已经读过newLib nano将解决这个问题,但我还没有测试过,因为我的IDE不支持它开箱即用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM