1## Show that if --remove-section is given, llvm-objcopy removes sections 2## specified by the option. 3 4# RUN: yaml2obj %s -o %t 5 6## Remove only __TEXT,__text section. 7# RUN: llvm-objcopy --remove-section __TEXT,__text %t %t2 8# RUN: llvm-readobj --sections --section-data %t2 \ 9# RUN: | FileCheck %s --check-prefixes=COMMON,REMOVE-TEXT-ONLY 10 11## Remove multiple sections. 12# RUN: llvm-objcopy --remove-section __TEXT,__text --remove-section __DATA,__data %t %t3 13# RUN: llvm-readobj --sections --section-data %t3 \ 14# RUN: | FileCheck %s --check-prefixes=COMMON,REMOVE-TEXT-AND-DATA 15 16# COMMON: Sections [ 17# REMOVE-TEXT-ONLY-NEXT: Section { 18# REMOVE-TEXT-ONLY-NEXT: Index: 0 19# REMOVE-TEXT-ONLY-NEXT: Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00) 20# REMOVE-TEXT-ONLY-NEXT: Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00) 21# REMOVE-TEXT-ONLY-NEXT: Address: 0x4 22# REMOVE-TEXT-ONLY-NEXT: Size: 0x4 23# REMOVE-TEXT-ONLY-NEXT: Offset: 264 24# REMOVE-TEXT-ONLY-NEXT: Alignment: 0 25# REMOVE-TEXT-ONLY-NEXT: RelocationOffset: 0x0 26# REMOVE-TEXT-ONLY-NEXT: RelocationCount: 0 27# REMOVE-TEXT-ONLY-NEXT: Type: Regular (0x0) 28# REMOVE-TEXT-ONLY-NEXT: Attributes [ (0x0) 29# REMOVE-TEXT-ONLY-NEXT: ] 30# REMOVE-TEXT-ONLY-NEXT: Reserved1: 0x0 31# REMOVE-TEXT-ONLY-NEXT: Reserved2: 0x0 32# REMOVE-TEXT-ONLY-NEXT: Reserved3: 0x0 33# REMOVE-TEXT-ONLY-NEXT: SectionData ( 34# REMOVE-TEXT-ONLY-NEXT: 0000: DDAADDAA |....| 35# REMOVE-TEXT-ONLY-NEXT: ) 36# REMOVE-TEXT-ONLY-NEXT: } 37# COMMON-NEXT: Section { 38# REMOVE-TEXT-ONLY-NEXT: Index: 1 39# REMOVE-TEXT-AND-DATA-NEXT: Index: 0 40# COMMON-NEXT: Name: __const (5F 5F 63 6F 6E 73 74 00 00 00 00 00 00 00 00 00) 41# COMMON-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00) 42# COMMON-NEXT: Address: 0x8 43# COMMON-NEXT: Size: 0x4 44# REMOVE-TEXT-ONLY-NEXT: Offset: 268 45# REMOVE-TEXT-AND-DATA-NEXT: Offset: 184 46# COMMON-NEXT: Alignment: 0 47# COMMON-NEXT: RelocationOffset: 0x0 48# COMMON-NEXT: RelocationCount: 0 49# COMMON-NEXT: Type: Regular (0x0) 50# COMMON-NEXT: Attributes [ (0x0) 51# COMMON-NEXT: ] 52# COMMON-NEXT: Reserved1: 0x0 53# COMMON-NEXT: Reserved2: 0x0 54# COMMON-NEXT: Reserved3: 0x0 55# COMMON-NEXT: SectionData ( 56# COMMON-NEXT: 0000: EEFFEEFF |....| 57# COMMON-NEXT: ) 58# COMMON-NEXT: } 59# COMMON-NEXT: ] 60 61## Keep all sections if the specified section name is not present in the 62## input. The output file should be the same as the input. 63# RUN: llvm-objcopy --remove-section __TEXT,__foo %t %t4 64# RUN: cmp %t %t4 65 66--- !mach-o 67FileHeader: 68 magic: 0xFEEDFACF 69 cputype: 0x01000007 70 cpusubtype: 0x00000003 71 filetype: 0x00000001 72 ncmds: 1 73 sizeofcmds: 312 74 flags: 0x00002000 75 reserved: 0x00000000 76LoadCommands: 77 - cmd: LC_SEGMENT_64 78 cmdsize: 312 79 segname: '' 80 vmaddr: 0 81 vmsize: 12 82 fileoff: 344 83 filesize: 12 84 maxprot: 7 85 initprot: 7 86 nsects: 3 87 flags: 0 88 Sections: 89 - sectname: __text 90 segname: __TEXT 91 addr: 0x0000000000000000 92 content: 'AABBCCDD' 93 size: 4 94 offset: 344 95 align: 0 96 reloff: 0x00000000 97 nreloc: 0 98 flags: 0x80000400 99 reserved1: 0x00000000 100 reserved2: 0x00000000 101 reserved3: 0x00000000 102 - sectname: __data 103 segname: __DATA 104 addr: 0x0000000000000004 105 content: 'DDAADDAA' 106 size: 4 107 offset: 348 108 align: 0 109 reloff: 0x00000000 110 nreloc: 0 111 flags: 0x00000000 112 reserved1: 0x00000000 113 reserved2: 0x00000000 114 reserved3: 0x00000000 115 - sectname: __const 116 segname: __TEXT 117 addr: 0x0000000000000008 118 content: 'EEFFEEFF' 119 size: 4 120 offset: 352 121 align: 0 122 reloff: 0x00000000 123 nreloc: 0 124 flags: 0x00000000 125 reserved1: 0x00000000 126 reserved2: 0x00000000 127 reserved3: 0x00000000 128