public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>,
	Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/5] Change linetables to be objfile-independent
Date: Thu, 16 Mar 2023 10:45:21 -0400	[thread overview]
Message-ID: <7ef34f41-d90a-8173-b0b8-08a19b0b4484@simark.ca> (raw)
In-Reply-To: <87y1nwiyk2.fsf@tromey.com>

On 3/16/23 10:02, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> Looks like we're trying to read from the inferior at an unrelocated
> Simon> address.  From some previous bug, I recall that you were using a system
> Simon> with no-PIE as a default, so that could be why you don't see it.
> 
> I tried building this executable with -fPIE and it still seems to work
> for me :(

Ok, I'll look into it then.

I can reproduce it like hand like this:

    $ gcc -fno-stack-protector -c \
        -o /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/disasm-optim/disasm-optim0.o \
        /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/disasm-optim.S \
        -fPIE
    $ gcc /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/disasm-optim/disasm-optim0.o \
        -pie -o disasm-optim

    $ gdb ./gdb -nx -q --data-directory=data-directory disasm-optim
    Reading symbols from disasm-optim...
    (gdb) start

    This GDB supports auto-downloading debuginfo from the following URLs:
      <https://debuginfod.archlinux.org>
    Enable debuginfod for this session? (y or [n]) n
    Debuginfod has been disabled.
    To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
    Temporary breakpoint 1 at 0x1120: file disasm-optim.c, line 25.
    Starting program: /home/smarchi/build/binutils-gdb/gdb/disasm-optim
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".

    Temporary breakpoint 1, main () at disasm-optim.c:25
    25      disasm-optim.c: No such file or directory.
    (gdb) disassemble main
    Dump of assembler code for function main:
    => 0x0000555555555120 <+0>:     mov    0x2ef2(%rip),%eax        # 0x555555558018 <y>
       0x0000555555555126 <+6>:     test   %eax,%eax
       0x0000555555555128 <+8>:     js     0x555555555140 <main+32>
       0x000055555555512a <+10>:    lea    0xa(%rax),%edx
       0x000055555555512d <+13>:    test   %eax,%eax
       0x000055555555512f <+15>:    mov    $0x1,%eax
       0x0000555555555134 <+20>:    cmovne %edx,%eax
       0x0000555555555137 <+23>:    mov    %eax,0x2ed7(%rip)        # 0x555555558014 <x>
       0x000055555555513d <+29>:    xor    %eax,%eax
       0x000055555555513f <+31>:    ret
       0x0000555555555140 <+32>:    add    %eax,%eax
       0x0000555555555142 <+34>:    jmp    0x555555555137 <main+23>
    End of assembler dump.
    (gdb) disassemble /s main
    Dump of assembler code for function main:
    Cannot access memory at address 0x1120

If I link with -no-pie, then it works.

Simon

  reply	other threads:[~2023-03-16 14:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 15:42 [PATCH 0/5] Make line tables independent of objfile Tom Tromey
2023-03-08 15:42 ` [PATCH 1/5] Add operator< and operator== to linetable_entry Tom Tromey
2023-03-11  3:21   ` Simon Marchi
2023-03-08 15:42 ` [PATCH 2/5] Change linetables to be objfile-independent Tom Tromey
2023-03-11  3:48   ` Simon Marchi
2023-03-11 15:36     ` Tom Tromey
2023-03-11 19:13       ` Simon Marchi
2023-03-12  3:24         ` Tom Tromey
2023-03-12 13:40           ` Simon Marchi
2023-03-16 14:02             ` Tom Tromey
2023-03-16 14:45               ` Simon Marchi [this message]
2023-03-16 23:43                 ` Tom Tromey
2023-03-17  2:45                   ` Simon Marchi
2023-03-17 13:09                     ` Tom Tromey
2023-03-17 22:21                       ` Tom Tromey
2023-03-20 14:57                         ` Simon Marchi
2023-03-08 15:42 ` [PATCH 3/5] Constify linetables Tom Tromey
2023-03-08 15:42 ` [PATCH 4/5] Remove extra scopes from objfile_relocate1 Tom Tromey
2023-03-08 15:42 ` [PATCH 5/5] Change linetable_entry::is_stmt to bool Tom Tromey
2023-03-11  3:51 ` [PATCH 0/5] Make line tables independent of objfile Simon Marchi

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=7ef34f41-d90a-8173-b0b8-08a19b0b4484@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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).