diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/patchelf.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc index 0e9aeb7..cd46f7e 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -135,9 +135,12 @@ private: ElfFile * elfFile; bool operator ()(const Elf_Phdr & x, const Elf_Phdr & y) { - if (x.p_type == PT_PHDR) return true; - if (y.p_type == PT_PHDR) return false; - return elfFile->rdi(x.p_paddr) < elfFile->rdi(y.p_paddr); + // A PHDR comes before everything else. + if (y.p_type == PT_PHDR) return false; + if (x.p_type == PT_PHDR) return true; + + // Sort non-PHDRs by address. + return elfFile->rdi(x.p_paddr) < elfFile->rdi(y.p_paddr); } }; |