[systemd-devel] [PATCH] build-sys: remove --gc-sections to fix debugging

Peter Wu peter at lekensteyn.nl
Tue Dec 2 09:21:43 PST 2014


On Monday 01 December 2014 01:06:12 Lennart Poettering wrote:
> On Mon, 24.11.14 20:00, Peter Wu (peter at lekensteyn.nl) wrote:
> 
> > The --gc-sections linker option triggers a bug in the gold linker[1] which
> > results in a bogus .eh_frame section making debugging harder: gdb backtraces
> > stop at a library built by systemd and libunwind simply segfaults.
> 
> To my knowledge libunwind is mostly obsolete, and libelfutils should
> be used instead.

The Fedora maintainer dropped libunwind support, but there is still
upstream activity. Documentation of libunwind is superior to
libelfutils. Even by looking in the headers, I could not find a way to
get a backtrace in libelfutils.

libunwind backtracing functionality is signal and thread-safe while
libelfutils does not have a strong focus on that as far as I can see.

See also the discussion on this X patch where libelfutils was ultimately
dropped in favor if libunwind. https://freedesktop.org/patch/15054/

> > Workaround by that bug by removing the option. The additional disk space
> > saved by this option is marginal anyway (less than 1%). To illustrate this, see
> > this `du -ks` on the installed files:
> > 
> >     83548   without-gc-sections/install
> >     25796   without-gc-sections/install-strip
> >     83432   with-gc-sections/install
> >     25752   with-gc-sections/install-strip
> > 
> >  [1]: https://sourceware.org/bugzilla/show_bug.cgi?id=17639
> 
> Are you sure you built the non-debug build?

Just ./autogen.sh && ./configure, nothing fancy. The default options
include '-g', but for some reason the linking drops this option and
there are no debugging symbols.

> The reason we use gc-sections logic is that much of what we hae in
> src/shared/ is linked into every single binary we have even though
> most binaries need only very little of it. We rely on the linker to
> remove all the bits that are unnecessary hence.

It turns out that my compiler (GCC 4.9.2) behaved worse with
--gc-sections because LTO already optimized the unused parts away.
-- 
Kind regards,
Peter
https://lekensteyn.nl



More information about the systemd-devel mailing list