public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: gdb@sourceware.org, elfutils-devel@sourceware.org,
	binutils@sourceware.org
Cc: Alan Modra <amodra@gmail.com>, Mark Wielaard <mark@klomp.org>,
	David Blaikie <dblaikie@gmail.com>
Subject: Tombstone values in debug sections (was: Range lists, zero-length functions, linker gc)
Date: Tue, 9 Jun 2020 13:24:14 -0700	[thread overview]
Message-ID: <20200609202414.2olgwq2jniweeyr6@google.com> (raw)
In-Reply-To: <CAENS6EvzJh6Z_XaqOWg+f0k0grXzBVSruHNvJSy=fNaakOtxcQ@mail.gmail.com>

I want to revive the thread, but focus on whether a tombstone value
(-1/-2) in .debug_* can cause trouble to various DWARF consumers (gdb,
debug related tools in elfutils and other utilities I don't know about).

Paul Robinson has proposed that DWARF v6 should reserve a tombstone
value  (the value a relocation referencing a discarded symbol in a
.debug_* section should be resolved to)
http://www.dwarfstd.org/ShowIssue.php?issue=200609.1

Some comments about the proposal:

> - deduplicating different functions with identical content; GNU refers
>   to this as ICF (Identical Code Folding);

ICF (gold --icf={safe,all}) can cause DW_TAG_subprogram with different DW_AT_name to have the same range.

> - functions with no callers; sometimes called dead-stripping or
>   garbage collection.

--gc-sections can lead to tombstone values. A referenced symbol may be
discarded because its containing sections is garbage collected.

> - functions emitted in COMDAT sections, typically C++ template
>   instantiations or inline functions from a header file;

This can cause either tombstone values (STB_LOCAL) or duplicate DIEs (non-STB_LOCAL).


On 2020-06-03, David Blaikie wrote:
>On Tue, Jun 2, 2020 at 8:10 PM Alan Modra <amodra@gmail.com> wrote:
>>
>> On Tue, Jun 02, 2020 at 11:06:10AM -0700, David Blaikie via Binutils wrote:
>> > On Tue, Jun 2, 2020 at 9:50 AM Mark Wielaard <mark@klomp.org> wrote:
>> > > where I
>> > > would argue the compiler simply needs to make sure that if it generates
>> > > code in separate sections it also should create the DWARF separate
>> > > section (groups).
>> >
>> > I don't think that's practical - the overhead, I believe, is too high.
>> > Headers for each section contribution (ELF headers but DWARF headers
>> > moreso - having a separate .debug_addr, .debug_line, etc section for
>> > each function would be very expensive) would make for very large
>> > object files.
>>
>> With a little linker magic I don't see the neccesity of duplicating
>> the DWARF headers.  Taking .debug_line as an example, a compiler could
>> emit the header, opcode, directory and file tables to a .debug_line
>> section with line statements for function foo emitted to
>> .debug_line.foo and for bar to .debug_line.bar, trusting that the
>> linker will combine these sections in order to create an output
>> .debug_line section.  If foo code is excluded then .debug_line.foo
>> info will also be dropped if section groups are used.
>
>I don't think this would apply to debug_addr - where the entries are
>referenced from elsewhere via index, or debug_rnglist where the
>rnglist header (or the debug_info directly) contains offsets into this
>section, so taking chunks out would break those offsets. (or to the
>file/directory name part of debug_line - where you might want to
>remove file/line entries that were eliminated as dead code - but
>that'd throw off the indexes)

  reply	other threads:[~2020-06-09 20:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 18:55 Range lists, zero-length functions, linker gc 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
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                     ` Fangrui Song [this message]
2020-06-19 20:04                       ` Tombstone values in debug sections (was: Range lists, zero-length functions, linker gc) 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
2021-09-27 14:00 Tombstone values in debug sections (was: Range lists, zero-length functions, linker gc) Fangrui Song

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=20200609202414.2olgwq2jniweeyr6@google.com \
    --to=maskray@google.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=dblaikie@gmail.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=gdb@sourceware.org \
    --cc=mark@klomp.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).