Search code examples
linuxembeddedramrom

Measure size of libraries in Linux


I'm developing S/W for some device which uses Linux O.S. So, the size of libraries (RAM/ROM) which I use is very important.

How can I easily calculate RAM / ROM required by my software? (including libraries I used). I think it's too easy question for experienced Linux developer.


Solution

  • Run

    size <object>
    

    or

    size <archive>
    

    or

    size <shared-object>
    

    . (or "target-"size in case you're cross-compiling: arm-size if you're using arm-gcc)

    It will give you a

    text    data     bss     dec     hex filename
    

    table where text is program-size, bss the initialized globals and data the read-only data.

    While this answers your question, you probably will want to use a specific LdScript (when using ld as linker) where you will place the sections into the available memories manually when doing the final link.