xref: /llvm-project/llvm/test/tools/llvm-ar/delete.test (revision a6316d6da5938328840d4161e4dc7c671808c20f)
1## Test the deletion of members and that symbols are removed from the symbol table.
2
3# RUN: yaml2obj %s -o %t-delete.o --docnum=1
4# RUN: yaml2obj %s -o %t-keep.o --docnum=2
5# RUN: touch %t1.txt
6# RUN: touch %t2.txt
7
8## Add file:
9# RUN: rm -f %t.a
10# RUN: llvm-ar rc %t.a %t1.txt %t-delete.o %t-keep.o %t2.txt
11# RUN: llvm-nm --print-armap %t.a \
12# RUN:   | FileCheck %s --check-prefix=SYMBOL-ADDED
13# RUN: llvm-ar t %t.a | FileCheck %s --check-prefix=FILE-ADDED
14
15# SYMBOL-ADDED:      symbol1
16# SYMBOL-ADDED-NEXT: symbol2
17
18# FILE-ADDED:      1.txt
19# FILE-ADDED-NEXT: delete.o
20# FILE-ADDED-NEXT: keep.o
21# FILE-ADDED-NEXT: 2.txt
22
23## Delete file that is not a member:
24# RUN: cp %t.a %t-archive-copy.a
25# RUN: llvm-ar d %t.a t/missing.o
26# RUN: cmp %t.a %t-archive-copy.a
27
28## Delete file:
29# RUN: llvm-ar d %t.a %t-delete.o
30# RUN: llvm-nm --print-armap %t.a \
31# RUN:   | FileCheck %s --check-prefix=SYMBOL-DELETED --implicit-check-not symbol1
32# RUN: llvm-ar t %t.a \
33# RUN:   | FileCheck %s --check-prefix=FILE-DELETED --implicit-check-not delete.o
34
35# SYMBOL-DELETED: symbol2
36
37# FILE-DELETED:      1.txt
38# FILE-DELETED-NEXT: keep.o
39# FILE-DELETED-NEXT: 2.txt
40
41--- !ELF
42FileHeader:
43  Class:   ELFCLASS64
44  Data:    ELFDATA2LSB
45  Type:    ET_REL
46  Machine: EM_X86_64
47Sections:
48  - Name: .text
49    Type: SHT_PROGBITS
50Symbols:
51  - Name:    symbol1
52    Binding: STB_GLOBAL
53    Section: .text
54
55--- !ELF
56FileHeader:
57  Class:   ELFCLASS64
58  Data:    ELFDATA2LSB
59  Type:    ET_REL
60  Machine: EM_X86_64
61Sections:
62  - Name: .text
63    Type: SHT_PROGBITS
64Symbols:
65  - Name:    symbol2
66    Binding: STB_GLOBAL
67    Section: .text
68