summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Ren-Wei Chen <vincentc@andestech.com>2017-01-17 07:31:24 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2017-01-22 10:06:29 +0100
commit6af3332a4cbd1ffbc81f74759ef7c5e1a87d2e10 (patch)
tree4deae5f23fd1e2664f21c09dfb57fda799dffd10
parent82af21a60bc6e53dd92c1c140f20179d2ae4ad40 (diff)
nds32: add NPTL/TLS, *context function, libm changes and code cleanup
This commit includes following features. 1. Support NPTL/TLS 2. Add libm function which is used to handle FP rounding and excpetions (ex: fclrexcpt,fedisblxcpti,feenablxcpt... ) 3. Add *context function for operating user context (ex: setcontext,getcontext,makecontext... ) 4. Change the return flow from signal handler 5. Cleanup of old code The testsuite only has 2 errors, tst-cpuclock1 and tst-cputimer1, which are related to timing accuracy. (math and locale tests are disabled) Signed-off-by: Vincent Ren-Wei Chen <vincentc@andestech.com>
-rw-r--r--extra/Configs/Config.in1
-rw-r--r--extra/Configs/Config.nds321
-rw-r--r--extra/Configs/defconfigs/nds32/defconfig167
-rw-r--r--include/elf.h3
-rw-r--r--ldso/ldso/nds32/dl-startup.h94
-rw-r--r--ldso/ldso/nds32/dl-sysdep.h5
-rw-r--r--ldso/ldso/nds32/dl-tlsdesc.S100
-rw-r--r--ldso/ldso/nds32/elfinterp.c94
-rw-r--r--ldso/ldso/nds32/resolve.S24
-rw-r--r--ldso/libdl/Makefile.in1
-rw-r--r--libc/string/nds32/memcpy.S22
-rw-r--r--libc/string/nds32/memset.S2
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise.c2
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise64.c2
-rw-r--r--libc/sysdeps/linux/common/sync_file_range.c2
-rw-r--r--libc/sysdeps/linux/nds32/Makefile6
-rw-r--r--libc/sysdeps/linux/nds32/Makefile.arch6
-rw-r--r--libc/sysdeps/linux/nds32/__longjmp.S2
-rw-r--r--libc/sysdeps/linux/nds32/bits/atomic.h110
-rw-r--r--libc/sysdeps/linux/nds32/bits/fcntl.h6
-rw-r--r--libc/sysdeps/linux/nds32/bits/fenv.h79
-rw-r--r--libc/sysdeps/linux/nds32/bits/mman.h1
-rw-r--r--libc/sysdeps/linux/nds32/bits/setjmp.h18
-rw-r--r--libc/sysdeps/linux/nds32/bits/sigcontext.h59
-rw-r--r--libc/sysdeps/linux/nds32/bits/sigcontextinfo.h35
-rw-r--r--libc/sysdeps/linux/nds32/bits/syscalls.h354
-rw-r--r--libc/sysdeps/linux/nds32/bits/uClibc_arch_features.h2
-rw-r--r--libc/sysdeps/linux/nds32/bsd-_setjmp.S5
-rw-r--r--libc/sysdeps/linux/nds32/bsd-setjmp.S4
-rw-r--r--libc/sysdeps/linux/nds32/clone.S200
-rw-r--r--libc/sysdeps/linux/nds32/crt1.S7
-rw-r--r--libc/sysdeps/linux/nds32/crti.S24
-rw-r--r--libc/sysdeps/linux/nds32/fpu_control.h77
-rw-r--r--libc/sysdeps/linux/nds32/getcontext.S106
-rw-r--r--libc/sysdeps/linux/nds32/jmpbuf-unwind.h18
-rw-r--r--libc/sysdeps/linux/nds32/makecontext.c77
-rw-r--r--libc/sysdeps/linux/nds32/mmap.S101
-rw-r--r--libc/sysdeps/linux/nds32/mremap.c28
-rw-r--r--libc/sysdeps/linux/nds32/prctl.c23
-rw-r--r--libc/sysdeps/linux/nds32/setcontext.S85
-rw-r--r--libc/sysdeps/linux/nds32/setjmp.S2
-rw-r--r--libc/sysdeps/linux/nds32/sigaction.c40
-rw-r--r--libc/sysdeps/linux/nds32/sigrestorer.S42
-rw-r--r--libc/sysdeps/linux/nds32/swapcontext.c38
-rw-r--r--libc/sysdeps/linux/nds32/sys/ucontext.h117
-rw-r--r--libc/sysdeps/linux/nds32/syscall.S60
-rw-r--r--libc/sysdeps/linux/nds32/syscall.c28
-rw-r--r--libc/sysdeps/linux/nds32/sysdep.S39
-rw-r--r--libc/sysdeps/linux/nds32/sysdep.h321
-rw-r--r--libc/sysdeps/linux/nds32/ucontext_i.sym27
-rw-r--r--libc/sysdeps/linux/nds32/vfork.S114
-rw-r--r--libm/nds32/Makefile.arch16
-rw-r--r--libm/nds32/e_sqrt.c34
-rw-r--r--libm/nds32/fclrexcpt.c52
-rw-r--r--libm/nds32/fedisblxcpt.c49
-rw-r--r--libm/nds32/feenablxcpt.c50
-rw-r--r--libm/nds32/fegetenv.c40
-rw-r--r--libm/nds32/fegetexcept.c41
-rw-r--r--libm/nds32/fegetround.c40
-rw-r--r--libm/nds32/feholdexcpt.c51
-rw-r--r--libm/nds32/fenv_libc.h33
-rw-r--r--libm/nds32/fesetenv.c51
-rw-r--r--libm/nds32/fesetround.c42
-rw-r--r--libm/nds32/feupdateenv.c48
-rw-r--r--libm/nds32/fgetexcptflg.c44
-rw-r--r--libm/nds32/fraiseexcpt.c104
-rw-r--r--libm/nds32/fsetexcptflg.c48
-rw-r--r--libm/nds32/ftestexcept.c40
-rw-r--r--libpthread/linuxthreads/sysdeps/nds32/pspinlock.c2
-rw-r--r--libpthread/linuxthreads/sysdeps/nds32/pt-machine.h2
-rw-r--r--libpthread/nptl/sysdeps/nds32/Makefile.arch16
-rw-r--r--libpthread/nptl/sysdeps/nds32/dl-tls.h59
-rw-r--r--libpthread/nptl/sysdeps/nds32/libc-dl-tlsdesc.S1
-rw-r--r--libpthread/nptl/sysdeps/nds32/pthread_spin_lock.c65
-rw-r--r--libpthread/nptl/sysdeps/nds32/pthread_spin_trylock.c26
-rw-r--r--libpthread/nptl/sysdeps/nds32/pthreaddef.h39
-rw-r--r--libpthread/nptl/sysdeps/nds32/tcb-offsets.sym12
-rw-r--r--libpthread/nptl/sysdeps/nds32/tls.h178
-rw-r--r--libpthread/nptl/sysdeps/nds32/tlsdesc.sym17
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/Makefile9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/Makefile.arch12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/bits/pthreadtypes.h177
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/bits/semaphore.h38
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/clone.S4
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/createthread.c22
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/fork.c27
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/lowlevellock.h323
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/pt-raise.c18
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/pthread_once.c92
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/sysdep-cancel.h273
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/vfork.S43
91 files changed, 4023 insertions, 996 deletions
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index f312e7a13..a9d62f50f 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -521,7 +521,6 @@ config UCLIBC_HAS_THREADS_NATIVE
!TARGET_hppa && \
!TARGET_ia64 && \
!TARGET_m68k && \
- !TARGET_nds32 && \
!TARGET_or1k && \
ARCH_USE_MMU
help
diff --git a/extra/Configs/Config.nds32 b/extra/Configs/Config.nds32
index a74249947..2ed6a32b7 100644
--- a/extra/Configs/Config.nds32
+++ b/extra/Configs/Config.nds32
@@ -13,6 +13,7 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_ANY_ENDIAN
select ARCH_HAS_DEPRECATED_SYSCALLS
select ARCH_HAS_MMU
+ select ARCH_HAS_UCONTEXT
choice
prompt "MMU Page Size"
diff --git a/extra/Configs/defconfigs/nds32/defconfig b/extra/Configs/defconfigs/nds32/defconfig
new file mode 100644
index 000000000..d870ad747
--- /dev/null
+++ b/extra/Configs/defconfigs/nds32/defconfig
@@ -0,0 +1,167 @@
+TARGET_nds32=y
+#
+# Using ELF file format
+#
+ARCH_HAS_DEPRECATED_SYSCALLS=y
+ARCH_ANY_ENDIAN=y
+ARCH_LITTLE_ENDIAN=y
+# ARCH_WANTS_BIG_ENDIAN is not set
+ARCH_WANTS_LITTLE_ENDIAN=y
+ARCH_HAS_MMU=y
+ARCH_USE_MMU=y
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FPU=y
+DO_C99_MATH=y
+DO_XSI_MATH=y
+UCLIBC_HAS_FENV=y
+KERNEL_HEADERS=""
+HAVE_DOT_CONFIG=y
+
+#
+# General Library Settings
+#
+DOPIC=y
+ARCH_HAS_UCONTEXT=y
+HAVE_SHARED=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+LDSO_LDD_SUPPORT=y
+LDSO_CACHE_SUPPORT=y
+# LDSO_PRELOAD_ENV_SUPPORT is not set
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_BASE_FILENAME="ld.so"
+# LDSO_STANDALONE_SUPPORT is not set
+# LDSO_PRELINK_SUPPORT is not set
+UCLIBC_STATIC_LDCONFIG=y
+LDSO_RUNPATH=y
+LDSO_RUNPATH_OF_EXECUTABLE=y
+LDSO_SAFE_RUNPATH=y
+LDSO_SEARCH_INTERP_PATH=y
+LDSO_LD_LIBRARY_PATH=y
+LDSO_NO_CLEANUP=y
+UCLIBC_CTOR_DTOR=y
+LDSO_GNU_HASH_SUPPORT=y
+# HAS_NO_THREADS is not set
+# UCLIBC_HAS_LINUXTHREADS is not set
+UCLIBC_HAS_THREADS_NATIVE=y
+UCLIBC_HAS_THREADS=y
+UCLIBC_HAS_TLS=y
+PTHREADS_DEBUG_SUPPORT=y
+UCLIBC_HAS_SYSLOG=y
+UCLIBC_HAS_LFS=y
+# MALLOC is not set
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+MALLOC_GLIBC_COMPAT=y
+# UCLIBC_HAS_OBSTACK is not set
+UCLIBC_DYNAMIC_ATEXIT=y
+COMPAT_ATEXIT=y
+UCLIBC_HAS_UTMPX=y
+UCLIBC_HAS_UTMP=y
+UCLIBC_SUSV2_LEGACY=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_HAS_CONTEXT_FUNCS=y
+UCLIBC_SUSV3_LEGACY_MACROS=y
+UCLIBC_SUSV4_LEGACY=y
+# UCLIBC_STRICT_HEADERS is not set
+# UCLIBC_HAS_STUBS is not set
+UCLIBC_HAS_SHADOW=y
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS___PROGNAME=y
+UCLIBC_HAS_PTY=y
+ASSUME_DEVPTS=y
+UNIX98PTY_ONLY=y
+UCLIBC_HAS_GETPT=y
+UCLIBC_HAS_LIBUTIL=y
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+UCLIBC_FALLBACK_TO_ETC_LOCALTIME=y
+
+#
+# Advanced Library Settings
+#
+UCLIBC_PWD_BUFFER_SIZE=256
+UCLIBC_GRP_BUFFER_SIZE=256
+
+#
+# Support various families of functions
+#
+UCLIBC_LINUX_MODULE_26=y
+# UCLIBC_LINUX_MODULE_24 is not set
+UCLIBC_LINUX_SPECIFIC=y
+UCLIBC_HAS_GNU_ERROR=y
+UCLIBC_BSD_SPECIFIC=y
+UCLIBC_HAS_BSD_ERR=y
+UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
+# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set
+# UCLIBC_NTP_LEGACY is not set
+UCLIBC_SV4_DEPRECATED=y
+UCLIBC_HAS_REALTIME=y
+UCLIBC_HAS_ADVANCED_REALTIME=y
+UCLIBC_HAS_EPOLL=y
+UCLIBC_HAS_XATTR=y
+UCLIBC_HAS_PROFILING=y
+UCLIBC_HAS_CRYPT_IMPL=y
+UCLIBC_HAS_SHA256_CRYPT_IMPL=y
+# UCLIBC_HAS_SHA512_CRYPT_IMPL is not set
+UCLIBC_HAS_CRYPT=y
+UCLIBC_HAS_NETWORK_SUPPORT=y
+UCLIBC_HAS_SOCKET=y
+UCLIBC_HAS_IPV4=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+# UCLIBC_HAS_REENTRANT_RPC is not set
+UCLIBC_USE_NETLINK=y
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
+UCLIBC_HAS_BSD_RES_CLOSE=y
+UCLIBC_HAS_COMPAT_RES_STATE=y
+# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBNSL_STUB=y
+
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_STDIO_FUTEXES=y
+UCLIBC_HAS_CTYPE_TABLES=y
+UCLIBC_HAS_CTYPE_SIGNED=y
+# UCLIBC_HAS_CTYPE_UNSAFE is not set
+UCLIBC_HAS_CTYPE_CHECKED=y
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+UCLIBC_HAS_WCHAR=y
+# UCLIBC_HAS_LOCALE is not set
+UCLIBC_HAS_HEXADECIMAL_FLOATS=y
+UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_PRINTF_M_SPEC=y
+UCLIBC_HAS_ERRNO_MESSAGES=y
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+UCLIBC_HAS_GNU_GETOPT=y
+UCLIBC_HAS_GETOPT_LONG=y
+UCLIBC_HAS_GNU_GETSUBOPT=y
+UCLIBC_HAS_ARGP=y
+
+UCLIBC_HAS_REGEX=y
+# UCLIBC_HAS_REGEX_OLD is not set
+UCLIBC_HAS_FNMATCH=y
+# UCLIBC_HAS_FNMATCH_OLD is not set
+UCLIBC_HAS_WORDEXP=y
+UCLIBC_HAS_NFTW=y
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_FTS=y
+UCLIBC_HAS_GLOB=y
+UCLIBC_HAS_GNU_GLOB=y
+
+CROSS_COMPILER_PREFIX=""
+UCLIBC_EXTRA_CFLAGS=""
+# DOSTRIP is not set
diff --git a/include/elf.h b/include/elf.h
index e0937b732..0f188e792 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -2985,6 +2985,9 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_NDS32_PLTREL_LO12 65
#define R_NDS32_PLT_GOTREL_HI20 66
#define R_NDS32_PLT_GOTREL_LO12 67
+#define R_NDS32_TLS_TPOFF 102
+#define R_NDS32_TLS_DESC 119
+
/* Processor specific section indices. These sections do not actually
exist. Symbols with a st_shndx field corresponding to one of these
diff --git a/ldso/ldso/nds32/dl-startup.h b/ldso/ldso/nds32/dl-startup.h
index f700531ca..56892a2ba 100644
--- a/ldso/ldso/nds32/dl-startup.h
+++ b/ldso/ldso/nds32/dl-startup.h
@@ -6,68 +6,7 @@
/* Need bootstrap relocations */
#define ARCH_NEEDS_BOOTSTRAP_RELOCS
-#if defined(NDS32_ABI_2) || defined(NDS32_ABI_2FP)
-# define STACK_PUSH
-# define STACK_POP
-#else
-# define STACK_PUSH "addi $sp, $sp, -24"
-# define STACK_POP "addi $sp, $sp, 24"
-#endif
-
-#ifdef __NDS32_N1213_43U1H__
-__asm__("\
- .text\n\
- .globl _start\n\
- .globl _dl_start\n\
- .globl _dl_start_user\n\
- .type _start,#function\n\
- .type _dl_start,#function\n\
- .type _dl_start_user,#function\n\
- .align 4\n\
- .pic\n\
-1:\n\
- ret\n\
-_start:\n\
- ! we are PIC code, so get global offset table\n\
- jal 1b\n\
- sethi $gp, HI20(_GLOBAL_OFFSET_TABLE_)\n\
- ori $gp, $gp, LO12(_GLOBAL_OFFSET_TABLE_+4)\n\
- add $gp, $lp, $gp\n\
-\n\
- ! at start time, all the args are on the stack\n\
- addi $r0, $sp, 0\n\
- ! adjust stack\n\
- !addi $sp, $sp, -24\n\
- "STACK_PUSH"\n\
- bal _dl_start@PLT\n\
- ! save user entry point in r6\n\
- addi $r6, $r0, 0\n\
- ! adjust sp and reload registers\n\
- !addi $sp, $sp, 24\n\
- "STACK_POP"\n\
-\n\
-_dl_start_user:\n\
-\n\
- ! See if we were run as a command with the executable file\n\
- ! name as an extra leading argument.\n\
- ! skip these arguments\n\
- l.w $r2, _dl_skip_args@GOTOFF ! args to skip\n\
- lwi $r0, [$sp+0] ! original argc\n\
- slli $r1, $r2, 2 ! offset for new sp\n\
- add $sp, $sp, $r1 ! adjust sp to skip args\n\
- sub $r0, $r0, $r2 ! set new argc\n\
- swi $r0, [$sp+0] ! save new argc\n\
-\n\
- ! load address of _dl_fini finalizer function\n\
- la $r5, _dl_fini@GOTOFF\n\
- ! jump to the user_s entry point\n\
- addi $r15, $r6, 0\n\
- jr $r15\n\
- .size _dl_start_user, . - _dl_start_user\n\
- .previous\n\
-");
-#else
__asm__("\
.text\n\
.globl _start\n\
@@ -89,13 +28,11 @@ _start:\n\
addi $r0, $sp, 0\n\
! adjust stack\n\
!addi $sp, $sp, -24\n\
- "STACK_PUSH"\n\
bal _dl_start@PLT\n\
! save user entry point in r6\n\
addi $r6, $r0, 0\n\
! adjust sp and reload registers\n\
!addi $sp, $sp, 24\n\
- "STACK_POP"\n\
\n\
_dl_start_user:\n\
! See if we were run as a command with the executable file\n\
@@ -115,31 +52,12 @@ _dl_start_user:\n\
.size _dl_start_user, . - _dl_start_user\n\
.previous\n\
");
-#endif
-#define COPY_UNALIGNED_WORD(swp, twp, align) \
- { \
- void *__s = (swp), *__t = (twp); \
- unsigned char *__s1 = __s, *__t1 = __t; \
- unsigned short *__s2 = __s, *__t2 = __t; \
- unsigned long *__s4 = __s, *__t4 = __t; \
- switch ((align)) \
- { \
- case 0: \
- *__t4 = *__s4; \
- break; \
- case 2: \
- *__t2++ = *__s2++; \
- *__t2 = *__s2; \
- break; \
- default: \
- *__t1++ = *__s1++; \
- *__t1++ = *__s1++; \
- *__t1++ = *__s1++; \
- *__t1 = *__s1; \
- break; \
- } \
- }
+#define COPY_UNALIGNED_WORD(swp, twp) \
+{ \
+ __typeof (swp) __tmp = __builtin_nds32_unaligned_load_w ((unsigned int*)&swp); \
+ __builtin_nds32_unaligned_store_w ((unsigned int *)twp, __tmp); \
+}
/* Get a pointer to the argv array. On many platforms this can be just
* the address if the first argu