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