diff options
author | Frederic Riss <friss@apple.com> | 2015-09-02 16:49:13 +0000 |
---|---|---|
committer | Frederic Riss <friss@apple.com> | 2015-09-02 16:49:13 +0000 |
commit | 24faade4b3f3bcbcd671e81c74db425b14b93c33 (patch) | |
tree | 1a66a7d2d5ff8978324be0fe0dbe1ea093794d88 /llvm/test | |
parent | 12004ebe2fd602f5b7a8eacae5cc125b7bb5c932 (diff) | |
download | bcm5719-llvm-24faade4b3f3bcbcd671e81c74db425b14b93c33.tar.gz bcm5719-llvm-24faade4b3f3bcbcd671e81c74db425b14b93c33.zip |
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.
llvm-svn: 246673
Diffstat (limited to 'llvm/test')
-rwxr-xr-x | llvm/test/tools/dsymutil/Inputs/basic.macho.i386 | bin | 0 -> 9080 bytes | |||
-rw-r--r-- | llvm/test/tools/dsymutil/X86/dsym-companion.test | 339 |
2 files changed, 339 insertions, 0 deletions
diff --git a/llvm/test/tools/dsymutil/Inputs/basic.macho.i386 b/llvm/test/tools/dsymutil/Inputs/basic.macho.i386 Binary files differnew file mode 100755 index 00000000000..ee6be096fe5 --- /dev/null +++ b/llvm/test/tools/dsymutil/Inputs/basic.macho.i386 diff --git a/llvm/test/tools/dsymutil/X86/dsym-companion.test b/llvm/test/tools/dsymutil/X86/dsym-companion.test new file mode 100644 index 00000000000..4327a2953d9 --- /dev/null +++ b/llvm/test/tools/dsymutil/X86/dsym-companion.test @@ -0,0 +1,339 @@ +RUN: llvm-dsymutil -o - %p/../Inputs/basic.macho.i386 -f | llvm-readobj -file-headers -program-headers -sections -symbols - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK32 +RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -f | llvm-readobj -file-headers -program-headers -sections -symbols - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK64 + +This test checks that the dSYM companion binaries generated in 32 and 64 bits +are correct. The check are pretty strict (we check even the offsets and sizes +of the sections) in order to test the VM address layout algorithm. As the +debug sections are generated, this is a bit risky, but I don't expect +llvm-dsymutil's output to change much for these tiny C programs so this should +be OK. +The 32bits version doesn't have object files, thus it has basically no debug +sections. + +CHECK32: Format: Mach-O 32-bit i386 +CHECK32: Arch: i386 +CHECK32: AddressSize: 32bit +CHECK64: Format: Mach-O 64-bit x86-64 +CHECK64: Arch: x86_64 +CHECK64: AddressSize: 64bit +CHECK: MachHeader { +CHECK32: Magic: Magic (0xFEEDFACE) +CHECK32: CpuType: X86 (0x7) +CHECK32: CpuSubType: CPU_SUBTYPE_I386_ALL (0x3) +CHECK64: Magic: Magic64 (0xFEEDFACF) +CHECK64: CpuType: X86-64 (0x1000007) +CHECK64: CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3) +CHECK: FileType: DWARFSymbol (0xA) +CHECK: NumOfLoadCommands: 7 +CHECK: Flags [ (0x0) +CHECK: } +CHECK: Sections [ +CHECK: Section { +CHECK: Name: __text +CHECK: Segment: __TEXT +CHECK32: Address: 0x1E90 +CHECK32: Size: 0x11A +CHECK64: Address: 0x100000EA0 +CHECK64: Size: 0x109 +CHECK: Offset: 0 +CHECK: Alignment: 4 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x800004) +CHECK: PureInstructions (0x800000) +CHECK: SomeInstructions (0x4) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __unwind_info +CHECK: Segment: __TEXT +CHECK32: Address: 0x1FAC +CHECK64: Address: 0x100000FAC +CHECK: Size: 0x48 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK32: Section { +CHECK32: Name: __nl_symbol_ptr +CHECK32: Segment: __DATA +CHECK32: Address: 0x2000 +CHECK32: Size: 0x4 +CHECK32: Offset: 0 +CHECK32: Alignment: 2 +CHECK32: RelocationOffset: 0x0 +CHECK32: RelocationCount: 0 +CHECK32: Type: 0x6 +CHECK32: Attributes [ (0x0) +CHECK32: ] +CHECK32: Reserved1: 0x0 +CHECK32: Reserved2: 0x0 +CHECK32: } +CHECK: Section { +CHECK: Name: __data +CHECK: Segment: __DATA +CHECK32: Address: 0x2004 +CHECK64: Address: 0x100001000 +CHECK: Size: 0x4 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __common +CHECK: Segment: __DATA +CHECK32: Address: 0x2008 +CHECK64: Address: 0x100001004 +CHECK: Size: 0x4 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: LocReloc (0x1) +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __bss +CHECK: Segment: __DATA +CHECK32: Address: 0x200C +CHECK64: Address: 0x100001008 +CHECK: Size: 0x4 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: LocReloc (0x1) +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK64: Section { +CHECK64: Name: __debug_line +CHECK64: Segment: __DWARF +CHECK64: Address: 0x100003000 +CHECK64: Size: 0xEA +CHECK64: Offset: 8192 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_pubnames +CHECK64: Segment: __DWARF +CHECK64: Address: 0x1000030EA +CHECK64: Size: 0x7F +CHECK64: Offset: 8426 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_pubtypes +CHECK64: Segment: __DWARF +CHECK64: Address: 0x100003169 +CHECK64: Size: 0x57 +CHECK64: Offset: 8553 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_aranges +CHECK64: Segment: __DWARF +CHECK64: Address: 0x1000031C0 +CHECK64: Size: 0xB0 +CHECK64: Offset: 8640 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_info +CHECK64: Segment: __DWARF +CHECK64: Address: 0x100003270 +CHECK64: Size: 0x1BC +CHECK64: Offset: 8816 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK: Section { +CHECK: Name: __debug_abbrev +CHECK: Segment: __DWARF +CHECK32: Address: 0x4000 +CHECK32: Size: 0x1 +CHECK32: Offset: 8192 +CHECK64: Address: 0x10000342C +CHECK64: Size: 0x8F +CHECK64: Offset: 9260 +CHECK: Alignment: 0 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __debug_str +CHECK: Segment: __DWARF +CHECK32: Address: 0x4001 +CHECK32: Size: 0x1 +CHECK32: Offset: 8193 +CHECK64: Address: 0x1000034BB +CHECK64: Size: 0x9F +CHECK64: Offset: 9403 +CHECK: Alignment: 0 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: ] +CHECK: Symbols [ +CHECK: Symbol { +CHECK: Name: _inc (2) +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1F20 +CHECK64: Value: 0x100000F20 +CHECK: } +CHECK: Symbol { +CHECK: Name: _inc (2) +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1F90 +CHECK64: Value: 0x100000F90 +CHECK: } +CHECK: Symbol { +CHECK: Name: _baz (7) +CHECK: Type: Section (0xE) +CHECK: Section: __data +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x2004 +CHECK64: Value: 0x100001000 +CHECK: } +CHECK: Symbol { +CHECK: Name: _private_int (12) +CHECK: Type: Section (0xE) +CHECK: Section: __bss +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x200C +CHECK64: Value: 0x100001008 +CHECK: } +CHECK: Symbol { +CHECK: Name: __mh_execute_header (25) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x10) +CHECK: ReferencedDynamically (0x10) +CHECK: ] +CHECK32: Value: 0x1000 +CHECK64: Value: 0x100000000 +CHECK: } +CHECK: Symbol { +CHECK: Name: _bar (45) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1F40 +CHECK64: Value: 0x100000F40 +CHECK: } +CHECK: Symbol { +CHECK: Name: _foo (50) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1EC0 +CHECK64: Value: 0x100000ED0 +CHECK: } +CHECK: Symbol { +CHECK: Name: _main (55) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1E90 +CHECK64: Value: 0x100000EA0 +CHECK: } +CHECK: Symbol { +CHECK: Name: _val (61) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __common +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x2008 +CHECK64: Value: 0x100001004 +CHECK: } +CHECK: ] + |