elf: Return is_reloc
This commit is contained in:
parent
2cc4ff856f
commit
41ea16e2ff
@ -479,7 +479,7 @@ static void elf64_get_ranges(uint8_t *elf, uint64_t slide, bool use_paddr, struc
|
||||
*_ranges = ranges;
|
||||
}
|
||||
|
||||
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, bool fully_virtual, uint64_t *physical_base, uint64_t *virtual_base, uint64_t *_image_size) {
|
||||
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, bool fully_virtual, uint64_t *physical_base, uint64_t *virtual_base, uint64_t *_image_size, bool *is_reloc) {
|
||||
struct elf64_hdr hdr;
|
||||
memcpy(&hdr, elf + (0), sizeof(struct elf64_hdr));
|
||||
|
||||
@ -496,6 +496,10 @@ int elf64_load(uint8_t *elf, uint64_t *entry_point, uint64_t *top, uint64_t *_sl
|
||||
panic(true, "elf: Not an x86_64 ELF file.\n");
|
||||
}
|
||||
|
||||
if (is_reloc) {
|
||||
*is_reloc = false;
|
||||
}
|
||||
|
||||
uint64_t slide = 0;
|
||||
bool simulation = true;
|
||||
size_t try_count = 0;
|
||||
@ -556,6 +560,10 @@ int elf64_load(uint8_t *elf, uint64_t *entry_point, uint64_t *top, uint64_t *_sl
|
||||
if (!elf64_is_relocatable(elf, &hdr)) {
|
||||
simulation = false;
|
||||
goto final;
|
||||
} else {
|
||||
if (is_reloc) {
|
||||
*is_reloc = true;
|
||||
}
|
||||
}
|
||||
|
||||
again:
|
||||
|
@ -27,7 +27,7 @@ struct elf_section_hdr_info {
|
||||
|
||||
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, bool fully_virtual, uint64_t *physical_base, uint64_t *virtual_base, uint64_t *image_size);
|
||||
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, bool fully_virtual, uint64_t *physical_base, uint64_t *virtual_base, uint64_t *image_size, bool *is_reloc);
|
||||
int elf64_load_section(uint8_t *elf, void *buffer, const char *name, size_t limit, uint64_t slide);
|
||||
struct elf_section_hdr_info* elf64_section_hdr_info(uint8_t *elf);
|
||||
|
||||
|
@ -142,14 +142,18 @@ bool limine_load(char *config, char *cmdline) {
|
||||
uint64_t ranges_count;
|
||||
|
||||
uint64_t image_size;
|
||||
bool is_reloc;
|
||||
|
||||
if (elf64_load(kernel, &entry_point, NULL, &slide,
|
||||
MEMMAP_KERNEL_AND_MODULES, kaslr, false,
|
||||
&ranges, &ranges_count,
|
||||
true, &physical_base, &virtual_base, &image_size)) {
|
||||
true, &physical_base, &virtual_base, &image_size,
|
||||
&is_reloc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
kaslr = is_reloc;
|
||||
|
||||
// Load requests
|
||||
requests_count = 0;
|
||||
uint64_t common_magic[2] = { LIMINE_COMMON_MAGIC };
|
||||
|
@ -106,7 +106,7 @@ bool multiboot1_load(char *config, char *cmdline) {
|
||||
break;
|
||||
case 64: {
|
||||
uint64_t e, t;
|
||||
if (elf64_load(kernel, &e, &t, NULL, MEMMAP_KERNEL_AND_MODULES, false, true, NULL, NULL, false, NULL, NULL, NULL))
|
||||
if (elf64_load(kernel, &e, &t, NULL, MEMMAP_KERNEL_AND_MODULES, false, true, NULL, NULL, false, NULL, NULL, NULL, NULL))
|
||||
panic(true, "multiboot1: ELF64 load failure");
|
||||
entry_point = e;
|
||||
kernel_top = t;
|
||||
|
@ -219,7 +219,7 @@ bool multiboot2_load(char *config, char* cmdline) {
|
||||
|
||||
break;
|
||||
case 64: {
|
||||
if (elf64_load(kernel, &e, &t, NULL, MEMMAP_KERNEL_AND_MODULES, false, true, NULL, NULL, false, NULL, NULL, NULL))
|
||||
if (elf64_load(kernel, &e, &t, NULL, MEMMAP_KERNEL_AND_MODULES, false, true, NULL, NULL, false, NULL, NULL, NULL, NULL))
|
||||
panic(true, "multiboot2: ELF64 load failure");
|
||||
|
||||
break;
|
||||
|
@ -143,7 +143,7 @@ bool stivale_load(char *config, char *cmdline) {
|
||||
if (!loaded_by_anchor) {
|
||||
if (elf64_load(kernel, &entry_point, NULL, &slide,
|
||||
STIVALE_MMAP_KERNEL_AND_MODULES, kaslr, false,
|
||||
NULL, NULL, false, NULL, NULL, NULL))
|
||||
NULL, NULL, false, NULL, NULL, NULL, NULL))
|
||||
panic(true, "stivale: ELF64 load failure");
|
||||
|
||||
ret = elf64_load_section(kernel, &stivale_hdr, ".stivalehdr",
|
||||
|
@ -188,7 +188,8 @@ bool stivale2_load(char *config, char *cmdline) {
|
||||
STIVALE2_MMAP_KERNEL_AND_MODULES, kaslr, false,
|
||||
want_pmrs ? &ranges : NULL,
|
||||
want_pmrs ? &ranges_count : NULL,
|
||||
want_fully_virtual, &physical_base, &virtual_base, NULL))
|
||||
want_fully_virtual, &physical_base, &virtual_base,
|
||||
NULL, NULL))
|
||||
panic(true, "stivale2: ELF64 load failure");
|
||||
|
||||
if (want_fully_virtual) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user