File: dylib-stub.yaml

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (138 lines) | stat: -rw-r--r-- 4,422 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
## 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
        Content:         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
        - ''
...