-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
prog/alloc: align address allocation for aligned[addr] #1894
Conversation
Codecov Report
|
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.
Thank you!
1db0c96
to
92d4f92
Compare
Type.Alignment() can be used to obtain byte alignment for correctly allocating aligned memory for the Type.
Calls to alloc didn't respect the alignment attribute. Now Type.Alignment() is used to ensure each type is correctly aligned. Existing descriptions with [align[X]] don't have an issue as they align to small blocks and default align is to 64 bytes. This commits adds support for [align[X]] for an X larger than 64.
@dvyukov I've tried to remove AlignAttr from StructType to use TypeAlign instead, but there are places where it is used -- and where using TypeAlign gives different semantics. It seems to me that we need two variables. If we use one and it is set to for example 4, we can't know if it is due inner elements or the attribute. |
OK, let's keep.
If there is alignment attribute, then it overrides any filed alignment: but I think there still may be some differences for variable-sized structs:
|
Nice! That's a useful capability that nicely fits into the code base. Thanks. |
AlignAttr was only used to set padding and not to align to the
given argument. Existing descriptions with [align[X]] don't have
an issue as they align to small blocks and default align is to 64.
This commits adds support for [align[X]] for an X larger than 64.
Before sending a pull request, please review Contribution Guidelines:
https://github.com/google/syzkaller/blob/master/docs/contributing.md