dumpbin equivalent in unix

1.1k views Asked by At

I'm using SCons to compile few programs and then I want to check what type of binary file is it. Is it 64bit or 32bit, in windows I used dumpbin. I tried using nm for unix and that returned the following

~/Documents/scons_unix/SCons_test$ nm VisualStudio08-32bit
0000000000600e50 d _DYNAMIC
0000000000600fe8 d _GLOBAL_OFFSET_TABLE_
00000000004005f8 R _IO_stdin_used
                 w _Jv_RegisterClasses
0000000000600e30 d __CTOR_END__
0000000000600e28 d __CTOR_LIST__
0000000000600e40 D __DTOR_END__
0000000000600e38 d __DTOR_LIST__
00000000004006f0 r __FRAME_END__
0000000000600e48 d __JCR_END__
0000000000600e48 d __JCR_LIST__
0000000000601020 A __bss_start
0000000000601010 D __data_start
00000000004005b0 t __do_global_ctors_aux
0000000000400460 t __do_global_dtors_aux
0000000000601018 D __dso_handle
                 w __gmon_start__
0000000000600e24 d __init_array_end
0000000000600e24 d __init_array_start
00000000004005a0 T __libc_csu_fini
0000000000400510 T __libc_csu_init
                 U __libc_start_main@@GLIBC_2.2.5
0000000000601020 A _edata
0000000000601030 A _end
00000000004005e8 T _fini
00000000004003c8 T _init
0000000000400410 T _start
000000000040043c t call_gmon_start
0000000000601020 b completed.6531
0000000000601010 W data_start
0000000000601028 b dtor_idx.6533
00000000004004d0 t frame_dummy
00000000004004f4 T main
                 U puts@@GLIBC_2.2.5

then I tried using objdump -f, that gave me the following result

VisualStudio08-64bit:     file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000400410

but here is the problem the below result is from a 32bit file, both 64bit and 32 bit look Identical to me,

VisualStudio08-32bit:     file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000400410

I don't know what's wrong with that, not sure if SCons is messing up the build. this is what I have in the SConstruct

#Builds a 32bit binary using the default compiler
env = Environment(TARGET_ARCH='x86')
env.Program('DefaultCompiler32-bit','helloworld-32bit.cpp')
1

There are 1 answers

0
Chris Dodd On BEST ANSWER

file is the easiest way to tell what a binary (or any other file) is on unix:

$ file program64
program64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
$ file program32
program32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped