forked from OSchip/llvm-project
COFF: actually synthesize CONST imports properly
CONSTANT imports expect both the `_imp_` prefixed and non-prefixed symbols should be added to the symbol table. This allows for linking symbols like _NSConcreteGlobalBlock in WinObjC. The previous change would generate the import library properly by handling the option but would not consume the generated entry properly. llvm-svn: 301657
This commit is contained in:
parent
24db6b800f
commit
5c98b74536
|
@ -327,6 +327,9 @@ void ImportFile::parse() {
|
|||
|
||||
ImpSym = cast<DefinedImportData>(
|
||||
Symtab->addImportData(ImpName, this)->body());
|
||||
if (Hdr->getType() == llvm::COFF::IMPORT_CONST)
|
||||
ConstSym =
|
||||
cast<DefinedImportData>(Symtab->addImportData(Name, this)->body());
|
||||
|
||||
// If type is function, we need to create a thunk which jump to an
|
||||
// address pointed by the __imp_ symbol. (This allows you to call
|
||||
|
|
|
@ -167,6 +167,7 @@ public:
|
|||
static bool classof(const InputFile *F) { return F->kind() == ImportKind; }
|
||||
|
||||
DefinedImportData *ImpSym = nullptr;
|
||||
DefinedImportData *ConstSym = nullptr;
|
||||
DefinedImportThunk *ThunkSym = nullptr;
|
||||
std::string DLLName;
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
.def __DllMainCRTStartup@12
|
||||
.type 32
|
||||
.scl 2
|
||||
.endef
|
||||
.global __DllMainCRTStartup@12
|
||||
__DllMainCRTStartup@12:
|
||||
ret
|
||||
|
||||
.data
|
||||
.def _Data
|
||||
.type 0
|
||||
.scl 2
|
||||
.endef
|
||||
.global _Data
|
||||
_Data:
|
||||
.long ___CFConstantStringClassReference
|
||||
|
||||
.section .drectve
|
||||
.ascii " -export:_Data"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
RUN: mkdir -p %t
|
||||
RUN: llvm-mc -triple i686-unknown-windows-msvc -filetype obj -o %t/import.o %S/Inputs/constant-import.s
|
||||
RUN: llc -mtriple i686-unknown-windows-msvc -filetype obj -o %t/export.o %S/Inputs/constant-export.ll
|
||||
RUN: lld-link -machine:x86 -dll -out:%t/export.dll %t/export.o -entry:__CFConstantStringClassReference
|
||||
RUN: lld-link -machine:x86 -dll -out:%t/import.dll %t/import.o %t/export.lib
|
Loading…
Reference in New Issue