This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix mcontext_t sigcontext namespace (bug 21457)


On 20/06/17 18:53, Joseph Myers wrote:
> This patch continues the ucontext.h namespace fixes by fixing issues
> related to the use of struct sigcontext as mcontext_t, and inclusion
> of <bits/sigcontext.h> even when struct sigcontext is not so used.
> 
> Inclusion of <bits/sigcontext.h> by <sys/ucontext.h> is removed; the
> way to get the sigcontext structure is by including <signal.h> (in a
> context where __USE_MISC is defined); the sysdeps/generic version of
> sys/ucontext.h keeps the inclusion by necessity, with a comment about
> how this is not namespace-clean, but the only configuration that used
> it, MicroBlaze, gets its own version of the header in this patch.
> Where mcontext_t was typedefed to struct sigcontext, the contents of
> struct sigcontext are inserted (with appropriate namespace handling to
> prefix fields with __ when __USE_MISC is not defined); review should
> check that this has been done correctly in each case, whether the
> definition of struct sigcontext comes from glibc headers or from the
> Linux kernel.  This changes C++ name mangling on affected
> architectures (which do not include x86_64/x86).
> 

i think glibc c++ abi stability is more important in
practice than posix namespace rules.

> diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h b/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
> index 4f602fc..90d0c42 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
> +++ b/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
> @@ -24,10 +24,15 @@
>  #include <features.h>
>  
>  #include <bits/types/sigset_t.h>
> -#include <bits/sigcontext.h>

this may break software that rely on declarations from
asm/sigcontext.h to be visible in sys/ucontext.h (e.g.
struct fpsimd_context ?), but i don't know if this is
actually the case.

>  #include <bits/types/stack_t.h>
>  
>  #ifdef __USE_MISC
> +# define __ctx(fld) fld
> +#else
> +# define __ctx(fld) __ ## fld
> +#endif
> +
> +#ifdef __USE_MISC
>  # include <sys/procfs.h>
>  
>  
> @@ -44,7 +49,15 @@ typedef elf_fpregset_t	fpregset_t;
>     the core registers; coprocessor registers get saved elsewhere
>     (e.g. in uc_regspace, or somewhere unspecified on the stack
>     during non-RT signal handlers).  */
> -typedef struct sigcontext mcontext_t;
> +typedef struct
> +  {
> +    unsigned long long int __ctx(fault_address);
> +    unsigned long long int __ctx(regs)[31];
> +    unsigned long long int __ctx(sp);
> +    unsigned long long int __ctx(pc);
> +    unsigned long long int __ctx(pstate);
> +    unsigned char __glibc_reserved1[4096] __attribute__ ((__aligned__ (16)));
> +  } mcontext_t;
>  

i find the c++ abi break problematic.

i would not expect mcontext_t to be common argument
in c++ code, but it's a moderately dangerous change,
while the status quo is not too bad.

>  /* Userlevel context.  */
>  typedef struct ucontext_t
> @@ -56,4 +69,6 @@ typedef struct ucontext_t
>      mcontext_t uc_mcontext;
>    } ucontext_t;
>  
> +#undef __ctx
> +
>  #endif /* sys/ucontext.h */
> diff --git a/sysdeps/unix/sysv/linux/aarch64/ucontext_i.sym b/sysdeps/unix/sysv/linux/aarch64/ucontext_i.sym
> index ab3930c..479bdda 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/ucontext_i.sym
> +++ b/sysdeps/unix/sysv/linux/aarch64/ucontext_i.sym
> @@ -38,7 +38,7 @@ oX0				mcontext (regs)
>  oSP				mcontext (sp)
>  oPC				mcontext (pc)
>  oPSTATE				mcontext (pstate)
> -oEXTENSION                      mcontext (__reserved)
> +oEXTENSION                      mcontext (__glibc_reserved1)
>  
>  #define fpsimd_context(member)  offsetof (struct fpsimd_context, member)
>  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]