public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Revert previous change of _Unwind_Find_FDE declaration
@ 2022-03-14 10:36 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-03-14 10:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:525e6b107d24ed4e614605eab885a36c5b44aa0a

commit 525e6b107d24ed4e614605eab885a36c5b44aa0a
Author: Matthew Malcomson <matthew.malcomson@arm.com>
Date:   Mon Mar 7 18:04:46 2022 +0000

    Revert previous change of _Unwind_Find_FDE declaration
    
    We had previously changed the declaration of _Unwind_Find_FDE to take an
    _Unwind_Address rather than a void *.  While this makes it clear that
    the function acts on addresses rather than pointers it also changes a
    relatively widely used function throughout the unwinder.
    
    While the _Unwind_Find_FDE function is not declared by any headers that
    get provided to the user of libgcc, it is still exported in the libgcc
    dynamic library.  Hence this is still an ABI determining function.
    
    We also fix some whitespace changes that have been introduced against
    trunk to make things a little tidier.
    
    N.b. in this patch we do a few superficially useless casts (turn a
    sealed pointer into an address, then cast it to a pointer).  This is
    because the logical meaning of `__builtin_code_address_from_pointer` is
    to return the address from a pointer, and even though the integer value
    is the same it's still nice to maintain that abstraction level.
    It also means that it's clear the value we're providing to
    _Unwind_Find_FDE is not something that can be dereferenced.

Diff:
---
 libgcc/config/aarch64/aarch64-unwind.h | 4 ++--
 libgcc/unwind-dw2-fde-dip.c            | 4 ++--
 libgcc/unwind-dw2-fde.c                | 9 +++++----
 libgcc/unwind-dw2-fde.h                | 2 +-
 libgcc/unwind-dw2.c                    | 8 +++++---
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h
index 0a68ad77e6c..f9c993111ed 100644
--- a/libgcc/config/aarch64/aarch64-unwind.h
+++ b/libgcc/config/aarch64/aarch64-unwind.h
@@ -38,8 +38,8 @@ aarch64_cie_signed_with_b_key (struct _Unwind_Context *context)
   /* MORELLO  Do not want to adjust for the LSB here since context->bases.func
      is initialised using the address read from the FDE, which does not have
      this LSB set.  */
-  const struct dwarf_fde *fde
-    = _Unwind_Find_FDE ((_Unwind_Address)context->bases.func, &context->bases);
+  const struct dwarf_fde *fde = _Unwind_Find_FDE (context->bases.func,
+						  &context->bases);
   if (fde != NULL)
     {
       const struct dwarf_cie *cie = get_cie (fde);
diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
index 9f88267f675..31fb1548005 100644
--- a/libgcc/unwind-dw2-fde-dip.c
+++ b/libgcc/unwind-dw2-fde-dip.c
@@ -90,7 +90,7 @@
 # define __RELOC_POINTER(ptr, base) ((ptr) + (base))
 #endif
 
-static const fde * _Unwind_Find_registered_FDE (_Unwind_Address pc, struct dwarf_eh_bases *bases);
+static const fde * _Unwind_Find_registered_FDE (void *pc, struct dwarf_eh_bases *bases);
 
 #define _Unwind_Find_FDE _Unwind_Find_registered_FDE
 #include "unwind-dw2-fde.c"
@@ -451,7 +451,7 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
 }
 
 const fde *
-_Unwind_Find_FDE (_Unwind_Address pc, struct dwarf_eh_bases *bases)
+_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
 {
   struct unw_eh_callback_data data;
   const fde *ret;
diff --git a/libgcc/unwind-dw2-fde.c b/libgcc/unwind-dw2-fde.c
index b58b381fd1a..a4359b9c82e 100644
--- a/libgcc/unwind-dw2-fde.c
+++ b/libgcc/unwind-dw2-fde.c
@@ -1033,8 +1033,9 @@ search_object (struct object* ob, _Unwind_Address pc)
 }
 
 const fde *
-_Unwind_Find_FDE (_Unwind_Address pc, struct dwarf_eh_bases *bases)
+_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
 {
+  _Unwind_Address pcaddr = (_Unwind_Address) pc;
   struct object *ob;
   const fde *f = NULL;
 
@@ -1058,9 +1059,9 @@ _Unwind_Find_FDE (_Unwind_Address pc, struct dwarf_eh_bases *bases)
      containing the pc.  Note that pc_begin is sorted descending, and
      we expect objects to be non-overlapping.  */
   for (ob = seen_objects; ob; ob = ob->next)
-    if (pc >= (_Unwind_Address)ob->pc_begin)
+    if (pc >= ob->pc_begin)
       {
-	f = search_object (ob, pc);
+	f = search_object (ob, pcaddr);
 	if (f)
 	  goto fini;
 	break;
@@ -1072,7 +1073,7 @@ _Unwind_Find_FDE (_Unwind_Address pc, struct dwarf_eh_bases *bases)
       struct object **p;
 
       unseen_objects = ob->next;
-      f = search_object (ob, pc);
+      f = search_object (ob, pcaddr);
 
       /* Insert the object into the classified list.  */
       for (p = &seen_objects; *p ; p = &(*p)->next)
diff --git a/libgcc/unwind-dw2-fde.h b/libgcc/unwind-dw2-fde.h
index 68b537a51d0..c5fe25fc305 100644
--- a/libgcc/unwind-dw2-fde.h
+++ b/libgcc/unwind-dw2-fde.h
@@ -166,7 +166,7 @@ next_fde (const fde *f)
 typedef unsigned _Unwind_Address __attribute__((__mode__(__address__)));
 typedef unsigned _Unwind_WordAddr __attribute__((__mode__(__unwind_word__)));
 typedef signed _Unwind_SwordAddr __attribute__((__mode__(__unwind_word__)));
-extern const fde * _Unwind_Find_FDE (_Unwind_Address, struct dwarf_eh_bases *);
+extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
 
 static inline int
 last_fde (struct object *obj __attribute__ ((__unused__)), const fde *f)
diff --git a/libgcc/unwind-dw2.c b/libgcc/unwind-dw2.c
index 67057a0a230..c3dfe85275c 100644
--- a/libgcc/unwind-dw2.c
+++ b/libgcc/unwind-dw2.c
@@ -389,7 +389,8 @@ _Unwind_FindEnclosingFunction (void *pc)
 {
   struct dwarf_eh_bases bases;
    _Unwind_Address pcaddr = __builtin_code_address_from_pointer (pc);
-  const struct dwarf_fde *fde = _Unwind_Find_FDE (pcaddr-1, &bases);
+  const struct dwarf_fde *fde
+    = _Unwind_Find_FDE ((void *)(_Unwind_Ptr)(pcaddr-1), &bases);
   if (fde)
     return bases.func;
   else
@@ -1308,8 +1309,9 @@ uw_frame_state_for (struct _Unwind_Context *context, _Unwind_FrameState *fs)
     return _URC_END_OF_STACK;
 
   _Unwind_Address retaddr = __builtin_code_address_from_pointer (context->ra);
-  fde = _Unwind_Find_FDE (retaddr + _Unwind_IsSignalFrame (context) - 1,
-			  &context->bases);
+  void *retptr = (void *)(_Unwind_Ptr)(retaddr
+				       + _Unwind_IsSignalFrame (context) - 1);
+  fde = _Unwind_Find_FDE (retptr, &context->bases);
   if (fde == NULL)
     {
 #ifdef MD_FALLBACK_FRAME_STATE_FOR


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-14 10:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 10:36 [gcc(refs/vendors/ARM/heads/morello)] Revert previous change of _Unwind_Find_FDE declaration Matthew Malcomson

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).