[Rpm-maint] [rpm-software-management/rpm] elfdeps: Generate dependencies on non-executable shared libraries (#1393)
Mark Wielaard
mark at klomp.org
Mon Oct 12 09:08:15 UTC 2020
Hi,
On Mon, 2020-10-12 at 00:35 -0700, Panu Matilainen wrote:
> The problem here is that we're trying to classify a hermaphrodite
> entity into one of two sexes. ET_EXEC is clear, but ET_DYN can be
> either an executable, a dynamic shared library *or both*. Until we
> embrace this fact, we'll get it wrong half of the time.
>
> So we need to stop trying to decide what *it is* and instead ask it
> what it's *capable of*, and act accordingly.
> libmagic doesn't know nearly enough to handle this, so the logic
> needs to live inside elfdeps or we need to enhance the classifier
> somehow (wouldn't be a bad thing at all but perhaps out of scope
> here). Which means a split on the .attr level likely isn't going to
> be meaningful.
>
> If we want to preserve the behavior where executables can disable
> dependency generation by stripping x, we need to come up with a new
> way of defining an executable. Given the nature of modern ELF, I
> think the only meaningful way is to draw the line at: regardless of
> it's possible other capabilities, does it do something if executed?
> Which AIUI in technical terms comes down to: does it have PT_INTERP?
> elfdeps looks that info up as it is, but it's not wired in a
> meaningful way at the moment.
That is indeed a tricky question to answer. Note that elfutils since
0.177 comes with a tool eu-elfclassify to answer precisely these
questions:
https://gnu.wildebeest.org/blog/mjw/2019/08/15/elfutils-0-177-released-with-eu-elfclassify/
You might want to use that or study the code to see how it determines
some of the corner cases. Specifically you may want to lookup
is_executable () and is_program (), is_library () and is_shared () for
some of the tricky corner cases:
--executable File is (primarily) an ELF program executable (not
primarily a DSO)
--program File is an ELF program executable (might also be a
DSO)
--library File is an ELF shared object (DSO) (might also be
an executable)
--shared File is (primarily) an ELF shared object (DSO)
(not primarily an executable)
Cheers,
Mark
More information about the Rpm-maint
mailing list