Reapply r246012 [dsymutil] Emit real dSYM companion binaries.
authorFrederic Riss <friss@apple.com>
Wed, 2 Sep 2015 16:49:13 +0000 (16:49 +0000)
committerFrederic Riss <friss@apple.com>
Wed, 2 Sep 2015 16:49:13 +0000 (16:49 +0000)
commitef8ad01b02bd6decc99f587bf800c58fb765384a
treebcbb8b9357b04ab025f279335889d9216af5041a
parent885eb98ce3c45970f097b180a0b7c1dc3f59649c
Reapply r246012 [dsymutil] Emit real dSYM companion binaries.

With a fix for big endian machines. Thanks to Daniel Sanders for the debugging!

Original commit message:

The binaries containing the linked DWARF generated by dsymutil are not
standard relocatable object files like emitted did previsously. They should be
dSYM companion files, which means they have a different file type in the
header, but also a couple other peculiarities:
 - they contain the segments and sections from the original binary in their
load commands, but not the actual contents. This means they get an address
and a size, but their offset is always 0 (but these are not virtual sections)
 - they also conatin all the defined symbols from the original binary

This makes MC a really bad fit to emit these kind of binaries. The approach
that was used in this patch is to leverage MC's section layout for the
debug sections, but to use a replacement for MachObjectWriter that lives
in MachOUtils.cpp. Some of the low-level helpers from MachObjectWriter
were reused too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246673 91177308-0d34-0410-b5e6-96231b3b80d8
test/tools/dsymutil/Inputs/basic.macho.i386 [new file with mode: 0755]
test/tools/dsymutil/X86/dsym-companion.test [new file with mode: 0644]
tools/dsymutil/DwarfLinker.cpp
tools/dsymutil/MachOUtils.cpp
tools/dsymutil/MachOUtils.h