xref: /llvm-project/llvm/test/tools/llvm-objcopy/MachO/dump-section-before-add-remove.test (revision 12e5b02687af0ddc21abfdd17afbc2176fdaa3f9)
1# RUN: yaml2obj %s -o %t
2
3## Verify that section is dumped before it is removed.
4# RUN: llvm-objcopy --dump-section __TEXT,__text=%t1.dump --remove-section __TEXT,__text %t %t1
5# RUN: FileCheck %s --input-file=%t1.dump --check-prefix=CONTENTS --implicit-check-not={{.}}
6
7# CONTENTS: abcd
8
9## Verify that the newly added section is not dumped.
10# RUN: echo CAFE > %t2.txt
11# RUN: not llvm-objcopy --dump-section __TEXT,__const=%t2.dump --add-section __TEXT,__const=%t2.txt %t %t2 2>&1 | \
12# RUN:     FileCheck %s --check-prefix=NODUMP -DINPUT=%t
13
14# NODUMP: error: '[[INPUT]]': section '__TEXT,__const' not found
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:      0x00002000
25  reserved:   0x00000000
26LoadCommands:
27  - cmd:      LC_SEGMENT_64
28    cmdsize:  312
29    segname:  ''
30    vmaddr:   0
31    vmsize:   12
32    fileoff:  344
33    filesize: 12
34    maxprot:  7
35    initprot: 7
36    nsects:   3
37    flags:    0
38    Sections:
39      - sectname:   __text
40        segname:    __TEXT
41        addr:       0x0000000000000000
42        content:    '61626364'
43        size:       4
44        offset:     344
45        align:      0
46        reloff:     0x00000000
47        nreloc:     0
48        flags:      0x80000400
49        reserved1:  0x00000000
50        reserved2:  0x00000000
51      - sectname:   __data
52        segname:    __DATA
53        addr:       0x0000000000000004
54        content:    'EEFFEEFF'
55        size:       4
56        offset:     348
57        align:      0
58        reloff:     0x00000000
59        nreloc:     0
60        flags:      0x00000000
61        reserved1:  0x00000000
62        reserved2:  0x00000000
63