1// RUN: llvm-mc -triple i386-apple-darwin10 %s -filetype=obj -o %t.o 2// RUN: llvm-readobj --file-headers -S --sd -r --symbols --macho-segment --macho-dysymtab --macho-indirect-symbols < %t.o - > %t.dump 3// RUN: FileCheck --check-prefix=CHECK-I386 < %t.dump %s 4 5// RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o %t.o 6// RUN: llvm-readobj --file-headers -S --sd -r --symbols --macho-segment --macho-dysymtab --macho-indirect-symbols < %t.o - > %t.dump 7// RUN: FileCheck --check-prefix=CHECK-X86_64 < %t.dump %s 8 9.data 10 11 .long 0 12a: 13 .long 0 14b = a 15 16c: .long b 17 18d2 = d 19.globl d2 20d3 = d + 4 21.globl d3 22 23e = a + 4 24 25g: 26f = g 27 .long 0 28 29 .long b 30 .long e 31 .long a + 4 32 .long d 33 .long d2 34 .long d3 35 .long f 36 .long g 37 38/// 39 .text 40t0: 41Lt0_a: 42 ret 43 44 .data 45Lt0_b: 46Lt0_x = Lt0_a - Lt0_b 47 .quad Lt0_x 48 49// CHECK-I386: File: <stdin> 50// CHECK-I386: Format: Mach-O 32-bit i386 51// CHECK-I386: Arch: i386 52// CHECK-I386: AddressSize: 32bit 53// CHECK-I386: MachHeader { 54// CHECK-I386: Magic: Magic (0xFEEDFACE) 55// CHECK-I386: CpuType: X86 (0x7) 56// CHECK-I386: CpuSubType: CPU_SUBTYPE_I386_ALL (0x3) 57// CHECK-I386: FileType: Relocatable (0x1) 58// CHECK-I386: NumOfLoadCommands: 4 59// CHECK-I386: SizeOfLoadCommands: 312 60// CHECK-I386: Flags [ (0x0) 61// CHECK-I386: ] 62// CHECK-I386: } 63// CHECK-I386: Sections [ 64// CHECK-I386: Section { 65// CHECK-I386: Index: 0 66// CHECK-I386: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00) 67// CHECK-I386: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00) 68// CHECK-I386: Address: 0x0 69// CHECK-I386: Size: 0x1 70// CHECK-I386: Offset: 340 71// CHECK-I386: Alignment: 0 72// CHECK-I386: RelocationOffset: 0x0 73// CHECK-I386: RelocationCount: 0 74// CHECK-I386: Type: Regular (0x0) 75// CHECK-I386: Attributes [ (0x800004) 76// CHECK-I386: PureInstructions (0x800000) 77// CHECK-I386: SomeInstructions (0x4) 78// CHECK-I386: ] 79// CHECK-I386: Reserved1: 0x0 80// CHECK-I386: Reserved2: 0x0 81// CHECK-I386: SectionData ( 82// CHECK-I386: 0000: C3 |.| 83// CHECK-I386: ) 84// CHECK-I386: } 85// CHECK-I386: Section { 86// CHECK-I386: Index: 1 87// CHECK-I386: Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00) 88// CHECK-I386: Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00) 89// CHECK-I386: Address: 0x1 90// CHECK-I386: Size: 0x38 91// CHECK-I386: Offset: 341 92// CHECK-I386: Alignment: 0 93// CHECK-I386: RelocationOffset: 0x190 94// CHECK-I386: RelocationCount: 9 95// CHECK-I386: Type: Regular (0x0) 96// CHECK-I386: Attributes [ (0x0) 97// CHECK-I386: ] 98// CHECK-I386: Reserved1: 0x0 99// CHECK-I386: Reserved2: 0x0 100// CHECK-I386: SectionData ( 101// CHECK-I386: 0000: 00000000 00000000 05000000 00000000 |................| 102// CHECK-I386: 0010: 05000000 09000000 09000000 00000000 |................| 103// CHECK-I386: 0020: 00000000 00000000 0D000000 0D000000 |................| 104// CHECK-I386: 0030: CFFFFFFF FFFFFFFF |........| 105// CHECK-I386: ) 106// CHECK-I386: } 107// CHECK-I386: ] 108// CHECK-I386: Relocations [ 109// CHECK-I386: Section __data { 110// CHECK-I386: 0x2C 0 2 0 GENERIC_RELOC_VANILLA 0 __data 111// CHECK-I386: 0x28 0 2 0 GENERIC_RELOC_VANILLA 0 __data 112// CHECK-I386: 0x24 0 2 1 GENERIC_RELOC_VANILLA 0 d3 113// CHECK-I386: 0x20 0 2 1 GENERIC_RELOC_VANILLA 0 d{{$}} 114// CHECK-I386: 0x1C 0 2 1 GENERIC_RELOC_VANILLA 0 d{{$}} 115// CHECK-I386: 0x18 0 2 n/a GENERIC_RELOC_VANILLA 1 0x5 116// CHECK-I386: 0x14 0 2 0 GENERIC_RELOC_VANILLA 0 __data 117// CHECK-I386: 0x10 0 2 0 GENERIC_RELOC_VANILLA 0 __data 118// CHECK-I386: 0x8 0 2 0 GENERIC_RELOC_VANILLA 0 __data 119// CHECK-I386: } 120// CHECK-I386: ] 121// CHECK-I386: Symbols [ 122// CHECK-I386: Symbol { 123// CHECK-I386: Name: a (13) 124// CHECK-I386: Type: Section (0xE) 125// CHECK-I386: Section: __data (0x2) 126// CHECK-I386: RefType: UndefinedNonLazy (0x0) 127// CHECK-I386: Flags [ (0x0) 128// CHECK-I386: ] 129// CHECK-I386: Value: 0x5 130// CHECK-I386: } 131// CHECK-I386: Symbol { 132// CHECK-I386: Name: b (11) 133// CHECK-I386: Type: Section (0xE) 134// CHECK-I386: Section: __data (0x2) 135// CHECK-I386: RefType: UndefinedNonLazy (0x0) 136// CHECK-I386: Flags [ (0x0) 137// CHECK-I386: ] 138// CHECK-I386: Value: 0x5 139// CHECK-I386: } 140// CHECK-I386: Symbol { 141// CHECK-I386: Name: c (9) 142// CHECK-I386: Type: Section (0xE) 143// CHECK-I386: Section: __data (0x2) 144// CHECK-I386: RefType: UndefinedNonLazy (0x0) 145// CHECK-I386: Flags [ (0x0) 146// CHECK-I386: ] 147// CHECK-I386: Value: 0x9 148// CHECK-I386: } 149// CHECK-I386: Symbol { 150// CHECK-I386: Name: e (5) 151// CHECK-I386: Type: Section (0xE) 152// CHECK-I386: Section: __data (0x2) 153// CHECK-I386: RefType: UndefinedNonLazy (0x0) 154// CHECK-I386: Flags [ (0x200) 155// CHECK-I386: ] 156// CHECK-I386: Value: 0x9 157// CHECK-I386: } 158// CHECK-I386: Symbol { 159// CHECK-I386: Name: g (1) 160// CHECK-I386: Type: Section (0xE) 161// CHECK-I386: Section: __data (0x2) 162// CHECK-I386: RefType: UndefinedNonLazy (0x0) 163// CHECK-I386: Flags [ (0x0) 164// CHECK-I386: ] 165// CHECK-I386: Value: 0xD 166// CHECK-I386: } 167// CHECK-I386: Symbol { 168// CHECK-I386: Name: f (3) 169// CHECK-I386: Type: Section (0xE) 170// CHECK-I386: Section: __data (0x2) 171// CHECK-I386: RefType: UndefinedNonLazy (0x0) 172// CHECK-I386: Flags [ (0x0) 173// CHECK-I386: ] 174// CHECK-I386: Value: 0xD 175// CHECK-I386: } 176// CHECK-I386: Symbol { 177// CHECK-I386: Name: t0 (21) 178// CHECK-I386: Type: Section (0xE) 179// CHECK-I386: Section: __text (0x1) 180// CHECK-I386: RefType: UndefinedNonLazy (0x0) 181// CHECK-I386: Flags [ (0x0) 182// CHECK-I386: ] 183// CHECK-I386: Value: 0x0 184// CHECK-I386: } 185// CHECK-I386: Symbol { 186// CHECK-I386: Name: d (7) 187// CHECK-I386: Extern 188// CHECK-I386: Type: Undef (0x0) 189// CHECK-I386: Section: (0x0) 190// CHECK-I386: RefType: UndefinedNonLazy (0x0) 191// CHECK-I386: Flags [ (0x0) 192// CHECK-I386: ] 193// CHECK-I386: Value: 0x0 194// CHECK-I386: } 195// CHECK-I386: Symbol { 196// CHECK-I386: Name: d2 (18) 197// CHECK-I386: Extern 198// CHECK-I386: Type: Indirect (0xA) 199// CHECK-I386: Section: (0x0) 200// CHECK-I386: RefType: UndefinedNonLazy (0x0) 201// CHECK-I386: Flags [ (0x0) 202// CHECK-I386: ] 203// CHECK-I386: Value: 0x7 204// CHECK-I386: } 205// CHECK-I386: Symbol { 206// CHECK-I386: Name: d3 (15) 207// CHECK-I386: Extern 208// CHECK-I386: Type: Undef (0x0) 209// CHECK-I386: Section: (0x0) 210// CHECK-I386: RefType: UndefinedNonLazy (0x0) 211// CHECK-I386: Flags [ (0x200) 212// CHECK-I386: ] 213// CHECK-I386: Value: 0x0 214// CHECK-I386: } 215// CHECK-I386: ] 216// CHECK-I386: Indirect Symbols { 217// CHECK-I386: Number: 0 218// CHECK-I386: Symbols [ 219// CHECK-I386: ] 220// CHECK-I386: } 221// CHECK-I386: Segment { 222// CHECK-I386: Cmd: LC_SEGMENT 223// CHECK-I386: Name: 224// CHECK-I386: Size: 192 225// CHECK-I386: vmaddr: 0x0 226// CHECK-I386: vmsize: 0x39 227// CHECK-I386: fileoff: 340 228// CHECK-I386: filesize: 57 229// CHECK-I386: maxprot: rwx 230// CHECK-I386: initprot: rwx 231// CHECK-I386: nsects: 2 232// CHECK-I386: flags: 0x0 233// CHECK-I386: } 234// CHECK-I386: Dysymtab { 235// CHECK-I386: ilocalsym: 0 236// CHECK-I386: nlocalsym: 7 237// CHECK-I386: iextdefsym: 7 238// CHECK-I386: nextdefsym: 0 239// CHECK-I386: iundefsym: 7 240// CHECK-I386: nundefsym: 3 241// CHECK-I386: tocoff: 0 242// CHECK-I386: ntoc: 0 243// CHECK-I386: modtaboff: 0 244// CHECK-I386: nmodtab: 0 245// CHECK-I386: extrefsymoff: 0 246// CHECK-I386: nextrefsyms: 0 247// CHECK-I386: indirectsymoff: 0 248// CHECK-I386: nindirectsyms: 0 249// CHECK-I386: extreloff: 0 250// CHECK-I386: nextrel: 0 251// CHECK-I386: locreloff: 0 252// CHECK-I386: nlocrel: 0 253// CHECK-I386: } 254 255// CHECK-X86_64: File: <stdin> 256// CHECK-X86_64: Format: Mach-O 64-bit x86-64 257// CHECK-X86_64: Arch: x86_64 258// CHECK-X86_64: AddressSize: 64bit 259// CHECK-X86_64: MachHeader { 260// CHECK-X86_64: Magic: Magic64 (0xFEEDFACF) 261// CHECK-X86_64: CpuType: X86-64 (0x1000007) 262// CHECK-X86_64: CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3) 263// CHECK-X86_64: FileType: Relocatable (0x1) 264// CHECK-X86_64: NumOfLoadCommands: 4 265// CHECK-X86_64: SizeOfLoadCommands: 352 266// CHECK-X86_64: Flags [ (0x0) 267// CHECK-X86_64: ] 268// CHECK-X86_64: Reserved: 0x0 269// CHECK-X86_64: } 270// CHECK-X86_64: Sections [ 271// CHECK-X86_64: Section { 272// CHECK-X86_64: Index: 0 273// CHECK-X86_64: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00) 274// CHECK-X86_64: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00) 275// CHECK-X86_64: Address: 0x0 276// CHECK-X86_64: Size: 0x1 277// CHECK-X86_64: Offset: 384 278// CHECK-X86_64: Alignment: 0 279// CHECK-X86_64: RelocationOffset: 0x0 280// CHECK-X86_64: RelocationCount: 0 281// CHECK-X86_64: Type: Regular (0x0) 282// CHECK-X86_64: Attributes [ (0x800004) 283// CHECK-X86_64: PureInstructions (0x800000) 284// CHECK-X86_64: SomeInstructions (0x4) 285// CHECK-X86_64: ] 286// CHECK-X86_64: Reserved1: 0x0 287// CHECK-X86_64: Reserved2: 0x0 288// CHECK-X86_64: Reserved3: 0x0 289// CHECK-X86_64: SectionData ( 290// CHECK-X86_64: 0000: C3 |.| 291// CHECK-X86_64: ) 292// CHECK-X86_64: } 293// CHECK-X86_64: Section { 294// CHECK-X86_64: Index: 1 295// CHECK-X86_64: Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00) 296// CHECK-X86_64: Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00) 297// CHECK-X86_64: Address: 0x1 298// CHECK-X86_64: Size: 0x38 299// CHECK-X86_64: Offset: 385 300// CHECK-X86_64: Alignment: 0 301// CHECK-X86_64: RelocationOffset: 0x1C0 302// CHECK-X86_64: RelocationCount: 9 303// CHECK-X86_64: Type: Regular (0x0) 304// CHECK-X86_64: Attributes [ (0x0) 305// CHECK-X86_64: ] 306// CHECK-X86_64: Reserved1: 0x0 307// CHECK-X86_64: Reserved2: 0x0 308// CHECK-X86_64: Reserved3: 0x0 309// CHECK-X86_64: SectionData ( 310// CHECK-X86_64: 0000: 00000000 00000000 00000000 00000000 |................| 311// CHECK-X86_64: 0010: 00000000 00000000 04000000 00000000 |................| 312// CHECK-X86_64: 0020: 00000000 00000000 00000000 00000000 |................| 313// CHECK-X86_64: 0030: CFFFFFFF FFFFFFFF |........| 314// CHECK-X86_64: ) 315// CHECK-X86_64: } 316// CHECK-X86_64: ] 317// CHECK-X86_64: Relocations [ 318// CHECK-X86_64: Section __data { 319// CHECK-X86_64: 0x2C 0 2 1 X86_64_RELOC_UNSIGNED 0 g 320// CHECK-X86_64: 0x28 0 2 1 X86_64_RELOC_UNSIGNED 0 f 321// CHECK-X86_64: 0x24 0 2 1 X86_64_RELOC_UNSIGNED 0 d3 322// CHECK-X86_64: 0x20 0 2 1 X86_64_RELOC_UNSIGNED 0 d{{$}} 323// CHECK-X86_64: 0x1C 0 2 1 X86_64_RELOC_UNSIGNED 0 d{{$}} 324// CHECK-X86_64: 0x18 0 2 1 X86_64_RELOC_UNSIGNED 0 a 325// CHECK-X86_64: 0x14 0 2 1 X86_64_RELOC_UNSIGNED 0 e 326// CHECK-X86_64: 0x10 0 2 1 X86_64_RELOC_UNSIGNED 0 b 327// CHECK-X86_64: 0x8 0 2 1 X86_64_RELOC_UNSIGNED 0 b 328// CHECK-X86_64: } 329// CHECK-X86_64: ] 330// CHECK-X86_64: Symbols [ 331// CHECK-X86_64: Symbol { 332// CHECK-X86_64: Name: a (13) 333// CHECK-X86_64: Type: Section (0xE) 334// CHECK-X86_64: Section: __data (0x2) 335// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 336// CHECK-X86_64: Flags [ (0x0) 337// CHECK-X86_64: ] 338// CHECK-X86_64: Value: 0x5 339// CHECK-X86_64: } 340// CHECK-X86_64: Symbol { 341// CHECK-X86_64: Name: b (11) 342// CHECK-X86_64: Type: Section (0xE) 343// CHECK-X86_64: Section: __data (0x2) 344// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 345// CHECK-X86_64: Flags [ (0x0) 346// CHECK-X86_64: ] 347// CHECK-X86_64: Value: 0x5 348// CHECK-X86_64: } 349// CHECK-X86_64: Symbol { 350// CHECK-X86_64: Name: c (9) 351// CHECK-X86_64: Type: Section (0xE) 352// CHECK-X86_64: Section: __data (0x2) 353// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 354// CHECK-X86_64: Flags [ (0x0) 355// CHECK-X86_64: ] 356// CHECK-X86_64: Value: 0x9 357// CHECK-X86_64: } 358// CHECK-X86_64: Symbol { 359// CHECK-X86_64: Name: e (5) 360// CHECK-X86_64: Type: Section (0xE) 361// CHECK-X86_64: Section: __data (0x2) 362// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 363// CHECK-X86_64: Flags [ (0x200) 364// CHECK-X86_64: ] 365// CHECK-X86_64: Value: 0x9 366// CHECK-X86_64: } 367// CHECK-X86_64: Symbol { 368// CHECK-X86_64: Name: g (1) 369// CHECK-X86_64: Type: Section (0xE) 370// CHECK-X86_64: Section: __data (0x2) 371// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 372// CHECK-X86_64: Flags [ (0x0) 373// CHECK-X86_64: ] 374// CHECK-X86_64: Value: 0xD 375// CHECK-X86_64: } 376// CHECK-X86_64: Symbol { 377// CHECK-X86_64: Name: f (3) 378// CHECK-X86_64: Type: Section (0xE) 379// CHECK-X86_64: Section: __data (0x2) 380// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 381// CHECK-X86_64: Flags [ (0x0) 382// CHECK-X86_64: ] 383// CHECK-X86_64: Value: 0xD 384// CHECK-X86_64: } 385// CHECK-X86_64: Symbol { 386// CHECK-X86_64: Name: t0 (21) 387// CHECK-X86_64: Type: Section (0xE) 388// CHECK-X86_64: Section: __text (0x1) 389// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 390// CHECK-X86_64: Flags [ (0x0) 391// CHECK-X86_64: ] 392// CHECK-X86_64: Value: 0x0 393// CHECK-X86_64: } 394// CHECK-X86_64: Symbol { 395// CHECK-X86_64: Name: d (7) 396// CHECK-X86_64: Extern 397// CHECK-X86_64: Type: Undef (0x0) 398// CHECK-X86_64: Section: (0x0) 399// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 400// CHECK-X86_64: Flags [ (0x0) 401// CHECK-X86_64: ] 402// CHECK-X86_64: Value: 0x0 403// CHECK-X86_64: } 404// CHECK-X86_64: Symbol { 405// CHECK-X86_64: Name: d2 (18) 406// CHECK-X86_64: Extern 407// CHECK-X86_64: Type: Indirect (0xA) 408// CHECK-X86_64: Section: (0x0) 409// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 410// CHECK-X86_64: Flags [ (0x0) 411// CHECK-X86_64: ] 412// CHECK-X86_64: Value: 0x7 413// CHECK-X86_64: } 414// CHECK-X86_64: Symbol { 415// CHECK-X86_64: Name: d3 (15) 416// CHECK-X86_64: Extern 417// CHECK-X86_64: Type: Undef (0x0) 418// CHECK-X86_64: Section: (0x0) 419// CHECK-X86_64: RefType: UndefinedNonLazy (0x0) 420// CHECK-X86_64: Flags [ (0x200) 421// CHECK-X86_64: ] 422// CHECK-X86_64: Value: 0x0 423// CHECK-X86_64: } 424// CHECK-X86_64: ] 425// CHECK-X86_64: Indirect Symbols { 426// CHECK-X86_64: Number: 0 427// CHECK-X86_64: Symbols [ 428// CHECK-X86_64: ] 429// CHECK-X86_64: } 430// CHECK-X86_64: Segment { 431// CHECK-X86_64: Cmd: LC_SEGMENT_64 432// CHECK-X86_64: Name: 433// CHECK-X86_64: Size: 232 434// CHECK-X86_64: vmaddr: 0x0 435// CHECK-X86_64: vmsize: 0x39 436// CHECK-X86_64: fileoff: 384 437// CHECK-X86_64: filesize: 57 438// CHECK-X86_64: maxprot: rwx 439// CHECK-X86_64: initprot: rwx 440// CHECK-X86_64: nsects: 2 441// CHECK-X86_64: flags: 0x0 442// CHECK-X86_64: } 443// CHECK-X86_64: Dysymtab { 444// CHECK-X86_64: ilocalsym: 0 445// CHECK-X86_64: nlocalsym: 7 446// CHECK-X86_64: iextdefsym: 7 447// CHECK-X86_64: nextdefsym: 0 448// CHECK-X86_64: iundefsym: 7 449// CHECK-X86_64: nundefsym: 3 450// CHECK-X86_64: tocoff: 0 451// CHECK-X86_64: ntoc: 0 452// CHECK-X86_64: modtaboff: 0 453// CHECK-X86_64: nmodtab: 0 454// CHECK-X86_64: extrefsymoff: 0 455// CHECK-X86_64: nextrefsyms: 0 456// CHECK-X86_64: indirectsymoff: 0 457// CHECK-X86_64: nindirectsyms: 0 458// CHECK-X86_64: extreloff: 0 459// CHECK-X86_64: nextrel: 0 460// CHECK-X86_64: locreloff: 0 461// CHECK-X86_64: nlocrel: 0 462// CHECK-X86_64: } 463