unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek via Libc-alpha <libc-alpha@sourceware.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, gcc-patches@gcc.gnu.org,
	Jason Merrill <jason@redhat.com>
Subject: Re: [PATCH 3/4] libgcc: Split FDE search code from PT_GNU_EH_FRAME lookup
Date: Thu, 18 Nov 2021 16:21:17 +0100	[thread overview]
Message-ID: <20211118152117.GE2646553@tucnak> (raw)
In-Reply-To: <53daedec153e3bf9b1a9c14f61cfe23385de80c9.1635955148.git.fweimer@redhat.com>

On Wed, Nov 03, 2021 at 05:28:48PM +0100, Florian Weimer wrote:
> @@ -383,12 +376,34 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
>  # endif
>  #endif
>  
> -  _Unwind_Ptr dbase = unw_eh_callback_data_dbase (data);
> +  return 1;
> +}
> +
> +/* Result type of find_fde_tail below.  */
> +struct find_fde_tail_result
> +{
> +  const fde *entry;
> +  void *func;
> +};
> +
> +/* Find the FDE for the program counter PC, in a previously located
> +   PT_GNU_EH_FRAME data region.  */
> +static struct find_fde_tail_result
> +find_fde_tail (_Unwind_Ptr pc,
> +	       const struct unw_eh_frame_hdr *hdr,
> +	       _Unwind_Ptr dbase)

I think returning a struct like find_fde_tail_result can work nicely
on certain targets, but on many others the psABI forces such returns through
stack etc.
Wouldn't it be better to return const fde * instead of
struct find_fde_tail_result, pass in struct dwarf_eh_bases *bases
as another argument to find_fde_tail, just return NULL on the failure
cases and return some fde pointer and set bases->func on success?

> +{
> +  const unsigned char *p = (const unsigned char *) (hdr + 1);
> +  _Unwind_Ptr eh_frame;
> +  struct object ob;
> +
> +  if (hdr->version != 1)
> +    return (struct find_fde_tail_result) { NULL, };

If really returning a struct, I would have preferred { NULL, NULL }
in these cases, but see above.

> +	  if (pc < table[mid].initial_loc + data_base + range)
> +	    return (struct find_fde_tail_result) { f, func };
> +	  else
> +	    return (struct find_fde_tail_result) { NULL, func };

This case was returning NULL fde and non-NULL func?  What it would be good
for, the caller just throws that away.

Otherwise LGTM.

	Jakub


  reply	other threads:[~2021-11-18 15:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 16:28 [PATCH 0/4] Use _dl_find_eh_frame to locate DWARF EH data in the unwinder Florian Weimer via Libc-alpha
2021-11-03 16:28 ` [PATCH 1/4] libgcc: Remove tbase member from struct unw_eh_callback_data Florian Weimer via Libc-alpha
2021-11-18 13:47   ` Jakub Jelinek via Libc-alpha
2021-11-03 16:28 ` [PATCH 2/4] libgcc: Remove dbase member from struct unw_eh_callback_data if NULL Florian Weimer via Libc-alpha
2021-11-18 14:33   ` Jakub Jelinek via Libc-alpha
2021-11-03 16:28 ` [PATCH 3/4] libgcc: Split FDE search code from PT_GNU_EH_FRAME lookup Florian Weimer via Libc-alpha
2021-11-18 15:21   ` Jakub Jelinek via Libc-alpha [this message]
2021-11-23 17:56     ` Florian Weimer via Libc-alpha
2021-11-25 17:16       ` Jakub Jelinek via Libc-alpha
2021-11-03 16:28 ` [PATCH 4/4] libgcc: Use _dl_find_eh_frame in _Unwind_Find_FDE Florian Weimer via Libc-alpha
2021-11-18 15:45   ` Jakub Jelinek via Libc-alpha
2021-11-25 20:42     ` Florian Weimer via Libc-alpha
2021-11-26 15:49       ` Jakub Jelinek via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211118152117.GE2646553@tucnak \
    --to=libc-alpha@sourceware.org \
    --cc=fweimer@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.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).