From: Mark Wielaard <mark@klomp.org>
To: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: Florian Weimer <fweimer@redhat.com>,
elfutils-devel@sourceware.org,
Panu Matilainen <pmatilai@laiskiainen.org>
Subject: Re: [PATCH] elfclassify tool
Date: Sat, 27 Jul 2019 11:54:00 -0000 [thread overview]
Message-ID: <20190727115432.GA2881@wildebeest.org> (raw)
In-Reply-To: <20190726230448.GB14246@altlinux.org>
On Sat, Jul 27, 2019 at 02:04:48AM +0300, Dmitry V. Levin wrote:
> On Sat, Jul 20, 2019 at 11:51:16PM +0200, Mark Wielaard wrote:
> > On Sat, Jul 20, 2019 at 01:57:27AM +0300, Dmitry V. Levin wrote:
> [...]
> > > btw, I think it would be appropriate to move the has_dynamic check before
> > > the first check in is_shared that returns true.
> >
> > Yes, that is probably fine, but does it really matter?
>
> It doesn't matter unless the file has DT_SONAME but doesn't have PT_DYNAMIC.
>
> If /lib64/ld-linux-x86-64.so.2 --verify doesn't like files without
> PT_DYNAMIC, elfclassify --shared shouldn't classify them as DSOs, too.
Yes, I see how theoretically that is "more correct". But if the file
doesn't have PT_DYNAMIC then it cannot have a DT_SONAME. And there
are no other checks that return true. So in practice there is no
difference. Still, if it looks more correct, then lets just swap the
checks.
diff --git a/src/elfclassify.c b/src/elfclassify.c
index 03655aea..0b1bb63a 100644
--- a/src/elfclassify.c
+++ b/src/elfclassify.c
@@ -498,6 +498,11 @@ is_shared (void)
if (elf_type == ET_EXEC)
return false;
+ /* If there is no dynamic section, the file cannot be loaded as a
+ shared object. */
+ if (!has_dynamic)
+ return false;
+
/* If the object is marked as PIE, it is definitely an executable,
and not a loadlable shared object. */
if (has_pie_flag)
@@ -526,10 +531,6 @@ is_shared (void)
if (has_dt_debug)
return false;
- /* If there is no dynamic section, the file cannot be loaded as a
- shared object. */
- if (!has_dynamic)
- return false;
return true;
}
Thanks,
Mark
next prev parent reply other threads:[~2019-07-27 11:54 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 15:38 Florian Weimer
2019-04-15 15:39 ` Mark Wielaard
2019-04-16 11:38 ` Florian Weimer
2019-04-18 11:17 ` Florian Weimer
2019-07-19 12:47 ` Mark Wielaard
2019-07-19 13:43 ` Dmitry V. Levin
2019-07-19 14:21 ` Mark
2019-07-19 18:35 ` Dmitry V. Levin
2019-07-19 21:00 ` Florian Weimer
2019-07-19 21:23 ` Dmitry V. Levin
2019-07-19 21:36 ` Mark Wielaard
2019-07-19 22:57 ` Dmitry V. Levin
2019-07-20 21:51 ` Mark Wielaard
2019-07-25 22:39 ` [PATCH] elfclassify: Add --library classification Mark Wielaard
2019-07-26 22:53 ` Dmitry V. Levin
2019-07-26 23:04 ` [PATCH] elfclassify tool Dmitry V. Levin
2019-07-27 11:54 ` Mark Wielaard [this message]
2019-07-20 21:40 ` Mark Wielaard
2019-07-22 15:55 ` Florian Weimer
2019-07-26 22:11 ` Mark Wielaard
2019-07-29 8:44 ` Florian Weimer
2019-07-29 14:24 ` Mark Wielaard
2019-08-11 23:38 ` Mark Wielaard
2019-08-12 8:14 ` Florian Weimer
2019-08-12 15:18 ` Mark Wielaard
2019-07-29 9:16 ` Florian Weimer
2019-07-29 14:34 ` Mark Wielaard
2019-07-29 14:38 ` Florian Weimer
2019-08-13 9:44 ` Mark Wielaard
2019-08-13 11:42 ` Mark Wielaard
2019-08-14 20:46 ` [PATCH] config/elfutils.spec.in: package eu-elfclassify Dmitry V. Levin
2019-08-15 7:33 ` Mark Wielaard
2019-07-29 9:22 ` [PATCH] elfclassify tool Florian Weimer
2019-07-29 14:40 ` Mark Wielaard
2019-07-29 14:42 ` Florian Weimer
2019-07-19 13:24 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190727115432.GA2881@wildebeest.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
--cc=fweimer@redhat.com \
--cc=ldv@altlinux.org \
--cc=pmatilai@laiskiainen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).