Fix ELF note alignment

The individual entries should be 4-byte aligned.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2025-02-06 17:19:27 +01:00
parent 2c5f34aee0
commit 73fdaa816d
2 changed files with 4 additions and 1 deletions

View File

@ -260,6 +260,9 @@ if ($from_notes) {
my $desc = substr($data, 0, $desc_size, ''); my $desc = substr($data, 0, $desc_size, '');
print("Found package '$name'\n"); print("Found package '$name'\n");
push @packages, $name; push @packages, $name;
# notes are 4-byte aligned, the header is already a multiple of 4 bytes, so:
my $skip = 3 & (4 - (3 & ($name_size + $desc_size)));
substr($data, 0, $skip, '');
} }
die "trailing data in notes section\n" if length($data); die "trailing data in notes section\n" if length($data);
@ARGV = @packages; @ARGV = @packages;

View File

@ -10,7 +10,7 @@ pub struct Info {
} }
*/ */
#[repr(C, packed)] #[repr(C, align(4))]
pub struct ElfNote<const N: usize> { pub struct ElfNote<const N: usize> {
pub name_size: u32, pub name_size: u32,
pub desc_size: u32, pub desc_size: u32,