diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -902,10 +902,10 @@ if (!isecPriorities.empty()) { if (auto *merged = dyn_cast(osec)) { - llvm::stable_sort(merged->inputs, - [&](InputSection *a, InputSection *b) { - return isecPriorities[a] > isecPriorities[b]; - }); + llvm::stable_sort( + merged->inputs, [&](InputSection *a, InputSection *b) { + return isecPriorities.lookup(a) > isecPriorities.lookup(b); + }); } } }