This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Feature request: improved build-id generation


On Thu, 2018-03-15 at 17:07 +0000, Andy Lutomirski wrote:
> On Thu, Mar 15, 2018 at 1:32 PM, Nick Clifton <nickc@redhat.com>
> wrote:
> > > That might be an interesting alternative. Could you use this for e.g.
> > > inserting a .comment section fragment with an unique (version) string?
> > > That would be stripped away, but should still count for the build-id
> > > hash calculation.
> 
> ...
> 
> >   % gcc hello.c -Wl,comment.t
> >   % readelf -p.comment a.out
> > 
> > String dump of section '.comment':
> >   [     0]  GCC: (GNU) 7.3.1 20180130 (Red Hat 7.3.1-2)
> >   [    2c]  GCC: (GNU) 7.2.1 20170915 (Red Hat 7.2.1-2)
> >   [    58]  ABC
> > 
> >   A simple perl or python script could be used to create the comment.t
> >   linker script fragment.
> 
> When you say 'stripped away', do you mean that 'strip' would remove
> it?  Neither plain strip nor 'strip -S' seem to be doing the job.

You are right, I assumed the .comment section was one of the special
sections that always got stripped away, but it isn't by default. But
everybody seems to use strip --remove-section=.comment (or eu-strip --
remove-comment, as is the default for rpm/fedora). So in practice it is
being stripped away (into the .debug file).

> Sticking additional information in the object that affects the
> build-id, shows up in the separate debug data, and does *not* show up
> in the actual running ELF file seems quite handy.  Then there could be
> a tool that would take an ELF file, find its debug info, and parse out
> the Fedora package name and version :)

Yes. Note that in theory just the build-id is enough for that. If you
have a service where the packages/build-ids are registered. e.g. Fedora
has darkserver which you can query which package a binary came from
given a build-id: https://darkserver.fedoraproject.org/
Which is very handy if someone gives you a core file with build-ids in
it and they forgot to tell you precisely which version they had
installed (assuming it was a distro package of course).

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]