Index: COFF/Config.h =================================================================== --- COFF/Config.h +++ COFF/Config.h @@ -63,6 +63,12 @@ // Global configuration. struct Configuration { + enum class DebugType { + None = 0x0, + CV = 0x1, /// CodeView + PData = 0x2, /// Procedure Data + Fixup = 0x4, /// Relocation Table + }; enum ManifestKind { SideBySide, Embed, No }; bool is64() { return Machine == AMD64; } @@ -78,6 +84,7 @@ bool Force = false; bool Debug = false; bool WriteSymtab = true; + unsigned DebugTypes = static_cast(DebugType::None); // Symbols in this set are considered as live by the garbage collector. std::set GCRoot; Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -16,6 +16,7 @@ #include "Writer.h" #include "lld/Driver/Driver.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/LibDriver/LibDriver.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" @@ -282,6 +283,31 @@ return Data.str(); } +static unsigned getDefaultDebugType(const llvm::opt::InputArgList &Args) { + unsigned DebugTypes = static_cast(Configuration::DebugType::CV); + if (Args.hasArg(OPT_driver)) + DebugTypes |= static_cast(Configuration::DebugType::PData); + if (Args.hasArg(OPT_profile)) + DebugTypes |= static_cast(Configuration::DebugType::Fixup); + return DebugTypes; +} + +static unsigned parseDebugType(StringRef Arg) { + llvm::SmallVector Types; + Arg.split(Types, ',', /*KeepEmpty=*/false); + + unsigned DebugTypes = static_cast(Configuration::DebugType::None); + for (auto Type : Types) + DebugTypes |= + llvm::StringSwitch(Type.lower()) + .Case("cv", static_cast(Configuration::DebugType::CV)) + .Case("pdata", + static_cast(Configuration::DebugType::PData)) + .Case("fixup", + static_cast(Configuration::DebugType::Fixup)); + return DebugTypes; +} + void LinkerDriver::link(llvm::ArrayRef ArgsArr) { // If the first command line argument is "/lib", link.exe acts like lib.exe. // We call our own implementation of lib.exe that understands bitcode files. @@ -341,8 +367,13 @@ Config->Force = true; // Handle /debug - if (Args.hasArg(OPT_debug)) + if (Args.hasArg(OPT_debug)) { Config->Debug = true; + Config->DebugTypes = + Args.hasArg(OPT_debugtype) + ? parseDebugType(Args.getLastArg(OPT_debugtype)->getValue()) + : getDefaultDebugType(Args); + } // Handle /noentry if (Args.hasArg(OPT_noentry)) { Index: COFF/Options.td =================================================================== --- COFF/Options.td +++ COFF/Options.td @@ -62,7 +62,9 @@ HelpText<"Use module-definition file">; def debug : F<"debug">, HelpText<"Embed a symbol table in the image">; +def debugtype : P<"debugtype", "Debug Info Options">; def dll : F<"dll">, HelpText<"Create a DLL">; +def driver : P<"driver", "Generate a Windows NT Kernel Mode Driver">; def nodefaultlib_all : F<"nodefaultlib">; def noentry : F<"noentry">; def profile : F<"profile">;