diff mbox series

libgcc: Fix eh_frame fast path in find_fde_tail

Message ID 871qioapgh.fsf@oldenburg3.str.redhat.com
State New
Headers show
Series libgcc: Fix eh_frame fast path in find_fde_tail | expand

Commit Message

Florian Weimer June 6, 2023, 9:51 a.m. UTC
The eh_frame value is only used by linear_search_fdes, not the binary
search directly in find_fde_tail, so the bug is not immediately
apparent with most programs.

Fixes commit e724b0480bfa5ec04f39be8c7290330b495c59de ("libgcc:
Special-case BFD ld unwind table encodings in find_fde_tail").

[I'd appreciate suggestions how I could add a test for this.  BFD ld
does not seem to allow ommitting the binary search table.]

libgcc/

	PR libgcc/109712
	* unwind-dw2-fde-dip.c (find_fde_tail): Correct fast path for
	parsing eh_frame.

---
 libgcc/unwind-dw2-fde-dip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: b327cbe8f4eefc91ee2bea49a1da7128adf30281

Comments

Richard Biener June 7, 2023, 2:20 p.m. UTC | #1
On Tue, Jun 6, 2023 at 11:53 AM Florian Weimer via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> The eh_frame value is only used by linear_search_fdes, not the binary
> search directly in find_fde_tail, so the bug is not immediately
> apparent with most programs.
>
> Fixes commit e724b0480bfa5ec04f39be8c7290330b495c59de ("libgcc:
> Special-case BFD ld unwind table encodings in find_fde_tail").

OK.

> [I'd appreciate suggestions how I could add a test for this.  BFD ld
> does not seem to allow ommitting the binary search table.]
>
> libgcc/
>
>         PR libgcc/109712
>         * unwind-dw2-fde-dip.c (find_fde_tail): Correct fast path for
>         parsing eh_frame.
>
> ---
>  libgcc/unwind-dw2-fde-dip.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
> index 6223f5f18a2..4e0b880513f 100644
> --- a/libgcc/unwind-dw2-fde-dip.c
> +++ b/libgcc/unwind-dw2-fde-dip.c
> @@ -403,8 +403,8 @@ find_fde_tail (_Unwind_Ptr pc,
>          BFD ld generates.  */
>        signed value __attribute__ ((mode (SI)));
>        memcpy (&value, p, sizeof (value));
> +      eh_frame = p + value;
>        p += sizeof (value);
> -      dbase = value;           /* No adjustment because pcrel has base 0.  */
>      }
>    else
>      p = read_encoded_value_with_base (hdr->eh_frame_ptr_enc,
>
> base-commit: b327cbe8f4eefc91ee2bea49a1da7128adf30281
>
diff mbox series

Patch

diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
index 6223f5f18a2..4e0b880513f 100644
--- a/libgcc/unwind-dw2-fde-dip.c
+++ b/libgcc/unwind-dw2-fde-dip.c
@@ -403,8 +403,8 @@  find_fde_tail (_Unwind_Ptr pc,
 	 BFD ld generates.  */
       signed value __attribute__ ((mode (SI)));
       memcpy (&value, p, sizeof (value));
+      eh_frame = p + value;
       p += sizeof (value);
-      dbase = value;		/* No adjustment because pcrel has base 0.  */
     }
   else
     p = read_encoded_value_with_base (hdr->eh_frame_ptr_enc,