David David - 6 months ago 30
Bash Question

How to check if a section is code or data(.elf)?

I am writing a script that supposed to analyze .elf's memory.
More specifically: code size and data size.
The GNU size utility lists the section sizes.

>mips-mti-elf-size.exe -A -x -t file.elf
section size addr
Total 0x-----

I also can check total .text size or total .data size.
Is there a way to decide for each sec(i) whether it is a code or a data?

Answer Source

Use mips-mti-elf-readelf.exe:

 mips-mti-elf-readelf.exe -S file.elf

This will return:

  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .secName                          9014d000 00d000 000480 00  AX  0   0 4096

use Flg: if X is up it is code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download