[RFC PATCH 02/10] C-SKY: TLS support
Mao Han
han_mao@c-sky.com
Tue Mar 20 04:57:00 GMT 2018
On Fri, Mar 16, 2018 at 08:09:10AM -0600, Carlos O'Donell wrote:
> On 03/16/2018 03:58 AM, Mao Han wrote:
> > This patch implements TLS support for C-SKY. We support all four
> > standard TLS addressing modes (LE, IE, LD, and GD) when running on
> > Linux via NPTL.
> >
> > *sysdeps/csky/dl-tls.h: New file
> > *sysdeps/csky/libc-tls.c: New file
> > *sysdeps/csky/nptl/tcb-offsets.sym: New file
> > *sysdeps/csky/nptl/tls.h: New file
> > *sysdeps/csky/stackinfo.h: New file
> >
>
> OK, fairly clean, was curious about stack guard and pointer guard support.
>
> Others may have more to comment on this in libc-alpha.
>
> > Signed-off-by: Mao Han <han_mao@c-sky.com>
> > ---
> > sysdeps/csky/dl-tls.h | 26 ++++++
> > sysdeps/csky/libc-tls.c | 32 ++++++++
> > sysdeps/csky/nptl/tcb-offsets.sym | 10 +++
> > sysdeps/csky/nptl/tls.h | 169 ++++++++++++++++++++++++++++++++++++++
> > sysdeps/csky/stackinfo.h | 32 ++++++++
> > 5 files changed, 269 insertions(+)
> > create mode 100644 sysdeps/csky/dl-tls.h
> > create mode 100644 sysdeps/csky/libc-tls.c
> > create mode 100644 sysdeps/csky/nptl/tcb-offsets.sym
> > create mode 100644 sysdeps/csky/nptl/tls.h
> > create mode 100644 sysdeps/csky/stackinfo.h
> > index 0000000..69fadad
> > --- /dev/null
> > +++ b/sysdeps/csky/nptl/tls.h
> > @@ -0,0 +1,169 @@
> > +/* Definitions for thread-local data handling. NPTL/csky version.
> > + Copyright (C) 2018 Free Software Foundation, Inc.
> > + This file is part of the GNU C Library.
> > +
> > + The GNU C Library is free software; you can redistribute it and/or
> > + modify it under the terms of the GNU Lesser General Public
> > + License as published by the Free Software Foundation; either
> > + version 2.1 of the License, or (at your option) any later version.
> > +
> > + The GNU C Library is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + Lesser General Public License for more details.
> > +
> > + You should have received a copy of the GNU Lesser General Public
> > + License along with the GNU C Library. If not, see
> > + <http://www.gnu.org/licenses/>. */
> > +
> > +#ifndef _TLS_H
> > +#define _TLS_H 1
> > +
> > +#ifndef __ASSEMBLER__
> > +
> > +#include <stdbool.h>
> > +#include <stddef.h>
> > +#include <stdint.h>
> > +#include <dl-dtv.h>
> > +
> > +#ifdef __CSKYABIV2__
> > +/* define r31 as thread pointer register. */
> > +#define READ_THREAD_POINTER() \
> > + ({ void *__result; \
> > + __asm__ __volatile__ ("mov %0, r31" \
> > + : "=r" (__result)); \
> > + __result; })
> > +#else
> > +#define READ_THREAD_POINTER() \
> > + ({ register unsigned int __result __asm__("a0"); \
> > + __asm__ __volatile__ ("trap 3;" \
> > + : "=r" (__result) : : ); \
> > + __result; })
> > +#endif
> > +
> > +#else /* __ASSEMBLER__ */
> > +#include <tcb-offsets.h>
> > +#ifdef __CSKYABIV2__
> > +/* define r31 as thread pointer register. */
> > +#define READ_THREAD_POINTER() \
> > + mov r0, r31;
> > +#else
> > +#define READ_THREAD_POINTER() \
> > + trap 3;
> > +#endif
> > +#endif /* __ASSEMBLER__ */
> > +
> > +#ifndef __ASSEMBLER__
> > +
> > +/* Get system call information. */
> > +#include <sysdep.h>
> > +
> > +/* The TP points to the start of the thread blocks. */
> > +#define TLS_DTV_AT_TP 1
> > +#define TLS_TCB_AT_TP 0
> > +
> > +/* Get the thread descriptor definition. */
> > +#include <nptl/descr.h>
> > +
> > +typedef struct
> > +{
> > + dtv_t *dtv;
> > + void *private;
>
> Stack guard or pointer guard support?
We have global stack protect support using __stack_chk_guard, but SSP_TLS
is not supported in our gcc. So there is no stack_guard here.
Pointer guard is not support at present. PTR_DEMANGLE and PTR_MANGLE are
defined empty. I think I'll add support for that later.
>
> > +} tcbhead_t;
> > +
More information about the Libc-help
mailing list