public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug mi/26935] New: [gdb/testsuite] Using gold in gdb.base/morestack.exp causes incorrect debug info
Date: Tue, 24 Nov 2020 01:07:20 +0000	[thread overview]
Message-ID: <bug-26935-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 26935
           Summary: [gdb/testsuite] Using gold in gdb.base/morestack.exp
                    causes incorrect debug info
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mi
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider test-case morestack.exp, compiled with target board
unix/-m32/-fPIE/-pie.

When running the test-case, it passes, but there are warnings, as mentioned in
PR26933.

The executable debug info contains the following info:
...
CU: ../../../../libgcc/config/i386/morestack.S:
File name    Line number       Starting address    View    Stmt
morestack.S  109               0xd0c               x
morestack.S  113               0xd0d               x
  ...
morestack.S  830               0xe66               x
morestack.S  831               0xe6a               x
morestack.S  832               0xe6e               x
morestack.S  838               0xe73               x
morestack.S  -                 0xe74               x

morestack.S  636                   0               x
morestack.S  637                 0x3               x
morestack.S  -                   0x4               x
...

Note that at 0xdc, we find:
...
00000d0c <__morestack_non_split>:
     d0c:       50                      push   %eax
...
but at address 0, there's no text section.

Looking at morestack.o, we see two relocations for .debug_line:
...
Relocation section '.rel.debug_line' at offset 0x8f4 contains 2 entries:
 Offset     Info    Type                Sym. Value  Symbol's Name
0000004e  00000101 R_386_32               00000000   .text
000000de  00000501 R_386_32               00000000  
.text.__x86.get_pc_thunk.bx
...

The first one to be applied here:
...
 Line Number Statements:
  [0x0000004b]  Extended opcode 2: set Address to 0x0
...
referring to:
...
Disassembly of section .text:

00000000 <__morestack_non_split>:
...

And the second one to be applied here:
...
  [0x000000db]  Extended opcode 2: set Address to 0x0
...
referring to:
...
Disassembly of section .text.__x86.get_pc_thunk.bx:

00000000 <__x86.get_pc_thunk.bx>:
...

In the executable we have correctly applied the first:
...
 Line Number Statements:
  [0x0000013b]  Extended opcode 2: set Address to 0xd0c
...
but not the second, it's still stuck at address 0:
...
  [0x000001ca]  Extended opcode 2: set Address to 0x0
...

The executable is build with gold.  If we use ld.bfd instead (and remove the
printf, which requires gold, from the test-case), the test-case also passes and
the warnings are gone.

However, the debug info problem described above is still there with ld.bfd.

With ld.bfd though, we have correct ranges:
...
    00000028 ffffffff 00000000 (base address)
    00000028 00000c9c 00000e04
    00000028 000009a0 000009a4
    00000028 <End of list>
...
while with gold we have the incorrect:
...
    00000028 ffffffff 00000000 (base address)
    00000028 00000d0c 00000e74
    00000028 00000000 00000004
    00000028 <End of list>
...
Likewise for .debug_aranges.

This is probably the cause for difference in behaviour between using ld.gold vs
ld.bfd.

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

             reply	other threads:[~2020-11-24  1:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24  1:07 vries at gcc dot gnu.org [this message]
2020-11-24  9:57 ` [Bug mi/26935] " vries at gcc dot gnu.org
2020-11-24 10:36 ` vries at gcc dot gnu.org
2020-11-24 12:32 ` vries at gcc dot gnu.org
2020-11-24 13:36 ` vries at gcc dot gnu.org
2021-01-04 14:01 ` [Bug win32/26935] " vries at gcc dot gnu.org
2021-01-04 14:02 ` vries at gcc dot gnu.org
2021-01-07  8:42 ` [Bug external/26935] " vries at gcc dot gnu.org

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=bug-26935-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).