[PATCH] D65242: [ELF] More dynamic relocation packing
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 00:22:52 PDT 2019
MaskRay added a comment.
In D65242#1638794 <https://reviews.llvm.org/D65242#1638794>, @grimar wrote:
> In D65242#1638787 <https://reviews.llvm.org/D65242#1638787>, @MaskRay wrote:
>
> > Weird. http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/34407/steps/test_lld/logs/stdio (http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/14511/steps/check-lld%20ubsan/logs/stdio has a similar error message)
> >
> > /usr/home/buildslave/as-bldslv5/lld-x86_64-freebsd/llvm.src/tools/lld/test/ELF/pack-dyn-relocs.s:106:20: error: ANDROID32-NEXT: is not on the line after the previous match
> > // ANDROID32-NEXT: 0x2044 R_ARM_ABS32 bar2 0x0
> > ^
> > <stdin>:36:2: note: 'next' match was here
> > 0x2044 R_ARM_ABS32 bar2 0x0
> > ^
> > <stdin>:34:29: note: previous match ended here
> > 0x2020 R_ARM_ABS32 bar2 0x0
> > ^
> > <stdin>:35:1: note: non-matching line after previous match is here
> > 0x2040 R_ARM_ABS32 zed2 0x0
> >
>
>
> I wonder if `llvm::sort` instead of stable sort can be the reason?
Probably not? I tried this before reverting...
@@ -38,6 +38,7 @@
#include "llvm/Support/MD5.h"
#include <cstdlib>
#include <thread>
+#include <random>
using namespace llvm;
using namespace llvm::dwarf;
@@ -1676,7 +1677,9 @@ bool AndroidPackedRelocationSection<ELFT>::updateAllocSize() {
else
nonRelatives.push_back(r);
}
+ std::mt19937 Generator(std::random_device{}());
+ std::shuffle(relatives.begin(), relatives.end(), Generator);
llvm::sort(relatives, [](const Elf_Rel &a, const Elf_Rel &b) {
return a.r_offset < b.r_offset;
});
@@ -1747,6 +1750,7 @@ bool AndroidPackedRelocationSection<ELFT>::updateAllocSize() {
i = j;
}
+ std::shuffle(ungroupedNonRelatives.begin(), ungroupedNonRelatives.end(), Generator);
// Sort ungrouped relocations by offset to minimize the encoded length.
llvm::sort(ungroupedNonRelatives, [](const Elf_Rela &a, const Elf_Rela &b) {
return a.r_offset < b.r_offset;
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65242/new/
https://reviews.llvm.org/D65242
More information about the llvm-commits
mailing list