1# REQUIRES: mips 2# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t.o 3# RUN: ld.lld %t.o -o %t.exe 4# RUN: llvm-readobj --file-headers --sections -l --symbols %t.exe \ 5# RUN: | FileCheck %s 6 7# Exits with return code 1 on Linux. 8 .globl __start 9__start: 10 li $a0,1 11 li $v0,4001 12 syscall 13 14# CHECK: ElfHeader { 15# CHECK-NEXT: Ident { 16# CHECK-NEXT: Magic: (7F 45 4C 46) 17# CHECK-NEXT: Class: 32-bit (0x1) 18# CHECK-NEXT: DataEncoding: LittleEndian (0x1) 19# CHECK-NEXT: FileVersion: 1 20# CHECK-NEXT: OS/ABI: SystemV (0x0) 21# CHECK-NEXT: ABIVersion: 1 22# CHECK-NEXT: Unused: (00 00 00 00 00 00 00) 23# CHECK-NEXT: } 24# CHECK-NEXT: Type: Executable (0x2) 25# CHECK-NEXT: Machine: EM_MIPS (0x8) 26# CHECK-NEXT: Version: 1 27# CHECK-NEXT: Entry: 0x20150 28# CHECK-NEXT: ProgramHeaderOffset: 0x34 29# CHECK-NEXT: SectionHeaderOffset: 0x200 30# CHECK-NEXT: Flags [ 31# CHECK-NEXT: EF_MIPS_ABI_O32 32# CHECK-NEXT: EF_MIPS_ARCH_32 33# CHECK-NEXT: EF_MIPS_CPIC 34# CHECK-NEXT: ] 35# CHECK-NEXT: HeaderSize: 52 36# CHECK-NEXT: ProgramHeaderEntrySize: 32 37# CHECK-NEXT: ProgramHeaderCount: 7 38# CHECK-NEXT: SectionHeaderEntrySize: 40 39# CHECK-NEXT: SectionHeaderCount: 11 40# CHECK-NEXT: StringTableSectionIndex: 9 41# CHECK-NEXT: } 42# CHECK-NEXT: Sections [ 43# CHECK-NEXT: Section { 44# CHECK-NEXT: Index: 0 45# CHECK-NEXT: Name: (0) 46# CHECK-NEXT: Type: SHT_NULL (0x0) 47# CHECK-NEXT: Flags [ (0x0) 48# CHECK-NEXT: ] 49# CHECK-NEXT: Address: 0x0 50# CHECK-NEXT: Offset: 0x0 51# CHECK-NEXT: Size: 0 52# CHECK-NEXT: Link: 0 53# CHECK-NEXT: Info: 0 54# CHECK-NEXT: AddressAlignment: 0 55# CHECK-NEXT: EntrySize: 0 56# CHECK-NEXT: } 57# CHECK-NEXT: Section { 58# CHECK-NEXT: Index: 1 59# CHECK-NEXT: Name: .MIPS.abiflags 60# CHECK-NEXT: Type: SHT_MIPS_ABIFLAGS (0x7000002A) 61# CHECK-NEXT: Flags [ (0x2) 62# CHECK-NEXT: SHF_ALLOC (0x2) 63# CHECK-NEXT: ] 64# CHECK-NEXT: Address: 0x10118 65# CHECK-NEXT: Offset: 0x118 66# CHECK-NEXT: Size: 24 67# CHECK-NEXT: Link: 0 68# CHECK-NEXT: Info: 0 69# CHECK-NEXT: AddressAlignment: 8 70# CHECK-NEXT: EntrySize: 24 71# CHECK-NEXT: } 72# CHECK-NEXT: Section { 73# CHECK-NEXT: Index: 2 74# CHECK-NEXT: Name: .reginfo 75# CHECK-NEXT: Type: SHT_MIPS_REGINFO (0x70000006) 76# CHECK-NEXT: Flags [ (0x2) 77# CHECK-NEXT: SHF_ALLOC (0x2) 78# CHECK-NEXT: ] 79# CHECK-NEXT: Address: 0x10130 80# CHECK-NEXT: Offset: 0x130 81# CHECK-NEXT: Size: 24 82# CHECK-NEXT: Link: 0 83# CHECK-NEXT: Info: 0 84# CHECK-NEXT: AddressAlignment: 4 85# CHECK-NEXT: EntrySize: 24 86# CHECK-NEXT: } 87# CHECK-NEXT: Section { 88# CHECK-NEXT: Index: 3 89# CHECK-NEXT: Name: .text 90# CHECK-NEXT: Type: SHT_PROGBITS (0x1) 91# CHECK-NEXT: Flags [ (0x6) 92# CHECK-NEXT: SHF_ALLOC (0x2) 93# CHECK-NEXT: SHF_EXECINSTR (0x4) 94# CHECK-NEXT: ] 95# CHECK-NEXT: Address: 0x20150 96# CHECK-NEXT: Offset: 0x150 97# CHECK-NEXT: Size: 12 98# CHECK-NEXT: Link: 0 99# CHECK-NEXT: Info: 0 100# CHECK-NEXT: AddressAlignment: 16 101# CHECK-NEXT: EntrySize: 0 102# CHECK-NEXT: } 103# CHECK-NEXT: Section { 104# CHECK-NEXT: Index: 4 105# CHECK-NEXT: Name: .data 106# CHECK-NEXT: Type: SHT_PROGBITS (0x1) 107# CHECK-NEXT: Flags [ (0x3) 108# CHECK-NEXT: SHF_ALLOC (0x2) 109# CHECK-NEXT: SHF_WRITE (0x1) 110# CHECK-NEXT: ] 111# CHECK-NEXT: Address: 0x30160 112# CHECK-NEXT: Offset: 0x160 113# CHECK-NEXT: Size: 0 114# CHECK-NEXT: Link: 0 115# CHECK-NEXT: Info: 0 116# CHECK-NEXT: AddressAlignment: 16 117# CHECK-NEXT: EntrySize: 0 118# CHECK-NEXT: } 119# CHECK-NEXT: Section { 120# CHECK-NEXT: Index: 5 121# CHECK-NEXT: Name: .got 122# CHECK-NEXT: Type: SHT_PROGBITS (0x1) 123# CHECK-NEXT: Flags [ (0x10000003) 124# CHECK-NEXT: SHF_ALLOC (0x2) 125# CHECK-NEXT: SHF_MIPS_GPREL (0x10000000) 126# CHECK-NEXT: SHF_WRITE (0x1) 127# CHECK-NEXT: ] 128# CHECK-NEXT: Address: 0x30160 129# CHECK-NEXT: Offset: 0x160 130# CHECK-NEXT: Size: 8 131# CHECK-NEXT: Link: 0 132# CHECK-NEXT: Info: 0 133# CHECK-NEXT: AddressAlignment: 16 134# CHECK-NEXT: EntrySize: 0 135# CHECK-NEXT: } 136# CHECK-NEXT: Section { 137# CHECK-NEXT: Index: 6 138# CHECK-NEXT: Name: .bss 139# CHECK-NEXT: Type: SHT_NOBITS (0x8) 140# CHECK-NEXT: Flags [ (0x3) 141# CHECK-NEXT: SHF_ALLOC (0x2) 142# CHECK-NEXT: SHF_WRITE (0x1) 143# CHECK-NEXT: ] 144# CHECK-NEXT: Address: 0x30170 145# CHECK-NEXT: Offset: 0x168 146# CHECK-NEXT: Size: 0 147# CHECK-NEXT: Link: 0 148# CHECK-NEXT: Info: 0 149# CHECK-NEXT: AddressAlignment: 16 150# CHECK-NEXT: EntrySize: 0 151# CHECK-NEXT: } 152# CHECK-NEXT: Section { 153# CHECK-NEXT: Index: 7 154# CHECK-NEXT: Name: .comment 155# CHECK-NEXT: Type: SHT_PROGBITS (0x1) 156# CHECK-NEXT: Flags [ (0x30) 157# CHECK-NEXT: SHF_MERGE (0x10) 158# CHECK-NEXT: SHF_STRINGS (0x20) 159# CHECK-NEXT: ] 160# CHECK-NEXT: Address: 0x0 161# CHECK-NEXT: Offset: 0x168 162# CHECK-NEXT: Size: 8 163# CHECK-NEXT: Link: 0 164# CHECK-NEXT: Info: 0 165# CHECK-NEXT: AddressAlignment: 1 166# CHECK-NEXT: EntrySize: 1 167# CHECK-NEXT: } 168# CHECK-NEXT: Section { 169# CHECK-NEXT: Index: 8 170# CHECK-NEXT: Name: .symtab 171# CHECK-NEXT: Type: SHT_SYMTAB (0x2) 172# CHECK-NEXT: Flags [ (0x0) 173# CHECK-NEXT: ] 174# CHECK-NEXT: Address: 0x0 175# CHECK-NEXT: Offset: 0x170 176# CHECK-NEXT: Size: 48 177# CHECK-NEXT: Link: 10 178# CHECK-NEXT: Info: 2 179# CHECK-NEXT: AddressAlignment: 4 180# CHECK-NEXT: EntrySize: 16 181# CHECK-NEXT: } 182# CHECK-NEXT: Section { 183# CHECK-NEXT: Index: 9 184# CHECK-NEXT: Name: .shstrtab 185# CHECK-NEXT: Type: SHT_STRTAB (0x3) 186# CHECK-NEXT: Flags [ (0x0) 187# CHECK-NEXT: ] 188# CHECK-NEXT: Address: 0x0 189# CHECK-NEXT: Offset: 0x1A0 190# CHECK-NEXT: Size: 82 191# CHECK-NEXT: Link: 0 192# CHECK-NEXT: Info: 0 193# CHECK-NEXT: AddressAlignment: 1 194# CHECK-NEXT: EntrySize: 0 195# CHECK-NEXT: } 196# CHECK-NEXT: Section { 197# CHECK-NEXT: Index: 10 198# CHECK-NEXT: Name: .strtab 199# CHECK-NEXT: Type: SHT_STRTAB (0x3) 200# CHECK-NEXT: Flags [ (0x0) 201# CHECK-NEXT: ] 202# CHECK-NEXT: Address: 0x0 203# CHECK-NEXT: Offset: 0x1F2 204# CHECK-NEXT: Size: 13 205# CHECK-NEXT: Link: 0 206# CHECK-NEXT: Info: 0 207# CHECK-NEXT: AddressAlignment: 1 208# CHECK-NEXT: EntrySize: 0 209# CHECK-NEXT: } 210# CHECK-NEXT: ] 211# CHECK-NEXT: ProgramHeaders [ 212# CHECK-NEXT: ProgramHeader { 213# CHECK-NEXT: Type: PT_PHDR (0x6) 214# CHECK-NEXT: Offset: 0x34 215# CHECK-NEXT: VirtualAddress: 0x10034 216# CHECK-NEXT: PhysicalAddress: 0x10034 217# CHECK-NEXT: FileSize: 224 218# CHECK-NEXT: MemSize: 224 219# CHECK-NEXT: Flags [ (0x4) 220# CHECK-NEXT: PF_R (0x4) 221# CHECK-NEXT: ] 222# CHECK-NEXT: Alignment: 4 223# CHECK-NEXT: } 224# CHECK-NEXT: ProgramHeader { 225# CHECK-NEXT: Type: PT_LOAD (0x1) 226# CHECK-NEXT: Offset: 0x0 227# CHECK-NEXT: VirtualAddress: 0x10000 228# CHECK-NEXT: PhysicalAddress: 0x10000 229# CHECK-NEXT: FileSize: 328 230# CHECK-NEXT: MemSize: 328 231# CHECK-NEXT: Flags [ (0x4) 232# CHECK-NEXT: PF_R (0x4) 233# CHECK-NEXT: ] 234# CHECK-NEXT: Alignment: 65536 235# CHECK-NEXT: } 236# CHECK-NEXT: ProgramHeader { 237# CHECK-NEXT: Type: PT_LOAD (0x1) 238# CHECK-NEXT: Offset: 0x150 239# CHECK-NEXT: VirtualAddress: 0x20150 240# CHECK-NEXT: PhysicalAddress: 0x20150 241# CHECK-NEXT: FileSize: 12 242# CHECK-NEXT: MemSize: 12 243# CHECK-NEXT: Flags [ (0x5) 244# CHECK-NEXT: PF_R (0x4) 245# CHECK-NEXT: PF_X (0x1) 246# CHECK-NEXT: ] 247# CHECK-NEXT: Alignment: 65536 248# CHECK-NEXT: } 249# CHECK-NEXT: ProgramHeader { 250# CHECK-NEXT: Type: PT_LOAD (0x1) 251# CHECK-NEXT: Offset: 0x160 252# CHECK-NEXT: VirtualAddress: 0x30160 253# CHECK-NEXT: PhysicalAddress: 0x30160 254# CHECK-NEXT: FileSize: 8 255# CHECK-NEXT: MemSize: 16 256# CHECK-NEXT: Flags [ 257# CHECK-NEXT: PF_R 258# CHECK-NEXT: PF_W 259# CHECK-NEXT: ] 260# CHECK-NEXT: Alignment: 65536 261# CHECK-NEXT: } 262# CHECK-NEXT: ProgramHeader { 263# CHECK-NEXT: Type: PT_GNU_STACK 264# CHECK-NEXT: Offset: 0x0 265# CHECK-NEXT: VirtualAddress: 0x0 266# CHECK-NEXT: PhysicalAddress: 0x0 267# CHECK-NEXT: FileSize: 0 268# CHECK-NEXT: MemSize: 0 269# CHECK-NEXT: Flags [ 270# CHECK-NEXT: PF_R 271# CHECK-NEXT: PF_W 272# CHECK-NEXT: ] 273# CHECK-NEXT: Alignment: 0 274# CHECK-NEXT: } 275# CHECK-NEXT: ProgramHeader { 276# CHECK-NEXT: Type: PT_MIPS_REGINFO 277# CHECK-NEXT: Offset: 0x130 278# CHECK-NEXT: VirtualAddress: 0x10130 279# CHECK-NEXT: PhysicalAddress: 0x10130 280# CHECK-NEXT: FileSize: 24 281# CHECK-NEXT: MemSize: 24 282# CHECK-NEXT: Flags [ (0x4) 283# CHECK-NEXT: PF_R (0x4) 284# CHECK-NEXT: ] 285# CHECK-NEXT: Alignment: 4 286# CHECK-NEXT: } 287# CHECK-NEXT: ProgramHeader { 288# CHECK-NEXT: Type: PT_MIPS_ABIFLAGS 289# CHECK-NEXT: Offset: 0x118 290# CHECK-NEXT: VirtualAddress: 0x10118 291# CHECK-NEXT: PhysicalAddress: 0x10118 292# CHECK-NEXT: FileSize: 24 293# CHECK-NEXT: MemSize: 24 294# CHECK-NEXT: Flags [ (0x4) 295# CHECK-NEXT: PF_R (0x4) 296# CHECK-NEXT: ] 297# CHECK-NEXT: Alignment: 8 298# CHECK-NEXT: } 299# CHECK-NEXT: ] 300# CHECK-NEXT: Symbols [ 301# CHECK-NEXT: Symbol { 302# CHECK-NEXT: Name: (0) 303# CHECK-NEXT: Value: 0x0 304# CHECK-NEXT: Size: 0 305# CHECK-NEXT: Binding: Local (0x0) 306# CHECK-NEXT: Type: None (0x0) 307# CHECK-NEXT: Other: 0 308# CHECK-NEXT: Section: Undefined (0x0) 309# CHECK-NEXT: } 310# CHECK-NEXT: Symbol { 311# CHECK-NEXT: Name: _gp 312# CHECK-NEXT: Value: 0x38150 313# CHECK-NEXT: Size: 0 314# CHECK-NEXT: Binding: Local 315# CHECK-NEXT: Type: None (0x0) 316# CHECK-NEXT: Other [ (0x2) 317# CHECK-NEXT: STV_HIDDEN (0x2) 318# CHECK-NEXT: ] 319# CHECK-NEXT: Section: .got 320# CHECK-NEXT: } 321# CHECK-NEXT: Symbol { 322# CHECK-NEXT: Name: __start 323# CHECK-NEXT: Value: 0x20150 324# CHECK-NEXT: Size: 0 325# CHECK-NEXT: Binding: Global (0x1) 326# CHECK-NEXT: Type: None (0x0) 327# CHECK-NEXT: Other: 0 328# CHECK-NEXT: Section: .text 329# CHECK-NEXT: } 330# CHECK-NEXT: ] 331