[Patch]: ld - add --print-memory-usage option

Nicholas Clifton nickc@redhat.com
Mon Jun 8 08:57:00 GMT 2015


Hi Tristan,

> this patch adds a new linker option to display memory usage on the target.
> This feature is useful for embedded targets when you need to monitor the
> amount of free memory.  As far as I know there is no binutils tool for that:
> the output of size is too rough, and the output of 'objdump -h’ is not clear
> enough.  Here is an example of output:
>
> Memory region           size  total size  Ratio
>             FLASH:     1524 B        3 MB    0.05%
>              SRAM:    22536 B      256 KB    8.60%
>             SDRAM:        0 GB       8 MB    0.00%
>
> The names of memory region directly comes from the linker script.

I think that the names of the columns are slightly confusing.  "size" is 
really "Size of Region" and "total size" is "Size Occupied".  Also 
"Ratio" probably ought to be "%age Used" or something like that.

It might also help if the format of this layout is defined in the 
documentation somewhere so that it becomes fixed, and users can write 
tools to parse the output if they want to.


> No regression on arm-elf.

What - no other targets ?  Please check x86 or x86_64 at least.


> Is it OK for trunk ?

I like it, but please could you add a testcase (or two) to check that 
the feature continues to work ?


Cheers
   Nick



More information about the Binutils mailing list