diff options
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 4939ca9c5b4..6d6af301a6d 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -24,6 +24,7 @@ #include "Target.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSet.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/Support/Casting.h" @@ -113,6 +114,9 @@ private: // True if a script being read is in a subdirectory specified by -sysroot. bool IsUnderSysroot; + + // A set to detect an INCLUDE() cycle. + StringSet<> Seen; }; } // namespace @@ -318,6 +322,11 @@ void ScriptParser::readGroup() { void ScriptParser::readInclude() { StringRef Tok = unquote(next()); + if (!Seen.insert(Tok).second) { + setError("there is a cycle in linker script INCLUDEs"); + return; + } + // https://sourceware.org/binutils/docs/ld/File-Commands.html: // The file will be searched for in the current directory, and in any // directory specified with the -L option. |