diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-04-28 17:06:40 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-04-28 17:06:40 +0000 |
commit | 5c98b74536e3ea4b491f47918828ac07c07e3def (patch) | |
tree | c4a8eb1467426e2fa63a4e824793eedd03546780 | |
parent | 24db6b800fcdf0b45f1e2489ec3a7fb57937f0d1 (diff) | |
download | bcm5719-llvm-5c98b74536e3ea4b491f47918828ac07c07e3def.tar.gz bcm5719-llvm-5c98b74536e3ea4b491f47918828ac07c07e3def.zip |
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
-rw-r--r-- | lld/COFF/InputFiles.cpp | 3 | ||||
-rw-r--r-- | lld/COFF/InputFiles.h | 1 | ||||
-rw-r--r-- | lld/test/COFF/Inputs/constant-import.s | 21 | ||||
-rw-r--r-- | lld/test/COFF/constant.test | 5 |
4 files changed, 30 insertions, 0 deletions
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index cb56e13014d..df3b6a032cf 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -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 diff --git a/lld/COFF/InputFiles.h b/lld/COFF/InputFiles.h index 3078de68752..a2fd3f59ad7 100644 --- a/lld/COFF/InputFiles.h +++ b/lld/COFF/InputFiles.h @@ -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; diff --git a/lld/test/COFF/Inputs/constant-import.s b/lld/test/COFF/Inputs/constant-import.s new file mode 100644 index 00000000000..4249d74c9cb --- /dev/null +++ b/lld/test/COFF/Inputs/constant-import.s @@ -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" + diff --git a/lld/test/COFF/constant.test b/lld/test/COFF/constant.test new file mode 100644 index 00000000000..3c8956beac9 --- /dev/null +++ b/lld/test/COFF/constant.test @@ -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 |