0

我正在使用 SCons 编译几个程序,然后我想检查它是什么类型的二进制文件。它是 64 位还是 32 位,在 Windows 中我使用了dumpbin。我尝试使用nm for unix 并返回以下内容

~/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

然后我尝试使用objdump -f,这给了我以下结果

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

但这是问题,以下结果来自 32 位文件,64 位和 32 位对我来说看起来相同,

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

我不知道这有什么问题,不确定 SCons 是否搞砸了构建。这就是我在 SConstruct 中所拥有的

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

1 回答 1

2

file是在 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
于 2012-08-13T22:24:28.687 回答