From: Muhammad Kamran <muhammad.kamran@arm.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: gdb-patches@sourceware.org, Andrew Burgess <aburgess@redhat.com>,
Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
Yury Khrustalev <Yury.Khrustalev@arm.com>,
Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
Carlos O'Donell <carlos@redhat.com>
Subject: Re: [PATCH v2 1/1] gdb: Preserve IFUNC marker when finding inferior functions
Date: Tue, 30 Jun 2026 15:15:06 +0100 [thread overview]
Message-ID: <549b8d25-1102-42bc-96d0-24ac30060ea0@arm.com> (raw)
In-Reply-To: <lhuh5ml6oic.fsf@oldenburg.str.redhat.com>
Hi Florian,
>> GDB calls find_function_in_inferior ("malloc") when expression
>> evaluation needs to allocate memory in the inferior, e.g. for string
>> literal arguments.
>
> So this looks fairly nasty. This looks fairly harmless as far as GDB
> expressions go:
>
>> + gdb_test "print (get_string (\"hello-ifunc\"), str_in_arena ())" \
>
> We can actually detect the GDB call and glibc and do the right thing:
>
> [PATCH 0/2] Work around GDB bug overwriting __libc_malloc
> <https://inbox.sourceware.org/libc-alpha/cover.1782766548.git.fweimer@redhat.com/>
>
> Of course the GDB bug still needs fixing.
>
> By the way, I don't think there is a safe way for GDB to call IFUNC
> resolvers. IFUNC resolvers in glibc may assume the presence of extra
> data that was not there in the initial definition of the interface.
> This shouldn't matter for malloc: elf_gnu_ifunc_resolve_by_got should
> always be able obtain the pre-relocated address (except before
> relocation has happened).
Yes. GDB should prefer the cache/GOT path and avoid resolver calls
where possible. The patch does not make resolver calls safer or add a
new resolver-calling mechanism; it just preserves the IFUNC marker so
the existing IFUNC resolution path is used instead of calling the
resolver address as though it were malloc itself.
>
> Does your patch change the behavior and output of this?
>
> (gdb) print strcpy
> $1 = {<text gnu-indirect-function variable, no debug info>} 0x7ffff7e0b8f0 <strcpy_ifunc>
>
> Currently, the workaround looks like this:
>
> (gdb) print dlsym(0, "strcpy")
> $2 = (void *) 0x7ffff7ecb970 <__strcpy_avx2>
>
No. `print strcpy` uses the normal minimal-symbol evaluation path,
which already classifies GNU IFUNC symbols. The patch only changes
find_function_in_inferior's internal fallback path.
I verified this on x86-64 with the patch applied and the output
remains unchanged.
Thanks,
Kamran
> Maybe going through dlsym would also be the right way to do the inferior
> calls involving IFUNC resolvers. We can also provide a symbol that GDB
> can call to make the IFUNC resolver call, given its handler address.
>
> Thanks,
> Florian
>
next prev parent reply other threads:[~2026-06-30 14:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 15:20 [PATCH v2 0/1] " Muhammad Kamran
2026-06-25 15:20 ` [PATCH v2 1/1] " Muhammad Kamran
2026-06-25 20:05 ` Simon Marchi
2026-06-26 9:24 ` Muhammad Kamran
2026-06-26 14:20 ` Simon Marchi
2026-06-29 15:43 ` Muhammad Kamran
2026-06-29 21:11 ` Florian Weimer
2026-06-30 9:13 ` Yury Khrustalev
2026-06-30 9:18 ` Yury Khrustalev
2026-06-30 9:42 ` Wilco Dijkstra
2026-06-30 11:53 ` Florian Weimer
2026-07-21 17:10 ` Tom Tromey
2026-07-21 19:45 ` Florian Weimer
2026-07-22 13:36 ` Tom Tromey
2026-06-30 14:15 ` Muhammad Kamran [this message]
2026-06-30 15:29 ` Wilco Dijkstra
2026-07-03 12:56 ` Simon Marchi
2026-07-07 12:15 ` Muhammad Kamran
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=549b8d25-1102-42bc-96d0-24ac30060ea0@arm.com \
--to=muhammad.kamran@arm.com \
--cc=Wilco.Dijkstra@arm.com \
--cc=Yury.Khrustalev@arm.com \
--cc=aburgess@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=carlos@redhat.com \
--cc=fweimer@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=thiago.bauermann@linaro.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