[PATCH] D41095: ELF: Do not follow relocation edges to output sections during GC.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 14:45:43 PST 2017
LGTM.
Thanks!
Peter Collingbourne via Phabricator <reviews at reviews.llvm.org> writes:
> pcc created this revision.
> Herald added a subscriber: emaste.
>
> This fixes an assertion error introduced by r320390.
>
>
> https://reviews.llvm.org/D41095
>
> Files:
> lld/ELF/MarkLive.cpp
> lld/test/ELF/gc-sections-linker-defined-symbol.s
>
>
> Index: lld/test/ELF/gc-sections-linker-defined-symbol.s
> ===================================================================
> --- lld/test/ELF/gc-sections-linker-defined-symbol.s
> +++ lld/test/ELF/gc-sections-linker-defined-symbol.s
> @@ -13,4 +13,6 @@
> # CHECK-NEXT: Section: .dynamic
>
> .data
> + .globl g
> + g:
> .quad _end
> Index: lld/ELF/MarkLive.cpp
> ===================================================================
> --- lld/ELF/MarkLive.cpp
> +++ lld/ELF/MarkLive.cpp
> @@ -71,12 +71,13 @@
> 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;
> }
>
>
>
> Index: lld/test/ELF/gc-sections-linker-defined-symbol.s
> ===================================================================
> --- lld/test/ELF/gc-sections-linker-defined-symbol.s
> +++ lld/test/ELF/gc-sections-linker-defined-symbol.s
> @@ -13,4 +13,6 @@
> # CHECK-NEXT: Section: .dynamic
>
> .data
> + .globl g
> + g:
> .quad _end
> Index: lld/ELF/MarkLive.cpp
> ===================================================================
> --- lld/ELF/MarkLive.cpp
> +++ lld/ELF/MarkLive.cpp
> @@ -71,12 +71,13 @@
> 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;
> }
>
More information about the llvm-commits
mailing list