[lld] r330379 - [ELF] Increase NextGroupId with --end-group
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 19 16:23:23 PDT 2018
Author: maskray
Date: Thu Apr 19 16:23:23 2018
New Revision: 330379
URL: http://llvm.org/viewvc/llvm-project?rev=330379&view=rev
Log:
[ELF] Increase NextGroupId with --end-group
Reviewers: ruiu, espindola
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D45846
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/ELF/ScriptParser.cpp
lld/trunk/test/ELF/warn-backrefs.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=330379&r1=330378&r2=330379&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Apr 19 16:23:23 2018
@@ -987,6 +987,7 @@ void LinkerDriver::createFiles(opt::Inpu
if (!InputFile::IsInGroup)
error("stray --end-group");
InputFile::IsInGroup = false;
+ ++InputFile::NextGroupId;
break;
case OPT_start_lib:
InLib = true;
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=330379&r1=330378&r2=330379&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Thu Apr 19 16:23:23 2018
@@ -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 {
Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=330379&r1=330378&r2=330379&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Thu Apr 19 16:23:23 2018
@@ -333,6 +333,8 @@ void ScriptParser::readGroup() {
InputFile::IsInGroup = true;
readInput();
InputFile::IsInGroup = Orig;
+ if (!Orig)
+ ++InputFile::NextGroupId;
}
void ScriptParser::readInclude() {
Modified: lld/trunk/test/ELF/warn-backrefs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/warn-backrefs.s?rev=330379&r1=330378&r2=330379&view=diff
==============================================================================
--- lld/trunk/test/ELF/warn-backrefs.s (original)
+++ lld/trunk/test/ELF/warn-backrefs.s Thu Apr 19 16:23:23 2018
@@ -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
More information about the llvm-commits
mailing list