Skip to content

Commit a7144b9

Browse files
KirillLykovvadorovsky
authored andcommitted
Align by 8b in include_bytes_aligned.
The max alignment required by ELF files is 8 bytes. There is no need to use 32b alignment.
1 parent 3992977 commit a7144b9

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

aya/src/util.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,14 @@ pub(crate) const fn tc_handler_make(major: u32, minor: u32) -> u32 {
392392
#[macro_export]
393393
macro_rules! include_bytes_aligned {
394394
($path:expr) => {{
395-
#[repr(align(32))]
396-
pub struct Aligned32;
397-
398-
#[repr(C)]
395+
// All eBPF programs are ELF64 objects (regardless of host target) with 8-byte
396+
// aligned headers and all eBPF instructions are 8 bytes each.
397+
#[repr(C, align(8))]
399398
pub struct Aligned<Bytes: ?Sized> {
400-
pub _align: [Aligned32; 0],
401399
pub bytes: Bytes,
402400
}
403401

404402
const ALIGNED: &Aligned<[u8]> = &Aligned {
405-
_align: [],
406403
bytes: *include_bytes!($path),
407404
};
408405

0 commit comments

Comments
 (0)