[lld] r301657 - COFF: actually synthesize CONST imports properly
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 28 10:06:41 PDT 2017
Author: compnerd
Date: Fri Apr 28 12:06:40 2017
New Revision: 301657
URL: http://llvm.org/viewvc/llvm-project?rev=301657&view=rev
Log:
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.
Added:
lld/trunk/test/COFF/Inputs/constant-import.s
lld/trunk/test/COFF/constant.test
Modified:
lld/trunk/COFF/InputFiles.cpp
lld/trunk/COFF/InputFiles.h
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=301657&r1=301656&r2=301657&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Fri Apr 28 12:06:40 2017
@@ -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
Modified: lld/trunk/COFF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.h?rev=301657&r1=301656&r2=301657&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.h (original)
+++ lld/trunk/COFF/InputFiles.h Fri Apr 28 12:06:40 2017
@@ -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;
Added: lld/trunk/test/COFF/Inputs/constant-import.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/constant-import.s?rev=301657&view=auto
==============================================================================
--- lld/trunk/test/COFF/Inputs/constant-import.s (added)
+++ lld/trunk/test/COFF/Inputs/constant-import.s Fri Apr 28 12:06:40 2017
@@ -0,0 +1,21 @@
+
+ .def __DllMainCRTStartup at 12
+ .type 32
+ .scl 2
+ .endef
+ .global __DllMainCRTStartup at 12
+__DllMainCRTStartup at 12:
+ ret
+
+ .data
+ .def _Data
+ .type 0
+ .scl 2
+ .endef
+ .global _Data
+_Data:
+ .long ___CFConstantStringClassReference
+
+ .section .drectve
+ .ascii " -export:_Data"
+
Added: lld/trunk/test/COFF/constant.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/constant.test?rev=301657&view=auto
==============================================================================
--- lld/trunk/test/COFF/constant.test (added)
+++ lld/trunk/test/COFF/constant.test Fri Apr 28 12:06:40 2017
@@ -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
More information about the llvm-commits
mailing list