diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-07-31 10:32:12 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-08-06 16:10:17 +0200 |
| commit | 2ac265d52951c2951281b25aa0aba3ad21b6565f (patch) | |
| tree | 4c8a08922981a5b279a52c1d8bae1bf7218e4e3d /src/elfs/elfparser.c | |
| parent | e261270eb8719a5a2e0c7fd86140390290d49ae9 (diff) | |
| download | box64-2ac265d52951c2951281b25aa0aba3ad21b6565f.tar.gz box64-2ac265d52951c2951281b25aa0aba3ad21b6565f.zip | |
All box internal memory alloc use __libc_ internal one (except on Android, using libc one gather from dlsym)
Diffstat (limited to 'src/elfs/elfparser.c')
| -rwxr-xr-x | src/elfs/elfparser.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/elfs/elfparser.c b/src/elfs/elfparser.c index af506749..9607efd9 100755 --- a/src/elfs/elfparser.c +++ b/src/elfs/elfparser.c @@ -23,7 +23,7 @@ int LoadSH(FILE *f, Elf64_Shdr *s, void** SH, const char* name, uint32_t type) if (type==SHT_SYMTAB && s->sh_size%sizeof(Elf64_Sym)) { printf_log(LOG_INFO, "Section Header \"%s\" (off=%ld, size=%ld) has size (not multiple of %ld)\n", name, s->sh_offset, s->sh_size, sizeof(Elf64_Sym)); } - *SH = calloc(1, s->sh_size); + *SH = box_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=%ld, size=%ld)\n", name, s->sh_offset, s->sh_size); @@ -119,8 +119,8 @@ elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec) return NULL; } - elfheader_t *h = calloc(1, sizeof(elfheader_t)); - h->name = strdup(name); + elfheader_t *h = box_calloc(1, sizeof(elfheader_t)); + h->name = box_strdup(name); h->entrypoint = header.e_entry; h->numPHEntries = header.e_phnum; h->numSHEntries = header.e_shnum; @@ -134,7 +134,7 @@ elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec) fseeko64(f, header.e_shoff, SEEK_SET); Elf64_Shdr section; if(fread(§ion, sizeof(Elf64_Shdr), 1, f)!=1) { - free(h); + box_free(h); printf_log(LOG_INFO, "Cannot read Initial Section Header\n"); return NULL; } @@ -142,7 +142,7 @@ elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec) } // now read all section headers printf_dump(LOG_DEBUG, "Read %zu Section header\n", h->numSHEntries); - h->SHEntries = (Elf64_Shdr*)calloc(h->numSHEntries, sizeof(Elf64_Shdr)); + h->SHEntries = (Elf64_Shdr*)box_calloc(h->numSHEntries, sizeof(Elf64_Shdr)); fseeko64(f, header.e_shoff ,SEEK_SET); if(fread(h->SHEntries, sizeof(Elf64_Shdr), h->numSHEntries, f)!=h->numSHEntries) { FreeElfHeader(&h); @@ -158,7 +158,7 @@ elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec) } printf_dump(LOG_DEBUG, "Read %zu Program header\n", h->numPHEntries); - h->PHEntries = (Elf64_Phdr*)calloc(h->numPHEntries, sizeof(Elf64_Phdr)); + h->PHEntries = (Elf64_Phdr*)box_calloc(h->numPHEntries, sizeof(Elf64_Phdr)); fseeko64(f, header.e_phoff ,SEEK_SET); if(fread(h->PHEntries, sizeof(Elf64_Phdr), h->numPHEntries, f)!=h->numPHEntries) { FreeElfHeader(&h); |