1## Check that obj2yaml is able to produce YAML from 2## an object containing symbols and sections with duplicate 3## names and produces same-named sections and symbols 4## with distinguishing suffixes. 5 6# RUN: yaml2obj --docnum=1 %s -o %t1 7# RUN: llvm-readobj -s -t %t1 | FileCheck %s 8 9# CHECK: Name: .foo ( 10# CHECK: Name: .foo ( 11# CHECK: Name: .foo ( 12# CHECK: Name: .bar ( 13# CHECK: Name: .bar ( 14# CHECK: Name: .bar ( 15 16# CHECK: Name: localfoo ( 17# CHECK: Name: localfoo ( 18# CHECK: Name: localfoo ( 19# CHECK: Name: localbar ( 20# CHECK: Name: localbar ( 21# CHECK: Name: localbar ( 22 23# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=CASE1 24 25# CASE1: --- !ELF 26# CASE1-NEXT: FileHeader: 27# CASE1-NEXT: Class: ELFCLASS64 28# CASE1-NEXT: Data: ELFDATA2LSB 29# CASE1-NEXT: Type: ET_REL 30# CASE1-NEXT: Sections: 31# CASE1-NEXT: - Name: .foo 32# CASE1-NEXT: Type: SHT_PROGBITS 33# CASE1-NEXT: - Name: '.foo (1)' 34# CASE1-NEXT: Type: SHT_PROGBITS 35# CASE1-NEXT: - Name: '.foo (2)' 36# CASE1-NEXT: Type: SHT_PROGBITS 37# CASE1-NEXT: - Name: .bar 38# CASE1-NEXT: Type: SHT_PROGBITS 39# CASE1-NEXT: - Name: '.bar (1)' 40# CASE1-NEXT: Type: SHT_PROGBITS 41# CASE1-NEXT: - Name: '.bar (2)' 42# CASE1-NEXT: Type: SHT_PROGBITS 43# CASE1-NEXT: Symbols: 44# CASE1-NEXT: - Name: localfoo 45# CASE1-NEXT: - Name: 'localfoo (1)' 46# CASE1-NEXT: - Name: 'localfoo (2)' 47# CASE1-NEXT: - Name: localbar 48# CASE1-NEXT: - Name: 'localbar (1)' 49# CASE1-NEXT: - Name: 'localbar (2)' 50# CASE1-NEXT: ... 51 52--- !ELF 53FileHeader: 54 Class: ELFCLASS64 55 Data: ELFDATA2LSB 56 Type: ET_REL 57Sections: 58 - Name: .foo 59 Type: SHT_PROGBITS 60 - Name: '.foo (555)' 61 Type: SHT_PROGBITS 62 - Name: '.foo (random_tag)' 63 Type: SHT_PROGBITS 64 - Name: .bar 65 Type: SHT_PROGBITS 66 - Name: '.bar (666)' 67 Type: SHT_PROGBITS 68 - Name: '.bar (random_tag)' 69 Type: SHT_PROGBITS 70Symbols: 71 - Name: 'localfoo (111)' 72 - Name: 'localfoo (222)' 73 - Name: 'localfoo (random_tag)' 74 - Name: 'localbar (333)' 75 - Name: 'localbar (444)' 76 - Name: 'localbar (random_tag)' 77 78## Check we can refer to symbols with the same 79## name from relocations. 80 81# RUN: yaml2obj --docnum=2 %s -o %t2 82# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=CASE2 83 84# CASE2: Relocations: 85# CASE2-NEXT: - Symbol: 'foo (1)' 86# CASE2-NEXT: Type: R_X86_64_PC32 87# CASE2-NEXT: - Offset: 0x4 88# CASE2-NEXT: Symbol: foo 89# CASE2-NEXT: Type: R_X86_64_PC32 90# CASE2-NEXT: Symbols: 91# CASE2-NEXT: - Name: foo 92# CASE2-NEXT: - Name: 'foo (1)' 93 94--- !ELF 95FileHeader: 96 Class: ELFCLASS64 97 Data: ELFDATA2LSB 98 Type: ET_REL 99 Machine: EM_X86_64 100Sections: 101 - Name: .text 102 Type: SHT_PROGBITS 103 Size: 8 104 - Name: .rela.text 105 Type: SHT_RELA 106 Info: .text 107 Link: .symtab 108 Relocations: 109 - Type: R_X86_64_PC32 110 Symbol: 'foo (1)' 111 - Type: R_X86_64_PC32 112 Offset: 4 113 Symbol: foo 114Symbols: 115 - Name: foo 116 - Name: 'foo (1)' 117 118## Check obj2yaml does not add a suffix to a name if the 119## symbol is in .symtab and .dynsym at the same time. 120 121# RUN: yaml2obj --docnum=3 %s -o %t3 122# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=CASE3 123 124# CASE3: Symbols: 125# CASE3-NEXT: - Name: foo 126# CASE3-NEXT: Binding: STB_GLOBAL 127# CASE3-NEXT: DynamicSymbols: 128# CASE3-NEXT: - Name: foo 129# CASE3-NEXT: Binding: STB_GLOBAL 130 131--- !ELF 132FileHeader: 133 Class: ELFCLASS64 134 Data: ELFDATA2LSB 135 Type: ET_DYN 136Symbols: 137 - Name: foo 138 Binding: STB_GLOBAL 139DynamicSymbols: 140 - Name: foo 141 Binding: STB_GLOBAL 142