GNU LD可以按内存空间而不是大容量百分比来打印内存使用情况吗? [英] Can GNU LD print memory usage by memory space, rather then just as a bulk percentage?

查看:155
本文介绍了GNU LD可以按内存空间而不是大容量百分比来打印内存使用情况吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个ARM mcu上的一个嵌入式项目上,该项目具有一个自定义链接器文件,该文件具有几个不同的存储空间:

I'm working on an embedded project on an ARM mcu that has a custom linker file with several different memory spaces:

/* Memory Spaces Definitions */
MEMORY
{
  rom      (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00200000
  data_tcm (rw)  : ORIGIN = 0x20000000, LENGTH = 0x00008000
  prog_tcm (rwx) : ORIGIN = 0x00000000, LENGTH = 0x00008000
  ram      (rwx) : ORIGIN = 0x20400000, LENGTH = 0x00050000
  sdram    (rw)  : ORIGIN = 0x70000000, LENGTH = 0x00200000
}

具体地说,我有许多具有不同特性的不同存储设备( TCM RAM(带有D-Cache)和一个外部SDRAM,都映射为同一地址空间的一部分.

Specifically, I have a number of different memory devices with different characteristics (TCM, plain RAM (with a D-Cache in the way), and an external SDRAM), all mapped as part of the same address space.

我具体地将不同的变量放置在不同的存储空间中,具体取决于需求(我在其中进行DMA操作,是否存在缓存一致性问题,是否希望D缓存溢出等). ).

I'm specifically placing different variables in the different memory spaces, depending on the requirements (am I DMA'ing into it, do I have cache-coherence issues, do I expect to overflow the D-cache, etc...).

如果我超过了任何一节,则会收到链接器错误.但是,除非我这样做,否则链接程序仅将内存使用率打印为批量百分比:

If I exceed any one of the sections, I get a linker error. However, unless I do so, the linker only prints the memory usage as bulk percentage:

            Program Memory Usage    :   33608 bytes   1.6 % Full
            Data Memory Usage       :   2267792 bytes   91.1 % Full

鉴于我有3个活跃使用的内存空间,并且我知道我正在使用其中之一(SDRAM)的100%,这是一种无用的输出.

Given that I have 3 actively used memory spaces, and I know for a fact that I'm using 100% of one of them (the SDRAM), it's kind of a useless output.

是否有任何方法可以使链接器分别输出每个内存空间的使用百分比?现在,我必须手动打开.map文件,搜索节标题,然后从.ld文件中指定的总可用内存中手动减去大小.

Is there any way to make the linker output the percentage of use for each memory space individually? Right now, I have to manually open the .map file, search for the section header, and then manually subtract the size from the total available memory specified in the .ld file.

虽然这是一件小事,但让链接器做当然会很好:

While this is kind of a minor thing, it'd sure be nice to just have the linker do:

Program Memory Usage    :   33608 bytes   1.6 % Full
Data Memory Usage       :   2267792 bytes   91.1 % Full
    data_dtcm           :   xxx bytes   xx % Full
    ram                 :   xxx bytes   xx % Full
    sdram               :   xxx bytes   xx % Full


这是与GCC-ARM一起使用的,因此与GCC-LD一起使用.


This is with GCC-ARM, and therefore GCC-LD.

推荐答案

Arrrgh,因此,我当然会在提出以下问题后找到答案:

Arrrgh, so of course, I find the answer right after asking the question:

--print-memory-usage

用作-Wl,--print-memory-usage,您将获得以下内容:

Used as -Wl,--print-memory-usage, you get the following:

    Memory region         Used Size  Region Size  %age Used
                 rom:       31284 B         2 MB      1.49%
            data_tcm:       26224 B        32 KB     80.03%
            prog_tcm:          0 GB        32 KB      0.00%
                 ram:      146744 B       320 KB     44.78%
               sdram:          2 MB         2 MB    100.00%

这篇关于GNU LD可以按内存空间而不是大容量百分比来打印内存使用情况吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆