mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-18 20:48:07 +00:00
Improvements to debug output
This commit is contained in:
@ -93,17 +93,18 @@ static void lib_read_text_section(lib_details_t *lib_details, Elf_Ehdr *hdr) {
|
||||
|
||||
}
|
||||
|
||||
FOKF("Image preferred load address 0x%016" G_GSIZE_MODIFIER "x",
|
||||
preferred_base);
|
||||
FVERBOSE("\tpreferred load address: 0x%016" G_GSIZE_MODIFIER "x",
|
||||
preferred_base);
|
||||
|
||||
shdr = (Elf_Shdr *)((char *)hdr + hdr->e_shoff);
|
||||
shstrtab = &shdr[hdr->e_shstrndx];
|
||||
shstr = (char *)hdr + shstrtab->sh_offset;
|
||||
|
||||
FOKF("shdr: %p", shdr);
|
||||
FOKF("shstrtab: %p", shstrtab);
|
||||
FOKF("shstr: %p", shstr);
|
||||
FVERBOSE("\tshdr: %p", shdr);
|
||||
FVERBOSE("\tshstrtab: %p", shstrtab);
|
||||
FVERBOSE("\tshstr: %p", shstr);
|
||||
|
||||
FVERBOSE("Sections:");
|
||||
for (size_t i = 0; i < hdr->e_shnum; i++) {
|
||||
|
||||
curr = &shdr[i];
|
||||
@ -111,21 +112,23 @@ static void lib_read_text_section(lib_details_t *lib_details, Elf_Ehdr *hdr) {
|
||||
if (curr->sh_name == 0) continue;
|
||||
|
||||
section_name = &shstr[curr->sh_name];
|
||||
FOKF("Section: %2" G_GSIZE_MODIFIER "u - base: 0x%016" G_GSIZE_MODIFIER
|
||||
"X size: 0x%016" G_GSIZE_MODIFIER "X %s",
|
||||
i, curr->sh_addr, curr->sh_size, section_name);
|
||||
FVERBOSE("\t%2" G_GSIZE_MODIFIER "u - base: 0x%016" G_GSIZE_MODIFIER
|
||||
"X size: 0x%016" G_GSIZE_MODIFIER "X %s",
|
||||
i, curr->sh_addr, curr->sh_size, section_name);
|
||||
if (memcmp(section_name, text_name, sizeof(text_name)) == 0 &&
|
||||
text_base == 0) {
|
||||
|
||||
text_base = lib_details->base_address + curr->sh_addr - preferred_base;
|
||||
text_limit = text_base + curr->sh_size;
|
||||
FOKF("> text_addr: 0x%016" G_GINT64_MODIFIER "X", text_base);
|
||||
FOKF("> text_limit: 0x%016" G_GINT64_MODIFIER "X", text_limit);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FVERBOSE(".text\n");
|
||||
FVERBOSE("\taddr: 0x%016" G_GINT64_MODIFIER "X", text_base);
|
||||
FVERBOSE("\tlimit: 0x%016" G_GINT64_MODIFIER "X", text_limit);
|
||||
|
||||
}
|
||||
|
||||
static void lib_get_text_section(lib_details_t *details) {
|
||||
@ -141,7 +144,7 @@ static void lib_get_text_section(lib_details_t *details) {
|
||||
|
||||
if (len == (off_t)-1) { FFATAL("Failed to lseek %s", details->path); }
|
||||
|
||||
FOKF("len: %ld", len);
|
||||
FVERBOSE("\tlength: %ld", len);
|
||||
|
||||
hdr = (Elf_Ehdr *)mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (hdr == MAP_FAILED) { FFATAL("Failed to map %s", details->path); }
|
||||
@ -162,8 +165,10 @@ void lib_init(void) {
|
||||
|
||||
lib_details_t lib_details;
|
||||
gum_process_enumerate_modules(lib_find_exe, &lib_details);
|
||||
FOKF("Executable: 0x%016" G_GINT64_MODIFIER "x - %s",
|
||||
lib_details.base_address, lib_details.path);
|
||||
FVERBOSE("Image");
|
||||
FVERBOSE("\tbase: 0x%016" G_GINT64_MODIFIER "x",
|
||||
lib_details.base_address);
|
||||
FVERBOSE("\tpath: %s", lib_details.path);
|
||||
lib_get_text_section(&lib_details);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user