Binary Utility Program Examples

Disassembly

The following command uses output redirection to generate a file

pic32-objdump -dS --stop-address=0x9d000500 calc.elf > calc1.da.txt

It produces the following information (abridged)

9d000018 <main>:
*/
#include <p32xxxx.h>

int main()
{
9d000018:    27bdffe8     addiu    sp,sp,-24
9d00001c:    afbe0010     sw    s8,16(sp)
9d000020:    03a0f021     move    s8,sp
    int na, nb, nc;

    na = 14;
9d000024:    2402000e     li    v0,14
9d000028:    afc20000     sw    v0,0(s8)
    nb = na + 21;
9d00002c:    8fc20000     lw    v0,0(s8)
9d000030:    24420015     addiu    v0,v0,21
9d000034:    afc20004     sw    v0,4(s8)
    nc = na & 0x3c;
9d000038:    8fc20000     lw    v0,0(s8)
9d00003c:    3042003c     andi    v0,v0,0x3c
9d000040:    afc20008     sw    v0,8(s8)
    return 0;
9d000044:    00001021     move    v0,zero
}
9d000048:    03c0e821     move    sp,s8
9d00004c:    8fbe0010     lw    s8,16(sp)
9d000050:    27bd0018     addiu    sp,sp,24
9d000054:    03e00008     jr    ra
9d000058:    00000000     nop

ELF Program Header

This command example shows the program header of an ELF file:

pic32-readelf -h calc.elf

with the following result:

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           MIPS
  Version:                           0x1
  Entry point address:               0xbfc00000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          734844 (bytes into file)
  Flags:                             0x70ff1001, noreorder, pic32mx, o32, mips32r2
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         98
  Section header string table index: 95


Maintained by John Loomis, last updated 18 September 2008