[lld] r330443 - [ELF] --warn-backrefs: use the same GroupId for object files in the same --{start, end}-lib
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 20 09:33:01 PDT 2018
Author: maskray
Date: Fri Apr 20 09:33:01 2018
New Revision: 330443
URL: http://llvm.org/viewvc/llvm-project?rev=330443&view=rev
Log:
[ELF] --warn-backrefs: use the same GroupId for object files in the same --{start,end}-lib
Reviewers: ruiu, espindola
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D45849
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/test/ELF/start-lib.s
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=330443&r1=330442&r2=330443&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Apr 20 09:33:01 2018
@@ -990,10 +990,19 @@ void LinkerDriver::createFiles(opt::Inpu
++InputFile::NextGroupId;
break;
case OPT_start_lib:
+ if (InLib)
+ error("nested --start-lib");
+ if (InputFile::IsInGroup)
+ error("may not nest --start-lib in --start-group");
InLib = true;
+ InputFile::IsInGroup = true;
break;
case OPT_end_lib:
+ if (!InLib)
+ error("stray --end-lib");
InLib = false;
+ InputFile::IsInGroup = false;
+ ++InputFile::NextGroupId;
break;
}
}
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=330443&r1=330442&r2=330443&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Fri Apr 20 09:33:01 2018
@@ -113,9 +113,9 @@ public:
bool JustSymbols = false;
// GroupId is used for --warn-backrefs which is an optional error
- // checking feature. All files within the same --{start,end}-group
- // get the same group ID. Otherwise, each file gets a new group
- // ID. For more info, see checkDependency() in SymbolTable.cpp.
+ // checking feature. All files within the same --{start,end}-group or
+ // --{start,end}-lib get the same group ID. Otherwise, each file gets a new
+ // group ID. For more info, see checkDependency() in SymbolTable.cpp.
uint32_t GroupId;
static bool IsInGroup;
static uint32_t NextGroupId;
Modified: lld/trunk/test/ELF/start-lib.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/start-lib.s?rev=330443&r1=330442&r2=330443&view=diff
==============================================================================
--- lld/trunk/test/ELF/start-lib.s (original)
+++ lld/trunk/test/ELF/start-lib.s Fri Apr 20 09:33:01 2018
@@ -21,5 +21,14 @@
// TEST3-NOT: Name: bar
// TEST3-NOT: Name: foo
+// RUN: not ld.lld %t1.o --start-lib --start-lib 2>&1 | FileCheck -check-prefix=NESTED-LIB %s
+// NESTED-LIB: nested --start-lib
+
+// RUN: not ld.lld %t1.o --start-group --start-lib 2>&1 | FileCheck -check-prefix=LIB-IN-GROUP %s
+// LIB-IN-GROUP: may not nest --start-lib in --start-group
+
+// RUN: not ld.lld --end-lib 2>&1 | FileCheck -check-prefix=END %s
+// END: stray --end-lib
+
.globl _start
_start:
Modified: lld/trunk/test/ELF/warn-backrefs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/warn-backrefs.s?rev=330443&r1=330442&r2=330443&view=diff
==============================================================================
--- lld/trunk/test/ELF/warn-backrefs.s (original)
+++ lld/trunk/test/ELF/warn-backrefs.s Fri Apr 20 09:33:01 2018
@@ -35,6 +35,10 @@
# RUN: not ld.lld --fatal-warnings --end-group 2>&1 | FileCheck -check-prefix=END %s
# END: stray --end-group
+# RUN: echo ".globl bar; bar:" | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t3.o
+# RUN: echo ".globl foo; foo: call bar" | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t4.o
+# RUN: ld.lld --fatal-warnings --warn-backrefs %t1.o --start-lib %t3.o %t4.o --end-lib
+
.globl _start, foo
_start:
call foo
More information about the llvm-commits
mailing list