This is an archive of the discontinued LLVM Phabricator instance.

Fix Mach-O unit tests breakage on Windows
Needs ReviewPublic

Authored by ruiu on Nov 6 2014, 6:37 PM.

Details

Reviewers
kledzik
Summary

Mach-O normalized file reader assumes that the entire file is aligned
to a large boundary. If the in-memory file is not aligned properly, it will
abort with an assertion failure in read32/read64. This patch forces the
in-memory file for the unit test to be aligned at 64-byte boundary.

I found these tests are failing on Windows, but theoretically they could
fail on other platform.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 15906.Nov 6 2014, 6:37 PM
ruiu retitled this revision from to Fix Mach-O unit tests breakage on Windows.
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added a reviewer: kledzik.
ruiu added a subscriber: Unknown Object (MLST).
kledzik edited edge metadata.Nov 6 2014, 6:51 PM

Funny. I just ran into this myself linking libc for arm64. Some of the .o files inside static archives are not 8-byte aligned, so the read64() is asserting. I think the read64() assert may be too aggressive. It may need to fallback to memcpy() for reading unaligned data, rather that asserting.

But this patch is goodness. Mach-O files should be at least 4 or 8 byte aligned, and the uint8_t[] does not guarantee that. Please commit this.

ruiu added a comment.Nov 6 2014, 7:06 PM

Thanks. Committed as r221508.