diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2025-01-11 10:25:27 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2025-01-11 10:26:02 +0100 |
| commit | f489761e682b75ede8754e9f9be48fa29ebaeb10 (patch) | |
| tree | eaa00441feadd61e7f0f291f7dfebd1fd7d3db2d /src/elfs | |
| parent | 56ccde005e9332662326b8446658e7a322633e46 (diff) | |
| download | box64-f489761e682b75ede8754e9f9be48fa29ebaeb10.tar.gz box64-f489761e682b75ede8754e9f9be48fa29ebaeb10.zip | |
[BOX32] Improved elf memory managment for 32bits process
Diffstat (limited to 'src/elfs')
| -rw-r--r-- | src/elfs/elfloader.c | 22 | ||||
| -rwxr-xr-x | src/elfs/elfparser32.c | 10 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index d8e1022b..9d54ac10 100644 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -80,22 +80,22 @@ void FreeElfHeader(elfheader_t** head) if(my_context) RemoveElfHeader(my_context, h); - box_free(h->PHEntries._64); //_64 or _32 doesn't mater for free, it's the same address - box_free(h->SHEntries._64); - box_free(h->SHStrTab); - box_free(h->StrTab); - box_free(h->Dynamic._64); - box_free(h->DynStr); - box_free(h->SymTab._64); - box_free(h->DynSym._64); + actual_free(h->PHEntries._64); //_64 or _32 doesn't mater for free, it's the same address + actual_free(h->SHEntries._64); + actual_free(h->SHStrTab); + actual_free(h->StrTab); + actual_free(h->Dynamic._64); + actual_free(h->DynStr); + actual_free(h->SymTab._64); + actual_free(h->DynSym._64); FreeElfMemory(h); - box_free(h->name); - box_free(h->path); + actual_free(h->name); + actual_free(h->path); if(h->file) fclose(h->file); - box_free(h); + actual_free(h); *head = NULL; } diff --git a/src/elfs/elfparser32.c b/src/elfs/elfparser32.c index 376bb34d..c12ab40d 100755 --- a/src/elfs/elfparser32.c +++ b/src/elfs/elfparser32.c @@ -24,7 +24,7 @@ static int LoadSH(FILE *f, Elf32_Shdr *s, void** SH, const char* name, uint32_t if (type==SHT_SYMTAB && s->sh_size%sizeof(Elf32_Sym)) { printf_log(LOG_INFO, "Section Header \"%s\" (off=%d, size=%d) has size (not multiple of %ld)\n", name, s->sh_offset, s->sh_size, sizeof(Elf32_Sym)); } - *SH = box_calloc(1, s->sh_size); + *SH = actual_calloc(1, s->sh_size); fseeko64(f, s->sh_offset ,SEEK_SET); if(fread(*SH, s->sh_size, 1, f)!=1) { printf_log(LOG_INFO, "Cannot read Section Header \"%s\" (off=%d, size=%d)\n", name, s->sh_offset, s->sh_size); @@ -115,7 +115,7 @@ elfheader_t* ParseElfHeader32(FILE* f, const char* name, int exec) return NULL; } - elfheader_t *h = box_calloc(1, sizeof(elfheader_t)); + elfheader_t *h = actual_calloc(1, sizeof(elfheader_t)); h->name = box_strdup(name); h->entrypoint = header.e_entry; h->numPHEntries = header.e_phnum; @@ -130,7 +130,7 @@ elfheader_t* ParseElfHeader32(FILE* f, const char* name, int exec) fseeko64(f, header.e_shoff, SEEK_SET); Elf32_Shdr section; if(fread(§ion, sizeof(Elf32_Shdr), 1, f)!=1) { - box_free(h); + actual_free(h); printf_log(LOG_INFO, "Cannot read Initial Section Header\n"); return NULL; } @@ -138,7 +138,7 @@ elfheader_t* ParseElfHeader32(FILE* f, const char* name, int exec) } // now read all section headers printf_log(LOG_DEBUG, "Read %d Section header\n", h->numSHEntries); - h->SHEntries._32 = (Elf32_Shdr*)box_calloc(h->numSHEntries, sizeof(Elf32_Shdr)); + h->SHEntries._32 = (Elf32_Shdr*)actual_calloc(h->numSHEntries, sizeof(Elf32_Shdr)); fseeko64(f, header.e_shoff ,SEEK_SET); if(fread(h->SHEntries._32, sizeof(Elf32_Shdr), h->numSHEntries, f)!=h->numSHEntries) { FreeElfHeader(&h); @@ -154,7 +154,7 @@ elfheader_t* ParseElfHeader32(FILE* f, const char* name, int exec) } printf_log(LOG_DEBUG, "Read %d Program header\n", h->numPHEntries); - h->PHEntries._32 = (Elf32_Phdr*)box_calloc(h->numPHEntries, sizeof(Elf32_Phdr)); + h->PHEntries._32 = (Elf32_Phdr*)actual_calloc(h->numPHEntries, sizeof(Elf32_Phdr)); fseeko64(f, header.e_phoff ,SEEK_SET); if(fread(h->PHEntries._32, sizeof(Elf32_Phdr), h->numPHEntries, f)!=h->numPHEntries) { FreeElfHeader(&h); |