1# RUN: yaml2obj %s -o %t 2# RUN: not llvm-objcopy --remove-section __DATA,C %t /dev/null 2>&1 | FileCheck %s 3 4# CHECK: symbol '_a' defined in section with index '2' cannot be removed because it is referenced by a relocation in section '__TEXT,__text' 5 6## The binary used in this test was built as follows: 7## main.c: 8## __attribute__((section("__DATA,C"))) int a = 2; 9## int f() { return a; } 10## build command: 11## clang -fno-exceptions -fno-unwind-tables -c main.c -o main.o 12 13--- !mach-o 14FileHeader: 15 magic: 0xFEEDFACF 16 cputype: 0x01000007 17 cpusubtype: 0x00000003 18 filetype: 0x00000001 19 ncmds: 4 20 sizeofcmds: 360 21 flags: 0x00002000 22 reserved: 0x00000000 23LoadCommands: 24 - cmd: LC_SEGMENT_64 25 cmdsize: 232 26 segname: '' 27 vmaddr: 0 28 vmsize: 16 29 fileoff: 392 30 filesize: 16 31 maxprot: 7 32 initprot: 7 33 nsects: 2 34 flags: 0 35 Sections: 36 - sectname: __text 37 segname: __TEXT 38 addr: 0x0000000000000000 39 size: 12 40 offset: 0x00000188 41 align: 4 42 reloff: 0x00000198 43 nreloc: 1 44 flags: 0x80000400 45 reserved1: 0x00000000 46 reserved2: 0x00000000 47 reserved3: 0x00000000 48 content: 554889E58B05000000005DC3 49 relocations: 50 - address: 0x00000006 51 symbolnum: 0 52 pcrel: true 53 length: 2 54 extern: true 55 type: 1 56 scattered: false 57 value: 0 58 - sectname: C 59 segname: __DATA 60 addr: 0x000000000000000C 61 size: 4 62 offset: 0x00000194 63 align: 2 64 reloff: 0x00000000 65 nreloc: 0 66 flags: 0x00000000 67 reserved1: 0x00000000 68 reserved2: 0x00000000 69 reserved3: 0x00000000 70 content: '02000000' 71 - cmd: LC_BUILD_VERSION 72 cmdsize: 24 73 platform: 1 74 minos: 658944 75 sdk: 658944 76 ntools: 0 77 - cmd: LC_SYMTAB 78 cmdsize: 24 79 symoff: 416 80 nsyms: 2 81 stroff: 448 82 strsize: 8 83 - cmd: LC_DYSYMTAB 84 cmdsize: 80 85 ilocalsym: 0 86 nlocalsym: 0 87 iextdefsym: 0 88 nextdefsym: 2 89 iundefsym: 2 90 nundefsym: 0 91 tocoff: 0 92 ntoc: 0 93 modtaboff: 0 94 nmodtab: 0 95 extrefsymoff: 0 96 nextrefsyms: 0 97 indirectsymoff: 0 98 nindirectsyms: 0 99 extreloff: 0 100 nextrel: 0 101 locreloff: 0 102 nlocrel: 0 103LinkEditData: 104 NameList: 105 - n_strx: 4 106 n_type: 0x0F 107 n_sect: 2 108 n_desc: 0 109 n_value: 12 110 - n_strx: 1 111 n_type: 0x0F 112 n_sect: 1 113 n_desc: 0 114 n_value: 0 115 StringTable: 116 - '' 117 - _f 118 - _a 119 - '' 120... 121