xref: /llvm-project/llvm/test/tools/llvm-objcopy/MachO/relocations.test (revision 0db3a5a93e113d681e78ea5f7dd8cd1020d02a7b)
1# RUN: yaml2obj %s -o %t
2
3## Show that llvm-objcopy copies relocation entries where r_extern = 0.
4# RUN: llvm-objcopy %t %t2
5# RUN: cmp %t %t2
6
7## Show that llvm-objcopy updates section indices properly.
8# RUN: llvm-objcopy --remove-section=__DATA,__foo %t %t3
9# RUN: llvm-objdump --macho --reloc %t3 | FileCheck %s
10
11# CHECK:      Relocation information (__DATA,__bar) 2 entries
12# CHECK-NEXT: address  pcrel length extern type    scattered symbolnum/value
13# CHECK-NEXT: 00000000 False quad   False  SUB     False     2 (__DATA,__bar)
14# CHECK-NEXT: 00000000 False quad   False  UNSIGND False     1 (__TEXT,__text)
15
16--- !mach-o
17FileHeader:
18  magic:           0xFEEDFACF
19  cputype:         0x01000007
20  cpusubtype:      0x00000003
21  filetype:        0x00000001
22  ncmds:           1
23  sizeofcmds:      312
24  flags:           0x00000000
25  reserved:        0x00000000
26LoadCommands:
27  - cmd:             LC_SEGMENT_64
28    cmdsize:         312
29    segname:         ''
30    vmaddr:          0
31    vmsize:          24
32    fileoff:         344
33    filesize:        24
34    maxprot:         7
35    initprot:        7
36    nsects:          3
37    flags:           0
38    Sections:
39      - sectname:        __text
40        segname:         __TEXT
41        addr:            0x0000000000000000
42        size:            8
43        offset:          0x00000158
44        align:           0
45        reloff:          0x00000000
46        nreloc:          0
47        flags:           0x80000000
48        reserved1:       0x00000000
49        reserved2:       0x00000000
50        reserved3:       0x00000000
51        content:         '0000000000000000'
52      - sectname:        __foo
53        segname:         __DATA
54        addr:            0x0000000000000008
55        size:            8
56        offset:          0x00000160
57        align:           0
58        reloff:          0x00000000
59        nreloc:          0
60        flags:           0x00000000
61        reserved1:       0x00000000
62        reserved2:       0x00000000
63        reserved3:       0x00000000
64        content:         '0000000000000000'
65      - sectname:        __bar
66        segname:         __DATA
67        addr:            0x0000000000000010
68        size:            8
69        offset:          0x00000168
70        align:           0
71        reloff:          0x00000170
72        nreloc:          2
73        flags:           0x00000000
74        reserved1:       0x00000000
75        reserved2:       0x00000000
76        reserved3:       0x00000000
77        content:         F0FFFFFFFFFFFFFF
78        relocations:
79          - address:         0x00000000
80            symbolnum:       3
81            pcrel:           false
82            length:          3
83            extern:          false
84            type:            5
85            scattered:       false
86            value:           0
87          - address:         0x00000000
88            symbolnum:       1
89            pcrel:           false
90            length:          3
91            extern:          false
92            type:            0
93            scattered:       false
94            value:           0
95...
96