ELF: Do not follow relocation edges to output sections during GC.

This fixes an assertion error introduced by r320390.

Differential Revision: https://reviews.llvm.org/D41095

llvm-svn: 320431
This commit is contained in:
Peter Collingbourne 2017-12-11 22:47:43 +00:00
parent 9c8d7f8dcc
commit 17f71de70b
2 changed files with 5 additions and 2 deletions

View File

@ -71,12 +71,13 @@ static void resolveReloc(InputSectionBase &Sec, RelT &Rel,
SS->getFile<ELFT>()->IsNeeded = true;
if (auto *D = dyn_cast<Defined>(&B)) {
if (!D->Section)
auto *RelSec = dyn_cast_or_null<InputSectionBase>(D->Section);
if (!RelSec)
return;
uint64_t Offset = D->Value;
if (D->isSection())
Offset += getAddend<ELFT>(Sec, Rel);
Fn(cast<InputSectionBase>(D->Section), Offset);
Fn(RelSec, Offset);
return;
}

View File

@ -13,4 +13,6 @@
# CHECK-NEXT: Section: .dynamic
.data
.globl g
g:
.quad _end