elf_section_hdr_info: return the info instead of void
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
diff --git a/stage23/lib/elf.c b/stage23/lib/elf.c
index 60463e7d..845ff30c 100644
--- a/stage23/lib/elf.c
+++ b/stage23/lib/elf.c
@@ -249,7 +249,7 @@ int elf64_load_section(uint8_t *elf, void *buffer, const char *name, size_t limi
/// SAFETY: The caller must ensure that the provided `elf` is a valid 64-bit
/// ELF file.
-void elf64_section_hdr_info(uint8_t *elf, struct elf_section_hdr_info** _info) {
+struct elf_section_hdr_info* elf64_section_hdr_info(uint8_t *elf) {
struct elf_section_hdr_info* info = ext_mem_alloc(sizeof(struct elf_section_hdr_info));
struct elf64_hdr hdr;
@@ -263,12 +263,12 @@ void elf64_section_hdr_info(uint8_t *elf, struct elf_section_hdr_info** _info) {
memcpy(info->section_hdrs, elf + (hdr.shoff), info->section_hdr_size);
- *_info = info;
+ return info;
}
-/// SAFETY: The caller must ensure that the provided `elf` is a valid 64-bit
+/// SAFETY: The caller must ensure that the provided `elf` is a valid 32-bit
/// ELF file.
-void elf32_section_hdr_info(uint8_t *elf, struct elf_section_hdr_info** _info) {
+struct elf_section_hdr_info* elf32_section_hdr_info(uint8_t *elf) {
struct elf_section_hdr_info* info = ext_mem_alloc(sizeof(struct elf_section_hdr_info));
struct elf32_hdr hdr;
@@ -282,7 +282,7 @@ void elf32_section_hdr_info(uint8_t *elf, struct elf_section_hdr_info** _info) {
memcpy(info->section_hdrs, elf + (hdr.shoff), info->section_hdr_size);
- *_info = info;
+ return info;
}
int elf32_load_section(uint8_t *elf, void *buffer, const char *name, size_t limit) {
diff --git a/stage23/lib/elf.h b/stage23/lib/elf.h
index d57be297..2d300f11 100644
--- a/stage23/lib/elf.h
+++ b/stage23/lib/elf.h
@@ -29,10 +29,10 @@ int elf_bits(uint8_t *elf);
int elf64_load(uint8_t *elf, uint64_t *entry_point, uint64_t *top, uint64_t *_slide, uint32_t alloc_type, bool kaslr, bool use_paddr, struct elf_range **ranges, uint64_t *ranges_count);
int elf64_load_section(uint8_t *elf, void *buffer, const char *name, size_t limit, uint64_t slide);
-void elf64_section_hdr_info(uint8_t *elf, struct elf_section_hdr_info** info);
+struct elf_section_hdr_info* elf64_section_hdr_info(uint8_t *elf);
int elf32_load(uint8_t *elf, uint32_t *entry_point, uint32_t *top, uint32_t alloc_type);
int elf32_load_section(uint8_t *elf, void *buffer, const char *name, size_t limit);
-void elf32_section_hdr_info(uint8_t *elf, struct elf_section_hdr_info** info);
+struct elf_section_hdr_info* elf32_section_hdr_info(uint8_t *elf);
#endif
diff --git a/stage23/protos/multiboot2.c b/stage23/protos/multiboot2.c
index defc4c76..f1ea92ee 100644
--- a/stage23/protos/multiboot2.c
+++ b/stage23/protos/multiboot2.c
@@ -106,23 +106,23 @@ void multiboot2_load(char *config, char* cmdline) {
switch (bits) {
case 32:
if (elf32_load(kernel, &entry_point, &kernel_top, MEMMAP_KERNEL_AND_MODULES))
- panic("multiboot1: ELF32 load failure");
+ panic("multiboot2: ELF32 load failure");
- elf32_section_hdr_info(kernel, §ion_hdr_info);
+ section_hdr_info = elf32_section_hdr_info(kernel);
break;
case 64: {
uint64_t e, t;
if (elf64_load(kernel, &e, &t, NULL, MEMMAP_KERNEL_AND_MODULES, false, true, NULL, NULL))
- panic("multiboot1: ELF64 load failure");
+ panic("multiboot2: ELF64 load failure");
entry_point = e;
kernel_top = t;
- elf64_section_hdr_info(kernel, §ion_hdr_info);
+ section_hdr_info = elf64_section_hdr_info(kernel);
break;
}
default:
- panic("multiboot1: invalid ELF file bitness");
+ panic("multiboot2: invalid ELF file bitness");
}
print("multiboot2: found kernel entry point at: %x\n", entry_point);
