• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## Test a basic copy of an archive containing a wasm object.
2
3# RUN: yaml2obj %s -o %t
4
5## Create an archive and copy it using llvm-objcopy.
6# RUN: rm -f %t.a
7# RUN: llvm-ar crs %t.a %t
8# RUN: cp %t.a %t.copy.a
9# RUN: llvm-objcopy %t.a %t2.a
10## Create another archive from an objcopy-copied object, verify that they match.
11# RUN: llvm-objcopy %t %t2
12# RUN: llvm-ar p %t2.a > %t3
13# RUN: cmp %t2 %t3
14
15## Check that the copied archive has the correct index contents.
16# RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=INDEX-TABLE %s
17# RUN: llvm-nm --print-armap %t2.a | FileCheck --check-prefix=INDEX-TABLE %s
18## Verify that llvm-objcopy has not modifed the input.
19# RUN: cmp %t.copy.a %t.a
20
21# INDEX-TABLE: Archive map
22# INDEX-TABLE-NEXT: func1 in
23
24## Do the same with an archive that has no index.
25# RUN: rm -f %t.no.index.a
26# RUN: llvm-ar crS %t.no.index.a %t
27# RUN: llvm-objcopy %t.no.index.a %t2.no.index.a
28# RUN: llvm-ar p %t2.no.index.a > %t4
29
30# RUN: llvm-nm --print-armap %t.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s
31# RUN: llvm-nm --print-armap %t2.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s
32# RUN: cmp %t2 %t4
33
34# NO-INDEX-TABLE-NOT: Archive map
35# NO-INDEX-TABLE-NOT: func1 in
36
37--- !WASM
38FileHeader:
39  Version: 0x00000001
40Sections:
41  - Type: TYPE
42    Signatures:
43      - Index: 0
44        ParamTypes:
45          - I32
46        ReturnTypes:
47          - F32
48      - Index: 1
49        ParamTypes:
50          - I32
51          - I64
52        ReturnTypes:     []
53  - Type: FUNCTION
54    FunctionTypes:
55      - 0
56      - 1
57  - Type: CODE
58    Relocations:
59      - Type:   R_WASM_TABLE_INDEX_SLEB
60        Index:  0
61        Offset: 0x00000002
62      - Type:   R_WASM_FUNCTION_INDEX_LEB
63        Index:  1
64        Offset: 0x0000002
65    Functions:
66      - Index:  0
67        Locals:
68         - Type:  I32
69           Count: 3
70        Body: 010101010B
71      - Index: 1
72        Locals:
73         - Type: I32
74           Count: 1
75        Body: 010101010B
76  - Type: CUSTOM
77    Name:    linking
78    Version: 2
79    SymbolTable:
80      - Index: 0
81        Kind:  FUNCTION
82        Name:  func1
83        Flags: [  ]
84        Function: 0
85      - Index: 1
86        Kind:  FUNCTION
87        Name:  func2
88        Flags: [  ]
89        Function: 1
90...
91