How to disassemble the main function of a stripped application?

前端 未结 4 1563
小鲜肉
小鲜肉 2021-01-30 01:06

Let\'s say I compiled the application below and stripped it\'s symbols.

#include 

int main()
{
    printf(\"Hello\\n\");
}

Buil

4条回答
  •  时光取名叫无心
    2021-01-30 01:38

    How about doing info files to get the section list (with addresses), and going from there?

    Example:

    gdb) info files
    
    Symbols from "/home/bob/tmp/t".
    Local exec file:
    `/home/bob/tmp/t', file type elf64-x86-64.
    Entry point: 0x400490
    0x0000000000400270 - 0x000000000040028c is .interp
    0x000000000040028c - 0x00000000004002ac is .note.ABI-tag
        ....
    
    0x0000000000400448 - 0x0000000000400460 is .init
        ....
    

    The disassemble .init:

    (gdb) disas 0x0000000000400448,0x0000000000400460
    Dump of assembler code from 0x400448 to 0x400460:
       0x0000000000400448:  sub    $0x8,%rsp
       0x000000000040044c:  callq  0x4004bc
       0x0000000000400451:  callq  0x400550
       0x0000000000400456:  callq  0x400650
       0x000000000040045b:  add    $0x8,%rsp
       0x000000000040045f:  retq   
    

    Then go ahead and disassemble the rest.

    If I were you, and I had the same GCC version as your executable was built with, I'd examine the sequence of functions called on a dummy non-stripped executable. The sequence of calls is probably similar in most usual cases, so that might help you grind through the startup sequence up to your main by comparison. Optimizations will probably come in the way though.

    If your binary is stripped and optimized, main might not exist as an "entity" in the binary; chances are you can't get much better than this type of procedure.

提交回复
热议问题