From 7dac9f4e481c9119a2205e869e07a643828f53db Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 28 Sep 2022 06:58:58 +0000 Subject: [PATCH] [ELF] Make --pack-dyn-relocs=android compatible with parallel relocation scanning --- lld/ELF/SyntheticSections.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index ce041c2..eb70c1d 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1779,8 +1779,7 @@ bool AndroidPackedRelocationSection::updateAllocSize() { r.r_offset = rel.getOffset(); r.setSymbolAndType(rel.getSymIndex(getPartition().dynSymTab.get()), rel.type, false); - if (config->isRela) - r.r_addend = rel.computeAddend(); + r.r_addend = config->isRela ? rel.computeAddend() : 0; if (r.getType(config->isMips64EL) == target->relativeRel) relatives.push_back(r); @@ -1824,12 +1823,12 @@ bool AndroidPackedRelocationSection::updateAllocSize() { // // For Rela, we also want to sort by r_addend when r_info is the same. This // enables us to group by r_addend as well. - llvm::stable_sort(nonRelatives, [](const Elf_Rela &a, const Elf_Rela &b) { + llvm::sort(nonRelatives, [](const Elf_Rela &a, const Elf_Rela &b) { if (a.r_info != b.r_info) return a.r_info < b.r_info; - if (config->isRela) + if (a.r_addend != b.r_addend) return a.r_addend < b.r_addend; - return false; + return a.r_offset < b.r_offset; }); // Group relocations with the same r_info. Note that each group emits a group -- 2.7.4