[ELF] Make --pack-dyn-relocs=android compatible with parallel relocation scanning

This commit is contained in:
Fangrui Song 2022-09-28 06:58:58 +00:00
parent f90c2acb5d
commit 7dac9f4e48
1 changed files with 4 additions and 5 deletions

View File

@ -1779,8 +1779,7 @@ bool AndroidPackedRelocationSection<ELFT>::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<ELFT>::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