public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Fangrui Song <maskray@google.com>
Cc: gdb@sourceware.org, elfutils-devel@sourceware.org,
	binutils@sourceware.org
Subject: Re: Range lists, zero-length functions, linker gc
Date: Mon, 1 Jun 2020 00:11:11 +0200	[thread overview]
Message-ID: <20200531221111.GL44629@wildebeest.org> (raw)
In-Reply-To: <20200531204738.xhyuemuaygi5ihdd@google.com>

Hi,

On Sun, May 31, 2020 at 01:47:38PM -0700, Fangrui Song via Elfutils-devel wrote:
> On 2020-05-31, Mark Wielaard wrote:
> > I think this is a producer problem. If a (code) section can be totally
> > dropped then the associated (.debug) sections should have been
> > generated together with that (code) section in a COMDAT group. That
> > way when the linker drops that section, all the associated sections in
> > that COMDAT group will get dropped with it. If you don't do that, then
> > the DWARF is malformed and there is not much a consumer can do about
> > it.
> > 
> > Said otherwise, I don't think it is correct for the linker (with
> > --gc-sections) to drop any sections that have references to it
> > (through relocation symbols) from other (.debug) sections.
> 
> I would love if we could solve the problem using ELF features, but
> putting DW_TAG_subprogram in the same section group is not an
> unqualified win

Sorry for pushing back a little, but as a DWARF consumer this feels a
little like the DWARF producer hasn't tried hard enough to produce
valid DWARF and now tries to pass the problems off onto the DWARF
consumer. Or when looking at it from the perspective of the linker,
the compiler gave it an impossible problem to solve because it didn't
really get all the pieces of the puzzle (the compiler already fused
some independent parts together).

I certainly appreciate the issue on 32-bit systems. It seems we
already have reached the limits for some programs to be linked (or
produce all the debuginfo) when all you got is 32-bits.

But maybe that means that the problem is actually that the compiler
already produced too much code/data. And the issue really is that it
passes some problems, like unused code elimination, off to the
linker. While the compiler really should have a better view of that,
and should do that job itself. If it did, then it would never even
produce the debuginfo in the first place.

GCC used to produce horrible DWARF years ago with early LTO
implementations, because they just handed it all off to the linker to
figure out. But they solved it by generating DWARF in phases, only
when it was known the DWARF was valid/consistent did it get
produced. So that if some code was actually eliminated then the linker
never even see any "code ranges" for code that disappeared. See Early
Debug: https://gcc.gnu.org/wiki/early-debug

Might some similar technique, where the compiler does a bit more work,
so that it actually produces less DWARF to be processed by the linker,
be used here?

Sorry for pushing the problem back to the producer side, but as a
consumer I think that is the more correct place to solve this.

Cheers,

Mark

  reply	other threads:[~2020-05-31 22:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 18:55 Fangrui Song
2020-05-31 19:15 ` Fangrui Song
2020-05-31 20:10 ` Mark Wielaard
2020-05-31 20:47   ` Fangrui Song
2020-05-31 22:11     ` Mark Wielaard [this message]
2020-05-31 23:17       ` David Blaikie
2020-05-31 20:49   ` David Blaikie
2020-05-31 22:29     ` Mark Wielaard
2020-05-31 22:36       ` David Blaikie
2020-06-01  9:31         ` Mark Wielaard
2020-06-01 20:18           ` David Blaikie
2020-06-02 16:50             ` Mark Wielaard
2020-06-02 18:06               ` David Blaikie
2020-06-03  3:10                 ` Alan Modra
2020-06-03  4:06                   ` Fangrui Song
2020-06-03 21:50                   ` David Blaikie
2020-06-09 20:24                     ` Tombstone values in debug sections (was: Range lists, zero-length functions, linker gc) Fangrui Song
2020-06-19 20:04                       ` Mark Wielaard
2020-06-20  1:02                         ` David Blaikie
2020-06-19 12:00                 ` Range lists, zero-length functions, linker gc Mark Wielaard
2020-06-20  0:46                   ` David Blaikie
2020-06-24 22:21                     ` Mark Wielaard
2020-06-25 23:45                       ` David Blaikie
2020-05-31 21:33 ` David Blaikie
2020-06-01 16:25 ` Andrew Burgess

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=20200531221111.GL44629@wildebeest.org \
    --to=mark@klomp.org \
    --cc=binutils@sourceware.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=gdb@sourceware.org \
    --cc=maskray@google.com \
    /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).