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