diff --git a/Plugins/HelloWorldPlugin/HelloWorldPlugin.cpp b/Plugins/HelloWorldPlugin/HelloWorldPlugin.cpp index 383da5518..a6bb9d904 100644 --- a/Plugins/HelloWorldPlugin/HelloWorldPlugin.cpp +++ b/Plugins/HelloWorldPlugin/HelloWorldPlugin.cpp @@ -11,6 +11,9 @@ #include class DLL_A_EXPORT HelloWorldPlugin : public eld::plugin::LinkerPlugin { +public: + static std::string getTypeName() { return "DLL_A_EXPORT"; } + public: HelloWorldPlugin() : eld::plugin::LinkerPlugin("HelloWorldPlugin") {} diff --git a/include/eld/BranchIsland/BranchIsland.h b/include/eld/BranchIsland/BranchIsland.h index 9356c4049..e24c70af3 100644 --- a/include/eld/BranchIsland/BranchIsland.h +++ b/include/eld/BranchIsland/BranchIsland.h @@ -33,6 +33,9 @@ class Relocation; * */ class BranchIsland { +public: + static std::string getTypeName() { return "BranchIsland"; } + public: typedef std::vector RelocationListType; typedef RelocationListType::iterator reloc_iterator; diff --git a/include/eld/BranchIsland/BranchIslandFactory.h b/include/eld/BranchIsland/BranchIslandFactory.h index e3adf01bf..a525dd7f7 100644 --- a/include/eld/BranchIsland/BranchIslandFactory.h +++ b/include/eld/BranchIsland/BranchIslandFactory.h @@ -31,6 +31,9 @@ class FragmentRef; * */ class BranchIslandFactory { +public: + static std::string getTypeName() { return "BranchIslandFactory"; } + public: BranchIslandFactory(bool UseAddends, LinkerConfig &Config); diff --git a/include/eld/BranchIsland/StubFactory.h b/include/eld/BranchIsland/StubFactory.h index ef37e699d..4effe2ca7 100644 --- a/include/eld/BranchIsland/StubFactory.h +++ b/include/eld/BranchIsland/StubFactory.h @@ -31,6 +31,9 @@ class IRBuilder; * */ class StubFactory { +public: + static std::string getTypeName() { return "StubFactory"; } + public: typedef std::vector StubVector; StubFactory(Stub *TargetStub); diff --git a/include/eld/Config/GeneralOptions.h b/include/eld/Config/GeneralOptions.h index 4faed78b0..02ec406a7 100644 --- a/include/eld/Config/GeneralOptions.h +++ b/include/eld/Config/GeneralOptions.h @@ -43,6 +43,9 @@ class ZOption; * - attribute of input files */ class GeneralOptions { +public: + static std::string getTypeName() { return "GeneralOptions"; } + public: typedef llvm::StringMap SymbolRenameMap; @@ -834,6 +837,16 @@ class GeneralOptions { void setTimingStatsFile(std::string StatsFile) { TimingStatsFile = StatsFile; } + //--------------------Memory Report-------------------------------- + // --print-memory-report + bool showMemoryReport() const { return PrintMemoryReport; } + + void setPrintMemoryReport() { PrintMemoryReport = true; } + + // --emit-memory-report + std::string getMemoryReportFile() const { return MemoryReportFile; } + + void setMemoryReportFile(std::string F) { MemoryReportFile = F; } //--------------------Plugin Config-------------------------------- void addPluginConfig(const std::string &Config) { PluginConfig.push_back(Config); @@ -1233,6 +1246,7 @@ class GeneralOptions { bool BExecuteOnly = false; // --execute-only bool BPrintTimeStats = false; // --print-stats bool BPrintAllUserPluginTimeStats = false; + bool PrintMemoryReport = false; // --print-memory-report bool BDemangle = true; // --demangle-style bool ValidateArchOpts = false; // check -mabi with backend bool DisableGuardForWeakUndefs = false; // hexagon specific option to @@ -1265,7 +1279,8 @@ class GeneralOptions { std::string Filter; std::string MapFile; // Mapfile std::string TarFile; // --reproduce output tarfile name - std::string TimingStatsFile; + std::string TimingStatsFile; // --emit-timing-stats + std::string MemoryReportFile; // --emit-memory-report std::string MappingFileName; // --Mapping-file std::string MappingDumpFile; // --dump-mapping-file std::string ResponseDumpFile; // --dump-response-file diff --git a/include/eld/Config/LinkerConfig.h b/include/eld/Config/LinkerConfig.h index 866df4fb5..c6c2013f0 100644 --- a/include/eld/Config/LinkerConfig.h +++ b/include/eld/Config/LinkerConfig.h @@ -34,6 +34,9 @@ class Module; class DiagnosticEngine; class SearchDirs; class LinkerConfig { +public: + static std::string getTypeName() { return "LinkerConfig"; } + public: enum CodeGenType { Unknown, Object, DynObj, Exec, External, Binary }; @@ -75,6 +78,8 @@ class LinkerConfig { enum SymDefStyle { Default, Provide, UnknownSymDefStyle }; struct WarnOptions { + public: + static std::string getTypeName() { return "WarnOptions"; } std::optional EnableAllWarnings; std::optional EnableLinkerScriptWarnings; std::optional EnableZeroSizedSectionsWarnings; @@ -88,6 +93,8 @@ class LinkerConfig { }; struct MappingFileInfo { + public: + static std::string getTypeName() { return "MappingFileInfo"; } std::unordered_map StringMapKeyToValue; void addStringMapEntry(llvm::StringRef Key, llvm::StringRef Value) { diff --git a/include/eld/Config/TargetOptions.h b/include/eld/Config/TargetOptions.h index 0295ae18e..a22085598 100644 --- a/include/eld/Config/TargetOptions.h +++ b/include/eld/Config/TargetOptions.h @@ -26,6 +26,9 @@ class LinkerScript; * backend. */ class TargetOptions { +public: + static std::string getTypeName() { return "TargetOptions"; } + public: enum Endian { Little, Big, Unknown }; diff --git a/include/eld/Core/CommandLine.h b/include/eld/Core/CommandLine.h index b0c58f81b..4a873cb49 100644 --- a/include/eld/Core/CommandLine.h +++ b/include/eld/Core/CommandLine.h @@ -11,6 +11,9 @@ namespace eld { struct CommandLine { +public: + static std::string getTypeName() { return "CommandLine"; } + public: typedef enum { Flag, Option, MultiValueOption } CmdType; @@ -23,6 +26,8 @@ struct CommandLine { }; struct Flags : public CommandLine { +public: + static std::string getTypeName() { return "Flags"; } Flags(const std::string &Opt, bool Flag) : CommandLine(CmdType::Flag), Option(Opt), Flag(Flag) {} @@ -39,6 +44,8 @@ struct Flags : public CommandLine { }; struct Options : public CommandLine { +public: + static std::string getTypeName() { return "Options"; } Options(const std::string &Opt, const std::string &Arg) : CommandLine(CmdType::Option), Option(Opt), Argument(Arg) {} @@ -55,6 +62,8 @@ struct Options : public CommandLine { }; struct MultiValueOption : public CommandLine { +public: + static std::string getTypeName() { return "MultiValueOption"; } MultiValueOption(const std::string &Opt, const std::vector &Arg) : CommandLine(CmdType::MultiValueOption), Option(Opt), ArgumentList(Arg) { } diff --git a/include/eld/Core/Linker.h b/include/eld/Core/Linker.h index db103334d..038b7ecd8 100644 --- a/include/eld/Core/Linker.h +++ b/include/eld/Core/Linker.h @@ -40,6 +40,9 @@ class ObjectLinker; * \brief Linker is a modular linker. */ class Linker { +public: + static std::string getTypeName() { return "Linker"; } + public: enum UnresolvedPolicy { NotSet = 0x0, diff --git a/include/eld/Core/LinkerScript.h b/include/eld/Core/LinkerScript.h index 31e031e8c..ebbd45b5d 100644 --- a/include/eld/Core/LinkerScript.h +++ b/include/eld/Core/LinkerScript.h @@ -55,6 +55,9 @@ class MemoryCmd; class SymbolContainer; class Phdrs { +public: + static std::string getTypeName() { return "Phdrs"; } + public: Phdrs(const PhdrSpec &PPhdrDesc) { ScriptSpec.Name = PPhdrDesc.Name; @@ -77,6 +80,9 @@ class Phdrs { * */ class LinkerScript { +public: + static std::string getTypeName() { return "LinkerScript"; } + public: typedef std::vector Assignments; typedef std::vector OverrideSectionMatchT; diff --git a/include/eld/Core/Module.h b/include/eld/Core/Module.h index 3343daa10..ef48cafcb 100644 --- a/include/eld/Core/Module.h +++ b/include/eld/Core/Module.h @@ -71,6 +71,9 @@ class ScriptSymbol; * \brief Module provides the intermediate representation for linking. */ class Module { +public: + static std::string getTypeName() { return "Module"; } + public: typedef enum { Attributes, diff --git a/include/eld/Diagnostics/Diagnostic.h b/include/eld/Diagnostics/Diagnostic.h index 96f5fb65d..1131ccfc1 100644 --- a/include/eld/Diagnostics/Diagnostic.h +++ b/include/eld/Diagnostics/Diagnostic.h @@ -25,6 +25,9 @@ namespace eld { * \brief Diagnostic provides current status to DiagnosticPrinters. */ class Diagnostic { +public: + static std::string getTypeName() { return "Diagnostic"; } + public: Diagnostic(DiagnosticEngine &PEngine); diff --git a/include/eld/Diagnostics/DiagnosticEngine.h b/include/eld/Diagnostics/DiagnosticEngine.h index ac94bb033..523ab8e46 100644 --- a/include/eld/Diagnostics/DiagnosticEngine.h +++ b/include/eld/Diagnostics/DiagnosticEngine.h @@ -89,6 +89,9 @@ using DiagnosticEntry = plugin::DiagnosticEntry; * maintain thread-safety of diagnostic functions. */ class DiagnosticEngine { +public: + static std::string getTypeName() { return "DiagnosticEngine"; } + public: enum Severity { // None must be 0 because currently 0 severity value represent @@ -161,6 +164,9 @@ class DiagnosticEngine { }; struct State { + public: + static std::string getTypeName() { return "State"; } + public: State() = default; ~State() {} @@ -282,6 +288,8 @@ class DiagnosticEngine { }; class Diag { +public: + static std::string getTypeName() { return "Diag"; } static DiagnosticEngine::DiagIDType Counter; public: diff --git a/include/eld/Diagnostics/DiagnosticInfos.h b/include/eld/Diagnostics/DiagnosticInfos.h index 763db4dd1..a4f56dd80 100644 --- a/include/eld/Diagnostics/DiagnosticInfos.h +++ b/include/eld/Diagnostics/DiagnosticInfos.h @@ -31,9 +31,15 @@ class DiagnosticEngine; * for the outside world. */ class DiagnosticInfos { +public: + static std::string getTypeName() { return "DiagnosticInfos"; } + public: /// Stores custom diagnostic info class CustomDiagInfo { + public: + static std::string getTypeName() { return "CustomDiagInfo"; } + public: CustomDiagInfo(const std::string &PFormatStr) : FormatStr(PFormatStr) {} llvm::StringRef getDescription() const { return FormatStr; } diff --git a/include/eld/Diagnostics/DiagnosticPrinter.h b/include/eld/Diagnostics/DiagnosticPrinter.h index 0a938566d..81d35b205 100644 --- a/include/eld/Diagnostics/DiagnosticPrinter.h +++ b/include/eld/Diagnostics/DiagnosticPrinter.h @@ -27,6 +27,9 @@ namespace eld { * messages and output. */ class DiagnosticPrinter { +public: + static std::string getTypeName() { return "DiagnosticPrinter"; } + public: enum TraceType { TraceFiles = 0x1, diff --git a/include/eld/Diagnostics/MsgHandler.h b/include/eld/Diagnostics/MsgHandler.h index 9e42ac8fe..c031c29e5 100644 --- a/include/eld/Diagnostics/MsgHandler.h +++ b/include/eld/Diagnostics/MsgHandler.h @@ -47,6 +47,9 @@ namespace eld { * \brief MsgHandler controls the timing to output message. */ class MsgHandler { +public: + static std::string getTypeName() { return "MsgHandler"; } + public: MsgHandler(DiagnosticEngine &PEngine, std::unique_lock Lock); ~MsgHandler(); diff --git a/include/eld/Driver/ARMLinkDriver.h b/include/eld/Driver/ARMLinkDriver.h index aae63035d..d55c45319 100644 --- a/include/eld/Driver/ARMLinkDriver.h +++ b/include/eld/Driver/ARMLinkDriver.h @@ -20,6 +20,9 @@ class DiagnosticEngine; // Create OptTable class for parsing actual command line arguments class OPT_ARMLinkOptTable : public llvm::opt::GenericOptTable { +public: + static std::string getTypeName() { return "OPT_ARMLinkOptTable"; } + public: enum { INVALID = 0, @@ -35,6 +38,9 @@ class OPT_ARMLinkOptTable : public llvm::opt::GenericOptTable { }; class ARMLinkDriver : public GnuLdDriver { +public: + static std::string getTypeName() { return "ARMLinkDriver"; } + public: static ARMLinkDriver *Create(eld::LinkerConfig &C, std::string InferredArchFromProgramName); diff --git a/include/eld/Driver/Driver.h b/include/eld/Driver/Driver.h index 3bd4ee080..7e8ef9c06 100644 --- a/include/eld/Driver/Driver.h +++ b/include/eld/Driver/Driver.h @@ -28,6 +28,9 @@ class DiagnosticEngine; class GnuLdDriver; class DLL_A_EXPORT Driver { +public: + static std::string getTypeName() { return "DLL_A_EXPORT"; } + public: Driver(DriverFlavor F = DriverFlavor::Invalid); diff --git a/include/eld/Driver/GnuLdDriver.h b/include/eld/Driver/GnuLdDriver.h index 4d514f1fe..1da017a86 100644 --- a/include/eld/Driver/GnuLdDriver.h +++ b/include/eld/Driver/GnuLdDriver.h @@ -35,6 +35,9 @@ class LinkerScript; // Create OptTable class for parsing actual command line arguments class OPT_GnuLdOptTable : public llvm::opt::GenericOptTable { +public: + static std::string getTypeName() { return "OPT_GnuLdOptTable"; } + public: enum { INVALID = 0, @@ -50,6 +53,9 @@ class OPT_GnuLdOptTable : public llvm::opt::GenericOptTable { }; class DLL_A_EXPORT GnuLdDriver { +public: + static std::string getTypeName() { return "DLL_A_EXPORT"; } + public: static GnuLdDriver *Create(eld::LinkerConfig &C, DriverFlavor F, std::string InferredArchFromProgramName); @@ -160,6 +166,8 @@ class DLL_A_EXPORT GnuLdDriver { void setDriverFlavor(DriverFlavor F) { m_DriverFlavor = F; } + bool emitMemoryReport() const; + private: // Raise diag entry for trace. bool checkAndRaiseTraceDiagEntry(eld::Expected E) const; diff --git a/include/eld/Driver/GnuLinkerOptions.td b/include/eld/Driver/GnuLinkerOptions.td index dc7ddd959..659e3bb1e 100644 --- a/include/eld/Driver/GnuLinkerOptions.td +++ b/include/eld/Driver/GnuLinkerOptions.td @@ -6,11 +6,11 @@ include "llvm/Option/OptParser.td" -//===----------------------------------------------------------------------===// -/// Utility Functions -//===----------------------------------------------------------------------===// -// Single and multiple dash options combined -multiclass smDash { + //===----------------------------------------------------------------------===// + /// Utility Functions + //===----------------------------------------------------------------------===// + // Single and multiple dash options combined + multiclass smDash { // Option def "" : Separate<["-"], opt1>, HelpText; def opt1_eq : Joined<["-"], opt1 #"=">, Alias(opt1)>; @@ -73,9 +73,10 @@ multiclass mDashEq { // --