Skip to content
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

Support all CIE versions in eh_frame #493

Merged
merged 1 commit into from
May 7, 2020

Conversation

jan-auer
Copy link
Contributor

@jan-auer jan-auer commented May 6, 2020

While .eh_frame always has version 1, it can contain CIEs with version 3. It also seems that CIE v1 always has U8 encoding for the return address, as opposed to the currently used LEB128. This would make it equivalent to .debug_frame. I am not sure why it was implemented like this in the first place, but considering that the RA is rarely >= 128, this might just have been coincidental.

My guess is that version 4 could potentially occur, although I've not seen it in the wild and would conservatively not implement it at the moment. LLVM seems to treat CIEs coming from debug_frame and eh_frame the same.

Fixes #244
See https://www.airs.com/blog/archives/460

@philipc
Copy link
Collaborator

philipc commented May 6, 2020

I think this bug is simply a result of bad documentation. The LSB spec says "Version: A 1 byte value that identifies the version number of the frame information structure. This value shall be 1.", and it doesn't give the return address encoding. We did notice problems in #244, so I guess this PR fixes that.

@@ -808,8 +814,12 @@ impl<R: Reader> _UnwindSectionPrivate<R> for EhFrame<R> {
0
}

fn return_address_register_encoding(_version: u8) -> ReturnAddressRegisterEncoding {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they are both the same now, we should delete this method from the trait.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, updated. Would you go even further and also support CIE v4; effectively removing the compatible_version method, too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, given that we already know the doc is wrong, we should do what other consumers do. I haven't recently looked at gdb, but I think that it handles eh_frame and debug_frame identically for version checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete the pub enum ReturnAddressRegisterEncoding definition too, and it's probably worth squashing these commits. Otherwise this looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, must have missed the warning. Amended.

@jan-auer jan-auer changed the title Support CIE version 3 in eh_frame Support all CIE versions in eh_frame May 7, 2020
Copy link
Collaborator

@philipc philipc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@philipc philipc merged commit f346d6f into gimli-rs:master May 7, 2020
@jan-auer jan-auer deleted the fix/eh-frame-cie-3 branch May 7, 2020 18:16
@jan-auer
Copy link
Contributor Author

@philipc would it be possible to release a patch version?

@philipc
Copy link
Collaborator

philipc commented May 11, 2020

I would prefer to release a minor version with all of the fixes since the last release (e.g. #487 too), if that works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libobjc.A.dylib has __eh_frame CIE with version 3
2 participants