188 lines · plain
1## Test the replace command without modifiers replaces the relevant members.2 3# RUN: rm -rf %t && mkdir -p %t/new/other4# RUN: yaml2obj %s -o %t/1.o --docnum=15# RUN: yaml2obj %s -o %t/2.o --docnum=26# RUN: yaml2obj %s -o %t/3.o --docnum=37 8# RUN: yaml2obj %s -o %t/new/1.o --docnum=49# RUN: yaml2obj %s -o %t/new/3.o --docnum=510 11# RUN: yaml2obj %s -o %t/new/other/1.o --docnum=612 13## Replace single member:14# RUN: llvm-ar rc %t/single.a %t/1.o %t/2.o %t/3.o15# RUN: llvm-ar r %t/single.a %t/new/1.o16# RUN: llvm-ar t %t/single.a \17# RUN: | FileCheck %s --check-prefix=SINGLE --implicit-check-not {{.}}18 19# SINGLE: 1.o20# SINGLE-NEXT: 2.o21# SINGLE-NEXT: 3.o22 23# RUN: llvm-nm --print-armap %t/single.a \24# RUN: | FileCheck %s --check-prefix=SINGLE-SYM25 26# SINGLE-SYM: symbolnew127# SINGLE-SYM-NEXT: symbol228# SINGLE-SYM-NEXT: symbol329 30## Replace multiple members:31# RUN: llvm-ar rc %t/multiple.a %t/1.o %t/2.o %t/3.o32# RUN: llvm-ar r %t/multiple.a %t/new/1.o %t/new/3.o33# RUN: llvm-ar t %t/multiple.a \34# RUN: | FileCheck %s --check-prefix=MULTIPLE --implicit-check-not {{.}}35 36# MULTIPLE: 1.o37# MULTIPLE-NEXT: 2.o38# MULTIPLE-NEXT: 3.o39 40# RUN: llvm-nm --print-armap %t/multiple.a \41# RUN: | FileCheck %s --check-prefix=MULTIPLE-SYM42 43# MULTIPLE-SYM: symbolnew144# MULTIPLE-SYM-NEXT: symbol245# MULTIPLE-SYM-NEXT: symbolnew346 47## Replace same member:48# RUN: llvm-ar rc %t/same.a %t/1.o %t/2.o %t/3.o49# RUN: llvm-ar r %t/same.a %t/new/1.o %t/new/other/1.o50# RUN: llvm-ar t %t/same.a \51# RUN: | FileCheck %s --check-prefix=SAME --implicit-check-not {{.}}52 53# SAME: 1.o54# SAME-NEXT: 2.o55# SAME-NEXT: 3.o56# SAME-NEXT: 1.o57 58# RUN: llvm-nm --print-armap %t/same.a \59# RUN: | FileCheck %s --check-prefix=SAME-SYM60 61# SAME-SYM: symbolnew162# SAME-SYM-NEXT: symbol263# SAME-SYM-NEXT: symbol364# SAME-SYM-NEXT: symbolother165 66## Replace without member:67# RUN: llvm-ar rc %t/without.a %t/1.o %t/2.o %t/3.o68# RUN: llvm-ar r %t/without.a69# RUN: llvm-ar t %t/without.a \70# RUN: | FileCheck %s --check-prefix=WITHOUT --implicit-check-not {{.}}71 72# WITHOUT: 1.o73# WITHOUT-NEXT: 2.o74# WITHOUT-NEXT: 3.o75 76# RUN: llvm-nm --print-armap %t/without.a \77# RUN: | FileCheck %s --check-prefix=WITHOUT-SYM78 79# WITHOUT-SYM: symbol180# WITHOUT-SYM-NEXT: symbol281# WITHOUT-SYM-NEXT: symbol382 83## No archive:84# RUN: not llvm-ar r 2>&1 \85# RUN: | FileCheck %s --check-prefix=NO-ARCHIVE86 87# NO-ARCHIVE: error: an archive name must be specified88 89## Member does not exist:90# RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o91# 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 -DMSG=%errc_ENOENT93 94# MISSING-FILE: error: [[FILE]]: [[MSG]]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.o98# RUN: yaml2obj %s -o %t/1.o --docnum=499# RUN: llvm-ar rT %t/thin.a %t/1.o100# RUN: llvm-ar t %t/thin.a | FileCheck %s --check-prefix=SINGLE101 102# RUN: llvm-nm --print-armap %t/thin.a \103# RUN: | FileCheck %s --check-prefix=SINGLE-SYM104 105--- !ELF106FileHeader:107 Class: ELFCLASS64108 Data: ELFDATA2LSB109 Type: ET_REL110 Machine: EM_X86_64111Sections:112 - Name: .text113 Type: SHT_PROGBITS114Symbols:115 - Name: symbol1116 Binding: STB_GLOBAL117 Section: .text118 119--- !ELF120FileHeader:121 Class: ELFCLASS64122 Data: ELFDATA2LSB123 Type: ET_REL124 Machine: EM_X86_64125Sections:126 - Name: .text127 Type: SHT_PROGBITS128Symbols:129 - Name: symbol2130 Binding: STB_GLOBAL131 Section: .text132 133--- !ELF134FileHeader:135 Class: ELFCLASS64136 Data: ELFDATA2LSB137 Type: ET_REL138 Machine: EM_X86_64139Sections:140 - Name: .text141 Type: SHT_PROGBITS142Symbols:143 - Name: symbol3144 Binding: STB_GLOBAL145 Section: .text146 147--- !ELF148FileHeader:149 Class: ELFCLASS64150 Data: ELFDATA2LSB151 Type: ET_REL152 Machine: EM_X86_64153Sections:154 - Name: .text155 Type: SHT_PROGBITS156Symbols:157 - Name: symbolnew1158 Binding: STB_GLOBAL159 Section: .text160 161--- !ELF162FileHeader:163 Class: ELFCLASS64164 Data: ELFDATA2LSB165 Type: ET_REL166 Machine: EM_X86_64167Sections:168 - Name: .text169 Type: SHT_PROGBITS170Symbols:171 - Name: symbolnew3172 Binding: STB_GLOBAL173 Section: .text174 175--- !ELF176FileHeader:177 Class: ELFCLASS64178 Data: ELFDATA2LSB179 Type: ET_REL180 Machine: EM_X86_64181Sections:182 - Name: .text183 Type: SHT_PROGBITS184Symbols:185 - Name: symbolother1186 Binding: STB_GLOBAL187 Section: .text188