1# RUN: echo -n AAAB > %t.diff 2# RUN: echo -n AAA > %t.smaller 3# RUN: echo -n AAAAAAAAA > %t.larger 4 5# RUN: yaml2obj --docnum=1 %s -o %t 6 7# RUN: llvm-objcopy --update-section __TEXT,__text=%t.diff %t - | obj2yaml | FileCheck %s 8# CHECK: content: '41414142' 9 10# RUN: llvm-objcopy --update-section __TEXT,__text=%t.smaller %t - | obj2yaml | FileCheck %s --check-prefix=SMALLER 11# SMALLER: content: '414141' 12 13# RUN: not llvm-objcopy --update-section __TEXT,__text=%t.larger %t /dev/null 2>&1 | FileCheck %s --check-prefix=TOO-LARGE 14# TOO-LARGE: error: {{.*}}new section cannot be larger than previous section 15 16# RUN: not llvm-objcopy --update-section __TEXT,__text=%t.noexist %t /dev/null 17 18# RUN: not llvm-objcopy --update-section __NOEXIST,__text=%t.diff %t /dev/null 2>&1 | FileCheck %s --check-prefix=NO-SEGMENT 19# NO-SEGMENT: error: {{.*}}could not find segment with name '__NOEXIST' 20 21# RUN: not llvm-objcopy --update-section __TEXT,__noexist=%t.diff %t /dev/null 2>&1 | FileCheck %s --check-prefix=NO-SECTION 22# NO-SECTION: error: {{.*}}could not find section with name '__noexist' 23 24# RUN: yaml2obj --docnum=2 %s -o %t 25 26# RUN: llvm-objcopy --update-section __TEXT,__text=%t.diff %t - | obj2yaml | FileCheck %s --check-prefix=FULL-SECNAME 27# FULL-SECNAME: content: '41414142' 28 29# RUN: not llvm-objcopy --update-section __text=%t.diff %t /dev/null 2>&1 | FileCheck %s --check-prefix=NON-CANONICAL-SECNAME 30# NON-CANONICAL-SECNAME: error: {{.*}}invalid section name '__text' (should be formatted as '<segment name>,<section name>') 31 32--- !mach-o 33FileHeader: 34 magic: 0xFEEDFACF 35 cputype: 0x01000007 36 cpusubtype: 0x00000003 37 filetype: 0x00000001 38 ncmds: 1 39 sizeofcmds: 152 40 flags: 0x00002000 41 reserved: 0x00000000 42LoadCommands: 43 - cmd: LC_SEGMENT_64 44 cmdsize: 152 45 segname: __TEXT 46 vmaddr: 0 47 vmsize: 4 48 fileoff: 184 49 filesize: 4 50 maxprot: 7 51 initprot: 7 52 nsects: 1 53 flags: 0 54 Sections: 55 - sectname: __text 56 segname: __TEXT 57 addr: 0x0000000000000000 58 content: '41414141' 59 size: 4 60 offset: 184 61 align: 0 62 reloff: 0x00000000 63 nreloc: 0 64 flags: 0x80000400 65 reserved1: 0x00000000 66 reserved2: 0x00000000 67 reserved3: 0x00000000 68 69--- !mach-o 70FileHeader: 71 magic: 0xFEEDFACF 72 cputype: 0x01000007 73 cpusubtype: 0x00000003 74 filetype: 0x00000001 75 ncmds: 1 76 sizeofcmds: 312 77 flags: 0x00002000 78 reserved: 0x00000000 79LoadCommands: 80 - cmd: LC_SEGMENT_64 81 cmdsize: 312 82 segname: '__TEXT' 83 vmaddr: 0 84 vmsize: 12 85 fileoff: 344 86 filesize: 12 87 maxprot: 7 88 initprot: 7 89 nsects: 3 90 flags: 0 91 Sections: 92 - sectname: __text 93 segname: __TEXT 94 addr: 0x0000000000000000 95 content: 'AABBCCDD' 96 size: 4 97 offset: 344 98 align: 0 99 reloff: 0x00000000 100 nreloc: 0 101 flags: 0x80000400 102 reserved1: 0x00000000 103 reserved2: 0x00000000 104 - sectname: __text 105 segname: __TEXT2 106 addr: 0x0000000000000004 107 content: '' 108 size: 0 109 offset: 348 110 align: 0 111 reloff: 0x00000000 112 nreloc: 0 113 flags: 0x00000000 114 reserved1: 0x00000000 115 reserved2: 0x00000000 116