summaryrefslogtreecommitdiff
path: root/COFF/Librarian.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'COFF/Librarian.cpp')
-rw-r--r--COFF/Librarian.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/COFF/Librarian.cpp b/COFF/Librarian.cpp
index 3ce72822180b..91316ee6b0c9 100644
--- a/COFF/Librarian.cpp
+++ b/COFF/Librarian.cpp
@@ -162,7 +162,7 @@ public:
// Create a short import file which is described in PE/COFF spec 7. Import
// Library Format.
NewArchiveMember createShortImport(StringRef Sym, uint16_t Ordinal,
- ImportNameType NameType, bool isData);
+ ImportType Type, ImportNameType NameType);
};
}
@@ -440,8 +440,8 @@ NewArchiveMember ObjectFactory::createNullThunk(std::vector<uint8_t> &Buffer) {
NewArchiveMember ObjectFactory::createShortImport(StringRef Sym,
uint16_t Ordinal,
- ImportNameType NameType,
- bool isData) {
+ ImportType ImportType,
+ ImportNameType NameType) {
size_t ImpSize = DLLName.size() + Sym.size() + 2; // +2 for NULs
size_t Size = sizeof(coff_import_header) + ImpSize;
char *Buf = Alloc.Allocate<char>(Size);
@@ -456,8 +456,7 @@ NewArchiveMember ObjectFactory::createShortImport(StringRef Sym,
Imp->SizeOfData = ImpSize;
if (Ordinal > 0)
Imp->OrdinalHint = Ordinal;
- Imp->TypeInfo = (isData ? IMPORT_DATA : IMPORT_CODE);
- Imp->TypeInfo |= NameType << 2;
+ Imp->TypeInfo = (NameType << 2) | ImportType;
// Write symbol name and DLL name.
memcpy(P, Sym.data(), Sym.size());
@@ -490,11 +489,18 @@ void lld::coff::writeImportLibrary() {
if (E.Private)
continue;
- ImportNameType Type = getNameType(E.SymbolName, E.Name);
+ ImportType ImportType = IMPORT_CODE;
+ if (E.Data)
+ ImportType = IMPORT_DATA;
+ if (E.Constant)
+ ImportType = IMPORT_CONST;
+
+ ImportNameType NameType = getNameType(E.SymbolName, E.Name);
std::string Name = E.ExtName.empty()
? std::string(E.SymbolName)
: replace(E.SymbolName, E.Name, E.ExtName);
- Members.push_back(OF.createShortImport(Name, E.Ordinal, Type, E.Data));
+ Members.push_back(OF.createShortImport(Name, E.Ordinal, ImportType,
+ NameType));
}
std::pair<StringRef, std::error_code> Result =