From f8cba388440ff846c5f479889fc64a03066ff39c Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Mon, 8 Aug 2016 15:37:59 +0300 Subject: [PATCH 2/5] Make the "gnu arguments in lld coff" patch not break using lld-link in normal MSVC mode --- COFF/Driver.cpp | 1 + COFF/DriverUtils.cpp | 5 ++++- COFF/Options.td | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp index 0821591..65cfa9f 100644 --- a/COFF/Driver.cpp +++ b/COFF/Driver.cpp @@ -602,6 +602,7 @@ void LinkerDriver::link(llvm::ArrayRef ArgsArr) { if (Config->ImageBase == uint64_t(-1)) Config->ImageBase = getDefaultImageBase(); + Symtab.addRelative(mangle("__ImageBase"), 0); Symtab.addRelative(mangle("__image_base__"), 0); if (Config->Machine == I386) { Config->SEHTable = Symtab.addRelative("___safe_se_handler_table", 0); diff --git a/COFF/DriverUtils.cpp b/COFF/DriverUtils.cpp index e2f1f2d..f9c37ec 100644 --- a/COFF/DriverUtils.cpp +++ b/COFF/DriverUtils.cpp @@ -591,7 +591,10 @@ static const llvm::opt::OptTable::Info infoTable[] = { class COFFOptTable : public llvm::opt::OptTable { public: - COFFOptTable() : OptTable(infoTable) {} + // GNU ld option style support requires case sensitive option matching + // (for -L vs -l), needing aliases for a few link.exe options that can + // appear in upper case in embedded directives in libraries. + COFFOptTable() : OptTable(infoTable, false) {} }; // Parses a given list of options. diff --git a/COFF/Options.td b/COFF/Options.td index 322b162..4e7338a 100644 --- a/COFF/Options.td +++ b/COFF/Options.td @@ -19,11 +19,13 @@ def align : P<"align", "Section alignment">; def alternatename : P<"alternatename", "Define weak alias">; def base : P<"base", "Base address of the program">; def defaultlib : P<"defaultlib", "Add the library to the list of input files">; +def DEFAULTLIB : P<"DEFAULTLIB", "">, Alias; def delayload : P<"delayload", "Delay loaded DLL name">; def entry : P<"entry", "Name of entry point symbol">; def export : P<"export", "Export a function">; // No help text because /failifmismatch is not intended to be used by the user. def failifmismatch : P<"failifmismatch", "">; +def FAILIFMISMATCH : P<"FAILIFMISMATCH", "">, Alias; def heap : P<"heap", "Size of the heap">; def implib : P<"implib", "Import library name">; def libpath : P<"libpath", "Additional library search path">; -- 2.7.4