[PATCH 1/2] Add is_executable to Dwfl_Module.

Mark Wielaard mjw at redhat.com
Wed Sep 10 20:15:42 UTC 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libdwfl-dwfl_segment_report_module-use-ei_class-ei_d.patch
Type: text/x-patch
Size: 6430 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/elfutils-devel/attachments/20140910/52f8ef07/attachment.bin>


More information about the elfutils-devel mailing list