How to disassemble one single function using objdump?

后端 未结 7 1090
囚心锁ツ
囚心锁ツ 2020-11-29 17:59

I\'ve got a binary installed on my system, and would like to look at the disassembly of a given function. Preferrably using objdump, but other solutions would b

7条回答
  •  盖世英雄少女心
    2020-11-29 18:45

    Bash completion for ./dasm

    Complete symbol names to this solution (D lang version):

    • By typing dasm test and then pressing TabTab, you will get a list of all functions.
    • By typing dasm test m and then pressing TabTab all functions starting with m will be shown, or in case only one function exists, it will be autocompleted.

    File /etc/bash_completion.d/dasm:

    # bash completion for dasm
    _dasm()
    {
        local cur=${COMP_WORDS[COMP_CWORD]}
    
        if [[ $COMP_CWORD -eq 1 ]] ; then
        # files
        COMPREPLY=( $( command ls *.o -F 2>/dev/null | grep "^$cur" ) )
    
        elif [[ $COMP_CWORD -eq 2 ]] ; then
        # functions
        OBJFILE=${COMP_WORDS[COMP_CWORD-1]}
    
        COMPREPLY=( $( command nm --demangle=dlang $OBJFILE | grep " W " | cut -d " " -f 3 | tr "()" "  " | grep "$cur" ) )
    
        else
        COMPREPLY=($(compgen -W "" -- "$cur"));
        fi
    }
    
    complete -F _dasm dasm
    

提交回复
热议问题