Index: include/lld/Core/LinkingContext.h =================================================================== --- include/lld/Core/LinkingContext.h +++ include/lld/Core/LinkingContext.h @@ -17,6 +17,7 @@ #include "lld/Core/Reference.h" #include "lld/Core/range.h" #include "lld/Core/Reader.h" +#include "lld/ReaderWriter/LinkerScript.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/raw_ostream.h" #include @@ -326,6 +327,13 @@ TaskGroup &getTaskGroup() { return _taskGroup; } + // LinkerScript + script::LinkerScript *getLinkerScriptAST() { return _linkerScript; }; + + void setLinkerScriptAST(script::LinkerScript *script) { + _linkerScript = script; + } + /// @} protected: LinkingContext(); // Must be subclassed @@ -344,6 +352,7 @@ /// Method to create an internal file for alias symbols std::unique_ptr createAliasSymbolFile() const; + script::LinkerScript *_linkerScript; StringRef _outputPath; StringRef _entrySymbolName; bool _deadStrip; Index: lib/Driver/GnuLdDriver.cpp =================================================================== --- lib/Driver/GnuLdDriver.cpp +++ lib/Driver/GnuLdDriver.cpp @@ -286,6 +286,9 @@ if (auto *group = dyn_cast(c)) if (std::error_code ec = evaluateLinkerScriptGroup(ctx, path, group, diag)) return ec; + + // LinkerScript is now accessible from LinkingContext. + ctx.setLinkerScriptAST(script); return std::error_code(); }