From c4053cd14eb9b5fe12b4ea9bc99bd83548d1f371 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 28 May 2021 20:37:39 -0400 Subject: [PATCH] [lld/mac] Don't crash on -order_file with assembly inputs on arm64 .s files with `-g` generate __debug_aranges on darwin/arm64 for some reason, and those lead to `nullptr` symbols. Don't crash on that. Fixes PR50517. Differential Revision: https://reviews.llvm.org/D103350 --- lld/MachO/Writer.cpp | 2 +- lld/test/MachO/order-file.s | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp index aa5f60f..fc5f239 100644 --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -748,7 +748,7 @@ static DenseMap buildInputSectionPriorities() { for (const InputFile *file : inputFiles) { if (isa(file)) for (Symbol *sym : file->symbols) - if (auto *d = dyn_cast(sym)) + if (auto *d = dyn_cast_or_null(sym)) addSym(*d); } diff --git a/lld/test/MachO/order-file.s b/lld/test/MachO/order-file.s index 63dfca1..d0efefc 100644 --- a/lld/test/MachO/order-file.s +++ b/lld/test/MachO/order-file.s @@ -172,3 +172,7 @@ _bar: _main: callq "-[Foo doFoo:andBar:]" ret + +.section __DWARF,__debug_aranges,regular,debug +ltmp1: + .byte 0 -- 2.7.4