Skip to content

Commit b6d0317

Browse files
committed
Merge branch 'strict_ordering' of https://github.com/kmillar/patchelf
2 parents aceb96e + 71e99c5 commit b6d0317

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/patchelf.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ class ElfFile
135135
ElfFile * elfFile;
136136
bool operator ()(const Elf_Phdr & x, const Elf_Phdr & y)
137137
{
138-
if (x.p_type == PT_PHDR) return true;
139-
if (y.p_type == PT_PHDR) return false;
140-
return elfFile->rdi(x.p_paddr) < elfFile->rdi(y.p_paddr);
138+
// A PHDR comes before everything else.
139+
if (y.p_type == PT_PHDR) return false;
140+
if (x.p_type == PT_PHDR) return true;
141+
142+
// Sort non-PHDRs by address.
143+
return elfFile->rdi(x.p_paddr) < elfFile->rdi(y.p_paddr);
141144
}
142145
};
143146

0 commit comments

Comments
 (0)