Skip to content

Commit 45183b2

Browse files
committed
multiboot2: load: remove weird offset thingy API
1 parent 9dd5c2a commit 45183b2

File tree

3 files changed

+111
-126
lines changed

3 files changed

+111
-126
lines changed

multiboot2/Changelog.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# CHANGELOG for crate `multiboot2`
22

33
## 0.16.0 (xxxx-xx-xx)
4-
- Add `TagTrait` trait which enables to use DSTs as multiboot2 tags. This is
5-
mostly relevant for the command line tag, the modules tag, and the bootloader
6-
name tag. However, this might also be relevant for users of custom multiboot2
7-
tags that use DSTs as types. See the example provided in the doc of the
8-
`get_tag` method.
9-
- renamed `MULTIBOOT2_BOOTLOADER_MAGIC` to `MAGIC`
4+
- **BREAKING** renamed `MULTIBOOT2_BOOTLOADER_MAGIC` to `MAGIC`
105
- added a `builder` feature and a `builder` module with a `Multiboot2InformationBuilder`
116
struct
12-
- `EFIMemoryDesc` was removed and is now an alias of
7+
- **BREAKING** `EFIMemoryDesc` was removed and is now an alias of
138
`uefi_raw::table::boot::MemoryDescriptor`
14-
- `EFIMemoryAreaType` was removed and is now an alias of
9+
- **BREAKING** `EFIMemoryAreaType` was removed and is now an alias of
1510
`uefi_raw::table::boot::MemoryType`
16-
- MSRV is 1.68.0
11+
- **BREAKING** MSRV is 1.68.0
12+
- **\[Might be\] BREAKING** Added `TagTrait` trait which enables to use DSTs as multiboot2 tags. This is
13+
mostly relevant for the command line tag, the modules tag, and the bootloader
14+
name tag. However, this might also be relevant for users of custom multiboot2
15+
tags that use DSTs as types. See the example provided in the doc of the
16+
`get_tag` method.
17+
- deprecated `load` and `load_with_offset`
18+
- added `BootInformation::load`
1719

1820
## 0.15.1 (2023-03-18)
1921
- **BREAKING** `MemoryMapTag::all_memory_areas()` was renamed to `memory_areas`

multiboot2/src/elf_sections.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use {
1212

1313
const METADATA_SIZE: usize = size_of::<TagTypeId>() + 4 * size_of::<u32>();
1414

15-
/// This tag contains section header table from an ELF kernel.
16-
///
17-
/// The sections iterator is provided via the `sections` method.
15+
/// This tag contains the section header table from an ELF binary.
16+
// The sections iterator is provided via the [`ElfSectionsTag::sections`]
17+
// method.
1818
#[derive(ptr_meta::Pointee)]
1919
#[repr(C, packed)]
2020
pub struct ElfSectionsTag {
@@ -41,7 +41,7 @@ impl ElfSectionsTag {
4141
}
4242

4343
/// Get an iterator of loaded ELF sections.
44-
pub(crate) fn sections(&self, offset: usize) -> ElfSectionIter {
44+
pub(crate) fn sections(&self) -> ElfSectionIter {
4545
let string_section_offset = (self.shndx * self.entry_size) as isize;
4646
let string_section_ptr =
4747
unsafe { self.first_section().offset(string_section_offset) as *const _ };
@@ -50,7 +50,6 @@ impl ElfSectionsTag {
5050
remaining_sections: self.number_of_sections,
5151
entry_size: self.entry_size,
5252
string_section: string_section_ptr,
53-
offset,
5453
}
5554
}
5655

@@ -81,7 +80,7 @@ impl Debug for ElfSectionsTag {
8180
.field("number_of_sections", &{ self.number_of_sections })
8281
.field("entry_size", &{ self.entry_size })
8382
.field("shndx", &{ self.shndx })
84-
.field("sections", &self.sections(0))
83+
.field("sections", &self.sections())
8584
.finish()
8685
}
8786
}
@@ -93,7 +92,6 @@ pub struct ElfSectionIter {
9392
remaining_sections: u32,
9493
entry_size: u32,
9594
string_section: *const u8,
96-
offset: usize,
9795
}
9896

9997
impl Iterator for ElfSectionIter {
@@ -105,7 +103,6 @@ impl Iterator for ElfSectionIter {
105103
inner: self.current_section,
106104
string_section: self.string_section,
107105
entry_size: self.entry_size,
108-
offset: self.offset,
109106
};
110107

111108
self.current_section = unsafe { self.current_section.offset(self.entry_size as isize) };
@@ -136,7 +133,6 @@ impl Default for ElfSectionIter {
136133
remaining_sections: 0,
137134
entry_size: 0,
138135
string_section: core::ptr::null(),
139-
offset: 0,
140136
}
141137
}
142138
}
@@ -147,7 +143,6 @@ pub struct ElfSection {
147143
inner: *const u8,
148144
string_section: *const u8,
149145
entry_size: u32,
150-
offset: usize,
151146
}
152147

153148
#[derive(Clone, Copy, Debug)]
@@ -282,7 +277,7 @@ impl ElfSection {
282277
64 => (*(self.string_section as *const ElfSectionInner64)).addr as usize,
283278
s => panic!("Unexpected entry size: {}", s),
284279
};
285-
(addr + self.offset) as *const _
280+
addr as *const _
286281
}
287282
}
288283

0 commit comments

Comments
 (0)