-1

I saw Valgrind is quite useful for things like memory leaks but it is focused more on dynamic memory. Is there any tool that can help analyze static memory?

Haven't really found any tool that can help me with my issue.

yeepaa
  • 1
  • 3
  • 1
    Seeking recommendations for libraries/tools is off topic here. – Ted Lyngmo May 08 '23 at 21:34
  • What is your issue, exactly? – pmacfarlane May 08 '23 at 21:35
  • There are tools that will dump the segments of an executable object, and their size. `nm` is one, IIRC. – ikegami May 08 '23 at 21:51
  • @ikegami ".bin" file too? – 0___________ May 08 '23 at 21:52
  • @0___________, I am unfamiliar with a specific format associated with `.bin`. (I've seen the extension popup here and there over the years, but it was just being used generically.) But then again, the question didn't mention `.bin`. – ikegami May 08 '23 at 21:56
  • @ikegami title dos – 0___________ May 08 '23 at 22:15
  • @ikegami FYI, `.bin` generally means using `ld --oformat=binary` or `objdump -O binary` to produce a flat image suitable for kernel boot, rom burn, etc. (e.g.) [Linking a file using ld to output a binary file gives error in OS development](https://stackoverflow.com/q/37344575/5382650) – Craig Estey May 08 '23 at 22:15
  • @0___________, No it doesn't. They just said they had a binary file. They might have meant `.bin`, but they did not say that. – ikegami May 08 '23 at 23:50
  • Your question subject, and the actual text, don't agree with each other. What are you trying to do? Find out how much space your static data uses? Or detect memory errors in static data? – pmacfarlane May 09 '23 at 00:05

1 Answers1

2

Only if you have the executable file which has section information (like .elf), you can see static storage duration segments sizes.

When you compile, you can generate a map file which will show all your segments, function & variable addresses and their sizes.

You will not be able to analyze the sizes of the automatic storage duration objects

If you have only a .bin file - it is not possible as it does not contain any information about the program memory layout.

0___________
  • 60,014
  • 4
  • 34
  • 74