121 lines · plain
1# RUN: yaml2obj %s -o %t2# RUN: not llvm-objcopy --remove-section __DATA,C %t /dev/null 2>&1 | FileCheck %s3 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.o12 13--- !mach-o14FileHeader:15 magic: 0xFEEDFACF16 cputype: 0x0100000717 cpusubtype: 0x0000000318 filetype: 0x0000000119 ncmds: 420 sizeofcmds: 36021 flags: 0x0000200022 reserved: 0x0000000023LoadCommands:24 - cmd: LC_SEGMENT_6425 cmdsize: 23226 segname: ''27 vmaddr: 028 vmsize: 1629 fileoff: 39230 filesize: 1631 maxprot: 732 initprot: 733 nsects: 234 flags: 035 Sections:36 - sectname: __text37 segname: __TEXT38 addr: 0x000000000000000039 size: 1240 offset: 0x0000018841 align: 442 reloff: 0x0000019843 nreloc: 144 flags: 0x8000040045 reserved1: 0x0000000046 reserved2: 0x0000000047 reserved3: 0x0000000048 content: 554889E58B05000000005DC349 relocations:50 - address: 0x0000000651 symbolnum: 052 pcrel: true53 length: 254 extern: true55 type: 156 scattered: false57 value: 058 - sectname: C59 segname: __DATA60 addr: 0x000000000000000C61 size: 462 offset: 0x0000019463 align: 264 reloff: 0x0000000065 nreloc: 066 flags: 0x0000000067 reserved1: 0x0000000068 reserved2: 0x0000000069 reserved3: 0x0000000070 content: '02000000'71 - cmd: LC_BUILD_VERSION72 cmdsize: 2473 platform: 174 minos: 65894475 sdk: 65894476 ntools: 077 - cmd: LC_SYMTAB78 cmdsize: 2479 symoff: 41680 nsyms: 281 stroff: 44882 strsize: 883 - cmd: LC_DYSYMTAB84 cmdsize: 8085 ilocalsym: 086 nlocalsym: 087 iextdefsym: 088 nextdefsym: 289 iundefsym: 290 nundefsym: 091 tocoff: 092 ntoc: 093 modtaboff: 094 nmodtab: 095 extrefsymoff: 096 nextrefsyms: 097 indirectsymoff: 098 nindirectsyms: 099 extreloff: 0100 nextrel: 0101 locreloff: 0102 nlocrel: 0103LinkEditData:104 NameList:105 - n_strx: 4106 n_type: 0x0F107 n_sect: 2108 n_desc: 0109 n_value: 12110 - n_strx: 1111 n_type: 0x0F112 n_sect: 1113 n_desc: 0114 n_value: 0115 StringTable:116 - ''117 - _f118 - _a119 - ''120...121