1# REQUIRES: x86
2
3# RUN: llvm-mc -filetype=obj -triple=x86_64-mingw32 -o %t.o %s
4# RUN: lld-link -lldmingw -dll -out:%t.dll %t.o -entry:__ImageBase 2>&1 | FileCheck %s --allow-empty --check-prefix=NOWARNING
5# RUN: llvm-readobj --coff-exports %t.dll | FileCheck %s
6# RUN: lld-link -lldmingw -dll -out:%t.dll %t.o -entry:__ImageBase -export:otherfunc 2>&1 | FileCheck %s --check-prefix=WARNING
7# RUN: llvm-readobj --coff-exports %t.dll | FileCheck %s
8
9# Check that the export table contains the manually crafted content
10# instead of the linker generated exports.
11
12# CHECK:      Export {
13# CHECK-NEXT:   Ordinal: 1
14# CHECK-NEXT:   Name: myfunc
15# CHECK-NEXT:   RVA:
16# CHECK-NEXT: }
17# CHECK-EMPTY:
18
19# NOWARNING-NOT: warning
20
21# WARNING: warning: literal .edata sections override exports
22
23    .text
24    .globl myfunc
25myfunc:
26    ret
27    .globl otherfunc
28otherfunc:
29    ret
30
31// The object contains a manually crafted .edata section, which exports
32// myfunc, not otherfunc.
33    .section .edata, "drw"
34    .align 4
35exports:
36    .long 0           // ExportFlags
37    .long 0           // TimeDateStamp
38    .long 0           // MajorVersion + MinorVersion
39    .rva name         // NameRVA
40    .long 1           // OrdinalBase
41    .long 1           // AddressTableEntries
42    .long 1           // NumberOfNamePointers
43    .rva functions    // ExportAddressTableRVA
44    .rva names        // NamePointerRVA
45    .rva nameordinals // OrdinalTableRVA
46
47names:
48    .rva funcname_myfunc
49
50nameordinals:
51    .short 0
52
53functions:
54    .rva myfunc
55    .long 0
56
57funcname_myfunc:
58    .asciz "myfunc"
59
60name:
61    .asciz "mydll.dll"
62