Question about alignment of struct _Unwind_Exception

Florian Weimer fweimer@redhat.com
Tue Nov 10 18:13:21 GMT 2020


* Matheus Castanho via Libc-alpha:

> diff --git a/sysdeps/generic/unwind.h b/sysdeps/generic/unwind.h
> index b667a5b652..da1b5e6ca7 100644
> --- a/sysdeps/generic/unwind.h
> +++ b/sysdeps/generic/unwind.h
> @@ -27,6 +27,8 @@
>  extern "C" {
>  #endif
>  
> +#include <unwind-arch.h>
> +
>  /* Level 1: Base ABI  */
>  
>  /* @@@ The IA-64 ABI uses uint64 throughout.  Most places this is
> @@ -83,7 +85,7 @@ struct _Unwind_Exception
>    /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
>       Taking that literally does not make much sense generically.  Instead we
>       provide the maximum alignment required by any type for the machine.  */
> -} __attribute__((__aligned__));
> +} __attribute__((__aligned__(UNWIND_EXCEPTION_ALIGN)));

Can you use an anonymous union to do just what the comment says,
something like this (untested)?

struct _Unwind_Exception
{
  union
  {
    struct
    {
      _Unwind_Exception_Class exception_class;
      _Unwind_Exception_Cleanup_Fn exception_cleanup;
      _Unwind_Word private_1;
      _Unwind_Word private_2;
    };

   /* The IA-64 ABI says that this structure must be double-word
      aligned.  */
   _Unwind_Word unwind_exception_align[2]
     __attributed__ ((aligned (2 * sizeof (_Unwind_Word))));
  };
};

The union ensures that the aligned attribute does not reduce alignment
for the entire struct.

As discussed, it's an internal ABI change on most targets, but that
should be okay.  The dependency on BIGGEST_ALIGNMENT is gone.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill



More information about the Libc-alpha mailing list