File: exportas.test

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (107 lines) | stat: -rw-r--r-- 3,686 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
REQUIRES: x86
RUN: split-file %s %t.dir && cd %t.dir

Link to an import library containing EXPORTAS and verify that we use proper name for the import.

RUN: llvm-mc -filetype=obj -triple=x86_64-windows test.s -o test.obj
RUN: llvm-lib -machine:amd64 -out:test.lib -def:test.def
RUN: lld-link -out:out1.dll -dll -noentry test.obj test.lib
RUN: llvm-readobj --coff-imports out1.dll | FileCheck --check-prefix=IMPORT %s
IMPORT: Symbol: expfunc

Pass -export argument with EXPORTAS.

RUN: llvm-mc -filetype=obj -triple=x86_64-windows func.s -o func.obj
RUN: lld-link -out:out2.dll -dll -noentry func.obj -export:func,EXPORTAS,expfunc
RUN: llvm-readobj --coff-exports out2.dll | FileCheck --check-prefix=EXPORT %s
EXPORT: Name: expfunc

RUN: llvm-readobj out2.lib | FileCheck --check-prefix=IMPLIB %s
IMPLIB:      Name type: export as
IMPLIB-NEXT: Export name: expfunc
IMPLIB-NEXT: Symbol: __imp_func
IMPLIB-NEXT: Symbol: func

Use .drectve section with EXPORTAS.

RUN: llvm-mc -filetype=obj -triple=x86_64-windows drectve.s -o drectve.obj
RUN: lld-link -out:out3.dll -dll -noentry func.obj drectve.obj
RUN: llvm-readobj --coff-exports out3.dll | FileCheck --check-prefix=EXPORT %s
RUN: llvm-readobj out3.lib | FileCheck --check-prefix=IMPLIB %s

Use a .def file with EXPORTAS.

RUN: lld-link -out:out4.dll -dll -noentry func.obj -def:test.def
RUN: llvm-readobj --coff-exports out4.dll | FileCheck --check-prefix=EXPORT %s
RUN: llvm-readobj out4.lib | FileCheck --check-prefix=IMPLIB %s

Use a .def file with EXPORTAS in a forwarding export.

RUN: lld-link -out:out5.dll -dll -noentry func.obj -def:test2.def
RUN: llvm-readobj --coff-exports out5.dll | FileCheck --check-prefix=FORWARD-EXPORT %s
FORWARD-EXPORT:      Export {
FORWARD-EXPORT-NEXT:   Ordinal: 1
FORWARD-EXPORT-NEXT:   Name: expfunc
FORWARD-EXPORT-NEXT:   ForwardedTo: otherdll.otherfunc
FORWARD-EXPORT-NEXT: }

RUN: llvm-readobj out5.lib | FileCheck --check-prefix=FORWARD-IMPLIB %s
FORWARD-IMPLIB:      Name type: export as
FORWARD-IMPLIB-NEXT: Export name: expfunc
FORWARD-IMPLIB-NEXT: Symbol: __imp_func
FORWARD-IMPLIB-NEXT: Symbol: func

Pass -export argument with EXPORTAS in a forwarding export.

RUN: lld-link -out:out6.dll -dll -noentry func.obj -export:func=otherdll.otherfunc,EXPORTAS,expfunc
RUN: llvm-readobj --coff-exports out6.dll | FileCheck --check-prefix=FORWARD-EXPORT %s
RUN: llvm-readobj out6.lib | FileCheck --check-prefix=FORWARD-IMPLIB %s

Pass -export argument with EXPORTAS in a data export.

RUN: lld-link -out:out7.dll -dll -noentry func.obj -export:func,DATA,@5,EXPORTAS,expfunc
RUN: llvm-readobj --coff-exports out7.dll | FileCheck --check-prefix=ORD %s
ORD:      Ordinal: 5
ORD-NEXT: Name: expfunc

RUN: llvm-readobj out7.lib | FileCheck --check-prefix=ORD-IMPLIB %s
ORD-IMPLIB:      Type: data
ORD-IMPLIB-NEXT: Name type: export as
ORD-IMPLIB-NEXT: Export name: expfunc
ORD-IMPLIB-NEXT: Symbol: __imp_func

Check invalid EXPORTAS syntax.

RUN: not lld-link -out:err1.dll -dll -noentry func.obj -export:func,EXPORTAS, 2>&1 | \
RUN:     FileCheck --check-prefix=ERR1 %s
ERR1: error: invalid EXPORTAS value: {{$}}

RUN: not lld-link -out:err2.dll -dll -noentry func.obj -export:func,EXPORTAS,expfunc,DATA 2>&1 | \
RUN:     FileCheck --check-prefix=ERR2 %s
ERR2: error: invalid EXPORTAS value: expfunc,DATA

#--- test.s
    .section ".test", "rd"
    .rva __imp_func

#--- test.def
LIBRARY test.dll
EXPORTS
    func EXPORTAS expfunc

#--- test2.def
LIBRARY test.dll
EXPORTS
    func=otherdll.otherfunc EXPORTAS expfunc

#--- func.s
    .text
    .globl func
    .p2align 2, 0x0
func:
    movl $1, %eax
    retq

#--- drectve.s
    .section .drectve, "yn"
    .ascii " -export:func,EXPORTAS,expfunc"