Okay so I have a really arcane problem!
I’m writing a compiler for macOS that outputs nasm code. I just added DWARF debugging output to the Linux version, all went fine but I’m struggling with the macOS version.
First of all when I compile a C program with Apple’s own tool chain, all functions that actually get called have relocations generated for them automatically. I understand that these relocations are referenced by an offset in the Mach-o header.
Obviously this is my own compiler so I don’t know how to encode the relocations - since nasm is generating the Mach-o header and I don’t have access to it or a way to influence what nasm does.
You may wonder why this even matters... well, Apple’s dsymutil appears to detect that there are no relocations on these functions, assumes they aren’t getting called, and so discards all of my carefully crafted DWARF information!
The above is what I THINK is happening. I can’t say for sure. I managed to patch dsymutil to force it to pass the DWARF through, but that brought other problems. And I don’t like maintaining patched versions of parts of LLVM.
Has anyone got any suggestions about what I should do?
Thank you!