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

aya: introduce include_bytes_aligned!() macro #76

Merged
merged 1 commit into from
Oct 25, 2021

Conversation

willfindlay
Copy link
Member

This is a helper macro that can be used to include bytes at compile-time that can then be
used in Bpf::load(). Unlike std's include_bytes!(), this macro also ensures that the
resulting byte array is correctly aligned so that it can be parsed as an ELF binary.

The motivation for this patch is that users have been confused in the past when trying to just use include_bytes!(). See #24.

Signed-off-by: William Findlay william@williamfindlay.com

Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

This looks good!

I think it should go in src/utils.rs tho? And can you please tweak the doc to be: "[brief description]\n[more details]"

@willfindlay
Copy link
Member Author

@alessandrod I've made the requested changes. Thanks!

@willfindlay willfindlay force-pushed the load_include_bytes branch 2 times, most recently from 090ec1b to 56fbeb0 Compare October 25, 2021 14:16
@willfindlay
Copy link
Member Author

Just had to fix a couple of typos in the documentation. Should be good to go now.

This is a helper macro that can be used to include bytes at compile-time that can then be
used in Bpf::load(). Unlike std's include_bytes!(), this macro also ensures that the
resulting byte array is correctly aligned so that it can be parsed as an ELF binary.

Signed-off-by: William Findlay <william@williamfindlay.com>
@alessandrod alessandrod merged commit a947747 into aya-rs:main Oct 25, 2021
@alessandrod
Copy link
Collaborator

Thank you! 🙏

@willfindlay willfindlay deleted the load_include_bytes branch October 25, 2021 20:15
@dave-tucker dave-tucker added the feature A PR that implements a new feature or enhancement label Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A PR that implements a new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants