We have the following code that is uncovered with the test:
https://github.com/llvm-mirror/lld/blob/master/ELF/Target.cpp#L95
This patch:
1) Removes "!IS" check. Because at that point of execution
(we are reolving the relocations during writing output)
we should only have InputSection type of the sections in the vector.
(because we already converted MergeInputSection in mergeSections()
and combined EhInputSections in combineEhFrameSections()).
2) Covers the "!IS->getParent()" with the test.
llvm-svn: 336106
template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *Loc) {
for (InputSectionBase *D : InputSections) {
- auto *IS = dyn_cast<InputSection>(D);
- if (!IS || !IS->getParent())
+ auto *IS = cast<InputSection>(D);
+ if (!IS->getParent())
continue;
uint8_t *ISLoc = IS->getParent()->Loc + IS->OutSecOff;
--- /dev/null
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-error.s -o %tabs
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+
+// We have some code in error reporting to check that
+// section belongs to the output section. Without that
+// check, the linker would crash, so it is useful to test it.
+// And the easy way to do that is to trigger GC. That way .text.dumb
+// be collected and mentioned check will execute.
+
+// RUN: not ld.lld -gc-sections -shared %tabs %t -o %t2
+
+.section .text.dumb,"ax"
+ nop
+
+.section .text,"ax"
+.globl _start
+_start:
+ movl $big, %edx