How to list functions present in object file?

I used objdump (in gnu c, windows platform).

    C:\...obj>objdump -t winsock001.o
         
    winsock001.o:     file format pe-x86-64
    SYMBOL TABLE:
    [  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x0000000000000000 winsock001.c
__main
__imp_WSAStartup
__imp_socket
__imp_htons
__imp_inet_addr
__imp_connect
__imp_closesocket
__imp_WSACleanup
__imp_WSAGetLastError
printf
puts

Dump the symbols instead. All .obj files have a symbol table. It will show you those symbols defined internally, and those that need resolution. The IO symbols you see may be UNDEF symbols, but the symbol table should make it more clear.

DUMPBIN /SYMBOLS func.obj

Keep in mind that /SYMBOLS is not available when the object is compiled with /GL (whole program optimization). Object modules created with /GL (as well as libraries) are created with a format that is not guaranteed to be compatible from one compiler version to the next.

Whole Program Optimization means that the optimizer can optimize across all modules, as opposed to just within each module. Functions can become "inline" and other tricks performed that presumably are not very COFF compatible. It is recommended that deliverable libraries not have the /GL option set unless you are supplying libraries for all supported compiler versions.

Tags:

C++

Visual C++