-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround for QEMU bugs causing TLS issues on AArch32 #55
Conversation
This range is much larger now that we implemented long jumps by storing pointers in the instruction stream.
For the x86 and PowerPC backends this didn't matter - we constructed the partial blocks and then threw them away since we couldn't rewrite them. This became a problem with the AArch32 backend, which actually inspects block terminators and panics when it can't figure out how to interpret failures. This commit just changes the logic to avoid even trying to translate incomplete blocks, which was useless work anyway.
For some reason, the mac build is using a version of the base package from ghc 8.10...
8f58284
to
8d6eb1c
Compare
Good news: This causes QEMU user-mode to calculate the correct value for
The binary: |
This is almost certainly another discrepancy between Linux and QEMU user-mode. On real ARM hardware running Linux, the binary doesn't crash at that point. In QEMU, the argument (r0) to |
QEMU bug report no. 2: https://bugs.launchpad.net/qemu/+bug/1886097 tl;dr: Linux calculates the program break based on the virtual address and size of the |
Status update: This causes the PPC64 tests to fail:
DetailsI've isolated the problem to
Here's where it hits the error: Looks like maybe an alignment issue? Here's the program headers for the rewritten binary:
|
One thing to note is that I introduced a bunch of |
Okay, this is cleaned up enough to be ready for review. |
then Nothing | ||
else | ||
let best = L.minimumBy (O.comparing (\addr -> abs (addr - phdrOffset))) validCandidates | ||
in if let m = minimum (fmap (\segInfo -> abs (pVAddr segInfo - pOffset segInfo)) segInfos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this essentially the calculation that QEMU usermode is doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, exactly. This is a last-ditch check to ensure that this function doesn't return a Just addr
where addr
would be unacceptable to QEMU.
@travitch What's your preference on how we merge this? I don't think cleaning up the git history is super feasible, and there's a lot of content... Should I squash? Rebase and try to get halfway coherent commits? |
Good question. I'm happy with a squash commit or, alternatively, you could do a local rebase (possibly into one commit?), force push to the branch, and then do a normal merge? |
Fixes #52
Based on #48 and #54