[dsymutil] Emit real dSYM companion binaries.
authorFrederic Riss <friss@apple.com>
Wed, 26 Aug 2015 05:10:04 +0000 (05:10 +0000)
committerFrederic Riss <friss@apple.com>
Wed, 26 Aug 2015 05:10:04 +0000 (05:10 +0000)
commit3f0363c1130960fc05704c9400b0ed1e95e9b0d4
tree208cb5c5226bb681470c12ff50ca8c4f425d7f2c
parent65ce0b1a58500376a94491ff99ba38db39a79707
[dsymutil] Emit real dSYM companion binaries.

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@246012 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