C代码使用gcc进行静默编译,但在objdump中引发“截断-格式错误的对象”错误

时间:2019-10-01 13:54:23

标签: c x86 x86-64

我有以下简短而又简单的C文件,名为composition.c

long inside (long a1,long a2)
{
  return a1+a2-a1*a2;
}

long outside(long b1,long b2,long b3,long b4)
{
  long first_half = inside(b2,b3);
  long second_half = inside(b1,b4);
  return(first_half+second_half);
}

int main(int argc, char** argv)
{
   long answer=outside(3,4,5,6);
   return 0;
}

在HighSierra MacBook Air的终端上,我做了gcc -g -O0 composition.c -o compositionobjdump -d composition,但是后者会产生错误消息:

$ objdump -d composition

composition:    file format Mach-O 64-bit x86-64

/Library/Developer/CommandLineTools/usr/bin/objdump: 'composition': truncated or malformed object (bad section index: 3 for symbol at index 2)

所以我要问我的C代码怎么了?

更新:以下是版本详细信息:

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ objdump --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
  Optimized build.
  Default target: x86_64-apple-darwin17.7.0
  Host CPU: broadwell

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_be - AArch64 (big endian)
    arm        - ARM
    arm64      - ARM64 (little endian)
    armeb      - ARM (big endian)
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64

0 个答案:

没有答案