[PATCH] D45846: [ELF] Increase NextGroupId with --end-group

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 16:25:38 PDT 2018


MaskRay updated this revision to Diff 143190.
MaskRay added a comment.

Add Rui's nested -( t3.script t1.o -) test


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D45846

Files:
  ELF/Driver.cpp
  ELF/InputFiles.h
  ELF/ScriptParser.cpp
  test/ELF/warn-backrefs.s


Index: test/ELF/warn-backrefs.s
===================================================================
--- test/ELF/warn-backrefs.s
+++ 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
 
Index: ELF/ScriptParser.cpp
===================================================================
--- ELF/ScriptParser.cpp
+++ ELF/ScriptParser.cpp
@@ -333,6 +333,8 @@
   InputFile::IsInGroup = true;
   readInput();
   InputFile::IsInGroup = Orig;
+  if (!Orig)
+    ++InputFile::NextGroupId;
 }
 
 void ScriptParser::readInclude() {
Index: ELF/InputFiles.h
===================================================================
--- ELF/InputFiles.h
+++ ELF/InputFiles.h
@@ -118,16 +118,15 @@
   // 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);
   std::vector<InputSectionBase *> Sections;
   std::vector<Symbol *> Symbols;
 
 private:
   const Kind FileKind;
-
-  static uint32_t NextGroupId;
 };
 
 template <typename ELFT> class ELFFileBase : public InputFile {
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -987,6 +987,7 @@
       if (!InputFile::IsInGroup)
         error("stray --end-group");
       InputFile::IsInGroup = false;
+      ++InputFile::NextGroupId;
       break;
     case OPT_start_lib:
       InLib = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45846.143190.patch
Type: text/x-patch
Size: 2066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180419/f1b66edb/attachment.bin>


More information about the llvm-commits mailing list