1# RUN: yaml2obj --docnum=1 %s -o %t 2# RUN: llvm-objdump --reloc %t > %t1 3# RUN: llvm-objdump -r %t > %t2 4# RUN: cmp %t1 %t2 5# RUN: FileCheck %s --input-file=%t1 --strict-whitespace --match-full-lines 6 7# CHECK:RELOCATION RECORDS FOR [.text]: 8# CHECK-NEXT:OFFSET TYPE VALUE 9# CHECK-NEXT:0000000000000001 R_X86_64_32 glob1 10# CHECK-NEXT:0000000000000001 R_X86_64_32S glob2 11# CHECK-NEXT:0000000000000002 R_X86_64_64 loc1 12# CHECK-NEXT:0000000000000001 R_X86_64_32 glob1+0x1 13# CHECK-NEXT:0000000000000001 R_X86_64_32S glob2+0x2 14# CHECK-NEXT:0000000000000002 R_X86_64_64 loc1+0x3 15 16--- !ELF 17FileHeader: !FileHeader 18 Class: ELFCLASS64 19 Data: ELFDATA2LSB 20 Type: ET_REL 21 Machine: EM_X86_64 22 23Sections: 24- Name: .text 25 Type: SHT_PROGBITS 26 Content: "0000000000000000" 27 AddressAlign: 16 28 Flags: [SHF_ALLOC] 29 30- Name: .rel.text 31 Type: SHT_REL 32 Info: .text 33 AddressAlign: 4 34 Relocations: 35 - Offset: 0x1 36 Symbol: glob1 37 Type: R_X86_64_32 38 - Offset: 0x1 39 Symbol: glob2 40 Type: R_X86_64_32S 41 - Offset: 0x2 42 Symbol: loc1 43 Type: R_X86_64_64 44 45- Name: .rela.text 46 Type: SHT_RELA 47 Link: .symtab 48 Info: .text 49 AddressAlign: 4 50 Relocations: 51 - Offset: 0x1 52 Addend: 1 53 Symbol: glob1 54 Type: R_X86_64_32 55 - Offset: 0x1 56 Addend: 2 57 Symbol: glob2 58 Type: R_X86_64_32S 59 - Offset: 0x2 60 Addend: 3 61 Symbol: loc1 62 Type: R_X86_64_64 63 64Symbols: 65 - Name: loc1 66 - Name: loc2 67 - Name: glob1 68 Section: .text 69 Value: 0x0 70 Size: 4 71 Binding: STB_GLOBAL 72 - Name: glob2 73 Binding: STB_GLOBAL 74 75## Check we report an error if the relocated section identified by the 76## sh_info field of a relocation section is invalid. 77# RUN: yaml2obj --docnum=2 %s -o %t2 78# RUN: not llvm-objdump --reloc %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=ERR 79# ERR: error: '[[FILE]]': section (1): unable to get a relocation target: invalid section index: 255 80 81--- !ELF 82FileHeader: 83 Class: ELFCLASS64 84 Data: ELFDATA2LSB 85 Type: ET_REL 86 Machine: EM_X86_64 87Sections: 88- Name: .rela.foo 89 Type: SHT_RELA 90 Info: 0xFF 91 Relocations: 92 - Offset: 0x1 93 Type: R_X86_64_NONE 94 95## Check ranges of addends being displayed in a dump of relocations. 96# RUN: yaml2obj --docnum=3 %s -o %t3 97# RUN: llvm-objdump -r %t3 | FileCheck %s --check-prefix=ADDENDS 98 99# ADDENDS: RELOCATION RECORDS FOR [.text]: 100# ADDENDS: R_X86_64_64 glob-0x8000000000000000 101# ADDENDS: R_X86_64_64 glob+0x7fffffffffffffff 102# ADDENDS: R_X86_64_64 glob-0x1 103# ADDENDS: R_X86_64_64 glob+0x12345678 104# ADDENDS: R_X86_64_64 glob{{$}} 105 106--- !ELF 107FileHeader: 108 Class: ELFCLASS64 109 Data: ELFDATA2LSB 110 Type: ET_REL 111 Machine: EM_X86_64 112Sections: 113- Name: .text 114 Type: SHT_PROGBITS 115 Size: 8 116 Flags: [SHF_EXECINSTR,SHF_ALLOC] 117- Name: .rela.text 118 Type: SHT_RELA 119 Info: .text 120 Relocations: 121 - Offset: 0x0 122 Addend: -9223372036854775808 123 Symbol: glob 124 Type: R_X86_64_64 125 - Offset: 0x1 126 Symbol: glob 127 Type: R_X86_64_64 128 Addend: 9223372036854775807 129 - Offset: 0x2 130 Symbol: glob 131 Type: R_X86_64_64 132 Addend: -1 133 - Offset: 0x3 134 Symbol: glob 135 Type: R_X86_64_64 136 Addend: 0x12345678 137 - Offset: 0x4 138 Symbol: glob 139 Type: R_X86_64_64 140 Addend: 0 141Symbols: 142 - Name: glob 143 Section: .text 144 Value: 0x0 145 Size: 0 146 Binding: STB_GLOBAL 147 148## Check relocation formatting on 32 bit as well to verify the formatting is correct. 149# RUN: yaml2obj --docnum=4 %s > %t4 150# RUN: llvm-objdump -r %t4 | FileCheck %s --check-prefix=ELF32 --strict-whitespace --match-full-lines 151 152# ELF32:RELOCATION RECORDS FOR [.text]: 153# ELF32-NEXT:OFFSET TYPE VALUE 154# ELF32-NEXT:00000001 R_386_32 global 155# ELF32-NEXT:00000002 R_386_PC32 local 156# ELF32-NEXT:00000001 R_386_NONE global+0x1 157# ELF32-NEXT:00000002 R_386_NONE local+0x2 158 159--- !ELF 160FileHeader: 161 Class: ELFCLASS32 162 Data: ELFDATA2LSB 163 Type: ET_REL 164 Machine: EM_386 165Sections: 166- Name: .text 167 Type: SHT_PROGBITS 168- Name: .rel.text 169 Type: SHT_REL 170 Info: .text 171 Relocations: 172 - Offset: 0x1 173 Symbol: global 174 Type: R_386_32 175 - Offset: 0x2 176 Symbol: local 177 Type: R_386_PC32 178- Name: .rela.text 179 Type: SHT_RELA 180 Info: .text 181 Relocations: 182 - Offset: 0x1 183 Addend: 1 184 Symbol: global 185 Type: R_386_NONE 186 - Offset: 0x2 187 Addend: 2 188 Symbol: local 189 Type: R_386_NONE 190Symbols: 191 - Name: local 192 - Name: global 193 Binding: STB_GLOBAL 194