This is somewhat separate from the rest of your proposed patch, but... > + // !execlike && ET_EXEC is PIE. > + // execlike && !ET_EXEC is a static executable. > + if (mod != NULL && (execlike || ehdr.e32.e_type == ET_EXEC)) > + mod->is_executable = true; This made me look in the function and there are a couple more places that just use ehdr.e32 fields without checking whether we are dealing with a ELFCLASS32/Elf32_Ehdr or ELFCLASS64/Elf64_Ehdr (or worse use the e32 variants even when we just checked it is Elf64). ehdr is a union of those two types. It happens to work for the first few struct members since they have the same underlying base type (but different type names). But that makes it somewhat hard to review this code is correct. You have to double check every time the field offsets really match up. So I propose a cleanup like the attached first. Cheers, Mark