public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects
@ 2021-02-08 10:45 mliska at suse dot cz
  2021-02-08 10:47 ` [Bug general/27367] " mliska at suse dot cz
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mliska at suse dot cz @ 2021-02-08 10:45 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

            Bug ID: 27367
           Summary: readelf: invalid loclists data with -ffat-lto-objects
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: general
          Assignee: unassigned at sourceware dot org
          Reporter: mliska at suse dot cz
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Using the GCC 11 (master) I see the following issue:

$ cat size.i
int main_argc_remaining;

int main_argc() {
  int result = 0;
  if (main_argc_remaining)
    result = 0;

  return 0;
}

$ gcc -c -flto -O size.i -g -ffat-lto-objects &&
/home/marxin/Programming/elfutils/src/readelf -aw size.o
...
DWARF section [27] '.debug_loclists' at offset 0x747:
Table at Offset 0x0:

 Length:               24
 DWARF version:         5
 Address size:          8
 Segment size:          0
 Offset entries:        0
 Not associated with a CU.

  Offset: c, Index: 0
    startx_endx 3, 8
      ???..
      ???
        (empty)
    end_of_list

  Offset: 18, Index: c
    startx_endx 30, 1f
      ???..
      ???
/home/marxin/Programming/elfutils/src/readelf: invalid loclists data

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
@ 2021-02-08 10:47 ` mliska at suse dot cz
  2021-02-08 11:09 ` mliska at suse dot cz
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mliska at suse dot cz @ 2021-02-08 10:47 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

--- Comment #1 from Martin Liska <mliska at suse dot cz> ---
Happens for version 0.182.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
  2021-02-08 10:47 ` [Bug general/27367] " mliska at suse dot cz
@ 2021-02-08 11:09 ` mliska at suse dot cz
  2021-02-08 11:10 ` mliska at suse dot cz
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mliska at suse dot cz @ 2021-02-08 11:09 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

Martin Liska <mliska at suse dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Martin Liska <mliska at suse dot cz> ---
And it's fixed on master.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
  2021-02-08 10:47 ` [Bug general/27367] " mliska at suse dot cz
  2021-02-08 11:09 ` mliska at suse dot cz
@ 2021-02-08 11:10 ` mliska at suse dot cz
  2021-02-08 11:14 ` mark at klomp dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mliska at suse dot cz @ 2021-02-08 11:10 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

Martin Liska <mliska at suse dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |---
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #3 from Martin Liska <mliska at suse dot cz> ---
(In reply to Martin Liska from comment #2)
> And it's fixed on master.

I take this back (I used a bad GCC compiler). So it's present even for elfutils
master.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
                   ` (2 preceding siblings ...)
  2021-02-08 11:10 ` mliska at suse dot cz
@ 2021-02-08 11:14 ` mark at klomp dot org
  2021-11-04 11:14 ` ldv at sourceware dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mark at klomp dot org @ 2021-02-08 11:14 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-02-08
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mark at klomp dot org

--- Comment #4 from Mark Wielaard <mark at klomp dot org> ---
Same for git HEAD/0.183

Without -flto and -ffat-lto-objects this looks like:

DWARF section [ 7] '.debug_loclists' at offset 0xff:
Table at Offset 0x0:

 Length:               24
 DWARF version:         5
 Address size:          8
 Segment size:          0
 Offset entries:        0
 CU [     c] base: .text+000000000000000000 <main_argc>

  Offset: c, Index: 0
    view pair 2, 3

  Offset: e, Index: 2
    start_length 0x0, 0
      .text+000000000000000000 <main_argc>..
      0xffffffffffffffff
        [ 0] lit0
        [ 1] stack_value
    end_of_list

Note that it starts with a view pair, and in the non-lto variant eu-readelf
does know which CU this is associated with, while in the lto variant it says
"Not associated with a CU."

The issue seems to be that eu-readelf seeing both .debug_info and
.gnu.debuglto_.debug_info (you get both when using -ffat-lto-objects) picks the
.gnu.debuglto_.debug_info and drops/skips the .debug_info.

The following "fixes" it:

diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 757ac4fa..49ec0f22 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -137,10 +137,10 @@ check_section (Dwarf *result, size_t shstrndx, Elf_Scn
*scn, bool inscngrp)
          gnu_compressed = true;
          break;
        }
-      else if (scnlen > 14 /* .gnu.debuglto_ prefix. */
-              && strncmp (scnname, ".gnu.debuglto_", 14) == 0
-              && strcmp (&scnname[14], dwarf_scnnames[cnt]) == 0)
-       break;
+//      else if (scnlen > 14 /* .gnu.debuglto_ prefix. */
+//            && strncmp (scnname, ".gnu.debuglto_", 14) == 0
+//            && strcmp (&scnname[14], dwarf_scnnames[cnt]) == 0)
+//     break;
     }

   if (cnt >= ndwarf_scnnames)

But of course that breaks showing .gnu.debuglto_ sections...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
                   ` (3 preceding siblings ...)
  2021-02-08 11:14 ` mark at klomp dot org
@ 2021-11-04 11:14 ` ldv at sourceware dot org
  2021-11-04 11:32 ` mark at klomp dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ldv at sourceware dot org @ 2021-11-04 11:14 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

--- Comment #5 from Dmitry V. Levin <ldv at sourceware dot org> ---
Could we have this issue fixed, please?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
                   ` (4 preceding siblings ...)
  2021-11-04 11:14 ` ldv at sourceware dot org
@ 2021-11-04 11:32 ` mark at klomp dot org
  2021-11-08  8:48 ` mark at klomp dot org
  2021-11-09 18:17 ` mark at klomp dot org
  7 siblings, 0 replies; 9+ messages in thread
From: mark at klomp dot org @ 2021-11-04 11:32 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

--- Comment #6 from Mark Wielaard <mark at klomp dot org> ---
The problem with fixing this in general is that an ELF file can contain
different sets of .debug sections that form a consistent DWARF. This can be the
.debug_* sections, the .debug_* sections in a particular comdat group (you can
get those using the inscngrp bool), the set of .debug_*_dwo sections (for split
dwarf).

A generic solution would introduce some selector method to create a Dwarf for
just one specific group of sections. I don't yet know how that would look like.
And it would require callers to be explicit about which one they want.

A workaround for now might be to create an ordering and pick just one set, so
no cross/incompatible sets of sections is selected to form one Dwarf.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
                   ` (5 preceding siblings ...)
  2021-11-04 11:32 ` mark at klomp dot org
@ 2021-11-08  8:48 ` mark at klomp dot org
  2021-11-09 18:17 ` mark at klomp dot org
  7 siblings, 0 replies; 9+ messages in thread
From: mark at klomp dot org @ 2021-11-08  8:48 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |mark at klomp dot org
             Status|NEW                         |ASSIGNED

--- Comment #7 from Mark Wielaard <mark at klomp dot org> ---
Proposed patch posted:
https://sourceware.org/pipermail/elfutils-devel/2021q4/004314.html

Also on https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=fat-lto

But I am slightly hesitant to commit it just before a release.
Also there should probably be an interface to select the type (plain, lto, dwo)
of Dwarf object you want instead of libdw just selecting "the best" one.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug general/27367] readelf: invalid loclists data with -ffat-lto-objects
  2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
                   ` (6 preceding siblings ...)
  2021-11-08  8:48 ` mark at klomp dot org
@ 2021-11-09 18:17 ` mark at klomp dot org
  7 siblings, 0 replies; 9+ messages in thread
From: mark at klomp dot org @ 2021-11-09 18:17 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=27367

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Mark Wielaard <mark at klomp dot org> ---
commit 5b21e70216b853065fa2fef34273db5f7dcdc88b
Author: Mark Wielaard <mark@klomp.org>
Date:   Mon Nov 8 09:27:51 2021 +0100

    libdw: dwarf_elf_begin should use either plain, dwo or lto DWARF sections.

    When opening an ELF file that contained a mix of plain, dwo or lto .debug
    sections the result could be confusing. Add a check to pick just the plain
    .debug sections, or the .dwo sections or the .gnu.debuglto_.debug sections
    (in that order of preference). That way there is always a consistent set.

    https://sourceware.org/bugzilla/show_bug.cgi?id=27367

    Signed-off-by: Mark Wielaard <mark@klomp.org>

Opened a new bug for having a new interface to open any (plain, dwo, lto)
subset if multiple are found in the same file:
https://sourceware.org/bugzilla/show_bug.cgi?id=28573

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-09 18:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 10:45 [Bug general/27367] New: readelf: invalid loclists data with -ffat-lto-objects mliska at suse dot cz
2021-02-08 10:47 ` [Bug general/27367] " mliska at suse dot cz
2021-02-08 11:09 ` mliska at suse dot cz
2021-02-08 11:10 ` mliska at suse dot cz
2021-02-08 11:14 ` mark at klomp dot org
2021-11-04 11:14 ` ldv at sourceware dot org
2021-11-04 11:32 ` mark at klomp dot org
2021-11-08  8:48 ` mark at klomp dot org
2021-11-09 18:17 ` mark at klomp dot org

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).