summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Millar <kmillar@google.com>2018-01-08 09:53:48 -0800
committerKarl Millar <kmillar@google.com>2018-01-08 09:55:47 -0800
commit71e99c549cb3acd03574c9c0b66c561ad35e71f7 (patch)
tree04da7b489606254b061763a1039fff28112399d8
parenta1eab1c9de4d93ac639c0e2305a1505fc28a3b1c (diff)
downloadpatchelf-71e99c549cb3acd03574c9c0b66c561ad35e71f7.tar.gz
Simplify ordering code as suggested in PR comments.
-rw-r--r--src/patchelf.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index a9696e4..855243a 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -135,12 +135,12 @@ private:
ElfFile * elfFile;
bool operator ()(const Elf_Phdr & x, const Elf_Phdr & y)
{
- if (x.p_type == PT_PHDR) {
- if (y.p_type == PT_PHDR) return false;
- 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);
}
};