COFF: Fix /export.

Mangled dllexported symbols may be defined in a library.
If that's the case, we have to read a member file from the library.

llvm-svn: 240947
This commit is contained in:
Rui Ueyama 2015-06-29 14:27:10 +00:00
parent fad30cf194
commit 6b79ed128a
3 changed files with 46 additions and 0 deletions

View File

@ -209,6 +209,10 @@ std::pair<StringRef, Symbol *> SymbolTable::findMangled(StringRef S) {
Symbol *Sym = I.second;
if (!Name.startswith(Prefix))
continue;
if (auto *B = dyn_cast<Lazy>(Sym->Body)) {
addMemberFile(B);
run();
}
if (isa<Defined>(Sym->Body))
return std::make_pair(Name, Sym);
}

View File

@ -0,0 +1,29 @@
---
header:
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: []
sections:
- Name: .text
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 4
SectionData: B800000000506800000000680000000050E80000000050E800000000
symbols:
- Name: .text
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
SectionDefinition:
Length: 28
NumberOfRelocations: 4
NumberOfLinenumbers: 0
CheckSum: 0
Number: 0
- Name: '?mangled2@@YAHXZ'
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
...

View File

@ -14,6 +14,19 @@ EXPORT-NEXT: 2 0x1010 exportfn2
EXPORT-NEXT: 3 0x1010 exportfn3
EXPORT-NEXT: 4 0x1010 mangled
# RUN: yaml2obj < %p/Inputs/export2.yaml > %t5.obj
# RUN: rm -f %t5.lib
# RUN: llvm-ar cru %t5.lib %t5.obj
# RUN: lld -flavor link2 /out:%t5.dll /dll %t.obj %t5.lib /export:mangled2
# RUN: llvm-objdump -p %t5.dll | FileCheck -check-prefix=EXPORT2 %s
EXPORT2: Export Table:
EXPORT2: DLL name: dll.test.tmp5.dll
EXPORT2: Ordinal RVA Name
EXPORT2-NEXT: 0 0
EXPORT2-NEXT: 1 0x1010 exportfn3
EXPORT2-NEXT: 2 0x101c mangled2
# RUN: llvm-as -o %t.lto.obj %p/Inputs/export.ll
# RUN: lld -flavor link2 /out:%t.lto.dll /dll %t.lto.obj /export:exportfn1 /export:exportfn2
# RUN: llvm-objdump -p %t.lto.dll | FileCheck -check-prefix=EXPORT-LTO %s