I can't seem to generate assembler with intermixed C source with assembler when using Apple LLVM objdump on macOS Sonoma with the --source
objdump option. What am I missing?
Environment:
OS: macOS Sonoma 14.5, Apple M2
cc --version:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
objdump --version:
Apple LLVM version 15.0.0
Optimized build.
Default target: arm64-apple-darwin23.5.0
Host CPU: apple-m1
compilation and objdump command lines I used:
cc FILE.c -o FILE
objdump --disassemble --demangle --source --no-addresses FILE > FILE.asm
FILE
is the name of a single C file program executable output file name.With FILE
being hello
, hello.c
being present, I end up with the hello
executable and hello.asm
. Same for other larger single-file C programs. I can see the ARM assembler code, but I never get the embedded C source inside the objdump output.
I looked for bug reports in LLVM but did not find any. Is there a problem with the command line options I used?
The issue is your compile command:
cc FILE.c -o FILE
You cannot extract what you don't put in the file. Normally, debug information (like the coresponding source file and line for a given instruction) is not included in created output file.
You can tell the compiler to add this information using option -g
.