From 2a5a15c8586b40fc85ae357a2db9fcafdf3c2617 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 19 Jun 2021 12:36:50 +0900 Subject: [PATCH] Support global functions as exception handlers Fixes a crash while building Gentoo's dev-lang/luajit-2.0.5-r3 package. --- object_file.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/object_file.cc b/object_file.cc index 9ce83885..0e303acc 100644 --- a/object_file.cc +++ b/object_file.cc @@ -364,24 +364,24 @@ void ObjectFile::read_ehframe(Context &ctx, InputSection &isec) { fdes[i].cie_idx = find_cie(fdes[i].input_offset + 4 - cie_offset); } + auto get_isec = [&](const FdeRecord &fde) -> InputSection * { + return get_section(elf_syms[rels[fde.rel_idx].r_sym]); + }; + // We assume that FDEs for the same input sections are contiguous // in `fdes` vector. std::stable_sort(fdes.begin() + fdes_begin, fdes.end(), [&](const FdeRecord &a, const FdeRecord &b) { - InputSection *x = this->symbols[rels[a.rel_idx].r_sym]->input_section; - InputSection *y = this->symbols[rels[b.rel_idx].r_sym]->input_section; - return x->get_priority() < y->get_priority(); + return get_isec(a)->get_priority() < get_isec(b)->get_priority(); }); // Associate FDEs to input sections. for (i64 i = fdes_begin; i < fdes.size();) { - InputSection *isec = - this->symbols[rels[fdes[i].rel_idx].r_sym]->input_section; + InputSection *isec = get_isec(fdes[i]); assert(isec->fde_begin == -1); isec->fde_begin = i++; - while (i < fdes.size() && - isec == this->symbols[rels[fdes[i].rel_idx].r_sym]->input_section) + while (i < fdes.size() && isec == get_isec(fdes[i])) i++; isec->fde_end = i; }