From 6d41f659d357116740ac0e4a821317033009c0bd Mon Sep 17 00:00:00 2001 From: antifallobst Date: Thu, 2 Mar 2023 18:31:36 +0100 Subject: [PATCH] fix (ELF): removed field alignment from 'elf_mapping_T' --- kernel/inc/drivers/elf/mapping.h | 1 - kernel/src/drivers/elf/elf.c | 3 +-- kernel/src/drivers/elf/mapping.c | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/inc/drivers/elf/mapping.h b/kernel/inc/drivers/elf/mapping.h index a86cc26..3da92cd 100644 --- a/kernel/inc/drivers/elf/mapping.h +++ b/kernel/inc/drivers/elf/mapping.h @@ -32,7 +32,6 @@ typedef struct { uint64_t offset_virtual; uint64_t length_file; uint64_t length_virtual; - uint64_t alignment; } elf_mapping_T; void elf_mappings_apply(elf_mapping_T* mappings, uint64_t num_mappings, uint8_t* buffer, void* base, page_map_T* page_map); diff --git a/kernel/src/drivers/elf/elf.c b/kernel/src/drivers/elf/elf.c index c539355..dc33765 100644 --- a/kernel/src/drivers/elf/elf.c +++ b/kernel/src/drivers/elf/elf.c @@ -169,8 +169,7 @@ elf_executable_T* elf_executable_create(uint8_t* buffer) { .offset_file = segments[i].offset, .offset_virtual = segments[i].address_virtual, .length_file = segments[i].length_file, - .length_virtual = segments[i].length_memory, - .alignment = segments[i].align + .length_virtual = segments[i].length_memory }; mappings_index++; break; diff --git a/kernel/src/drivers/elf/mapping.c b/kernel/src/drivers/elf/mapping.c index 386d8e0..38804e6 100644 --- a/kernel/src/drivers/elf/mapping.c +++ b/kernel/src/drivers/elf/mapping.c @@ -41,7 +41,8 @@ void elf_mapping_apply(elf_mapping_T* mapping, uint8_t* buffer, void* base, page } if (mapping->length_virtual > mapping->length_file) { - memory_set(virtual_address + mapping->length_file, 0, mapping->length_virtual - mapping->length_file); + log(LOG_INFO, " zeroing out area: 0x%x <--> 0x%x", virtual_address + mapping->length_file, virtual_address + mapping->length_virtual); + memory_set(virtual_address + mapping->length_file, 0, mapping->length_virtual - mapping->length_file-1); } log(LOG_INFO, "Copying data 0x%x --[%d]-> 0x%x", &buffer[mapping->offset_file], mapping->length_file, virtual_address);