Author Topic: Memory Analysis with size Command in C  (Read 2662 times)

0 Members and 2 Guests are viewing this topic.

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 115
  • Country: in
Memory Analysis with size Command in C
« on: April 01, 2024, 11:41:13 am »
How do we analyze the memory utilization of different sections such as text, data, and bss in a compiled binary file in C programming?

The size command on linux -systems provides information about the sizes of various sections. The output includes columns such as text, data, bss, dec, hex, and filename.

The text section represents the size of the code segment, which contains executable instructions.
The data section shows the size of initialized data variables, while the bss section indicates the size of uninitialized data variables
 

Offline audiotubes

  • Regular Contributor
  • *
  • Posts: 176
  • Country: cz
Re: Memory Analysis with size Command in C
« Reply #1 on: April 01, 2024, 01:27:26 pm »
I don't know, does this help? https://en.wikipedia.org/wiki/Valgrind
I have taken apart more gear than many people. But I have put less gear back together than most people. So there is still room for improvement.
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 3980
  • Country: gb
Re: Memory Analysis with size Command in C
« Reply #2 on: April 01, 2024, 03:14:56 pm »
You can search for documentation on "GNU binutils", there are specific tools and tutorial for this type of analysis  :popcorn:
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 
The following users thanked this post: Kittu20

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6462
  • Country: fi
    • My home page and email address
Re: Memory Analysis with size Command in C
« Reply #3 on: April 01, 2024, 08:30:55 pm »
How do we analyze the memory utilization of different sections such as text, data, and bss in a compiled binary file in C programming?
On systems like Linux that use ELF binaries (and thus almost certainly either binutils or compatible tools), using
    objdump -hw binary
or
    readelf -SW binary
or parsing the ELF file directly.  There are two formats: 32-bit and 64-bit.  Both formats have two variants depending on byte order (endianness): little-endian or big-endian.

The size command is part of binutils like objdump and readelf are and provides a concise summary, whereas objdump and readelf provide the exact details.  The two differ in their low-level implementation: objdump uses the Binary File Descriptor library (BFD), readelf does not.
 
The following users thanked this post: DiTBho, Kittu20

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14698
  • Country: fr
Re: Memory Analysis with size Command in C
« Reply #4 on: April 01, 2024, 10:10:54 pm »
I don't think the OP was waiting for answers, as they answer their own question. Kinda.
 :horse:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf