diff options
| -rw-r--r-- | lld/ELF/MarkLive.cpp | 5 | ||||
| -rw-r--r-- | lld/test/ELF/gc-sections-linker-defined-symbol.s | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index fbf57a9ee2d..36f994f2049 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -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; } diff --git a/lld/test/ELF/gc-sections-linker-defined-symbol.s b/lld/test/ELF/gc-sections-linker-defined-symbol.s index 8720b845091..796f7b36355 100644 --- a/lld/test/ELF/gc-sections-linker-defined-symbol.s +++ b/lld/test/ELF/gc-sections-linker-defined-symbol.s @@ -13,4 +13,6 @@ # CHECK-NEXT: Section: .dynamic .data + .globl g + g: .quad _end |

