diff options
-rw-r--r-- | lld/ELF/Driver.cpp | 1 | ||||
-rw-r--r-- | lld/ELF/InputFiles.h | 3 | ||||
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 2 | ||||
-rw-r--r-- | lld/test/ELF/warn-backrefs.s | 5 |
4 files changed, 9 insertions, 2 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 39314c2aef1..4cbc701edea 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -987,6 +987,7 @@ void LinkerDriver::createFiles(opt::InputArgList &Args) { if (!InputFile::IsInGroup) error("stray --end-group"); InputFile::IsInGroup = false; + ++InputFile::NextGroupId; break; case OPT_start_lib: InLib = true; diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index 6b60ba9f1fa..cb6bccb5e8c 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -118,6 +118,7 @@ public: // ID. For more info, see checkDependency() in SymbolTable.cpp. uint32_t GroupId; static bool IsInGroup; + static uint32_t NextGroupId; protected: InputFile(Kind K, MemoryBufferRef M); @@ -126,8 +127,6 @@ protected: private: const Kind FileKind; - - static uint32_t NextGroupId; }; template <typename ELFT> class ELFFileBase : public InputFile { diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 907f1025e93..5ed5b491aa4 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -333,6 +333,8 @@ void ScriptParser::readGroup() { InputFile::IsInGroup = true; readInput(); InputFile::IsInGroup = Orig; + if (!Orig) + ++InputFile::NextGroupId; } void ScriptParser::readInclude() { diff --git a/lld/test/ELF/warn-backrefs.s b/lld/test/ELF/warn-backrefs.s index 9eaaeb481c5..192d7ee438d 100644 --- a/lld/test/ELF/warn-backrefs.s +++ b/lld/test/ELF/warn-backrefs.s @@ -21,6 +21,11 @@ # RUN: not ld.lld --fatal-warnings --warn-backrefs -o %t.exe %t2.a %t1.o 2>&1 | FileCheck %s # RUN: not ld.lld --fatal-warnings --warn-backrefs -o %t.exe %t2.a "-(" %t1.o "-)" 2>&1 | FileCheck %s +# RUN: not ld.lld --fatal-warnings --warn-backrefs -o %t.exe --start-group %t2.a --end-group %t1.o 2>&1 | FileCheck %s + +# RUN: echo "GROUP(\"%t2.a\")" > %t3.script +# RUN: not ld.lld --fatal-warnings --warn-backrefs -o %t.exe %t3.script %t1.o 2>&1 | FileCheck %s +# RUN: ld.lld --fatal-warnings --warn-backrefs -o %t.exe "-(" %t3.script %t1.o "-)" # CHECK: backward reference detected: foo in {{.*}}1.o refers to {{.*}}2.a |