check if ELF is a position independent exectuable
@@ -456,10 +456,11 @@ initGoHook(elf_buf_t *ebuf)
//try to retrieve the version symbol address from the .go.buildinfo section
go_ver = getGoVersionAddr(ebuf->buf);
}
-
- // if it's a dynamic app, get the base address from /proc/self/maps
+ //check ELF type
+ Elf64_Ehdr *ehdr = (Elf64_Ehdr *)ebuf->buf;
+ // if it's a position independent executable, get the base address from /proc/self/maps
uint64_t base = 0LL;
- if (!g_go_static && getBaseAddress(&base) != 0) {
+ if (ehdr->e_type == ET_DYN && !g_go_static && getBaseAddress(&base) != 0) {
sysprint("ERROR: can't get the base address\n");
return; // don't install our hooks
}
