summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/COFFModuleDefinition.cpp
diff options
context:
space:
mode:
authorMartell Malone <martellmalone@gmail.com>2017-07-18 21:26:38 +0000
committerMartell Malone <martellmalone@gmail.com>2017-07-18 21:26:38 +0000
commit1079ef8dfe867945bbced7cdc3e724d406cd2c41 (patch)
treeb3158e44cbb012317a88e547e354ec35391316b8 /llvm/lib/Object/COFFModuleDefinition.cpp
parentf6b8ac28ab582bd0850482e9bee450c7d78450d7 (diff)
downloadbcm5719-llvm-1079ef8dfe867945bbced7cdc3e724d406cd2c41.tar.gz
bcm5719-llvm-1079ef8dfe867945bbced7cdc3e724d406cd2c41.zip
llvm: add llvm-dlltool support to the archiver
A PE COFF spec compliant import library generator. Intended to be used with mingw-w64. Supports: PE COFF spec (section 8, Import Library Format) PE COFF spec (Aux Format 3: Weak Externals) Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D29892 This reapplies rL308329, which was reverted in rL308374 llvm-svn: 308379
Diffstat (limited to 'llvm/lib/Object/COFFModuleDefinition.cpp')
-rw-r--r--llvm/lib/Object/COFFModuleDefinition.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/Object/COFFModuleDefinition.cpp b/llvm/lib/Object/COFFModuleDefinition.cpp
index 0d69cb6b709..d6729684e20 100644
--- a/llvm/lib/Object/COFFModuleDefinition.cpp
+++ b/llvm/lib/Object/COFFModuleDefinition.cpp
@@ -55,8 +55,10 @@ struct Token {
StringRef Value;
};
-static bool isDecorated(StringRef Sym) {
- return Sym.startswith("_") || Sym.startswith("@") || Sym.startswith("?");
+static bool isDecorated(StringRef Sym, bool MingwDef) {
+ // mingw does not prepend "_".
+ return (!MingwDef && Sym.startswith("_")) || Sym.startswith("@") ||
+ Sym.startswith("?");
}
static Error createError(const Twine &Err) {
@@ -83,6 +85,9 @@ 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();
@@ -120,7 +125,8 @@ private:
class Parser {
public:
- explicit Parser(StringRef S, MachineTypes M) : Lex(S), Machine(M) {}
+ explicit Parser(StringRef S, MachineTypes M, bool B)
+ : Lex(S), Machine(M), MingwDef(B) {}
Expected<COFFModuleDefinition> parse() {
do {
@@ -213,9 +219,9 @@ private:
}
if (Machine == IMAGE_FILE_MACHINE_I386) {
- if (!isDecorated(E.Name))
+ if (!isDecorated(E.Name, MingwDef))
E.Name = (std::string("_").append(E.Name));
- if (!E.ExtName.empty() && !isDecorated(E.ExtName))
+ if (!E.ExtName.empty() && !isDecorated(E.ExtName, MingwDef))
E.ExtName = (std::string("_").append(E.ExtName));
}
@@ -308,11 +314,13 @@ private:
std::vector<Token> Stack;
MachineTypes Machine;
COFFModuleDefinition Info;
+ bool MingwDef;
};
Expected<COFFModuleDefinition> parseCOFFModuleDefinition(MemoryBufferRef MB,
- MachineTypes Machine) {
- return Parser(MB.getBuffer(), Machine).parse();
+ MachineTypes Machine,
+ bool MingwDef) {
+ return Parser(MB.getBuffer(), Machine, MingwDef).parse();
}
} // namespace object
OpenPOWER on IntegriCloud