summaryrefslogtreecommitdiffstats
path: root/src/patchelf.cc
diff options
context:
space:
mode:
authorKarl Millar <kmillar@google.com>2018-01-08 17:53:48 (GMT)
committerKarl Millar <kmillar@google.com>2018-01-08 17:55:47 (GMT)
commit71e99c549cb3acd03574c9c0b66c561ad35e71f7 (patch)
tree04da7b489606254b061763a1039fff28112399d8 /src/patchelf.cc
parenta1eab1c9de4d93ac639c0e2305a1505fc28a3b1c (diff)
downloadpatchelf-71e99c549cb3acd03574c9c0b66c561ad35e71f7.zip
patchelf-71e99c549cb3acd03574c9c0b66c561ad35e71f7.tar.gz
patchelf-71e99c549cb3acd03574c9c0b66c561ad35e71f7.tar.bz2
Simplify ordering code as suggested in PR comments.
Diffstat (limited to 'src/patchelf.cc')
-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);
}
};