1## Show that the value field is omitted when a relocation does not reference a symbol. 2## In other cases, particularly when a symbol has a zero value or when it has an empty 3## name, we print it. Test for both static and dynamic relocation printing. 4 5# RUN: yaml2obj %s -o %t 6# RUN: llvm-readelf --relocations --dyn-relocations %t 2>&1 | FileCheck %s -DFILE=%t 7# RUN: llvm-readobj --relocations %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=LLVM 8 9# CHECK: Relocation section '.rela.text' at offset {{.*}} contains 5 entries: 10# CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend 11# CHECK-NEXT: 0000000000000000 0000000000000000 R_X86_64_NONE 1 12# CHECK-NEXT: 0000000000000000 0000000100000000 R_X86_64_NONE 0000000000000000 sym + 1 13# CHECK-NEXT: 0000000000000000 0000000200000000 R_X86_64_NONE 0000000000000123 <null> + 456 14# CHECK-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF) 15# CHECK-NEXT: 0000000000000000 0000000300000000 R_X86_64_NONE 0000000000000000 <?> + 678 16# CHECK-NEXT: 0000000000000000 0000000400000000 R_X86_64_NONE 0000000000000000 <null> + 2 17 18# CHECK: Relocation section '.rela.dyn' at offset {{.*}} contains 5 entries: 19# CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend 20# CHECK-NEXT: 0000000000000000 0000000000000000 R_X86_64_NONE 1 21# CHECK-NEXT: 0000000000000000 0000000100000000 R_X86_64_NONE 0000000000000000 sym + 1 22# CHECK-NEXT: 0000000000000000 0000000200000000 R_X86_64_NONE 0000000000000123 <null> + 456 23# CHECK-NEXT: 0000000000000000 0000000300000000 R_X86_64_NONE 0000000000000000 <?> + 678 24# CHECK-NEXT: 0000000000000000 0000000400000000 R_X86_64_NONE 0000000000000000 <null> + 2 25 26# CHECK: 'RELA' relocation section at offset {{.*}} contains 120 bytes: 27# CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend 28# CHECK-NEXT: 0000000000000000 0000000000000000 R_X86_64_NONE 1 29# CHECK-NEXT: 0000000000000000 0000000100000000 R_X86_64_NONE 0000000000000000 sym + 1 30# CHECK-NEXT: 0000000000000000 0000000200000000 R_X86_64_NONE 0000000000000123 <null> + 456 31# CHECK-NEXT: 0000000000000000 0000000300000000 R_X86_64_NONE 0000000000000000 <null> + 678 32# CHECK-NEXT: 0000000000000000 0000000400000000 R_X86_64_NONE 0000000000000000 <null> + 2 33 34# LLVM: Relocations [ 35# LLVM-NEXT: Section (2) .rela.text { 36# LLVM-NEXT: 0x0 R_X86_64_NONE - 0x1 37# LLVM-NEXT: 0x0 R_X86_64_NONE sym 0x1 38# LLVM-NEXT: 0x0 R_X86_64_NONE <null> 0x456 39# LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0x0 (SHN_UNDEF) 40# LLVM-NEXT: 0x0 R_X86_64_NONE <?> 0x678 41# LLVM-NEXT: 0x0 R_X86_64_NONE <null> 0x2 42# LLVM-NEXT: } 43# LLVM-NEXT: Section (4) .rela.dyn { 44# LLVM-NEXT: 0x0 R_X86_64_NONE - 0x1 45# LLVM-NEXT: 0x0 R_X86_64_NONE sym 0x1 46# LLVM-NEXT: 0x0 R_X86_64_NONE <null> 0x456 47# LLVM-NEXT: 0x0 R_X86_64_NONE <?> 0x678 48# LLVM-NEXT: 0x0 R_X86_64_NONE <null> 0x2 49# LLVM-NEXT: } 50# LLVM-NEXT: ] 51 52--- !ELF 53FileHeader: 54 Class: ELFCLASS64 55 Data: ELFDATA2LSB 56 Type: ET_EXEC 57 Machine: EM_X86_64 58Sections: 59 - Name: .text 60 Type: SHT_PROGBITS 61 Size: 0x10 62 - Name: .rela.text 63 Type: SHT_RELA 64 Link: .symtab 65 Info: .text 66 Relocations: 67 - Offset: 0 68 Type: R_X86_64_NONE 69 Addend: 1 70 - Offset: 0 71 Type: R_X86_64_NONE 72 Addend: 1 73 Symbol: sym 74 - Offset: 0 75 Type: R_X86_64_NONE 76 Addend: 0x456 77 Symbol: 2 78 - Offset: 0 79 Addend: 0x678 80 Type: R_X86_64_NONE 81 Symbol: 3 82## References a symbol with a zero value and an empty name. 83 - Offset: 0 84 Type: R_X86_64_NONE 85 Addend: 2 86 Symbol: 4 87 - Name: .dynamic 88 Type: SHT_DYNAMIC 89 Flags: [SHF_ALLOC] 90 Address: 0x1000 91 AddressAlign: 0x1000 92 Entries: 93 - Tag: DT_RELA 94 Value: 0x1100 95 - Tag: DT_RELASZ 96 Value: 120 97 - Tag: DT_RELAENT 98 Value: 24 99 - Tag: DT_NULL 100 Value: 0 101 - Name: .rela.dyn 102 Type: SHT_RELA 103 Flags: [SHF_ALLOC] 104 Info: .text 105 Address: 0x1100 106 AddressAlign: 0x100 107 Relocations: 108 - Offset: 0 109 Type: R_X86_64_NONE 110 Addend: 1 111 - Offset: 0 112 Type: R_X86_64_NONE 113 Addend: 1 114 Symbol: sym 115 - Offset: 0 116 Type: R_X86_64_NONE 117 Addend: 0x456 118 Symbol: 2 119 - Offset: 0 120 Addend: 0x678 121 Type: R_X86_64_NONE 122 Symbol: 3 123## References a symbol with a zero value and an empty name. 124 - Offset: 0 125 Type: R_X86_64_NONE 126 Addend: 2 127 Symbol: 4 128Symbols: 129 - Name: sym 130 Value: 0 131 Section: .text 132 Binding: STB_GLOBAL 133 - Value: 0x123 134 Section: .text 135 Binding: STB_GLOBAL 136 - Type: STT_SECTION 137 Index: 0 138 - Value: 0x0 139 Section: .text 140 Binding: STB_GLOBAL 141DynamicSymbols: 142 - Name: sym 143 Value: 0 144 Section: .text 145 Binding: STB_GLOBAL 146 - Value: 0x123 147 Section: .text 148 Binding: STB_GLOBAL 149 - Type: STT_SECTION 150 Index: 0 151 - Value: 0x0 152 Section: .text 153 Binding: STB_GLOBAL 154ProgramHeaders: 155 - Type: PT_LOAD 156 VAddr: 0x1000 157 FirstSec: .dynamic 158 LastSec: .rela.dyn 159 - Type: PT_DYNAMIC 160 VAddr: 0x1000 161 FirstSec: .dynamic 162 LastSec: .dynamic 163