From b751bc69cb9badc33a247afaca693e28970589e9 Mon Sep 17 00:00:00 2001 From: Shankar Easwaran Date: Tue, 18 Nov 2025 14:59:44 -0600 Subject: [PATCH] Emit memory reports to debug link time memory usage This prints memory allocated by linker core data structures with a count of how many and total bytes used. This will be followed up by improvements to report virtual memory / resident memory size. Resolves #606 Signed-off-by: Shankar Easwaran --- Plugins/HelloWorldPlugin/HelloWorldPlugin.cpp | 3 + include/eld/BranchIsland/BranchIsland.h | 3 + .../eld/BranchIsland/BranchIslandFactory.h | 3 + include/eld/BranchIsland/StubFactory.h | 3 + include/eld/Config/GeneralOptions.h | 17 +- include/eld/Config/LinkerConfig.h | 7 + include/eld/Config/TargetOptions.h | 3 + include/eld/Core/CommandLine.h | 9 + include/eld/Core/Linker.h | 3 + include/eld/Core/LinkerScript.h | 6 + include/eld/Core/Module.h | 3 + include/eld/Diagnostics/Diagnostic.h | 3 + include/eld/Diagnostics/DiagnosticEngine.h | 8 + include/eld/Diagnostics/DiagnosticInfos.h | 6 + include/eld/Diagnostics/DiagnosticPrinter.h | 3 + include/eld/Diagnostics/MsgHandler.h | 3 + include/eld/Driver/ARMLinkDriver.h | 6 + include/eld/Driver/Driver.h | 3 + include/eld/Driver/GnuLdDriver.h | 8 + include/eld/Driver/GnuLinkerOptions.td | 349 +++++++++--------- include/eld/Driver/HexagonLinkDriver.h | 6 + include/eld/Driver/RISCVLinkDriver.h | 6 + include/eld/Driver/x86_64LinkDriver.h | 6 + include/eld/Fragment/BuildIDFragment.h | 4 + include/eld/Fragment/EhFrameFragment.h | 12 + include/eld/Fragment/EhFrameHdrFragment.h | 7 + include/eld/Fragment/FillFragment.h | 4 + include/eld/Fragment/Fragment.h | 4 + include/eld/Fragment/FragmentRef.h | 5 + include/eld/Fragment/GNUHashFragment.h | 3 + include/eld/Fragment/GOT.h | 4 + include/eld/Fragment/MergeStringFragment.h | 6 + include/eld/Fragment/OutputSectDataFragment.h | 4 + include/eld/Fragment/PLT.h | 4 + include/eld/Fragment/RegionFragment.h | 5 + include/eld/Fragment/RegionFragmentEx.h | 4 + include/eld/Fragment/StringFragment.h | 4 + include/eld/Fragment/Stub.h | 8 + include/eld/Fragment/TargetFragment.h | 4 + include/eld/Fragment/TimingFragment.h | 4 + .../eld/GarbageCollection/GarbageCollection.h | 6 + include/eld/Input/ArchiveFile.h | 5 + include/eld/Input/ArchiveFileInfo.h | 2 + include/eld/Input/ArchiveMemberInput.h | 3 + include/eld/Input/BinaryFile.h | 3 + include/eld/Input/BitcodeFile.h | 3 + include/eld/Input/ELDDirectory.h | 3 + include/eld/Input/ELFDynObjectFile.h | 3 + include/eld/Input/ELFExecutableFile.h | 3 + include/eld/Input/ELFFileBase.h | 3 + include/eld/Input/ELFObjectFile.h | 3 + include/eld/Input/Input.h | 3 + include/eld/Input/InputAction.h | 51 +++ include/eld/Input/InputBuilder.h | 3 + include/eld/Input/InputFile.h | 3 + include/eld/Input/InputTree.h | 17 + include/eld/Input/InternalInputFile.h | 3 + include/eld/Input/JustSymbolsAction.h | 3 + include/eld/Input/LinkerScriptFile.h | 3 + include/eld/Input/ObjectFile.h | 5 + include/eld/Input/SearchDirs.h | 2 + include/eld/Input/SymDefFile.h | 3 + include/eld/Input/ZOption.h | 3 + include/eld/LayoutMap/LDYAML.h | 52 +++ include/eld/LayoutMap/LayoutInfo.h | 10 + include/eld/LayoutMap/LinkStats.h | 3 + include/eld/LayoutMap/TextLayoutPrinter.h | 3 + include/eld/LayoutMap/YamlLayoutPrinter.h | 4 + include/eld/Object/GroupReader.h | 3 + include/eld/Object/ObjectBuilder.h | 3 + include/eld/Object/ObjectLinker.h | 5 + include/eld/Object/OutputSectionEntry.h | 3 + include/eld/Object/RuleContainer.h | 3 + include/eld/Object/ScriptMemoryRegion.h | 3 + include/eld/Object/SectionMap.h | 3 + include/eld/Plugin/PluginData.h | 3 + include/eld/Plugin/PluginManager.h | 3 + include/eld/Plugin/PluginOp.h | 30 ++ include/eld/PluginAPI/ControlFileSizePlugin.h | 3 + .../eld/PluginAPI/ControlMemorySizePlugin.h | 3 + include/eld/PluginAPI/DWARF.h | 10 + include/eld/PluginAPI/DiagnosticBuilder.h | 3 + include/eld/PluginAPI/DiagnosticEntry.h | 18 + include/eld/PluginAPI/Expected.h | 3 + include/eld/PluginAPI/LayoutADT.h | 4 + include/eld/PluginAPI/LayoutWrapper.h | 3 + include/eld/PluginAPI/LinkerPlugin.h | 3 + include/eld/PluginAPI/LinkerPluginConfig.h | 3 + include/eld/PluginAPI/LinkerScript.h | 48 +++ include/eld/PluginAPI/LinkerWrapper.h | 5 + .../PluginAPI/OutputSectionIteratorPlugin.h | 3 + include/eld/PluginAPI/PluginADT.h | 49 +++ include/eld/PluginAPI/PluginConfig.h | 6 + include/eld/PluginAPI/SectionIteratorPlugin.h | 3 + include/eld/PluginAPI/SectionMatcherPlugin.h | 3 + include/eld/PluginAPI/SmallJSON.h | 7 + include/eld/PluginAPI/TarWriter.h | 2 + include/eld/PluginAPI/ThreadPool.h | 3 + include/eld/Readers/ArchiveParser.h | 5 + include/eld/Readers/BinaryFileParser.h | 3 + include/eld/Readers/BitcodeReader.h | 4 + include/eld/Readers/CommonELFSection.h | 3 + include/eld/Readers/ELFDynObjParser.h | 3 + include/eld/Readers/ELFExecObjParser.h | 3 + include/eld/Readers/ELFReaderBase.h | 3 + include/eld/Readers/ELFRelocObjParser.h | 3 + include/eld/Readers/ELFSection.h | 6 + include/eld/Readers/EhFrameHdrSection.h | 3 + include/eld/Readers/EhFrameSection.h | 3 + include/eld/Readers/ObjectReader.h | 6 + include/eld/Readers/Relocation.h | 2 + include/eld/Readers/Section.h | 3 + include/eld/Readers/SymDefReader.h | 2 + include/eld/Readers/TimingSection.h | 3 + include/eld/Readers/TimingSlice.h | 3 + include/eld/Script/Assignment.h | 3 + include/eld/Script/EnterScopeCmd.h | 3 + include/eld/Script/EntryCmd.h | 3 + include/eld/Script/ExcludeFiles.h | 9 + include/eld/Script/ExitScopeCmd.h | 3 + include/eld/Script/Expression.h | 138 +++++++ include/eld/Script/ExternCmd.h | 3 + include/eld/Script/FileToken.h | 3 + include/eld/Script/GroupCmd.h | 3 + include/eld/Script/IncludeCmd.h | 3 + include/eld/Script/InputCmd.h | 3 + include/eld/Script/InputSectDesc.h | 5 + include/eld/Script/InputToken.h | 3 + include/eld/Script/MemoryCmd.h | 3 + include/eld/Script/MemoryDesc.h | 5 + include/eld/Script/NameSpec.h | 3 + include/eld/Script/NoCrossRefsCmd.h | 3 + include/eld/Script/OutputArchCmd.h | 3 + include/eld/Script/OutputCmd.h | 3 + include/eld/Script/OutputFormatCmd.h | 3 + include/eld/Script/OutputSectData.h | 3 + include/eld/Script/OutputSectDesc.h | 7 + include/eld/Script/PhdrDesc.h | 5 + include/eld/Script/PhdrsCmd.h | 3 + include/eld/Script/Plugin.h | 8 + include/eld/Script/PluginCmd.h | 3 + include/eld/Script/RegionAlias.h | 3 + include/eld/Script/ScriptAction.h | 3 + include/eld/Script/ScriptCommand.h | 3 + include/eld/Script/ScriptFile.h | 3 + include/eld/Script/ScriptReader.h | 3 + include/eld/Script/ScriptSymbol.h | 3 + include/eld/Script/SearchDirCmd.h | 3 + include/eld/Script/SectionsCmd.h | 3 + include/eld/Script/StrToken.h | 3 + include/eld/Script/StringList.h | 3 + include/eld/Script/SymbolContainer.h | 3 + include/eld/Script/VersionScript.h | 18 + include/eld/Script/WildcardPattern.h | 3 + include/eld/ScriptParser/ScriptLexer.h | 5 + include/eld/ScriptParser/ScriptParser.h | 3 + include/eld/Support/INIReader.h | 6 + include/eld/Support/INIWriter.h | 6 + include/eld/Support/MappingFile.h | 3 + include/eld/Support/MappingFileReader.h | 3 + include/eld/Support/Memory.h | 123 +++++- include/eld/Support/MemoryArea.h | 3 + include/eld/Support/OutputTarWriter.h | 3 + include/eld/Support/Path.h | 3 + include/eld/Support/ProgressBar.h | 3 + include/eld/Support/RegisterTimer.h | 5 + include/eld/Support/Target.h | 2 + include/eld/Support/TargetRegistry.h | 6 + include/eld/SymbolResolver/IRBuilder.h | 3 + include/eld/SymbolResolver/LDSymbol.h | 3 + include/eld/SymbolResolver/NamePool.h | 3 + include/eld/SymbolResolver/ResolveInfo.h | 3 + include/eld/SymbolResolver/Resolver.h | 5 + include/eld/SymbolResolver/StaticResolver.h | 3 + include/eld/SymbolResolver/SymbolInfo.h | 5 + .../eld/SymbolResolver/SymbolResolutionInfo.h | 3 + include/eld/Target/ARMEXIDXSection.h | 4 + include/eld/Target/ELFDynamic.h | 6 + include/eld/Target/ELFFileFormat.h | 5 + include/eld/Target/ELFSegment.h | 3 + include/eld/Target/ELFSegmentFactory.h | 3 + include/eld/Target/GNULDBackend.h | 5 + include/eld/Target/LDFileFormat.h | 3 + include/eld/Target/Relocator.h | 3 + include/eld/Target/TargetInfo.h | 5 + include/eld/Writers/ELFObjectWriter.h | 3 + include/eld/Writers/SymDefWriter.h | 3 + lib/Diagnostics/DiagnosticInfos.cpp | 3 + lib/LinkerWrapper/GnuLdDriver.cpp | 36 ++ lib/Object/ObjectLinker.cpp | 7 + lib/Script/Plugin.cpp | 2 + lib/Support/Memory.cpp | 42 +++ lib/Target/AArch64/AArch64ELFDynamic.h | 3 + lib/Target/AArch64/AArch64Errata843419Stub.h | 3 + lib/Target/AArch64/AArch64ErrataFactory.h | 3 + .../AArch64/AArch64ErrataIslandFactory.h | 3 + lib/Target/AArch64/AArch64FarcallStub.h | 3 + lib/Target/AArch64/AArch64GOT.h | 15 + lib/Target/AArch64/AArch64Info.h | 3 + lib/Target/AArch64/AArch64InsnHelpers.h | 3 + lib/Target/AArch64/AArch64LDBackend.h | 3 + lib/Target/AArch64/AArch64LinuxInfo.h | 3 + .../AArch64/AArch64NoteGNUPropertyFragment.h | 3 + lib/Target/AArch64/AArch64PLT.h | 9 + lib/Target/AArch64/AArch64Relocator.cpp | 3 + lib/Target/AArch64/AArch64Relocator.h | 3 + lib/Target/ARM/ARMAttributeFragment.h | 5 + lib/Target/ARM/ARMELFDynamic.h | 3 + lib/Target/ARM/ARMGOT.h | 18 + lib/Target/ARM/ARMInfo.h | 3 + lib/Target/ARM/ARMLDBackend.h | 3 + lib/Target/ARM/ARMPLT.h | 9 + lib/Target/ARM/ARMRelocator.cpp | 2 + lib/Target/ARM/ARMRelocator.h | 3 + lib/Target/ARM/ARMToARMStub.h | 3 + lib/Target/ARM/ARMToTHMStub.h | 3 + lib/Target/ARM/THMToARMStub.h | 3 + lib/Target/ARM/THMToTHMStub.h | 3 + lib/Target/Hexagon/HexagonAbsoluteStub.h | 3 + lib/Target/Hexagon/HexagonAttributeFragment.h | 3 + lib/Target/Hexagon/HexagonELFDynamic.h | 3 + lib/Target/Hexagon/HexagonGOT.h | 18 + lib/Target/Hexagon/HexagonInfo.h | 3 + lib/Target/Hexagon/HexagonLDBackend.cpp | 3 + lib/Target/Hexagon/HexagonLDBackend.h | 3 + lib/Target/Hexagon/HexagonLinuxInfo.h | 3 + lib/Target/Hexagon/HexagonPLT.h | 9 + .../Hexagon/HexagonRelocationFunctions.h | 3 + lib/Target/Hexagon/HexagonRelocator.h | 3 + lib/Target/Hexagon/HexagonStandaloneInfo.h | 3 + lib/Target/Hexagon/HexagonTLSStub.h | 12 + lib/Target/RISCV/RISCVAttributeFragment.h | 5 + lib/Target/RISCV/RISCVELFDynamic.h | 3 + lib/Target/RISCV/RISCVGOT.h | 21 ++ lib/Target/RISCV/RISCVInfo.h | 3 + lib/Target/RISCV/RISCVLDBackend.h | 3 + lib/Target/RISCV/RISCVPLT.h | 12 + lib/Target/RISCV/RISCVRelaxationStats.h | 3 + lib/Target/RISCV/RISCVRelocator.cpp | 2 + lib/Target/RISCV/RISCVRelocator.h | 3 + lib/Target/RISCV/RISCVStandaloneInfo.h | 3 + lib/Target/TargetInfo.cpp | 2 + lib/Target/Template/TemplateInfo.h | 3 + lib/Target/Template/TemplateLDBackend.h | 3 + .../Template/TemplateRelocationFunctions.h | 12 +- lib/Target/Template/TemplateRelocator.h | 3 + lib/Target/Template/TemplateStandaloneInfo.h | 3 + lib/Target/x86_64/x86_64ELFDynamic.h | 3 + lib/Target/x86_64/x86_64GOT.h | 20 +- lib/Target/x86_64/x86_64Info.h | 3 + lib/Target/x86_64/x86_64LDBackend.h | 3 + lib/Target/x86_64/x86_64PLT.h | 9 + lib/Target/x86_64/x86_64RelocationFunctions.h | 3 + lib/Target/x86_64/x86_64Relocator.h | 3 + lib/Target/x86_64/x86_64StandaloneInfo.h | 3 + .../CommandLine/PrintMemoryReport/Inputs/1.c | 1 + .../PrintMemoryReport/PrintMemoryReport.test | 11 + tools/LSParserVerifier/LSParserVerifier.cpp | 8 + 258 files changed, 1841 insertions(+), 180 deletions(-) create mode 100644 test/Common/standalone/CommandLine/PrintMemoryReport/Inputs/1.c create mode 100644 test/Common/standalone/CommandLine/PrintMemoryReport/PrintMemoryReport.test 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 { // --