public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/30911] [gdb/symtab] Cannot call ifunc strstr with debuginfo installed
Date: Mon, 16 Oct 2023 14:32:06 +0000	[thread overview]
Message-ID: <bug-30911-4717-atJAPG1GnH@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30911-4717@http.sourceware.org/bugzilla/>

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

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1d45d90934b10862c00a22bcf4075815a785001b

commit 1d45d90934b10862c00a22bcf4075815a785001b
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Oct 16 16:32:28 2023 +0200

    [gdb/symtab] Work around PR gas/29517

    When using glibc debuginfo generated with gas 2.39, we run into PR
gas/29517:
    ...
    $ gdb -q -batch a.out -ex start -ex "p (char *)strstr (\"haha\", \"ah\")"
    Temporary breakpoint 1 at 0x40051b: file hello.c, line 6.

    Temporary breakpoint 1, main () at hello.c:6
    6         printf ("hello\n");
    Invalid cast.
    ...
    while without glibc debuginfo installed we get the expected result:
    ...
    $n = 0x7ffff7daa1b1 "aha"
    ...
    and likewise with glibc debuginfo generated with gas 2.40.

    The strstr ifunc resolves to __strstr_sse2_unaligned.  The problem is that
gas
    generates dwarf that states that the return type is void:
    ...
    <1><3e1e58>: Abbrev Number: 2 (DW_TAG_subprogram)
        <3e1e59>   DW_AT_name        : __strstr_sse2_unaligned
        <3e1e5d>   DW_AT_external    : 1
        <3e1e5e>   DW_AT_low_pc      : 0xbbd2e
        <3e1e66>   DW_AT_high_pc     : 0xbc1c3
    ...
    while the return type should be a DW_TAG_unspecified_type, as is the case
    with gas 2.40.

    We can still use the workaround of casting to another function type for
both
    __strstr_sse2_unaligned:
    ...
    (gdb) p ((char * (*) (const char *, const char *))__strstr_sse2_unaligned)
\
      ("haha", "ah")
    $n = 0x7ffff7daa211 "aha"
    ...
    and strstr (which requires using *strstr to dereference the ifunc before we
    cast):
    ...
    gdb) p ((char * (*) (const char *, const char *))*strstr) ("haha", "ah")
    $n = 0x7ffff7daa251 "aha"
    ...
    but that's a bit cumbersome to use.

    Work around this in the dwarf reader, such that we have instead:
    ...
    (gdb) p (char *)strstr ("haha", "ah")
    $n = 0x7ffff7daa1b1 "aha"
    ...

    This also requires fixing producer_is_gcc to stop returning true for
    producer "GNU AS 2.39.0".

    Tested on x86_64-linux.

    Approved-By: Andrew Burgess <aburgess@redhat.com>

    PR symtab/30911
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30911

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

  parent reply	other threads:[~2023-10-16 14:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] " vries at gcc dot gnu.org
2023-09-28 10:49 ` [Bug exp/30911] " vries at gcc dot gnu.org
2023-09-28 10:50 ` sam at gentoo dot org
2023-09-28 11:24 ` vries at gcc dot gnu.org
2023-09-28 11:54 ` vries at gcc dot gnu.org
2023-09-28 13:09 ` [Bug symtab/30911] " vries at gcc dot gnu.org
2023-09-28 16:08 ` vries at gcc dot gnu.org
2023-09-30  8:37 ` [Bug symtab/30911] [gdb/symtab] " vries at gcc dot gnu.org
2023-10-16 14:32 ` cvs-commit at gcc dot gnu.org [this message]
2023-10-16 14:33 ` 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-30911-4717-atJAPG1GnH@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).