[llvm] r308384 - Object: rename parameter from DLLName to ImportName
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 15:11:02 PDT 2017
Author: compnerd
Date: Tue Jul 18 15:11:01 2017
New Revision: 308384
URL: http://llvm.org/viewvc/llvm-project?rev=308384&view=rev
Log:
Object: rename parameter from DLLName to ImportName
When I originally wrote this code, I neglected the fact that the import
library may be created for executables. This name is not the name of
the DLL, but rather the name for the imported module. It will be
embedded into the IAT/ILT reference. Rename it to make it more obvious.
NFC.
Modified:
llvm/trunk/include/llvm/Object/COFFImportFile.h
llvm/trunk/lib/Object/COFFImportFile.cpp
Modified: llvm/trunk/include/llvm/Object/COFFImportFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFFImportFile.h?rev=308384&r1=308383&r2=308384&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFFImportFile.h (original)
+++ llvm/trunk/include/llvm/Object/COFFImportFile.h Tue Jul 18 15:11:01 2017
@@ -95,7 +95,7 @@ struct COFFShortExport {
}
};
-std::error_code writeImportLibrary(StringRef DLLName,
+std::error_code writeImportLibrary(StringRef ImportName,
StringRef Path,
ArrayRef<COFFShortExport> Exports,
COFF::MachineTypes Machine);
Modified: llvm/trunk/lib/Object/COFFImportFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFImportFile.cpp?rev=308384&r1=308383&r2=308384&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFImportFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFImportFile.cpp Tue Jul 18 15:11:01 2017
@@ -131,14 +131,14 @@ class ObjectFactory {
using u32 = support::ulittle32_t;
MachineTypes Machine;
BumpPtrAllocator Alloc;
- StringRef DLLName;
+ StringRef ImportName;
StringRef Library;
std::string ImportDescriptorSymbolName;
std::string NullThunkSymbolName;
public:
ObjectFactory(StringRef S, MachineTypes M)
- : Machine(M), DLLName(S), Library(S.drop_back(4)),
+ : Machine(M), ImportName(S), Library(S.drop_back(4)),
ImportDescriptorSymbolName(("__IMPORT_DESCRIPTOR_" + Library).str()),
NullThunkSymbolName(("\x7f" + Library + "_NULL_THUNK_DATA").str()) {}
@@ -184,7 +184,7 @@ ObjectFactory::createImportDescriptor(st
sizeof(coff_import_directory_table_entry) +
NumberOfRelocations * sizeof(coff_relocation) +
// .idata$4
- (DLLName.size() + 1)),
+ (ImportName.size() + 1)),
u32(NumberOfSymbols),
u16(0),
u16(is32bit(Machine) ? IMAGE_FILE_32BIT_MACHINE : 0),
@@ -208,7 +208,7 @@ ObjectFactory::createImportDescriptor(st
{{'.', 'i', 'd', 'a', 't', 'a', '$', '6'},
u32(0),
u32(0),
- u32(DLLName.size() + 1),
+ u32(ImportName.size() + 1),
u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section) +
sizeof(coff_import_directory_table_entry) +
NumberOfRelocations * sizeof(coff_relocation)),
@@ -239,9 +239,9 @@ ObjectFactory::createImportDescriptor(st
// .idata$6
auto S = Buffer.size();
- Buffer.resize(S + DLLName.size() + 1);
- memcpy(&Buffer[S], DLLName.data(), DLLName.size());
- Buffer[S + DLLName.size()] = '\0';
+ Buffer.resize(S + ImportName.size() + 1);
+ memcpy(&Buffer[S], ImportName.data(), ImportName.size());
+ Buffer[S + ImportName.size()] = '\0';
// Symbol Table
coff_symbol16 SymbolTable[NumberOfSymbols] = {
@@ -305,7 +305,7 @@ ObjectFactory::createImportDescriptor(st
NullThunkSymbolName});
StringRef F{reinterpret_cast<const char *>(Buffer.data()), Buffer.size()};
- return {MemoryBufferRef(F, DLLName)};
+ return {MemoryBufferRef(F, ImportName)};
}
NewArchiveMember
@@ -366,7 +366,7 @@ ObjectFactory::createNullImportDescripto
writeStringTable(Buffer, {NullImportDescriptorSymbolName});
StringRef F{reinterpret_cast<const char *>(Buffer.data()), Buffer.size()};
- return {MemoryBufferRef(F, DLLName)};
+ return {MemoryBufferRef(F, ImportName)};
}
NewArchiveMember ObjectFactory::createNullThunk(std::vector<uint8_t> &Buffer) {
@@ -448,14 +448,14 @@ NewArchiveMember ObjectFactory::createNu
writeStringTable(Buffer, {NullThunkSymbolName});
StringRef F{reinterpret_cast<const char *>(Buffer.data()), Buffer.size()};
- return {MemoryBufferRef{F, DLLName}};
+ return {MemoryBufferRef{F, ImportName}};
}
NewArchiveMember ObjectFactory::createShortImport(StringRef Sym,
uint16_t Ordinal,
ImportType ImportType,
ImportNameType NameType) {
- size_t ImpSize = DLLName.size() + Sym.size() + 2; // +2 for NULs
+ size_t ImpSize = ImportName.size() + Sym.size() + 2; // +2 for NULs
size_t Size = sizeof(coff_import_header) + ImpSize;
char *Buf = Alloc.Allocate<char>(Size);
memset(Buf, 0, Size);
@@ -474,9 +474,9 @@ NewArchiveMember ObjectFactory::createSh
// Write symbol name and DLL name.
memcpy(P, Sym.data(), Sym.size());
P += Sym.size() + 1;
- memcpy(P, DLLName.data(), DLLName.size());
+ memcpy(P, ImportName.data(), ImportName.size());
- return {MemoryBufferRef(StringRef(Buf, Size), DLLName)};
+ return {MemoryBufferRef(StringRef(Buf, Size), ImportName)};
}
NewArchiveMember ObjectFactory::createWeakExternal(StringRef Sym,
@@ -555,15 +555,15 @@ NewArchiveMember ObjectFactory::createWe
// Copied here so we can still use writeStringTable
char *Buf = Alloc.Allocate<char>(Buffer.size());
memcpy(Buf, Buffer.data(), Buffer.size());
- return {MemoryBufferRef(StringRef(Buf, Buffer.size()), DLLName)};
+ return {MemoryBufferRef(StringRef(Buf, Buffer.size()), ImportName)};
}
-std::error_code writeImportLibrary(StringRef DLLName, StringRef Path,
+std::error_code writeImportLibrary(StringRef ImportName, StringRef Path,
ArrayRef<COFFShortExport> Exports,
MachineTypes Machine) {
std::vector<NewArchiveMember> Members;
- ObjectFactory OF(llvm::sys::path::filename(DLLName), Machine);
+ ObjectFactory OF(llvm::sys::path::filename(ImportName), Machine);
std::vector<uint8_t> ImportDescriptor;
Members.push_back(OF.createImportDescriptor(ImportDescriptor));
More information about the llvm-commits
mailing list