Skip to content

Commit ab6bb32

Browse files
committed
tree-wide: remove align(8) for tags
This breaks the sizeof() property for many tags that I verify. Furthermore, the builder structs already take care of any alignments when they construct the MBI/MB header.
1 parent d54cddc commit ab6bb32

19 files changed

+35
-43
lines changed

multiboot2-header/src/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use core::mem::size_of;
66
/// other format. Required for legacy boot (BIOS).
77
/// Determines load addresses.
88
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
9-
#[repr(C, align(8))]
9+
#[repr(C)]
1010
pub struct AddressHeaderTag {
1111
typ: HeaderTagType,
1212
flags: HeaderTagFlag,

multiboot2-header/src/end.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::mem::size_of;
33

44
/// Terminates a list of optional tags in a Multiboot2 header.
55
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6-
#[repr(C, align(8))]
6+
#[repr(C)]
77
pub struct EndHeaderTag {
88
// u16 value
99
typ: HeaderTagType,

multiboot2-header/src/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl core::error::Error for LoadError {}
227227
/// The "basic" Multiboot2 header. This means only the properties, that are known during
228228
/// compile time. All other information are derived during runtime from the size property.
229229
#[derive(Copy, Clone, PartialEq, Eq)]
230-
#[repr(C, align(8))]
230+
#[repr(C)]
231231
pub struct Multiboot2BasicHeader {
232232
/// Must be the value of [`MULTIBOOT2_HEADER_MAGIC`].
233233
header_magic: u32,

multiboot2-header/src/module_align.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::mem::size_of;
33

44
/// If this tag is present, provided boot modules must be page aligned.
55
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6-
#[repr(C, align(8))]
6+
#[repr(C)]
77
pub struct ModuleAlignHeaderTag {
88
typ: HeaderTagType,
99
flags: HeaderTagFlag,

multiboot2-header/src/relocatable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum RelocatableHeaderTagPreference {
2020

2121
/// This tag indicates that the image is relocatable.
2222
#[derive(Copy, Clone, PartialEq, Eq)]
23-
#[repr(C, align(8))]
23+
#[repr(C)]
2424
pub struct RelocatableHeaderTag {
2525
typ: HeaderTagType,
2626
flags: HeaderTagFlag,

multiboot2-header/src/tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub enum HeaderTagFlag {
6464
/// that depend on the `typ` and the `size` field. All tags share the same beginning of the
6565
/// struct.
6666
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
67-
#[repr(C, align(8))]
67+
#[repr(C)]
6868
pub struct HeaderTag {
6969
// u16 value
7070
typ: HeaderTagType,

multiboot2-header/src/uefi_bs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::mem::size_of;
44
/// This tag indicates that payload supports starting without terminating UEFI boot services.
55
/// Or in other words: The payload wants to use UEFI boot services.
66
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
7-
#[repr(C, align(8))]
7+
#[repr(C)]
88
pub struct EfiBootServiceHeaderTag {
99
typ: HeaderTagType,
1010
flags: HeaderTagFlag,

multiboot2/src/boot_loader_name.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ use {
1212
const METADATA_SIZE: usize = size_of::<TagTypeId>() + size_of::<u32>();
1313

1414
/// The bootloader name tag.
15-
#[derive(ptr_meta::Pointee)]
16-
#[derive(PartialEq, Eq)]
17-
#[repr(C, align(8))]
15+
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
16+
#[repr(C)]
1817
pub struct BootLoaderNameTag {
1918
typ: TagTypeId,
2019
size: u32,

multiboot2/src/command_line.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ pub(crate) const METADATA_SIZE: usize = mem::size_of::<TagTypeId>() + mem::size_
1818
///
1919
/// The string is a normal C-style UTF-8 zero-terminated string that can be
2020
/// obtained via the `command_line` method.
21-
#[derive(ptr_meta::Pointee)]
22-
#[derive(PartialEq, Eq)]
23-
#[repr(C, align(8))]
21+
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
22+
#[repr(C)]
2423
pub struct CommandLineTag {
2524
typ: TagTypeId,
2625
size: u32,

multiboot2/src/efi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::builder::traits::StructAsBytes;
1010

1111
/// EFI system table in 32 bit mode
1212
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
13-
#[repr(C, align(8))]
13+
#[repr(C)]
1414
pub struct EFISdt32 {
1515
typ: TagTypeId,
1616
size: u32,
@@ -42,7 +42,7 @@ impl StructAsBytes for EFISdt32 {
4242

4343
/// EFI system table in 64 bit mode
4444
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
45-
#[repr(C, align(8))]
45+
#[repr(C)]
4646
pub struct EFISdt64 {
4747
typ: TagTypeId,
4848
size: u32,
@@ -74,7 +74,7 @@ impl StructAsBytes for EFISdt64 {
7474

7575
/// Contains pointer to boot loader image handle.
7676
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
77-
#[repr(C, align(8))]
77+
#[repr(C)]
7878
pub struct EFIImageHandle32 {
7979
typ: TagTypeId,
8080
size: u32,
@@ -106,7 +106,7 @@ impl StructAsBytes for EFIImageHandle32 {
106106

107107
/// Contains pointer to boot loader image handle.
108108
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
109-
#[repr(C, align(8))]
109+
#[repr(C)]
110110
pub struct EFIImageHandle64 {
111111
typ: TagTypeId,
112112
size: u32,

multiboot2/src/elf_sections.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ const METADATA_SIZE: usize = size_of::<TagTypeId>() + 4 * size_of::<u32>();
1515
/// This tag contains section header table from an ELF kernel.
1616
///
1717
/// The sections iterator is provided via the `sections` method.
18-
#[derive(ptr_meta::Pointee)]
19-
#[derive(PartialEq, Eq)]
20-
#[repr(C, align(8))]
18+
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
19+
#[repr(C)]
2120
pub struct ElfSectionsTag {
2221
typ: TagTypeId,
2322
pub(crate) size: u32,

multiboot2/src/framebuffer.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ const METADATA_SIZE: usize = size_of::<TagTypeId>()
5151
+ 2 * size_of::<u8>();
5252

5353
/// The VBE Framebuffer information Tag.
54-
#[derive(ptr_meta::Pointee)]
55-
#[derive(Eq)]
56-
#[repr(C, align(8))]
54+
#[derive(ptr_meta::Pointee, Eq)]
55+
#[repr(C)]
5756
pub struct FramebufferTag {
5857
typ: TagTypeId,
5958
size: u32,

multiboot2/src/image_load_addr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use {
88
/// If the image has relocatable header tag, this tag contains the image's
99
/// base physical address.
1010
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
11-
#[repr(C, align(8))]
11+
#[repr(C)]
1212
pub struct ImageLoadPhysAddr {
1313
typ: TagTypeId,
1414
size: u32,

multiboot2/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ pub unsafe fn load_with_offset(
173173

174174
/// Error type that describes errors while loading/parsing a multiboot2 information structure
175175
/// from a given address.
176-
#[derive(Display)]
177-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
176+
#[derive(Display, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
178177
pub enum MbiLoadError {
179178
/// The address is invalid. Make sure that the address is 8-byte aligned,
180179
/// according to the spec.
@@ -386,7 +385,7 @@ impl BootInformation {
386385
/// use std::str::Utf8Error;
387386
/// use multiboot2::{Tag, TagTrait, TagTypeId};
388387
///
389-
/// #[repr(C, align(8))]
388+
/// #[repr(C)]
390389
/// #[derive(multiboot2::Pointee)] // Only needed for DSTs.
391390
/// struct CustomTag {
392391
/// // new type from the lib: has repr(u32)

multiboot2/src/memory_map.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ const METADATA_SIZE: usize = mem::size_of::<TagTypeId>() + 3 * mem::size_of::<u3
2222
/// This tag may not be provided by some boot loaders on EFI platforms if EFI
2323
/// boot services are enabled and available for the loaded image (The EFI boot
2424
/// services tag may exist in the Multiboot2 boot information structure).
25-
#[derive( ptr_meta::Pointee)]
26-
#[derive(Debug, PartialEq, Eq)]
27-
#[repr(C, align(8))]
25+
#[derive(ptr_meta::Pointee, Debug, PartialEq, Eq)]
26+
#[repr(C)]
2827
pub struct MemoryMapTag {
2928
typ: TagTypeId,
3029
size: u32,
@@ -82,7 +81,7 @@ impl StructAsBytes for MemoryMapTag {
8281

8382
/// A memory area entry descriptor.
8483
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
85-
#[repr(C, align(8))]
84+
#[repr(C)]
8685
pub struct MemoryArea {
8786
base_addr: u64,
8887
length: u64,
@@ -192,7 +191,7 @@ impl<'a> Iterator for MemoryAreaIter<'a> {
192191
/// Nowadays, much bigger chunks of continuous memory are available at higher
193192
/// addresses, but the Multiboot standard still references those two terms.
194193
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
195-
#[repr(C, align(8))]
194+
#[repr(C)]
196195
pub struct BasicMemoryInfoTag {
197196
typ: TagTypeId,
198197
size: u32,
@@ -232,7 +231,7 @@ const EFI_METADATA_SIZE: usize = mem::size_of::<TagTypeId>() + 3 * mem::size_of:
232231
#[derive(ptr_meta::Pointee)]
233232
// #[derive(Debug, PartialEq, Eq)] // wait for uefi-raw 0.3.0
234233
#[derive(Debug)]
235-
#[repr(C, align(8))]
234+
#[repr(C)]
236235
pub struct EFIMemoryMapTag {
237236
typ: TagTypeId,
238237
size: u32,
@@ -300,7 +299,7 @@ impl StructAsBytes for EFIMemoryDesc {
300299

301300
/// EFI ExitBootServices was not called
302301
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
303-
#[repr(C, align(8))]
302+
#[repr(C)]
304303
pub struct EFIBootServicesNotExited {
305304
typ: TagTypeId,
306305
size: u32,

multiboot2/src/module.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ const METADATA_SIZE: usize = size_of::<TagTypeId>() + 3 * size_of::<u32>();
1414

1515
/// This tag indicates to the kernel what boot module was loaded along with
1616
/// the kernel image, and where it can be found.
17-
#[derive(ptr_meta::Pointee)]
18-
#[derive(PartialEq, Eq)]
19-
#[repr(C, align(8))]
17+
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
18+
#[repr(C)]
2019
pub struct ModuleTag {
2120
typ: TagTypeId,
2221
size: u32,

multiboot2/src/rsdp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const RSDPV1_LENGTH: usize = 20;
2424

2525
/// This tag contains a copy of RSDP as defined per ACPI 1.0 specification.
2626
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
27-
#[repr(C, align(8))]
27+
#[repr(C)]
2828
pub struct RsdpV1Tag {
2929
typ: TagTypeId,
3030
size: u32,
@@ -97,7 +97,7 @@ impl StructAsBytes for RsdpV1Tag {
9797

9898
/// This tag contains a copy of RSDP as defined per ACPI 2.0 or later specification.
9999
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
100-
#[repr(C, align(8))]
100+
#[repr(C)]
101101
pub struct RsdpV2Tag {
102102
typ: TagTypeId,
103103
size: u32,

multiboot2/src/smbios.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ const METADATA_SIZE: usize = core::mem::size_of::<TagTypeId>()
1111
+ core::mem::size_of::<u8>() * 8;
1212

1313
/// This tag contains a copy of SMBIOS tables as well as their version.
14-
#[derive(ptr_meta::Pointee)]
15-
#[derive(PartialEq, Eq)]
16-
#[repr(C, align(8))]
14+
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
15+
#[repr(C)]
1716
pub struct SmbiosTag {
1817
typ: TagTypeId,
1918
size: u32,

multiboot2/src/vbe_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::fmt;
44
/// This tag contains VBE metadata, VBE controller information returned by the
55
/// VBE Function 00h and VBE mode information returned by the VBE Function 01h.
66
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
7-
#[repr(C, align(8))]
7+
#[repr(C)]
88
pub struct VBEInfoTag {
99
typ: TagTypeId,
1010
length: u32,

0 commit comments

Comments
 (0)