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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 23:59:06 PDT 2022


Author: Fangrui Song
Date: 2022-09-28T06:58:58Z
New Revision: 7dac9f4e481c9119a2205e869e07a643828f53db

URL: https://github.com/llvm/llvm-project/commit/7dac9f4e481c9119a2205e869e07a643828f53db
DIFF: https://github.com/llvm/llvm-project/commit/7dac9f4e481c9119a2205e869e07a643828f53db.diff

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

Added: 
    

Modified: 
    lld/ELF/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index ce041c2053ed9..eb70c1d5504f1 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -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


        


More information about the llvm-commits mailing list