Re: [PATCH v5 0/2] gdb: Fix internal inferior calls through GNU IFUNCs

Kevin Buettner <[email protected]>
Newsgroups gmane.comp.gdb.patches
Organization Red Hat
Message-ID <20260816002317.2a44f116@f44-mesa-1>
On Tue, 11 Aug 2026 13:12:17 +0000
Muhammad Kamran <[email protected]> wrote:

> This series fixes a GDB inferior-call issue exposed by malloc being a GNU
> IFUNC in glibc on AArch64.  The underlying problem is not AArch64-specific:
> it can affect any inferior helper found through find_function_in_inferior's
> minimal-symbol fallback when that helper is a GNU IFUNC.
> 
> GDB calls find_function_in_inferior ("malloc") when expression evaluation
> needs to allocate memory in the inferior, for example for string literal
> arguments.  In the minimal-symbol fallback, GDB created a synthetic ordinary
> function pointer from the minimal symbol address.  If the symbol was a GNU
> IFUNC, this lost the IFUNC marker, so call_function_by_hand did not resolve
> the symbol before calling it.
> 
> Patch 1 checks the minimal symbol kind directly and propagates the GNU IFUNC
> marker to the synthetic function type for mst_text_gnu_ifunc and
> mst_data_gnu_ifunc symbols.  The existing fallback address and return type
> are unchanged.
> 
> Patch 2 fixes the follow-on return-type issue after IFUNC resolution.  When
> the resolved target type, or the type inferred from the resolver return type,
> does not provide a usable return type, find_function_addr now keeps the
> original function type's return type.  This preserves the synthetic fallback
> return type used by find_function_in_inferior ("malloc").
> 
> The tests add an internal inferior-call case using an IFUNC malloc and run it
> through the existing gdb.base/gnu-ifunc.exp matrix for resolver attr,
> resolver debug info, and resolved-target debug info.
> 
> Changes since v4:
> 	* Address feedback from Andrew Burgess <[email protected]>.
> 
> Changes since v3:
> 	* Move the ifunc resolver into a shared library.
> 
> Changes since v2:
> 	* Rework the minimal-symbol fallback to check the minimal symbol kind
> 	  directly as suggested by Simon.
> 	* Add coverage for both debug and no-debug IFUNC malloc variants by
> 	  using the existing framework.
> 	* Preserve the original IFUNC return type when the resolved target type
> 	  is unknown.

Andrew gave conditional approval for both parts in his v4 replies. 
I've looked over this v5 series; IMO, you've completely addressed his
concerns.  Therefore, I think you can consider this version approved;
but do add Andrew's Approved-By tag.  If you need a maintainer to push
it for you, I'll be happy to do that.

Reviewed-By: Kevin Buettner <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.