[dsymutil] Implement support for universal mach-o object files.

This patch allows llvm-dsymutil to read universal (aka fat) macho object
files and archives. The patch touches nearly everything in the BinaryHolder,
but it is fairly mechinical: the methods that returned MemoryBufferRefs or
ObjectFiles now return a vector of those, and the high-level access function
takes a triple argument to select the architecture.

There is no support yet for handling fat executables and thus no support for
writing fat object files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243096 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frederic Riss
2015-07-24 06:41:11 +00:00
parent 1556296615
commit fa7f7bd017
13 changed files with 300 additions and 107 deletions

View File

@@ -0,0 +1,13 @@
# REQUIRES: object-emission
# RUN: llvm-dsymutil -oso-prepend-path=%p/../Inputs -y %s -o - 2>&1 | FileCheck %s
---
triple: 'armv7-apple-darwin'
objects:
- filename: libfat-test.a(fat-test.o)
symbols:
- { sym: _armv7_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 }
...
# CHECK: libfat-test.a(fat-test.o): No object file for requested architecture

View File

@@ -0,0 +1,2 @@
if not 'X86' in config.root.targets:
config.unsupported = True

View File

@@ -0,0 +1,17 @@
/* Compile with:
clang -c -g -arch x86_64h -arch x86_64 -arch i386 fat-test.c
libtool -static -o libfat-test.a fat-test.o
To reduce the size of the fat .o:
lipo -thin i386 -o fat-test.i386.o fat-test.o
lipo -thin x86_64 -o fat-test.x86_64.o fat-test.o
lipo -thin x86_64h -o fat-test.x86_64h.o fat-test.o
lipo -create -arch x86_64h fat-test.x86_64h.o -arch x86_64 fat-test.x86_64.o -arch i386 fat-test.i386.o -o fat-test.o -segalign i386 8 -segalign x86_64 8 -segalign x86_64h 8
*/
#ifdef __x86_64h__
int x86_64h_var;
#elif defined(__x86_64__)
int x86_64_var;
#else
int i386_var;
#endif

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,16 @@
# REQUIRES: object-emission
# RUN: llvm-dsymutil -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s
---
triple: 'i386-apple-darwin'
objects:
- filename: libfat-test.a(fat-test.o)
symbols:
- { sym: _i386_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 }
...
# CHECK: .debug_info contents:
# CHECK: DW_TAG_variable
# CHECK-NOT: {{DW_TAG|NULL}}
# CHECK: DW_AT_name{{.*}}"i386_var"

View File

@@ -0,0 +1,16 @@
# REQUIRES: object-emission
# RUN: llvm-dsymutil -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s
---
triple: 'x86_64-apple-darwin'
objects:
- filename: fat-test.o
symbols:
- { sym: _x86_64_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 }
...
# CHECK: .debug_info contents:
# CHECK: DW_TAG_variable
# CHECK-NOT: {{DW_TAG|NULL}}
# CHECK: DW_AT_name{{.*}}"x86_64_var"

View File

@@ -0,0 +1,16 @@
# REQUIRES: object-emission
# RUN: llvm-dsymutil -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s
---
triple: 'x86_64h-apple-darwin'
objects:
- filename: fat-test.o
symbols:
- { sym: _x86_64h_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 }
...
# CHECK: .debug_info contents:
# CHECK: DW_TAG_variable
# CHECK-NOT: {{DW_TAG|NULL}}
# CHECK: DW_AT_name{{.*}}"x86_64h_var"