Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Plugins/HelloWorldPlugin/HelloWorldPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <iostream>

class DLL_A_EXPORT HelloWorldPlugin : public eld::plugin::LinkerPlugin {
public:
static std::string getTypeName() { return "DLL_A_EXPORT"; }

public:
HelloWorldPlugin() : eld::plugin::LinkerPlugin("HelloWorldPlugin") {}

Expand Down
3 changes: 3 additions & 0 deletions include/eld/BranchIsland/BranchIsland.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class Relocation;
*
*/
class BranchIsland {
public:
static std::string getTypeName() { return "BranchIsland"; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use macros to get these? Adding this to every single type feels needlessly complex and hard to scale.

Copy link
Contributor Author

@quic-seaswara quic-seaswara Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I think that is much better. Let me explore


public:
typedef std::vector<Relocation *> RelocationListType;
typedef RelocationListType::iterator reloc_iterator;
Expand Down
3 changes: 3 additions & 0 deletions include/eld/BranchIsland/BranchIslandFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class FragmentRef;
*
*/
class BranchIslandFactory {
public:
static std::string getTypeName() { return "BranchIslandFactory"; }

public:
BranchIslandFactory(bool UseAddends, LinkerConfig &Config);

Expand Down
3 changes: 3 additions & 0 deletions include/eld/BranchIsland/StubFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class IRBuilder;
*
*/
class StubFactory {
public:
static std::string getTypeName() { return "StubFactory"; }

public:
typedef std::vector<Stub *> StubVector;
StubFactory(Stub *TargetStub);
Expand Down
17 changes: 16 additions & 1 deletion include/eld/Config/GeneralOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class ZOption;
* - attribute of input files
*/
class GeneralOptions {
public:
static std::string getTypeName() { return "GeneralOptions"; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please return std::string_view / llvm::StringRef / const char * instead of std::string as these are more memory efficient?


public:
typedef llvm::StringMap<std::string> SymbolRenameMap;

Expand Down Expand Up @@ -834,6 +837,16 @@ class GeneralOptions {
void setTimingStatsFile(std::string StatsFile) {
TimingStatsFile = StatsFile;
}
//--------------------Memory Report--------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this feature useful to anyone other than an eld developer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only eld developer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make this option hidden if that is what you were hinting at.

// --print-memory-report
bool showMemoryReport() const { return PrintMemoryReport; }

void setPrintMemoryReport() { PrintMemoryReport = true; }

// --emit-memory-report <file>
std::string getMemoryReportFile() const { return MemoryReportFile; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string getMemoryReportFile() const { return MemoryReportFile; }
llvm::StringRef getMemoryReportFile() const { return MemoryReportFile; }


void setMemoryReportFile(std::string F) { MemoryReportFile = F; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should try to use llvm::StringRef / std::string_view wherever we can as they avoid copying strings. What do you think about it?

Suggested change
void setMemoryReportFile(std::string F) { MemoryReportFile = F; }
void setMemoryReportFile(llvm::StringRef F) { MemoryReportFile = F; }

//--------------------Plugin Config--------------------------------
void addPluginConfig(const std::string &Config) {
PluginConfig.push_back(Config);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use one option std::optional<MemoryReportFile> instead of using two options PrintMemoryReport and MemoryReportFile?

std::string MappingFileName; // --Mapping-file
std::string MappingDumpFile; // --dump-mapping-file
std::string ResponseDumpFile; // --dump-response-file
Expand Down
7 changes: 7 additions & 0 deletions include/eld/Config/LinkerConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -75,6 +78,8 @@ class LinkerConfig {
enum SymDefStyle { Default, Provide, UnknownSymDefStyle };

struct WarnOptions {
public:
static std::string getTypeName() { return "WarnOptions"; }
std::optional<bool> EnableAllWarnings;
std::optional<bool> EnableLinkerScriptWarnings;
std::optional<bool> EnableZeroSizedSectionsWarnings;
Expand All @@ -88,6 +93,8 @@ class LinkerConfig {
};

struct MappingFileInfo {
public:
static std::string getTypeName() { return "MappingFileInfo"; }
std::unordered_map<std::string, std::string> StringMapKeyToValue;

void addStringMapEntry(llvm::StringRef Key, llvm::StringRef Value) {
Expand Down
3 changes: 3 additions & 0 deletions include/eld/Config/TargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class LinkerScript;
* backend.
*/
class TargetOptions {
public:
static std::string getTypeName() { return "TargetOptions"; }

public:
enum Endian { Little, Big, Unknown };

Expand Down
9 changes: 9 additions & 0 deletions include/eld/Core/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
namespace eld {

struct CommandLine {
public:
static std::string getTypeName() { return "CommandLine"; }

public:
typedef enum { Flag, Option, MultiValueOption } CmdType;

Expand All @@ -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) {}

Expand All @@ -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) {}

Expand All @@ -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<std::string> &Arg)
: CommandLine(CmdType::MultiValueOption), Option(Opt), ArgumentList(Arg) {
}
Expand Down
3 changes: 3 additions & 0 deletions include/eld/Core/Linker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions include/eld/Core/LinkerScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -77,6 +80,9 @@ class Phdrs {
*
*/
class LinkerScript {
public:
static std::string getTypeName() { return "LinkerScript"; }

public:
typedef std::vector<Assignment *> Assignments;
typedef std::vector<ChangeOutputSectionPluginOp *> OverrideSectionMatchT;
Expand Down
3 changes: 3 additions & 0 deletions include/eld/Core/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions include/eld/Diagnostics/Diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 8 additions & 0 deletions include/eld/Diagnostics/DiagnosticEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -161,6 +164,9 @@ class DiagnosticEngine {
};

struct State {
public:
static std::string getTypeName() { return "State"; }

public:
State() = default;
~State() {}
Expand Down Expand Up @@ -282,6 +288,8 @@ class DiagnosticEngine {
};

class Diag {
public:
static std::string getTypeName() { return "Diag"; }
static DiagnosticEngine::DiagIDType Counter;

public:
Expand Down
6 changes: 6 additions & 0 deletions include/eld/Diagnostics/DiagnosticInfos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 3 additions & 0 deletions include/eld/Diagnostics/DiagnosticPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace eld {
* messages and output.
*/
class DiagnosticPrinter {
public:
static std::string getTypeName() { return "DiagnosticPrinter"; }

public:
enum TraceType {
TraceFiles = 0x1,
Expand Down
3 changes: 3 additions & 0 deletions include/eld/Diagnostics/MsgHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::timed_mutex> Lock);
~MsgHandler();
Expand Down
6 changes: 6 additions & 0 deletions include/eld/Driver/ARMLinkDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions include/eld/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 8 additions & 0 deletions include/eld/Driver/GnuLdDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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<void> E) const;
Expand Down
Loading
Loading