forked from OSchip/llvm-project
139 lines
4.3 KiB
YAML
139 lines
4.3 KiB
YAML
## Stub dylibs differ from "real" dylibs in that they lack any content in their
|
|
## sections. What they do have are export tries and symbol tables, which means
|
|
## we can still link against them. I (jezng) am unclear how to properly create
|
|
## these stub dylibs; XCode 11.3's `lipo` is able to create stub dylibs, but
|
|
## those lack LC_ID_DYLIB load commands and are considered invalid by most
|
|
## tooling. Newer versions of `lipo` aren't able to create stub dylibs at all.
|
|
## However, recent SDKs in XCode still come with valid stub dylibs, so it still
|
|
## seems worthwhile to support them. The YAML in this test was generated by
|
|
## taking a non-stub dylib and editing the appropriate fields.
|
|
|
|
# REQUIRES: x86
|
|
# RUN: rm -rf %t; split-file %s %t
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
|
|
# RUN: yaml2obj %t/fat.dylib.yaml > %t/fat.dylib
|
|
# RUN: %lld -lSystem %t/test.o %t/fat.dylib -o %t/test
|
|
# RUN: llvm-objdump --macho --lazy-bind %t/test | FileCheck %s
|
|
# CHECK: __DATA __la_symbol_ptr 0x100002000 foo _foo
|
|
|
|
#--- test.s
|
|
.globl _main
|
|
_main:
|
|
callq _foo
|
|
ret
|
|
|
|
#--- fat.dylib.yaml
|
|
--- !fat-mach-o
|
|
FatHeader:
|
|
magic: 0xCAFEBABE
|
|
nfat_arch: 1
|
|
FatArchs:
|
|
- cputype: 0x01000007
|
|
cpusubtype: 0x00000003
|
|
offset: 0x0000000000001000
|
|
size: 16432
|
|
align: 12
|
|
Slices:
|
|
- !mach-o
|
|
FileHeader:
|
|
magic: 0xFEEDFACF
|
|
cputype: 0x01000007
|
|
cpusubtype: 0x00000003
|
|
filetype: 0x00000009
|
|
ncmds: 5
|
|
sizeofcmds: 568
|
|
flags: 0x00100085
|
|
reserved: 0x00000000
|
|
LoadCommands:
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 232
|
|
segname: __TEXT
|
|
vmaddr: 0
|
|
vmsize: 16384
|
|
fileoff: 0
|
|
filesize: 16384
|
|
maxprot: 5
|
|
initprot: 5
|
|
nsects: 1
|
|
flags: 0
|
|
Sections:
|
|
- sectname: __text
|
|
segname: __TEXT
|
|
addr: 0x0000000000000000
|
|
size: 0
|
|
offset: 0x00003FB7
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x80000400
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
content: ''
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 72
|
|
segname: __LINKEDIT
|
|
vmaddr: 16384
|
|
vmsize: 16384
|
|
fileoff: 16384
|
|
filesize: 48
|
|
maxprot: 1
|
|
initprot: 1
|
|
nsects: 0
|
|
flags: 0
|
|
- cmd: LC_ID_DYLIB
|
|
cmdsize: 40
|
|
dylib:
|
|
name: 24
|
|
timestamp: 1
|
|
current_version: 0
|
|
compatibility_version: 0
|
|
PayloadString: foo.dylib
|
|
ZeroPadBytes: 7
|
|
- cmd: LC_DYLD_INFO_ONLY
|
|
cmdsize: 48
|
|
rebase_off: 0
|
|
rebase_size: 0
|
|
bind_off: 0
|
|
bind_size: 0
|
|
weak_bind_off: 0
|
|
weak_bind_size: 0
|
|
lazy_bind_off: 0
|
|
lazy_bind_size: 0
|
|
export_off: 16384
|
|
export_size: 16
|
|
- cmd: LC_SYMTAB
|
|
cmdsize: 24
|
|
symoff: 16408
|
|
nsyms: 1
|
|
stroff: 16424
|
|
strsize: 8
|
|
LinkEditData:
|
|
ExportTrie:
|
|
TerminalSize: 0
|
|
NodeOffset: 0
|
|
Name: ''
|
|
Flags: 0x0000000000000000
|
|
Address: 0x0000000000000000
|
|
Other: 0x0000000000000000
|
|
ImportName: ''
|
|
Children:
|
|
- TerminalSize: 3
|
|
NodeOffset: 8
|
|
Name: _foo
|
|
Flags: 0x0000000000000000
|
|
Address: 0x0000000000003FB7
|
|
Other: 0x0000000000000000
|
|
ImportName: ''
|
|
NameList:
|
|
- n_strx: 2
|
|
n_type: 0x0F
|
|
n_sect: 1
|
|
n_desc: 0
|
|
n_value: 16311
|
|
StringTable:
|
|
- ' '
|
|
- _foo
|
|
- ''
|
|
...
|