-
Notifications
You must be signed in to change notification settings - Fork 34
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
uleb128 decoding #3
base: master
Are you sure you want to change the base?
uleb128 decoding #3
Conversation
The call site is now being parsed correctly with a proper uleb128 decoding function, but still the abi can't access |
It's amazing that you're contributing a fix for this, thanks a lot! I'm sure we'll manage to figure why it isn't working. If you traced the problem to uleb decoding, I guess my initial assumption is that any uleb's stored would be small enough to need no decoding at all. If that's the case, adding a proper decoder is a great first step. Have you verified if the types defined for the LSDA actually match those that are defined by a real libcpp? For example: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/eh_personality.cc#L49 - while somewhat less didactic than my own ABI version, is much more likely to be correct! |
Well, you were right from the beginning about the types, they match the ones in the libsupc. The problem was the decoding and some pointer arithmetic. The entire call site now is being accessed correctly as stated in the previous commit along with the type table this time. The problem is the catch_type_info variable. It contains the last 4 bytes in the LSDA as intended (more specifically the value represented by |
v08 now successfully works. After tracing the personality routine in libsupc, it turns out that type table entries are pc relative addresses (relative to the entry itself). After implementing a simplified version of the decoding function, the new address now points to a valid type_info object and the name() method can be invoked safely. I will try propagating the changes to later version to see what happens. |
This is amazing work, thanks @IsmailShaheen. I doubt I'll be able to test your changes any time soon, but if you update it so that successive entries also work I'll be more than happy to merge the PR.
Thanks again for the fix! |
Sure thing, I will be updating later entries next week and I will make sure it has the "bare minimum" as you intended. As for the fixed version I have been working on it with @amroadel. |
Well, that's it. v12 now finally works on an 86_64bit architecture. We will be doing some cleanup and commenting but you can review the changes now if you want. I have also written something for the problem and I would love to share our findings with you as well, if you could send me your contact info. |
@IsmailShaheen this is awesome work, thank you so much! Would love to followup on this with your group. If you'd like we can get in contact by email and maybe even plan a video-call if you think it'd help. I believe I'm already in contact with different people from your group via Linked in, email and even Facebook, but feel free to reach out to my gmail account, nicolasbrailo, anytime. Thanks again! |
Thanks so much @IsmailShaheen for creating this PR! I was stuck on exactly the same problem of invalid type info ptr. Also, thanks @nicolasbrailo for creating the excellent tutorial series! It would be great if this PR got merged, so that at least the main code repo would be correct (even if the blogposts aren't fully updated). Would've saved me about a day's worth of cursing at gdb :) |
First of all, thank you for writing this blog it's been a tremendus help. Now I've tried to run this code on an x86_64 Linux 18.04 machine and I didn't have any problem until v08. in v08 the personality function tries to access a weird memory location. On further inspection it turns out that the larger machine code produced by the 64bit architecture produces relative offset values (the ones that are stored in the LSDA call site) greater than 127 which requires 2 bytes for ULEB128 encoding and this is where it goes downhill. I know that you have mentioned ignoring this issue in your blog, that's why I have tried implementing a decoding function which works (for an extent) but for some odd reasons the start and len of the first entry are ignored and the readings shifts accordingly. Now, I am still working on it, but I would appreciate your help if you have any idea why this might happen.
PS. I am working with a group on a small university project and two of my colleagues have already contacted you previously, in case this issue seemed familiar.