[llvm] r308374 - Revert r308329: llvm: add llvm-dlltool support to the archiver
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 14:07:13 PDT 2017
Author: ruiu
Date: Tue Jul 18 14:07:13 2017
New Revision: 308374
URL: http://llvm.org/viewvc/llvm-project?rev=308374&view=rev
Log:
Revert r308329: llvm: add llvm-dlltool support to the archiver
This reverts commit r308329 because it broke buildbots.
Removed:
llvm/trunk/include/llvm/ToolDrivers/llvm-dlltool/
llvm/trunk/lib/ToolDrivers/llvm-dlltool/
llvm/trunk/test/DllTool/
Modified:
llvm/trunk/include/llvm/Object/COFFModuleDefinition.h
llvm/trunk/lib/Object/ArchiveWriter.cpp
llvm/trunk/lib/Object/COFFImportFile.cpp
llvm/trunk/lib/Object/COFFModuleDefinition.cpp
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/lib/ToolDrivers/CMakeLists.txt
llvm/trunk/lib/ToolDrivers/LLVMBuild.txt
llvm/trunk/tools/llvm-ar/CMakeLists.txt
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Modified: llvm/trunk/include/llvm/Object/COFFModuleDefinition.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFFModuleDefinition.h?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFFModuleDefinition.h (original)
+++ llvm/trunk/include/llvm/Object/COFFModuleDefinition.h Tue Jul 18 14:07:13 2017
@@ -16,6 +16,7 @@
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_OBJECT_COFF_MODULE_DEFINITION_H
#define LLVM_OBJECT_COFF_MODULE_DEFINITION_H
@@ -39,12 +40,8 @@ struct COFFModuleDefinition {
uint32_t MinorOSVersion = 0;
};
-// mingw and wine def files do not mangle _ for x86 which
-// is a consequence of legacy binutils' dlltool functionality.
-// This MingwDef flag should be removed once mingw stops this pratice.
Expected<COFFModuleDefinition>
-parseCOFFModuleDefinition(MemoryBufferRef MB, COFF::MachineTypes Machine,
- bool MingwDef = false);
+parseCOFFModuleDefinition(MemoryBufferRef MB, COFF::MachineTypes Machine);
} // End namespace object.
} // End namespace llvm.
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Tue Jul 18 14:07:13 2017
@@ -318,8 +318,7 @@ writeSymbolTable(raw_fd_ostream &Out, ob
continue;
if (!(Symflags & object::SymbolRef::SF_Global))
continue;
- if (Symflags & object::SymbolRef::SF_Undefined &&
- !(Symflags & object::SymbolRef::SF_Indirect))
+ if (Symflags & object::SymbolRef::SF_Undefined)
continue;
unsigned NameOffset = NameOS.tell();
Modified: llvm/trunk/lib/Object/COFFImportFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFImportFile.cpp?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFImportFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFImportFile.cpp Tue Jul 18 14:07:13 2017
@@ -162,17 +162,14 @@ public:
// Library Format.
NewArchiveMember createShortImport(StringRef Sym, uint16_t Ordinal,
ImportType Type, ImportNameType NameType);
-
- // Create a weak external file which is described in PE/COFF Aux Format 3.
- NewArchiveMember createWeakExternal(StringRef Sym, StringRef Weak, bool Imp);
};
} // namespace
NewArchiveMember
ObjectFactory::createImportDescriptor(std::vector<uint8_t> &Buffer) {
- const uint32_t NumberOfSections = 2;
- const uint32_t NumberOfSymbols = 7;
- const uint32_t NumberOfRelocations = 3;
+ static const uint32_t NumberOfSections = 2;
+ static const uint32_t NumberOfSymbols = 7;
+ static const uint32_t NumberOfRelocations = 3;
// COFF Header
coff_file_header Header{
@@ -192,7 +189,7 @@ ObjectFactory::createImportDescriptor(st
append(Buffer, Header);
// Section Header Table
- const coff_section SectionTable[NumberOfSections] = {
+ static const coff_section SectionTable[NumberOfSections] = {
{{'.', 'i', 'd', 'a', 't', 'a', '$', '2'},
u32(0),
u32(0),
@@ -222,12 +219,12 @@ ObjectFactory::createImportDescriptor(st
append(Buffer, SectionTable);
// .idata$2
- const coff_import_directory_table_entry ImportDescriptor{
+ static const coff_import_directory_table_entry ImportDescriptor{
u32(0), u32(0), u32(0), u32(0), u32(0),
};
append(Buffer, ImportDescriptor);
- const coff_relocation RelocationTable[NumberOfRelocations] = {
+ static const coff_relocation RelocationTable[NumberOfRelocations] = {
{u32(offsetof(coff_import_directory_table_entry, NameRVA)), u32(2),
u16(getImgRelRelocation(Machine))},
{u32(offsetof(coff_import_directory_table_entry, ImportLookupTableRVA)),
@@ -310,8 +307,8 @@ ObjectFactory::createImportDescriptor(st
NewArchiveMember
ObjectFactory::createNullImportDescriptor(std::vector<uint8_t> &Buffer) {
- const uint32_t NumberOfSections = 1;
- const uint32_t NumberOfSymbols = 1;
+ static const uint32_t NumberOfSections = 1;
+ static const uint32_t NumberOfSymbols = 1;
// COFF Header
coff_file_header Header{
@@ -328,7 +325,7 @@ ObjectFactory::createNullImportDescripto
append(Buffer, Header);
// Section Header Table
- const coff_section SectionTable[NumberOfSections] = {
+ static const coff_section SectionTable[NumberOfSections] = {
{{'.', 'i', 'd', 'a', 't', 'a', '$', '3'},
u32(0),
u32(0),
@@ -345,7 +342,7 @@ ObjectFactory::createNullImportDescripto
append(Buffer, SectionTable);
// .idata$3
- const coff_import_directory_table_entry ImportDescriptor{
+ static const coff_import_directory_table_entry ImportDescriptor{
u32(0), u32(0), u32(0), u32(0), u32(0),
};
append(Buffer, ImportDescriptor);
@@ -370,8 +367,8 @@ ObjectFactory::createNullImportDescripto
}
NewArchiveMember ObjectFactory::createNullThunk(std::vector<uint8_t> &Buffer) {
- const uint32_t NumberOfSections = 2;
- const uint32_t NumberOfSymbols = 1;
+ static const uint32_t NumberOfSections = 2;
+ static const uint32_t NumberOfSymbols = 1;
uint32_t VASize = is32bit(Machine) ? 4 : 8;
// COFF Header
@@ -391,7 +388,7 @@ NewArchiveMember ObjectFactory::createNu
append(Buffer, Header);
// Section Header Table
- const coff_section SectionTable[NumberOfSections] = {
+ static const coff_section SectionTable[NumberOfSections] = {
{{'.', 'i', 'd', 'a', 't', 'a', '$', '5'},
u32(0),
u32(0),
@@ -479,85 +476,6 @@ NewArchiveMember ObjectFactory::createSh
return {MemoryBufferRef(StringRef(Buf, Size), DLLName)};
}
-NewArchiveMember ObjectFactory::createWeakExternal(StringRef Sym,
- StringRef Weak, bool Imp) {
- std::vector<uint8_t> Buffer;
- const uint32_t NumberOfSections = 1;
- const uint32_t NumberOfSymbols = 5;
-
- // COFF Header
- coff_file_header Header{
- u16(0),
- u16(NumberOfSections),
- u32(0),
- u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section))),
- u32(NumberOfSymbols),
- u16(0),
- u16(0),
- };
- append(Buffer, Header);
-
- // Section Header Table
- const coff_section SectionTable[NumberOfSections] = {
- {{'.', 'd', 'r', 'e', 'c', 't', 'v', 'e'},
- u32(0),
- u32(0),
- u32(0),
- u32(0),
- u32(0),
- u32(0),
- u16(0),
- u16(0),
- u32(IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE)}};
- append(Buffer, SectionTable);
-
- // Symbol Table
- coff_symbol16 SymbolTable[NumberOfSymbols] = {
- {{{'@', 'c', 'o', 'm', 'p', '.', 'i', 'd'}},
- u32(0),
- u16(0xFFFF),
- u16(0),
- IMAGE_SYM_CLASS_STATIC,
- 0},
- {{{'@', 'f', 'e', 'a', 't', '.', '0', '0'}},
- u32(0),
- u16(0xFFFF),
- u16(0),
- IMAGE_SYM_CLASS_STATIC,
- 0},
- {{{0, 0, 0, 0, 0, 0, 0, 0}},
- u32(0),
- u16(0),
- u16(0),
- IMAGE_SYM_CLASS_EXTERNAL,
- 0},
- {{{0, 0, 0, 0, 0, 0, 0, 0}},
- u32(0),
- u16(0),
- u16(0),
- IMAGE_SYM_CLASS_WEAK_EXTERNAL,
- 1},
- {{{2, 0, 0, 0, 3, 0, 0, 0}}, u32(0), u16(0), u16(0), uint8_t(0), 0},
- };
- SymbolTable[2].Name.Offset.Offset = sizeof(uint32_t);
-
- //__imp_ String Table
- if (Imp) {
- SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 7;
- writeStringTable(Buffer, {std::string("__imp_").append(Sym),
- std::string("__imp_").append(Weak)});
- } else {
- SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 1;
- writeStringTable(Buffer, {Sym, Weak});
- }
- append(Buffer, SymbolTable);
-
- // 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)};
-}
-
std::error_code writeImportLibrary(StringRef DLLName, StringRef Path,
ArrayRef<COFFShortExport> Exports,
MachineTypes Machine) {
@@ -578,12 +496,6 @@ std::error_code writeImportLibrary(Strin
if (E.Private)
continue;
- if (E.isWeak()) {
- Members.push_back(OF.createWeakExternal(E.Name, E.ExtName, false));
- Members.push_back(OF.createWeakExternal(E.Name, E.ExtName, true));
- continue;
- }
-
ImportType ImportType = IMPORT_CODE;
if (E.Data)
ImportType = IMPORT_DATA;
Modified: llvm/trunk/lib/Object/COFFModuleDefinition.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFModuleDefinition.cpp?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFModuleDefinition.cpp (original)
+++ llvm/trunk/lib/Object/COFFModuleDefinition.cpp Tue Jul 18 14:07:13 2017
@@ -55,10 +55,8 @@ struct Token {
StringRef Value;
};
-static bool isDecorated(StringRef Sym, bool MingwDef) {
- // mingw does not prepend "_".
- return (!MingwDef && Sym.startswith("_")) || Sym.startswith("@") ||
- Sym.startswith("?");
+static bool isDecorated(StringRef Sym) {
+ return Sym.startswith("_") || Sym.startswith("@") || Sym.startswith("?");
}
static Error createError(const Twine &Err) {
@@ -85,9 +83,6 @@ public:
}
case '=':
Buf = Buf.drop_front();
- // GNU dlltool accepts both = and ==.
- if (Buf.startswith("="))
- Buf = Buf.drop_front();
return Token(Equal, "=");
case ',':
Buf = Buf.drop_front();
@@ -125,8 +120,7 @@ private:
class Parser {
public:
- explicit Parser(StringRef S, MachineTypes M, bool B)
- : Lex(S), Machine(M), MingwDef(B) {}
+ explicit Parser(StringRef S, MachineTypes M) : Lex(S), Machine(M) {}
Expected<COFFModuleDefinition> parse() {
do {
@@ -219,9 +213,9 @@ private:
}
if (Machine == IMAGE_FILE_MACHINE_I386) {
- if (!isDecorated(E.Name, MingwDef))
+ if (!isDecorated(E.Name))
E.Name = (std::string("_").append(E.Name));
- if (!E.ExtName.empty() && !isDecorated(E.ExtName, MingwDef))
+ if (!E.ExtName.empty() && !isDecorated(E.ExtName))
E.ExtName = (std::string("_").append(E.ExtName));
}
@@ -314,13 +308,11 @@ private:
std::vector<Token> Stack;
MachineTypes Machine;
COFFModuleDefinition Info;
- bool MingwDef;
};
Expected<COFFModuleDefinition> parseCOFFModuleDefinition(MemoryBufferRef MB,
- MachineTypes Machine,
- bool MingwDef) {
- return Parser(MB.getBuffer(), Machine, MingwDef).parse();
+ MachineTypes Machine) {
+ return Parser(MB.getBuffer(), Machine).parse();
}
} // namespace object
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Tue Jul 18 14:07:13 2017
@@ -227,11 +227,8 @@ uint32_t COFFObjectFile::getSymbolFlags(
if (Symb.isExternal() || Symb.isWeakExternal())
Result |= SymbolRef::SF_Global;
- if (Symb.isWeakExternal()) {
+ if (Symb.isWeakExternal())
Result |= SymbolRef::SF_Weak;
- // We use indirect to allow the archiver to write weak externs
- Result |= SymbolRef::SF_Indirect;
- }
if (Symb.getSectionNumber() == COFF::IMAGE_SYM_ABSOLUTE)
Result |= SymbolRef::SF_Absolute;
Modified: llvm/trunk/lib/ToolDrivers/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ToolDrivers/CMakeLists.txt?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/lib/ToolDrivers/CMakeLists.txt (original)
+++ llvm/trunk/lib/ToolDrivers/CMakeLists.txt Tue Jul 18 14:07:13 2017
@@ -1,2 +1 @@
-add_subdirectory(llvm-dlltool)
add_subdirectory(llvm-lib)
Modified: llvm/trunk/lib/ToolDrivers/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ToolDrivers/LLVMBuild.txt?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/lib/ToolDrivers/LLVMBuild.txt (original)
+++ llvm/trunk/lib/ToolDrivers/LLVMBuild.txt Tue Jul 18 14:07:13 2017
@@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===;
[common]
-subdirectories = llvm-dlltool llvm-lib
+subdirectories = llvm-lib
[component_0]
type = Group
Modified: llvm/trunk/tools/llvm-ar/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/CMakeLists.txt?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-ar/CMakeLists.txt Tue Jul 18 14:07:13 2017
@@ -1,7 +1,6 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Core
- DlltoolDriver
LibDriver
Object
Support
@@ -16,4 +15,3 @@ add_llvm_tool(llvm-ar
add_llvm_tool_symlink(llvm-ranlib llvm-ar)
add_llvm_tool_symlink(llvm-lib llvm-ar)
-add_llvm_tool_symlink(llvm-dlltool llvm-ar)
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=308374&r1=308373&r2=308374&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Tue Jul 18 14:07:13 2017
@@ -16,7 +16,6 @@
#include "llvm/ADT/Triple.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-#include "llvm/ToolDrivers/llvm-dlltool/DlltoolDriver.h"
#include "llvm/ToolDrivers/llvm-lib/LibDriver.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ArchiveWriter.h"
@@ -864,9 +863,6 @@ int main(int argc, char **argv) {
llvm::InitializeAllAsmParsers();
StringRef Stem = sys::path::stem(ToolName);
- if (Stem.find("dlltool") != StringRef::npos)
- return dlltoolDriverMain(makeArrayRef(argv, argc));
-
if (Stem.find("ranlib") == StringRef::npos &&
Stem.find("lib") != StringRef::npos)
return libDriverMain(makeArrayRef(argv, argc));
@@ -882,5 +878,5 @@ int main(int argc, char **argv) {
return ranlib_main();
if (Stem.find("ar") != StringRef::npos)
return ar_main();
- fail("Not ranlib, ar, lib or dlltool!");
+ fail("Not ranlib, ar or lib!");
}
More information about the llvm-commits
mailing list