forked from OSchip/llvm-project
Simplify logic to find the last executable segment. NFC.
llvm-svn: 316742
This commit is contained in:
parent
df15559c80
commit
0f46e45b03
|
@ -1858,18 +1858,13 @@ template <class ELFT> void Writer<ELFT>::writeTrapInstr() {
|
|||
// Round up the file size of the last segment to the page boundary iff it is
|
||||
// an executable segment to ensure that other tools don't accidentally
|
||||
// trim the instruction padding (e.g. when stripping the file).
|
||||
PhdrEntry *LastRX = nullptr;
|
||||
for (PhdrEntry *P : Phdrs) {
|
||||
if (P->p_type != PT_LOAD)
|
||||
continue;
|
||||
if (P->p_flags & PF_X)
|
||||
LastRX = P;
|
||||
else
|
||||
LastRX = nullptr;
|
||||
}
|
||||
if (LastRX)
|
||||
LastRX->p_memsz = LastRX->p_filesz =
|
||||
alignTo(LastRX->p_filesz, Target->PageSize);
|
||||
PhdrEntry *Last = nullptr;
|
||||
for (PhdrEntry *P : Phdrs)
|
||||
if (P->p_type == PT_LOAD)
|
||||
Last = P;
|
||||
|
||||
if (Last && (Last->p_flags & PF_X))
|
||||
Last->p_memsz = Last->p_filesz = alignTo(Last->p_filesz, Target->PageSize);
|
||||
}
|
||||
|
||||
// Write section contents to a mmap'ed file.
|
||||
|
|
Loading…
Reference in New Issue