PackVmlinuxBase::canPack bug for AMD64 with holes between PT_LOAD

This commit is contained in:
John Reiser
2006-12-19 18:18:47 -08:00
parent cd6a318903
commit 1d39796e3f
+10 -5
View File
@@ -137,8 +137,9 @@ bool PackVmlinuxBase<T>::canPack()
|| ehdri.e_machine != my_e_machine || ehdri.e_machine != my_e_machine
|| ehdri.e_version != 1 // version || ehdri.e_version != 1 // version
|| ehdri.e_ehsize != sizeof(ehdri) // different <elf.h> ? || ehdri.e_ehsize != sizeof(ehdri) // different <elf.h> ?
) ) {
return false; return false;
}
// additional requirements for vmlinux // additional requirements for vmlinux
if (ehdri.e_type != Ehdr::ET_EXEC if (ehdri.e_type != Ehdr::ET_EXEC
@@ -162,9 +163,10 @@ bool PackVmlinuxBase<T>::canPack()
break; break;
} }
} }
if (j < 0) if (j < 0) {
return false; return false;
} }
}
phdri = new Phdr[(unsigned) ehdri.e_phnum]; phdri = new Phdr[(unsigned) ehdri.e_phnum];
fi->seek(ehdri.e_phoff, SEEK_SET); fi->seek(ehdri.e_phoff, SEEK_SET);
@@ -181,9 +183,12 @@ bool PackVmlinuxBase<T>::canPack()
return false; return false;
} }
if (0 < j) { if (0 < j) {
unsigned const sz = (0u - phdri[j-1].p_align) unsigned const org = (0u - phdri[j].p_align) &
& (phdri[j-1].p_align -1 + phdri[j-1].p_filesz); (-1 + phdri[j].p_align +
if ((sz + phdri[j-1].p_offset)!=phdri[j].p_offset) { phdri[j-1].p_filesz + phdri[j-1].p_offset);
unsigned const loc = (0u - phdri[j].p_align) &
(-1 + phdri[j].p_align + phdri[j].p_offset);
if (org!=loc) {
return false; return false;
} }
} }