src: fix pefile.cpp otls allocation not accounting for alignment. Closes #621.
This commit is contained in:
+3
-2
@@ -1386,11 +1386,12 @@ void PeFile::processTls1(Interval *iv,
|
|||||||
// ... and those dwords should be correctly aligned
|
// ... and those dwords should be correctly aligned
|
||||||
if (use_tls_callbacks)
|
if (use_tls_callbacks)
|
||||||
sotls = ALIGN_UP(sotls, cb_size) + 2 * cb_size;
|
sotls = ALIGN_UP(sotls, cb_size) + 2 * cb_size;
|
||||||
|
const unsigned aligned_sotls = ALIGN_UP(sotls, (unsigned)sizeof(LEXX));
|
||||||
|
|
||||||
// the PE loader wants this stuff uncompressed
|
// the PE loader wants this stuff uncompressed
|
||||||
mb_otls.alloc(sotls);
|
mb_otls.alloc(aligned_sotls);
|
||||||
mb_otls.clear();
|
mb_otls.clear();
|
||||||
otls = mb_otls; // => SPAN_S
|
otls = mb_otls; // => otls now is a SPAN_S
|
||||||
unsigned const take1 = sizeof(tls);
|
unsigned const take1 = sizeof(tls);
|
||||||
unsigned const skip1 = IDADDR(PEDIR_TLS);
|
unsigned const skip1 = IDADDR(PEDIR_TLS);
|
||||||
memcpy(otls,ibuf.subref("bad tls %#x", skip1, take1), take1);
|
memcpy(otls,ibuf.subref("bad tls %#x", skip1, take1), take1);
|
||||||
|
|||||||
Reference in New Issue
Block a user