1## Test the replace command without modifiers replaces the relevant members. 2 3# RUN: rm -rf %t && mkdir -p %t/new/other 4# RUN: yaml2obj %s -o %t/1.o --docnum=1 5# RUN: yaml2obj %s -o %t/2.o --docnum=2 6# RUN: yaml2obj %s -o %t/3.o --docnum=3 7 8# RUN: yaml2obj %s -o %t/new/1.o --docnum=4 9# RUN: yaml2obj %s -o %t/new/3.o --docnum=5 10 11# RUN: yaml2obj %s -o %t/new/other/1.o --docnum=6 12 13## Replace single member: 14# RUN: llvm-ar rc %t/single.a %t/1.o %t/2.o %t/3.o 15# RUN: llvm-ar r %t/single.a %t/new/1.o 16# RUN: llvm-ar t %t/single.a \ 17# RUN: | FileCheck %s --check-prefix=SINGLE --implicit-check-not {{.}} 18 19# SINGLE: 1.o 20# SINGLE-NEXT: 2.o 21# SINGLE-NEXT: 3.o 22 23# RUN: llvm-nm --print-armap %t/single.a \ 24# RUN: | FileCheck %s --check-prefix=SINGLE-SYM 25 26# SINGLE-SYM: symbolnew1 27# SINGLE-SYM-NEXT: symbol2 28# SINGLE-SYM-NEXT: symbol3 29 30## Replace multiple members: 31# RUN: llvm-ar rc %t/multiple.a %t/1.o %t/2.o %t/3.o 32# RUN: llvm-ar r %t/multiple.a %t/new/1.o %t/new/3.o 33# RUN: llvm-ar t %t/multiple.a \ 34# RUN: | FileCheck %s --check-prefix=MULTIPLE --implicit-check-not {{.}} 35 36# MULTIPLE: 1.o 37# MULTIPLE-NEXT: 2.o 38# MULTIPLE-NEXT: 3.o 39 40# RUN: llvm-nm --print-armap %t/multiple.a \ 41# RUN: | FileCheck %s --check-prefix=MULTIPLE-SYM 42 43# MULTIPLE-SYM: symbolnew1 44# MULTIPLE-SYM-NEXT: symbol2 45# MULTIPLE-SYM-NEXT: symbolnew3 46 47## Replace same member: 48# RUN: llvm-ar rc %t/same.a %t/1.o %t/2.o %t/3.o 49# RUN: llvm-ar r %t/same.a %t/new/1.o %t/new/other/1.o 50# RUN: llvm-ar t %t/same.a \ 51# RUN: | FileCheck %s --check-prefix=SAME --implicit-check-not {{.}} 52 53# SAME: 1.o 54# SAME-NEXT: 2.o 55# SAME-NEXT: 3.o 56# SAME-NEXT: 1.o 57 58# RUN: llvm-nm --print-armap %t/same.a \ 59# RUN: | FileCheck %s --check-prefix=SAME-SYM 60 61# SAME-SYM: symbolnew1 62# SAME-SYM-NEXT: symbol2 63# SAME-SYM-NEXT: symbol3 64# SAME-SYM-NEXT: symbolother1 65 66## Replace without member: 67# RUN: llvm-ar rc %t/without.a %t/1.o %t/2.o %t/3.o 68# RUN: llvm-ar r %t/without.a 69# RUN: llvm-ar t %t/without.a \ 70# RUN: | FileCheck %s --check-prefix=WITHOUT --implicit-check-not {{.}} 71 72# WITHOUT: 1.o 73# WITHOUT-NEXT: 2.o 74# WITHOUT-NEXT: 3.o 75 76# RUN: llvm-nm --print-armap %t/without.a \ 77# RUN: | FileCheck %s --check-prefix=WITHOUT-SYM 78 79# WITHOUT-SYM: symbol1 80# WITHOUT-SYM-NEXT: symbol2 81# WITHOUT-SYM-NEXT: symbol3 82 83## No archive: 84# RUN: not llvm-ar r 2>&1 \ 85# RUN: | FileCheck %s --check-prefix=NO-ARCHIVE 86 87# NO-ARCHIVE: error: an archive name must be specified 88 89## Member does not exist: 90# RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o 91# RUN: not llvm-ar r %t/missing.a %t/missing.txt 2>&1 \ 92# RUN: | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt 93 94# MISSING-FILE: error: [[FILE]]: {{[Nn]}}o such file or directory 95 96## Create and Replace member of thin archive: 97# RUN: llvm-ar rcT %t/thin.a %t/1.o %t/2.o %t/3.o 98# RUN: yaml2obj %s -o %t/1.o --docnum=4 99# RUN: llvm-ar rT %t/thin.a %t/1.o 100# RUN: llvm-ar t %t/thin.a | FileCheck %s --check-prefix=SINGLE 101 102# RUN: llvm-nm --print-armap %t/thin.a \ 103# RUN: | FileCheck %s --check-prefix=SINGLE-SYM 104 105--- !ELF 106FileHeader: 107 Class: ELFCLASS64 108 Data: ELFDATA2LSB 109 Type: ET_REL 110 Machine: EM_X86_64 111Sections: 112 - Name: .text 113 Type: SHT_PROGBITS 114Symbols: 115 - Name: symbol1 116 Binding: STB_GLOBAL 117 Section: .text 118 119--- !ELF 120FileHeader: 121 Class: ELFCLASS64 122 Data: ELFDATA2LSB 123 Type: ET_REL 124 Machine: EM_X86_64 125Sections: 126 - Name: .text 127 Type: SHT_PROGBITS 128Symbols: 129 - Name: symbol2 130 Binding: STB_GLOBAL 131 Section: .text 132 133--- !ELF 134FileHeader: 135 Class: ELFCLASS64 136 Data: ELFDATA2LSB 137 Type: ET_REL 138 Machine: EM_X86_64 139Sections: 140 - Name: .text 141 Type: SHT_PROGBITS 142Symbols: 143 - Name: symbol3 144 Binding: STB_GLOBAL 145 Section: .text 146 147--- !ELF 148FileHeader: 149 Class: ELFCLASS64 150 Data: ELFDATA2LSB 151 Type: ET_REL 152 Machine: EM_X86_64 153Sections: 154 - Name: .text 155 Type: SHT_PROGBITS 156Symbols: 157 - Name: symbolnew1 158 Binding: STB_GLOBAL 159 Section: .text 160 161--- !ELF 162FileHeader: 163 Class: ELFCLASS64 164 Data: ELFDATA2LSB 165 Type: ET_REL 166 Machine: EM_X86_64 167Sections: 168 - Name: .text 169 Type: SHT_PROGBITS 170Symbols: 171 - Name: symbolnew3 172 Binding: STB_GLOBAL 173 Section: .text 174 175--- !ELF 176FileHeader: 177 Class: ELFCLASS64 178 Data: ELFDATA2LSB 179 Type: ET_REL 180 Machine: EM_X86_64 181Sections: 182 - Name: .text 183 Type: SHT_PROGBITS 184Symbols: 185 - Name: symbolother1 186 Binding: STB_GLOBAL 187 Section: .text 188