Код на Си без компиляции с gcc, но вызывает ошибку «усеченный - неправильно сформированный объект» в objdump - PullRequest
1 голос
/ 01 октября 2019

У меня есть следующий короткий и простой 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 composition и objdump -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
...