diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -4490,6 +4490,14 @@ std::vector Symbols; auto getNewSectionIndex = [&](uint32_t OldIndex) { + // For dynamic symbol table, the section index could be wrong on the input, + // and its value is ignored by the runtime if it's different from + // SHN_UNDEF and SHN_ABS. + // However, we still need to update dynamic symbol table, so return a + // section index, even though the index is broken. + if (IsDynSym && OldIndex >= NewSectionIndex.size()) + return OldIndex; + assert(OldIndex < NewSectionIndex.size() && "section index out of bounds"); const uint32_t NewIndex = NewSectionIndex[OldIndex];