Search code examples
binarysystem-callselfobjdumpreadelf

how to see the assembly of libc functions in an elf


how can i see the assembly of standard c library functions in an elf? for example, i have a binary that i have the source code of this binary and i know that printf is called in main function. i want to see the assembly of printf function in this elf. please notice that i want to see the assembly in elf itself. i search a lot but i don't find anything


Solution

  • You can compile with

    ~$ gcc -static prog.c
    

    while prog.c uses the functions you the assembly of. That will statically link the libraries used to the binary.

    Then you can just:

    ~$ objdump --disassemble a.out
    

    EDIT

    You can even take a simpler way: just objdump the libc library:

    ~$ objdump --disassemble /usr/lib/libc.so.6 // or whatever the path of libc is