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--- !ELF 97FileHeader: 98 Class: ELFCLASS64 99 Data: ELFDATA2LSB 100 Type: ET_REL 101 Machine: EM_X86_64 102Sections: 103 - Name: .text 104 Type: SHT_PROGBITS 105Symbols: 106 - Name: symbol1 107 Binding: STB_GLOBAL 108 Section: .text 109 110--- !ELF 111FileHeader: 112 Class: ELFCLASS64 113 Data: ELFDATA2LSB 114 Type: ET_REL 115 Machine: EM_X86_64 116Sections: 117 - Name: .text 118 Type: SHT_PROGBITS 119Symbols: 120 - Name: symbol2 121 Binding: STB_GLOBAL 122 Section: .text 123 124--- !ELF 125FileHeader: 126 Class: ELFCLASS64 127 Data: ELFDATA2LSB 128 Type: ET_REL 129 Machine: EM_X86_64 130Sections: 131 - Name: .text 132 Type: SHT_PROGBITS 133Symbols: 134 - Name: symbol3 135 Binding: STB_GLOBAL 136 Section: .text 137 138--- !ELF 139FileHeader: 140 Class: ELFCLASS64 141 Data: ELFDATA2LSB 142 Type: ET_REL 143 Machine: EM_X86_64 144Sections: 145 - Name: .text 146 Type: SHT_PROGBITS 147Symbols: 148 - Name: symbolnew1 149 Binding: STB_GLOBAL 150 Section: .text 151 152--- !ELF 153FileHeader: 154 Class: ELFCLASS64 155 Data: ELFDATA2LSB 156 Type: ET_REL 157 Machine: EM_X86_64 158Sections: 159 - Name: .text 160 Type: SHT_PROGBITS 161Symbols: 162 - Name: symbolnew3 163 Binding: STB_GLOBAL 164 Section: .text 165 166--- !ELF 167FileHeader: 168 Class: ELFCLASS64 169 Data: ELFDATA2LSB 170 Type: ET_REL 171 Machine: EM_X86_64 172Sections: 173 - Name: .text 174 Type: SHT_PROGBITS 175Symbols: 176 - Name: symbolother1 177 Binding: STB_GLOBAL 178 Section: .text 179