Skip to contentSkip to conversation

glibc port to ARC processors

PATCH In review Vineet Gupta 6 participants 98 messages Dec 18, 2018 – Jan 29, 2019 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

cover glibc port to ARC processors

Hi,

This is reposting of glibc port to ARC processors from synopsys.

The original posting was a while back [1]. The issues at the time were
(1). Need for working upstream gcc/binutils (vs. the github forks) (2). Too many testsuite failures.

All the ducks seem to be in a row now, with last remaining gcc patch backported to gcc-8-branch last week [2] and testsuite failures tended to/reduced significantly.

(a) build-many-glibcs.py check results are clean

| Summary of test results:
|   1173 PASS
|      15 XFAIL
|
| PASS: glibcs-arc-linux-gnu check

(b) Full testsuite ran in a cross compile setup using buildroot on HSDK development platform.

Summary of test results:

     24 FAIL

5124 PASS
27 UNSUPPORTED
19 XFAIL

| FAIL: localedata/sort-test		# Needs more RAM:
| FAIL: stdio-common/bug22		# Needs more RAM: 2 GB memory
| FAIL: sunrpc/bug20790			# missing cpp on target
| FAIL: nptl/test-mutexattr-printers	# need Python3 and target GDB on target
| FAIL: nptl/test-mutex-printers	# need Python3 and target GDB on target
| FAIL: nptl/test-condattr-printers	# need Python3 and target GDB on target
| FAIL: nptl/test-cond-printers		# need Python3 and target GDB on target
| FAIL: nptl/test-rwlockattr-printers	# need Python3 and target GDB on target
| FAIL: nptl/test-rwlock-printers	# need Python3 and target GDB on target
| FAIL: iconv/test-iconvconfig		# Needs gconv installed
| FAIL: posix/bug-ga2			# DNS issue: google DNS vs. SNPS
| FAIL: posix/tst-getaddrinfo5		# DNS server not configured
| FAIL: posix/globtest			# require same user on target and host

| FAIL: elf/check-localplt # passes for build-many-glibcs.py

					# buildroot builds with slightly different toggles (-Os)
					# such that gcc generates an extra memcpy PLT call
| FAIL: gmon/tst-gmon-pie-gprof
| FAIL: gmon/tst-sprofil
| FAIL: posix/tst-spawn
| FAIL: posix/tst-spawn-static
| FAIL: nptl/tst-cond16
| FAIL: nptl/tst-cond17
| FAIL: nptl/tst-umask1
| FAIL: nptl/tst-setuid2
| FAIL: nss/bug-erange
| FAIL: nss/tst-nss-test3

The full log for above can be found at [3]

Bulk of failures are due to cross test setup and/or RAM accessible on target. We are analysing the other failures and will tend to them as we go along.

(c) Code was rebased off of master yesterday. Please review and comment.

(d) We currently only support soft float ABI, although I'm working on hard float and hopefully will have it ready sometime during the review of this series

Thx,
-Vineet

[1] https://sourceware.org/ml/libc-alpha/2017-06/msg01355.html
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88001
[3] https://github.com/foss-for-synopsys-dwc-arc-processors/glibc/issues/1

Cupertino Miranda (2):
ARC: testsuite fix: GD TLS issue
ARC: fix several unwining and cancelation tests

Vineet Gupta (19):
longlong.h: sync from gcc to fix ARC inline asm constraints
ARC: add definitions to elf/elf.h
ARC: ABI Implementation
ARC: startup and dynamic linking code
ARC: Thread Local Storage support
ARC: Atomics and Locking primitives
ARC: math soft float support
ARC: Linux Syscall Interface
ARC: Linux ABI
ARC: Linux Startup and Dynamic Loading
ARC: ABI lists
ARC: Update syscall-names.list for ARC specific syscalls
ARC: Build Infrastructure
ARC: Enable __start as entry point vs. canonical _start
ARC: testsuite fix: elf/check-initfini
ARC: testsuite fix: sysvipc/*
ARC: testsuite fix: stdlib/tst-makecontext build-many-glibcs.py: Enable ARC builds
NEWS: mention ARC port

 ChangeLog                                          |  127 ++
 NEWS                                               |    2 +
 elf/elf.h                                          |   70 +-
 scripts/build-many-glibcs.py                       |    4 +
 stdlib/longlong.h                                  |   65 +-
 sysdeps/arc/Implies                                |    3 +
 sysdeps/arc/Makefile                               |   25 +
 sysdeps/arc/Versions                               |   14 +
 sysdeps/arc/__longjmp.S                            |   50 +
 sysdeps/arc/abort-instr.h                          |    2 +
 sysdeps/arc/atomic-machine.h                       |   89 +
 sysdeps/arc/bits/endian.h                          |   12 +
 sysdeps/arc/bits/fenv.h                            |   92 +
 sysdeps/arc/bits/link.h                            |   52 +
 sysdeps/arc/bits/setjmp.h                          |   33 +
 sysdeps/arc/bsd-_setjmp.S                          |    1 +
 sysdeps/arc/bsd-setjmp.S                           |    1 +
 sysdeps/arc/configure                              |   17 +
 sysdeps/arc/configure.ac                           |   13 +
 sysdeps/arc/crti.S                                 |   79 +
 sysdeps/arc/crtn.S                                 |   56 +
 sysdeps/arc/dl-machine.h                           |  339 ++++
 sysdeps/arc/dl-runtime.c                           |   21 +
 sysdeps/arc/dl-sysdep.h                            |   25 +
 sysdeps/arc/dl-tls.h                               |   30 +
 sysdeps/arc/dl-trampoline.S                        |   81 +
 sysdeps/arc/entry.h                                |    5 +
 sysdeps/arc/gccframe.h                             |   21 +
 sysdeps/arc/gmp-mparam.h                           |   23 +
 sysdeps/arc/jmpbuf-offsets.h                       |   46 +
 sysdeps/arc/jmpbuf-unwind.h                        |   47 +
 sysdeps/arc/ldsodefs.h                             |   43 +
 sysdeps/arc/libc-tls.c                             |   27 +
 sysdeps/arc/machine-gmon.h                         |   33 +
 sysdeps/arc/math_private.h                         |    6 +
 sysdeps/arc/memusage.h                             |   23 +
 sysdeps/arc/nofpu/Implies                          |    1 +
 sysdeps/arc/nofpu/libm-test-ulps                   |  390 ++++
 sysdeps/arc/nofpu/libm-test-ulps-name              |    1 +
 sysdeps/arc/nofpu/math-tests-exception.h           |   27 +
 sysdeps/arc/nofpu/math-tests-rounding.h            |   27 +
 sysdeps/arc/nptl/Makefile                          |   22 +
 sysdeps/arc/nptl/bits/pthreadtypes-arch.h          |   72 +
 sysdeps/arc/nptl/bits/semaphore.h                  |   32 +
 sysdeps/arc/nptl/pthread-offsets.h                 |    5 +
 sysdeps/arc/nptl/pthreaddef.h                      |   32 +
 sysdeps/arc/nptl/tcb-offsets.sym                   |   11 +
 sysdeps/arc/nptl/tls.h                             |  150 ++
 sysdeps/arc/preconfigure                           |   14 +
 sysdeps/arc/setjmp.S                               |   64 +
 sysdeps/arc/sfp-machine.h                          |   51 +
 sysdeps/arc/sotruss-lib.c                          |   51 +
 sysdeps/arc/stackinfo.h                            |   33 +
 sysdeps/arc/start.S                                |   89 +
 sysdeps/arc/sysdep.h                               |   51 +
 sysdeps/arc/tls-macros.h                           |   29 +
 sysdeps/arc/tst-audit.h                            |   23 +
 sysdeps/unix/sysv/linux/arc/Implies                |    3 +
 sysdeps/unix/sysv/linux/arc/Makefile               |   20 +
 sysdeps/unix/sysv/linux/arc/Versions               |   16 +
 sysdeps/unix/sysv/linux/arc/bits/procfs-id.h       |   25 +
 sysdeps/unix/sysv/linux/arc/bits/procfs.h          |   35 +
 sysdeps/unix/sysv/linux/arc/bits/sigaction.h       |   85 +
 sysdeps/unix/sysv/linux/arc/c++-types.data         |   67 +
 sysdeps/unix/sysv/linux/arc/cacheflush.c           |   29 +
 sysdeps/unix/sysv/linux/arc/clone.S                |  100 +
 sysdeps/unix/sysv/linux/arc/configure              |    4 +
 sysdeps/unix/sysv/linux/arc/configure.ac           |    4 +
 sysdeps/unix/sysv/linux/arc/dl-static.c            |   84 +
 sysdeps/unix/sysv/linux/arc/getcontext.S           |   65 +
 sysdeps/unix/sysv/linux/arc/ipc_priv.h             |   21 +
 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h       |    6 +
 sysdeps/unix/sysv/linux/arc/kernel-features.h      |   28 +
 sysdeps/unix/sysv/linux/arc/ld.abilist             |    9 +
 sysdeps/unix/sysv/linux/arc/ldconfig.h             |   25 +
 sysdeps/unix/sysv/linux/arc/ldsodefs.h             |   32 +
 .../unix/sysv/linux/arc/libBrokenLocale.abilist    |    1 +
 sysdeps/unix/sysv/linux/arc/libanl.abilist         |    4 +
 sysdeps/unix/sysv/linux/arc/libc.abilist           | 2089 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/libcrypt.abilist       |    2 +
 sysdeps/unix/sysv/linux/arc/libdl.abilist          |    9 +
 sysdeps/unix/sysv/linux/arc/libm.abilist           |  753 +++++++
 sysdeps/unix/sysv/linux/arc/libnsl.abilist         |  120 ++
 sysdeps/unix/sysv/linux/arc/libpthread.abilist     |  235 +++
 sysdeps/unix/sysv/linux/arc/libresolv.abilist      |   79 +
 sysdeps/unix/sysv/linux/arc/librt.abilist          |   35 +
 sysdeps/unix/sysv/linux/arc/libthread_db.abilist   |   40 +
 sysdeps/unix/sysv/linux/arc/libutil.abilist        |    6 +
 sysdeps/unix/sysv/linux/arc/localplt.data          |   15 +
 sysdeps/unix/sysv/linux/arc/makecontext.c          |   75 +
 sysdeps/unix/sysv/linux/arc/mmap_internal.h        |   26 +
 sysdeps/unix/sysv/linux/arc/profil-counter.h       |    2 +
 sysdeps/unix/sysv/linux/arc/pt-vfork.S             |    1 +
 sysdeps/unix/sysv/linux/arc/setcontext.S           |   95 +
 sysdeps/unix/sysv/linux/arc/shlib-versions         |    2 +
 sysdeps/unix/sysv/linux/arc/sigaction.c            |   63 +
 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h       |   23 +
 sysdeps/unix/sysv/linux/arc/sigrestorer.S          |   28 +
 sysdeps/unix/sysv/linux/arc/swapcontext.S          |   92 +
 sysdeps/unix/sysv/linux/arc/sys/cachectl.h         |   36 +
 sysdeps/unix/sysv/linux/arc/sys/ucontext.h         |   71 +
 sysdeps/unix/sysv/linux/arc/sys/user.h             |   32 +
 sysdeps/unix/sysv/linux/arc/syscall.S              |   38 +
 sysdeps/unix/sysv/linux/arc/sysdep.c               |   33 +
 sysdeps/unix/sysv/linux/arc/sysdep.h               |  259 +++
 sysdeps/unix/sysv/linux/arc/ucontext-macros.h      |   29 +
 sysdeps/unix/sysv/linux/arc/ucontext_i.sym         |   20 +
 sysdeps/unix/sysv/linux/arc/vfork.S                |   42 +
 sysdeps/unix/sysv/linux/syscall-names.list         |    3 +
 109 files changed, 7709 insertions(+), 59 deletions(-)
 create mode 100644 sysdeps/arc/Implies
 create mode 100644 sysdeps/arc/Makefile
 create mode 100644 sysdeps/arc/Versions
 create mode 100644 sysdeps/arc/__longjmp.S
 create mode 100644 sysdeps/arc/abort-instr.h
 create mode 100644 sysdeps/arc/atomic-machine.h
 create mode 100644 sysdeps/arc/bits/endian.h
 create mode 100644 sysdeps/arc/bits/fenv.h
 create mode 100644 sysdeps/arc/bits/link.h
 create mode 100644 sysdeps/arc/bits/setjmp.h
 create mode 100644 sysdeps/arc/bsd-_setjmp.S
 create mode 100644 sysdeps/arc/bsd-setjmp.S
 create mode 100644 sysdeps/arc/configure
 create mode 100644 sysdeps/arc/configure.ac
 create mode 100644 sysdeps/arc/crti.S
 create mode 100644 sysdeps/arc/crtn.S
 create mode 100644 sysdeps/arc/dl-machine.h
 create mode 100644 sysdeps/arc/dl-runtime.c
 create mode 100644 sysdeps/arc/dl-sysdep.h
 create mode 100644 sysdeps/arc/dl-tls.h
 create mode 100644 sysdeps/arc/dl-trampoline.S
 create mode 100644 sysdeps/arc/entry.h
 create mode 100644 sysdeps/arc/gccframe.h
 create mode 100644 sysdeps/arc/gmp-mparam.h
 create mode 100644 sysdeps/arc/jmpbuf-offsets.h
 create mode 100644 sysdeps/arc/jmpbuf-unwind.h
 create mode 100644 sysdeps/arc/ldsodefs.h
 create mode 100644 sysdeps/arc/libc-tls.c
 create mode 100644 sysdeps/arc/machine-gmon.h
 create mode 100644 sysdeps/arc/math_private.h
 create mode 100644 sysdeps/arc/memusage.h
 create mode 100644 sysdeps/arc/nofpu/Implies
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps-name
 create mode 100644 sysdeps/arc/nofpu/math-tests-exception.h
 create mode 100644 sysdeps/arc/nofpu/math-tests-rounding.h
 create mode 100644 sysdeps/arc/nptl/Makefile
 create mode 100644 sysdeps/arc/nptl/bits/pthreadtypes-arch.h
 create mode 100644 sysdeps/arc/nptl/bits/semaphore.h
 create mode 100644 sysdeps/arc/nptl/pthread-offsets.h
 create mode 100644 sysdeps/arc/nptl/pthreaddef.h
 create mode 100644 sysdeps/arc/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/arc/nptl/tls.h
 create mode 100644 sysdeps/arc/preconfigure
 create mode 100644 sysdeps/arc/setjmp.S
 create mode 100644 sysdeps/arc/sfp-machine.h
 create mode 100644 sysdeps/arc/sotruss-lib.c
 create mode 100644 sysdeps/arc/stackinfo.h
 create mode 100644 sysdeps/arc/start.S
 create mode 100644 sysdeps/arc/sysdep.h
 create mode 100644 sysdeps/arc/tls-macros.h
 create mode 100644 sysdeps/arc/tst-audit.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/Implies
 create mode 100644 sysdeps/unix/sysv/linux/arc/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/arc/Versions
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs-id.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/sigaction.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/arc/cacheflush.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/clone.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/arc/dl-static.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/kernel-features.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldconfig.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldsodefs.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libnsl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/localplt.data
 create mode 100644 sysdeps/unix/sysv/linux/arc/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/mmap_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/profil-counter.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/pt-vfork.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigaction.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigrestorer.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/cachectl.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscall.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext_i.sym
 create mode 100644 sysdeps/unix/sysv/linux/arc/vfork.S
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/21 longlong.h: sync from gcc to fix ARC inline asm constraints

This corresponds to the version

Author: law <law at 138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Jun 27 16:10:15 2017 +0000

* longlong.h: Remove ns32k support.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk at 249696 138bc75d-0d04-0410-961f-82ee72b054a4

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog         |  1 +
 stdlib/longlong.h | 65 ++++++-------------------------------------------------
 2 files changed, 8 insertions(+), 58 deletions(-)
ChangeLog +1 -0
index 027b23493ed8..456e4b670c23 100644
@@ -2,6 +2,7 @@
 
 	* sysdeps/unix/make-syscalls.sh: Fix comment referencing
 	syscall-template file.
+	* stdlib/longlong.h: Fix asm constraints for ARC code.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
stdlib/longlong.h +7 -58

102 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/21 longlong.h: sync from gcc to fix ARC inline asm constraints

ChangeLog line 5

Quoted 9 lines · Vineet Gupta
ChangeLog +1 -0
index 027b23493ed8..456e4b670c23 100644
@@ -2,6 +2,7 @@
 
 	* sysdeps/unix/make-syscalls.sh: Fix comment referencing
 	syscall-template file.
+	* stdlib/longlong.h: Fix asm constraints for ARC code.

I don't see the above context in the current checked-in ChangeLog file. Patch 1 in a series should be creating a new ChangeLog entry in any case, not adding to an existing one (and it's best not to include the ChangeLog entry in the diffs, only adding it at the final commit time, to avoid problems for people applying your patches).

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#3 lore raw

PATCH 1/21 longlong.h: sync from gcc to fix ARC inline asm constraints

Quoted 9 lines · Joseph Myers

ChangeLog line 5

Quoted 3 lines
ChangeLog +1 -0
 	* sysdeps/unix/make-syscalls.sh: Fix comment referencing
 	syscall-template file.
+	* stdlib/longlong.h: Fix asm constraints for ARC code.

I don't see the above context in the current checked-in ChangeLog file. Patch 1 in a series should be creating a new ChangeLog entry in any case, not adding to an existing one (and it's best not to include the ChangeLog entry in the diffs, only adding it at the final commit time, to avoid problems for people applying your patches).

Sorry my bad. I had one preceding patch in the pile which
- created the Changlog entry
- fixed a minor typo in make-syscalls.sh

I'll add that to v2.

Thx,
-Vineet

#4 lore raw

PATCH 1/21 longlong.h: sync from gcc to fix ARC inline asm constraints

In reply to Vineet Gupta
Quoted 6 lines · Vineet Gupta

This corresponds to the version

Author: law <law at 138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Jun 27 16:10:15 2017 +0000

* longlong.h: Remove ns32k support.

It seems odd to update from an out-of-date version of longlong.h, missing the subsequent RISC-V changes. So I've committed this patch instead to update to the current version in GCC.

Update longlong.h.

This patch updates longlong.h from GCC. There were no local changes in glibc (the previous version was identical to the r232143 GCC version, apart from copyright dates which had been updated in both places), so this patch makes it identical to the version in GCC again.

Tested for x86_64 and x86. Also tested with build-many-glibcs.py for its RISC-V configurations, as the glibc architecture with the most substantial changes in longlong.h in this patch.

2018-12-21 Joseph Myers <joseph at codesourcery.com>

* stdlib/longlong.h: Update from GCC.

stdlib/longlong.h +57 -58
index c7c6977c9f..7f3dc17dc0 100644
@@ -197,17 +197,17 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
 	   : "=r" ((USItype) (sh)),					\
 	     "=&r" ((USItype) (sl))					\
 	   : "%r" ((USItype) (ah)),					\
-	     "rIJ" ((USItype) (bh)),					\
+	     "rICal" ((USItype) (bh)),					\
 	     "%r" ((USItype) (al)),					\
-	     "rIJ" ((USItype) (bl)))
+	     "rICal" ((USItype) (bl)))
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
   __asm__ ("sub.f	%1, %4, %5\n\tsbc	%0, %2, %3"		\
 	   : "=r" ((USItype) (sh)),					\
 	     "=&r" ((USItype) (sl))					\
 	   : "r" ((USItype) (ah)),					\
-	     "rIJ" ((USItype) (bh)),					\
+	     "rICal" ((USItype) (bh)),					\
 	     "r" ((USItype) (al)),					\
-	     "rIJ" ((USItype) (bl)))
+	     "rICal" ((USItype) (bl)))
 
 #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
 #ifdef __ARC_NORM__
@@ -221,8 +221,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
     }									\
   while (0)
 #define COUNT_LEADING_ZEROS_0 32
-#endif
-#endif
+#endif /* __ARC_NORM__ */
+#endif /* __arc__ */
 
 #if defined (__arm__) && (defined (__thumb2__) || !defined (__thumb__)) \
  && W_TYPE_SIZE == 32
@@ -858,42 +858,6 @@ extern UDItype __umulsidi3 (USItype, USItype);
 #endif
 #endif /* __mips__ */
 
-#if defined (__ns32000__) && W_TYPE_SIZE == 32
-#define umul_ppmm(w1, w0, u, v) \
-  ({union {UDItype __ll;						\
-	   struct {USItype __l, __h;} __i;				\
-	  } __xx;							\
-  __asm__ ("meid %2,%0"							\
-	   : "=g" (__xx.__ll)						\
-	   : "%0" ((USItype) (u)),					\
-	     "g" ((USItype) (v)));					\
-  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
-#define __umulsidi3(u, v) \
-  ({UDItype __w;							\
-    __asm__ ("meid %2,%0"						\
-	     : "=g" (__w)						\
-	     : "%0" ((USItype) (u)),					\
-	       "g" ((USItype) (v)));					\
-    __w; })
-#define udiv_qrnnd(q, r, n1, n0, d) \
-  ({union {UDItype __ll;						\
-	   struct {USItype __l, __h;} __i;				\
-	  } __xx;							\
-  __xx.__i.__h = (n1); __xx.__i.__l = (n0);				\
-  __asm__ ("deid %2,%0"							\
-	   : "=g" (__xx.__ll)						\
-	   : "0" (__xx.__ll),						\
-	     "g" ((USItype) (d)));					\
-  (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
-#define count_trailing_zeros(count,x) \
-  do {									\
-    __asm__ ("ffsd     %2,%0"						\
-	    : "=r" ((USItype) (count))					\
-	    : "0" ((USItype) 0),					\
-	      "r" ((USItype) (x)));					\
-  } while (0)
-#endif /* __ns32000__ */
-
 /* FIXME: We should test _IBMR2 here when we add assembly support for the
    system vendor compilers.
    FIXME: What's needed for gcc PowerPC VxWorks?  __vxworks__ is not good
@@ -1086,7 +1050,57 @@ extern UDItype __umulsidi3 (USItype, USItype);
   } while (0)
 #endif
 
-#if defined(__sh__) && (!defined (__SHMEDIA__) || !__SHMEDIA__) && W_TYPE_SIZE == 32
+#if defined(__riscv)
+#ifdef __riscv_mul
+#define __umulsidi3(u,v) ((UDWtype)(UWtype)(u) * (UWtype)(v))
+#define __muluw3(a, b) ((UWtype)(a) * (UWtype)(b))
+#else
+#if __riscv_xlen == 32
+  #define MULUW3 "call __mulsi3"
+#elif __riscv_xlen == 64
+  #define MULUW3 "call __muldi3"
+#else
+#error unsupport xlen
+#endif /* __riscv_xlen */
+/* We rely on the fact that MULUW3 doesn't clobber the t-registers.
+   It can get better register allocation result.  */
+#define __muluw3(a, b) \
+  ({ \
+    register UWtype __op0 asm ("a0") = a; \
+    register UWtype __op1 asm ("a1") = b; \
+    asm volatile (MULUW3 \
+                  : "+r" (__op0), "+r" (__op1) \
+                  : \
+                  : "ra", "a2", "a3"); \
+    __op0; \
+  })
+#endif /* __riscv_mul */
+#define umul_ppmm(w1, w0, u, v) \
+  do { \
+    UWtype __x0, __x1, __x2, __x3; \
+    UHWtype __ul, __vl, __uh, __vh; \
+ \
+    __ul = __ll_lowpart (u); \
+    __uh = __ll_highpart (u); \
+    __vl = __ll_lowpart (v); \
+    __vh = __ll_highpart (v); \
+ \
+    __x0 = __muluw3 (__ul, __vl); \
+    __x1 = __muluw3 (__ul, __vh); \
+    __x2 = __muluw3 (__uh, __vl); \
+    __x3 = __muluw3 (__uh, __vh); \
+ \
+    __x1 += __ll_highpart (__x0);/* this can't give carry */ \
+    __x1 += __x2; /* but this indeed can */ \
+    if (__x1 < __x2) /* did we get it? */ \
+      __x3 += __ll_B; /* yes, add it in the proper pos.  */ \
+ \
+    (w1) = __x3 + __ll_highpart (__x1); \
+    (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
+  } while (0)
+#endif /* __riscv */
+
+#if defined(__sh__) && W_TYPE_SIZE == 32
 #ifndef __sh1__
 #define umul_ppmm(w1, w0, u, v) \
   __asm__ (								\
@@ -1159,21 +1173,6 @@ extern UDItype __umulsidi3 (USItype, USItype);
 
 #endif /* __sh__ */
 
-#if defined (__SH5__) && defined (__SHMEDIA__) && __SHMEDIA__ && W_TYPE_SIZE == 32
-#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
-#define count_leading_zeros(count, x) \
-  do									\
-    {									\
-      UDItype x_ = (USItype)(x);					\
-      SItype c_;							\
-									\
-      __asm__ ("nsb %1, %0" : "=r" (c_) : "r" (x_));			\
-      (count) = c_ - 31;						\
-    }									\
-  while (0)
-#define COUNT_LEADING_ZEROS_0 32
-#endif
-
 #if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \
     && W_TYPE_SIZE == 32
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#5 lore raw

PATCH 1/21 longlong.h: sync from gcc to fix ARC inline asm constraints

Quoted 10 lines · Joseph Myers
Quoted 6 lines · Vineet Gupta

This corresponds to the version

Author: law <law at 138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Jun 27 16:10:15 2017 +0000

* longlong.h: Remove ns32k support.

It seems odd to update from an out-of-date version of longlong.h, missing the subsequent RISC-V changes.

Sorry, that was way back when I started the port (not an excuse for sure).

Quoted 2 lines

So I've committed this patch instead to
update to the current version in GCC.

Thx, a lot. I'll drop this from v2.

Quoted 14 lines

Update longlong.h.

This patch updates longlong.h from GCC. There were no local changes in glibc (the previous version was identical to the r232143 GCC version, apart from copyright dates which had been updated in both places), so this patch makes it identical to the version in GCC again.

Tested for x86_64 and x86. Also tested with build-many-glibcs.py for its RISC-V configurations, as the glibc architecture with the most substantial changes in longlong.h in this patch.

2018-12-21 Joseph Myers <joseph at codesourcery.com>

* stdlib/longlong.h: Update from GCC.

#6 lore raw

PATCH 2/21 ARC: add definitions to elf/elf.h

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog |  1 +
 elf/elf.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 1 deletion(-)
ChangeLog +1 -0
index 456e4b670c23..3ec6eb82d2fe 100644
@@ -3,6 +3,7 @@
 	* sysdeps/unix/make-syscalls.sh: Fix comment referencing
 	syscall-template file.
 	* stdlib/longlong.h: Fix asm constraints for ARC code.
+	* elf/elf.h: add defines for ARC.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
elf/elf.h +69 -1

82 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH 3/21 ARC: ABI Implementation

In reply to Vineet Gupta

This code deals with the ARC ABI.

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                    | 20 ++++++++++++
 sysdeps/arc/__longjmp.S      | 50 ++++++++++++++++++++++++++++
 sysdeps/arc/abort-instr.h    |  2 ++
 sysdeps/arc/bits/endian.h    | 12 +++++++
 sysdeps/arc/bits/setjmp.h    | 33 +++++++++++++++++++
 sysdeps/arc/bsd-_setjmp.S    |  1 +
 sysdeps/arc/bsd-setjmp.S     |  1 +
 sysdeps/arc/crti.S           | 77 ++++++++++++++++++++++++++++++++++++++++++++
 sysdeps/arc/crtn.S           | 56 ++++++++++++++++++++++++++++++++
 sysdeps/arc/dl-runtime.c     | 21 ++++++++++++
 sysdeps/arc/dl-sysdep.h      | 25 ++++++++++++++
 sysdeps/arc/dl-trampoline.S  | 72 +++++++++++++++++++++++++++++++++++++++++
 sysdeps/arc/gccframe.h       | 21 ++++++++++++
 sysdeps/arc/gmp-mparam.h     | 23 +++++++++++++
 sysdeps/arc/jmpbuf-offsets.h | 46 ++++++++++++++++++++++++++
 sysdeps/arc/jmpbuf-unwind.h  | 47 +++++++++++++++++++++++++++
 sysdeps/arc/machine-gmon.h   | 33 +++++++++++++++++++
 sysdeps/arc/memusage.h       | 23 +++++++++++++
 sysdeps/arc/setjmp.S         | 64 ++++++++++++++++++++++++++++++++++++
 sysdeps/arc/sysdep.h         | 49 ++++++++++++++++++++++++++++
 sysdeps/arc/tls-macros.h     | 29 +++++++++++++++++
 21 files changed, 705 insertions(+)
 create mode 100644 sysdeps/arc/__longjmp.S
 create mode 100644 sysdeps/arc/abort-instr.h
 create mode 100644 sysdeps/arc/bits/endian.h
 create mode 100644 sysdeps/arc/bits/setjmp.h
 create mode 100644 sysdeps/arc/bsd-_setjmp.S
 create mode 100644 sysdeps/arc/bsd-setjmp.S
 create mode 100644 sysdeps/arc/crti.S
 create mode 100644 sysdeps/arc/crtn.S
 create mode 100644 sysdeps/arc/dl-runtime.c
 create mode 100644 sysdeps/arc/dl-sysdep.h
 create mode 100644 sysdeps/arc/dl-trampoline.S
 create mode 100644 sysdeps/arc/gccframe.h
 create mode 100644 sysdeps/arc/gmp-mparam.h
 create mode 100644 sysdeps/arc/jmpbuf-offsets.h
 create mode 100644 sysdeps/arc/jmpbuf-unwind.h
 create mode 100644 sysdeps/arc/machine-gmon.h
 create mode 100644 sysdeps/arc/memusage.h
 create mode 100644 sysdeps/arc/setjmp.S
 create mode 100644 sysdeps/arc/sysdep.h
 create mode 100644 sysdeps/arc/tls-macros.h
ChangeLog +20 -0
index 3ec6eb82d2fe..c2efdafa9861 100644
@@ -4,6 +4,26 @@
 	syscall-template file.
 	* stdlib/longlong.h: Fix asm constraints for ARC code.
 	* elf/elf.h: add defines for ARC.
+	* sysdeps/arc/__longjmp.S: New file.
+	* sysdeps/arc/abort-instr.h: New file.
+	* sysdeps/arc/bits/endian.h: New file.
+	* sysdeps/arc/bits/setjmp.h: New file.
+	* sysdeps/arc/bsd-_setjmp.S: New file.
+	* sysdeps/arc/bsd-setjmp.S: New file.
+	* sysdeps/arc/crti.S: New file.
+	* sysdeps/arc/crtn.S: New file.
+	* sysdeps/arc/dl-runtime.c: New file.
+	* sysdeps/arc/dl-sysdep.h: New file.
+	* sysdeps/arc/dl-trampoline.S: New file.
+	* sysdeps/arc/gccframe.h: New file.
+	* sysdeps/arc/gmp-mparam.h: New file.
+	* sysdeps/arc/jmpbuf-offsets.h: New file.
+	* sysdeps/arc/jmpbuf-unwind.h: New file.
+	* sysdeps/arc/machine-gmon.h: New file.
+	* sysdeps/arc/memusage.h: New file.
+	* sysdeps/arc/setjmp.S: New file.
+	* sysdeps/arc/sysdep.h: New file.
+	* sysdeps/arc/tls-macros.h: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/__longjmp.S new file +50 -0

50 lines not on this page · raw message

sysdeps/arc/abort-instr.h new file +2 -0
new file mode 100644
index 000000000000..474098e9a819
@@ -0,0 +1,2 @@
+/* FLAG 1 is privilege mode only instruction, hence will crash any program */
+#define ABORT_INSTRUCTION asm ("flag 1")
sysdeps/arc/bits/endian.h new file +12 -0
new file mode 100644
index 000000000000..88fbcf39a58a
@@ -0,0 +1,12 @@
+/* The ARC architecture has selectable endianness.  */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#ifdef __BIG_ENDIAN__
+# define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#ifdef __LITTLE_ENDIAN__
+# define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
sysdeps/arc/bits/setjmp.h new file +33 -0
new file mode 100644
index 000000000000..3a014955ee5a
@@ -0,0 +1,33 @@
+/* Define the machine-dependent type `jmp_buf'.  ARC version.
+   Copyright (C) 1992-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 _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined(_SETJMP_H) && !defined(_PTHREAD_H)
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef __ASSEMBLER__
+
+/* Saves r13-r25 (callee-saved), fp (frame pointer), sp (stack pointer),
+ * blink (branch-n-link) */
+typedef int __jmp_buf[32];
+#endif
+
+#endif
sysdeps/arc/bsd-_setjmp.S new file +1 -0
new file mode 100644
index 000000000000..4e6a2da560c4
@@ -0,0 +1 @@
+/* _setjmp is in setjmp.S  */
sysdeps/arc/bsd-setjmp.S new file +1 -0
new file mode 100644
index 000000000000..1da848d2f1ee
@@ -0,0 +1 @@
+/* setjmp is in setjmp.S  */
sysdeps/arc/crti.S new file +77 -0

77 lines not on this page · raw message

sysdeps/arc/crtn.S new file +56 -0

56 lines not on this page · raw message

sysdeps/arc/dl-runtime.c new file +21 -0
new file mode 100644
index 000000000000..76d39fab5ab8
@@ -0,0 +1,21 @@
+/* PLT jump into resolver passes PC of PLTn, while _dl_fixup expects the
+   address of corresponding .rela.plt entry */
+
+#ifdef __A7__
+#define ARC_PLT_SIZE	12
+#else
+#define ARC_PLT_SIZE	16
+#endif
+
+#define reloc_index					\
+({							\
+  unsigned long plt0 = D_PTR (l, l_info[DT_PLTGOT]);	\
+  unsigned long pltn = reloc_arg;			\
+  /* exclude PL0 and PLT1 */				\
+  unsigned long idx = (pltn - plt0)/ARC_PLT_SIZE - 2;	\
+  idx;							\
+})
+
+#define reloc_offset reloc_index * sizeof (PLTREL)
+
+#include <elf/dl-runtime.c>
sysdeps/arc/dl-sysdep.h new file +25 -0
new file mode 100644
index 000000000000..a3e734c1020c
@@ -0,0 +1,25 @@
+/* System-specific settings for dynamic linker code.  ARC version.
+   Copyright (C) 2009-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/>.  */
+
+#include_next <dl-sysdep.h>
+
+/* _dl_argv cannot be attribute_relro, because _dl_start_user
+   might write into it after _dl_start returns.  */
+#define DL_ARGV_NOT_RELRO 1
+
+#define DL_EXTERN_PROTECTED_DATA
sysdeps/arc/dl-trampoline.S new file +72 -0

72 lines not on this page · raw message

sysdeps/arc/gccframe.h new file +21 -0
new file mode 100644
index 000000000000..54a1225284b6
@@ -0,0 +1,21 @@
+/* Definition of object in frame unwind info.  ARC version.
+   Copyright (C) 2017-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/>.  */
+
+#define FIRST_PSEUDO_REGISTER 40
+
+#include <sysdeps/generic/gccframe.h>
sysdeps/arc/gmp-mparam.h new file +23 -0
new file mode 100644
index 000000000000..2b09517766e3
@@ -0,0 +1,23 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP Library; see the file COPYING.LIB.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include <sysdeps/generic/gmp-mparam.h>
+
+#define IEEE_DOUBLE_BIG_ENDIAN 0
sysdeps/arc/jmpbuf-offsets.h new file +46 -0

46 lines not on this page · raw message

sysdeps/arc/jmpbuf-unwind.h new file +47 -0

47 lines not on this page · raw message

sysdeps/arc/machine-gmon.h new file +33 -0
new file mode 100644
index 000000000000..55facf77a858
@@ -0,0 +1,33 @@
+/* Machine-dependent definitions for profiling support.  ARC version.
+   Copyright (C) 1996-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/>.  */
+
+#include <sysdep.h>
+
+#define _MCOUNT_DECL(frompc, selfpc)
+static void __mcount_internal (unsigned long frompc, unsigned long selfpc)
+
+/* this is very simple as gcc does all the heavy lifting at _mcount call site
+ *  - sets up caller's blink in r0, so frompc is setup correctly
+ *  - preserve argument registers for original call */
+
+#define MCOUNT								\
+void _mcount (void *frompc)						\
+{									\
+  __mcount_internal ((unsigned long int) frompc,				\
+		   (unsigned long int) __builtin_return_address(0));	\
+}
sysdeps/arc/memusage.h new file +23 -0
new file mode 100644
index 000000000000..536f1fdbf614
@@ -0,0 +1,23 @@
+/* Machine-specific definitions for memory usage profiling, ARC version.
+   Copyright (C) 2000-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/>.  */
+
+#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
+
+#define uatomic32_t unsigned int
+
+#include <sysdeps/generic/memusage.h>
sysdeps/arc/setjmp.S new file +64 -0

64 lines not on this page · raw message

sysdeps/arc/sysdep.h new file +49 -0

49 lines not on this page · raw message

sysdeps/arc/tls-macros.h new file +29 -0
new file mode 100644
index 000000000000..51855edef6e7
@@ -0,0 +1,29 @@
+/* Macros to support TLS testing in times of missing compiler support.  */
+
+/* For now */
+#define TLS_LD(x)	TLS_IE(x)
+
+#define TLS_GD(x)					\
+  ({ int *__result;					\
+     __asm__ ("add r0, pcl, @" #x "@tlsgd      \n"     	\
+	  ".tls_gd_ld " #x "`bl __tls_get_addr at plt \n"	\
+	  "mov %0, r0                    \n"		\
+	  : "=&r" (__result)				\
+	  ::"r0","r1","r2","r3","r4","r5","r6","r7",	\
+	    "r8","r9","r10","r11","r12");		\
+     __result; })
+
+#define TLS_LE(x)					\
+  ({ int *__result;					\
+     void *tp = __builtin_thread_pointer();		\
+     __asm__ ("add %0, %1, @" #x "@tpoff   \n"		\
+	  : "=r" (__result) : "r"(tp));	        	\
+     __result; })
+
+#define TLS_IE(x)					\
+  ({ int *__result;					\
+     void *tp = __builtin_thread_pointer();		\
+     __asm__ ("ld %0, [pcl, @" #x "@tlsie]      \n"     \
+	  "add %0, %1, %0                       \n"	\
+	  : "=&r" (__result) : "r" (tp));		\
+     __result; })
Signature · 1 line
2.7.4
#8 lore raw

PATCH 3/21 ARC: ABI Implementation

Quoted 1 line · Vineet Gupta

+/* FLAG 1 is privilege mode only instruction, hence will crash any program */

Generally, throughout the port, make sure comments end ". " (full stop, two spaces, end of comment). I won't remark on other places with this formatting issue.

sysdeps/arc/crti.S

Quoted 1 line
sysdeps/arc/crti.S +0 -0

As a new port I think it would be best to use init_array in your Implies file so you don't need these crti / crtn files, and make GCC generate init_array / fini_array exclusively. (See RISC-V and C-Sky discussions of this issue.)

sysdeps/arc/crti.S

Quoted 5 lines
sysdeps/arc/crti.S +5 -0
+#ifdef __A7__
+#define ARC_PLT_SIZE	12
+#else
+#define ARC_PLT_SIZE	16
+#endif

Except for the multiple-include guards round a whole header file, preprocessor directives inside #if should have indentation in glibc, so "# define" (and "# define" inside two levels of #if, etc.). (As usual, fix this throughout the port; I won't list other individual places with this issue.)

sysdeps/arc/crti.S

Quoted 5 lines
sysdeps/arc/crti.S +5 -0
+#define reloc_index					\
+({							\
+  unsigned long plt0 = D_PTR (l, l_info[DT_PLTGOT]);	\
+  unsigned long pltn = reloc_arg;			\
+  /* exclude PL0 and PLT1 */				\

Note the first letter of a comment should be capitalized (in addition to ending with ". ").

Quoted 1 line

+ unsigned long idx = (pltn - plt0)/ARC_PLT_SIZE - 2; \

glibc style uses "unsigned long int", not just "unsigned long".

sysdeps/arc/tls-macros.h line 1

Quoted 7 lines
sysdeps/arc/tls-macros.h new file +1 -0
new file mode 100644
index 000000000000..51855edef6e7
@@ -0,0 +1,29 @@
+/* Macros to support TLS testing in times of missing compiler support.  */

Any file more than ten lines long should have copyright and license notices.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#9 lore raw

PATCH 3/21 ARC: ABI Implementation

Quoted 7 lines · Joseph Myers
Quoted 1 line · Vineet Gupta

+/* FLAG 1 is privilege mode only instruction, hence will crash any program */

Generally, throughout the port, make sure comments end ". " (full stop, two spaces, end of comment). I won't remark on other places with this formatting issue.

OK. Fixed series wide.

Quoted 6 lines

sysdeps/arc/crti.S

Quoted 1 line
sysdeps/arc/crti.S +0 -0

As a new port I think it would be best to use init_array in your Implies file so you don't need these crti / crtn files, and make GCC generate init_array / fini_array exclusively. (See RISC-V and C-Sky discussions of this issue.)

OK I can try enabling this !

Quoted 11 lines

sysdeps/arc/crti.S

Quoted 5 lines
sysdeps/arc/crti.S +5 -0
+#ifdef __A7__
+#define ARC_PLT_SIZE	12
+#else
+#define ARC_PLT_SIZE	16
+#endif

Except for the multiple-include guards round a whole header file, preprocessor directives inside #if should have indentation in glibc, so "# define" (and "# define" inside two levels of #if, etc.). (As usual, fix this throughout the port; I won't list other individual places with this issue.)

Done series wide.

Quoted 10 lines

sysdeps/arc/crti.S

Quoted 6 lines
sysdeps/arc/crti.S +5 -0
+#define reloc_index					\
+({							\
+  unsigned long plt0 = D_PTR (l, l_info[DT_PLTGOT]);	\
+  unsigned long pltn = reloc_arg;			\
+  /* exclude PL0 and PLT1 */				\

Note the first letter of a comment should be capitalized (in addition to ending with ". ").

Quoted 3 lines
Quoted 1 line

+ unsigned long idx = (pltn - plt0)/ARC_PLT_SIZE - 2; \

glibc style uses "unsigned long int", not just "unsigned long".

Done series wide.

Quoted 10 lines

sysdeps/arc/tls-macros.h line 1

Quoted 7 lines
sysdeps/arc/tls-macros.h new file +1 -0
new file mode 100644
index 000000000000..51855edef6e7
@@ -0,0 +1,29 @@
+/* Macros to support TLS testing in times of missing compiler support.  */

Any file more than ten lines long should have copyright and license notices.

Done.

P.S. Is there a lint file or are these style guidelines in wiki somewhere. If not I can volunteer to capture them in a wiki/readme for future port submissions.

#10 lore raw

PATCH 3/21 ARC: ABI Implementation

Quoted 3 lines · Vineet Gupta

P.S. Is there a lint file or are these style guidelines in wiki somewhere. If not I can volunteer to capture them in a wiki/readme for future port submissions.

In addition to the GNU Coding Standards (which cover many things such as comment formatting and spaces before '('), we have
<https://sourceware.org/glibc/wiki/Style_and_Conventions> which discusses various glibc-specific details. If you find there are points of the style in glibc which aren't documented in either place, then, yes, it would be a good idea to add them to the wiki (I just added a few).

Architecture maintainers need wiki accounts in any case (to post test results for their architectures during every release freeze period), so you should create an account and post its name so someone can add it to EditorGroup so you can edit.

Where the formatting issues pointed out exist in some existing code in glibc, it might also make sense to fix that existing code to follow the standards more closely so it provides a better example for new code. However, such formatting changes to existing code may be controversial (especially for code that originally came from third-party sources using completely different formatting - though in my view, where such files are now maintained in glibc without ongoing updates from upstream, we ought to make the formatting consistent to simplify maintenance).

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#11 lore raw

PATCH 3/21 ARC: ABI Implementation

Quoted 4 lines · Joseph Myers

Architecture maintainers need wiki accounts in any case (to post test results for their architectures during every release freeze period), so you should create an account and post its name so someone can add it to EditorGroup so you can edit.

Created now: VineetGupta

Thx,
-Vineet

#12 lore raw

PATCH 3/21 ARC: ABI Implementation

Quoted 7 lines · Vineet Gupta
Quoted 4 lines · Joseph Myers

Architecture maintainers need wiki accounts in any case (to post test results for their architectures during every release freeze period), so you should create an account and post its name so someone can add it to EditorGroup so you can edit.

Created now: VineetGupta

Added to EditorGroup.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#13 lore raw

ARC binutils init/fini (was Re: [PATCH 03/21] ARC: ABI Implementation)

In reply to Joseph Myers
Quoted 6 lines · Joseph Myers

sysdeps/arc/crti.S

Quoted 1 line
sysdeps/arc/crti.S +0 -0

As a new port I think it would be best to use init_array in your Implies file so you don't need these crti / crtn files, and make GCC generate init_array / fini_array exclusively. (See RISC-V and C-Sky discussions of this issue.)

I did the switch and while is working, there are additional test failures

| FAIL: dlfcn/bug-atexit1
| FAIL: dlfcn/bug-atexit2
| FAIL: dlfcn/tstatexit
| FAIL: dlfcn/tstcxaatexit
| FAIL: nptl/tst-atfork2
| FAIL: nptl/tst-cond17
| FAIL: stdlib/test-dlclose-exit-race

In the failing case, the dsos are NOT getting the DT_INIT/DT_FINI dynamic tags

Consider glibc test dlfcn/tstatexit, which uses a dso modatexit.so

In good case

| arc-linux-readelf -a modatexit.os
|
| Section Headers:
|  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
|  [ 9] .init             PROGBITS        0000047c 00047c 000044 00  AX  0   0  4
|  [12] .fini             PROGBITS        000006f8 0006f8 000028 00  AX  0   0  4
|
| Dynamic section at offset 0x1f08 contains 23 entries:
|  0x0000000c (INIT)                       0x47c
|  0x0000000d (FINI)                       0x6f8

In broken case, init/fini sections exist, but DT_INI/DT_FINI are missing.

|
| Dynamic section at offset 0x1f2c contains 19 entries: <-- missing INIT/FINI
|

I suspected some bintuils/gcc shenanigans and tried hacking around, but was led far too astray.

(1). gcc config test failing (false alaram)

| host-gcc-final-ab544139bfee/build/gcc/config.log
|
|configure:22941: checking for .preinit_array/.init_array/.fini_array support
|configure:23106: checking cross compile... guessing
|configure:23111: result: no

gcc was seemingly built w/o init_array support leading to inclusion of default gcc/config/initfini-array.h
However doing a glibc aarch64 build I see the same output so perhaps it is not relevant.

(2). ARC binutils port seems to hardwire _init/_fini (and the only arch to do that) so I ripped out the relevant handling from ld, but that doesn't help.

https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb/commit/56771171fa7cb9e31c65e26a656a8588d603d924

So I'm not sure if this is deficiency of linker emulation script or code ld/bfd etc..

-Vineet

#14 lore raw

ARC binutils init/fini (was Re: [PATCH 03/21] ARC: ABI Implementation)

Quoted 2 lines · Vineet Gupta

In the failing case, the dsos are NOT getting the DT_INIT/DT_FINI dynamic tags

And they shouldn't be (they should have DT_INIT_ARRAY / DT_FINI_ARRAY instead).

Quoted 8 lines

(1). gcc config test failing (false alaram)

| host-gcc-final-ab544139bfee/build/gcc/config.log
|
|configure:22941: checking for .preinit_array/.init_array/.fini_array support
|configure:23106: checking cross compile... guessing
|configure:23111: result: no
Quoted 4 lines

gcc was seemingly built w/o init_array support leading to inclusion of default gcc/config/initfini-array.h
However doing a glibc aarch64 build I see the same output so perhaps it is not relevant.

This was discussed at length in the C-Sky discussion. In short: the proper fix is to change that configure test to apply for cross compilation as well, other than in the very limited case where it tries to run something (but doing so is not appropriate in the current regression-fixes-only GCC development stage). You can hack around it with gcc_cv_initfini_array=yes for the target in config.gcc, as done by a few architectures. Or you can define the relevant target macros in gcc/config/<arch>/<something>.h to force init_array / fini_array use independent of the configure test, as done for AArch64.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#15 lore raw

ARC binutils init/fini (was Re: [PATCH 03/21] ARC: ABI Implementation)

Quoted 9 lines · Joseph Myers

This was discussed at length in the C-Sky discussion. In short: the proper fix is to change that configure test to apply for cross compilation as well, other than in the very limited case where it tries to run something (but doing so is not appropriate in the current regression-fixes-only GCC development stage). You can hack around it with gcc_cv_initfini_array=yes for the target in config.gcc, as done by a few architectures. Or you can define the relevant target macros in gcc/config/<arch>/<something>.h to force init_array / fini_array use independent of the configure test, as done for AArch64.

Awesome, now I see how it was working for RISCV (config test printed "cached") and AArch64
I've added a local hack to gcc.config to test things out and will tackle this over at gcc mailing list.

Many thx for untangling this for me. I found the C-Sky discussion as well [1] adding a link here for someone else in future who trips on this again.

-Vineet

[1] https://sourceware.org/ml/libc-alpha/2018-11/msg00870.html

#16 lore raw

PATCH 4/21 ARC: startup and dynamic linking code

In reply to Vineet Gupta

Code for C runtime startup and dynamic loading including PLT layout.

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                 |   6 +
 sysdeps/arc/bits/link.h   |  52 ++++++++
 sysdeps/arc/dl-machine.h  | 333 ++++++++++++++++++++++++++++++++++++++++++++++
 sysdeps/arc/ldsodefs.h    |  43 ++++++
 sysdeps/arc/sotruss-lib.c |  51 +++++++
 sysdeps/arc/start.S       |  81 +++++++++++
 sysdeps/arc/tst-audit.h   |  23 ++++
 7 files changed, 589 insertions(+)
 create mode 100644 sysdeps/arc/bits/link.h
 create mode 100644 sysdeps/arc/dl-machine.h
 create mode 100644 sysdeps/arc/ldsodefs.h
 create mode 100644 sysdeps/arc/sotruss-lib.c
 create mode 100644 sysdeps/arc/start.S
 create mode 100644 sysdeps/arc/tst-audit.h
ChangeLog +6 -0
index c2efdafa9861..fd5602bde1a7 100644
@@ -24,6 +24,12 @@
 	* sysdeps/arc/setjmp.S: New file.
 	* sysdeps/arc/sysdep.h: New file.
 	* sysdeps/arc/tls-macros.h: New file.
+	* sysdeps/arc/bits/link.h: New file.
+	* sysdeps/arc/dl-machine.h: New file.
+	* sysdeps/arc/ldsodefs.h: New file.
+	* sysdeps/arc/sotruss-lib.c: New file.
+	* sysdeps/arc/start.S: New file.
+	* sysdeps/arc/tst-audit.h: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/bits/link.h new file +52 -0

52 lines not on this page · raw message

sysdeps/arc/dl-machine.h new file +333 -0

333 lines not on this page · raw message

sysdeps/arc/ldsodefs.h new file +43 -0

43 lines not on this page · raw message

sysdeps/arc/sotruss-lib.c new file +51 -0

51 lines not on this page · raw message

sysdeps/arc/start.S new file +81 -0

81 lines not on this page · raw message

sysdeps/arc/tst-audit.h new file +23 -0
new file mode 100644
index 000000000000..8ae3734cd50c
@@ -0,0 +1,23 @@
+/* Definitions for testing PLT entry/exit auditing.  ARC version.
+   Copyright (C) 2009-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/>.  */
+
+#define pltenter la_arc_gnu_pltenter
+#define pltexit la_arc_gnu_pltexit
+#define La_regs La_arc_regs
+#define La_retval La_arc_retval
+#define int_retval lrv_reg[0]
Signature · 1 line
2.7.4
#17 lore raw

PATCH 4/21 ARC: startup and dynamic linking code

Quoted 3 lines · Vineet Gupta

+/*
+ * Dynamic Linking ABI for ARCv2 ISA
+ *

glibc does not use leading '*' on each line of a comment (needs fixing throughout this file).

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#18 lore raw

PATCH 4/21 ARC: startup and dynamic linking code

Quoted 7 lines · Joseph Myers
Quoted 3 lines · Vineet Gupta

+/*
+ * Dynamic Linking ABI for ARCv2 ISA
+ *

glibc does not use leading '*' on each line of a comment (needs fixing throughout this file).

OK !

#19 lore raw

PATCH 5/21 ARC: Thread Local Storage support

In reply to Vineet Gupta

This includes all 4 TLS addressing models

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                        |   5 ++
 sysdeps/arc/dl-tls.h             |  30 ++++++++
 sysdeps/arc/libc-tls.c           |  27 +++++++
 sysdeps/arc/nptl/tcb-offsets.sym |  11 +++
 sysdeps/arc/nptl/tls.h           | 150 +++++++++++++++++++++++++++++++++++++++
 sysdeps/arc/stackinfo.h          |  33 +++++++++
 6 files changed, 256 insertions(+)
 create mode 100644 sysdeps/arc/dl-tls.h
 create mode 100644 sysdeps/arc/libc-tls.c
 create mode 100644 sysdeps/arc/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/arc/nptl/tls.h
 create mode 100644 sysdeps/arc/stackinfo.h
ChangeLog +5 -0
index fd5602bde1a7..6e53b171a72d 100644
@@ -30,6 +30,11 @@
 	* sysdeps/arc/sotruss-lib.c: New file.
 	* sysdeps/arc/start.S: New file.
 	* sysdeps/arc/tst-audit.h: New file.
+	* sysdeps/arc/dl-tls.h: New file.
+	* sysdeps/arc/libc-tls.c: New file.
+	* sysdeps/arc/nptl/tcb-offsets.sym: New file.
+	* sysdeps/arc/nptl/tls.h: New file.
+	* sysdeps/arc/stackinfo.h: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/dl-tls.h new file +30 -0
new file mode 100644
index 000000000000..42b5df9ca4da
@@ -0,0 +1,30 @@
+/* Thread-local storage handling in the ELF dynamic linker.  ARC version.
+   Copyright (C) 2012-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/>.  */
+
+
+/* Type used for the representation of TLS information in the GOT.  */
+typedef struct
+{
+  unsigned long int ti_module;
+  unsigned long int ti_offset;
+} tls_index;
+
+extern void *__tls_get_addr (tls_index *ti);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
sysdeps/arc/libc-tls.c new file +27 -0
new file mode 100644
index 000000000000..c6c865daac3e
@@ -0,0 +1,27 @@
+/* Thread-local storage handling in the ELF dynamic linker.  ARC version.
+   Copyright (C) 2005-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/>.  */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+  dtv_t *dtv = THREAD_DTV ();
+  return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
sysdeps/arc/nptl/tcb-offsets.sym new file +11 -0
new file mode 100644
index 000000000000..56950e0676ed
@@ -0,0 +1,11 @@
+#include <sysdep.h>
+#include <tls.h>
+
+-- Derive offsets relative to the thread register.
+#define thread_offsetof(mem)	(long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
+
+MULTIPLE_THREADS_OFFSET		offsetof (struct pthread, header.multiple_threads)
+TLS_PRE_TCB_SIZE		sizeof (struct pthread)
+TLS_TCB_SIZE            	sizeof(tcbhead_t)
+
+PTHREAD_TID			offsetof(struct pthread, tid)
sysdeps/arc/nptl/tls.h new file +150 -0

150 lines not on this page · raw message

sysdeps/arc/stackinfo.h new file +33 -0
new file mode 100644
index 000000000000..42821ada1027
@@ -0,0 +1,33 @@
+/* Stack environment definitions for ARC.
+   Copyright (C) 2012-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/>.  */
+
+/* This file contains a bit of information about the stack allocation
+   of the processor.  */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H	1
+
+#include <elf.h>
+
+/* On ARC the stack grows down.  */
+#define _STACK_GROWS_DOWN	1
+
+/* Default to a non-executable stack.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W)
+
+#endif	/* stackinfo.h */
Signature · 1 line
2.7.4
#20 lore raw

PATCH 6/21 ARC: Atomics and Locking primitives

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                 |  3 ++
 sysdeps/arc/atomic-machine.h              | 89 +++++++++++++++++++++++++++++++
 sysdeps/arc/nptl/bits/pthreadtypes-arch.h | 72 +++++++++++++++++++++++++
 sysdeps/arc/nptl/bits/semaphore.h         | 32 +++++++++++
 4 files changed, 196 insertions(+)
 create mode 100644 sysdeps/arc/atomic-machine.h
 create mode 100644 sysdeps/arc/nptl/bits/pthreadtypes-arch.h
 create mode 100644 sysdeps/arc/nptl/bits/semaphore.h
ChangeLog +3 -0
index 6e53b171a72d..d2f6cd2d0d09 100644
@@ -35,6 +35,9 @@
 	* sysdeps/arc/nptl/tcb-offsets.sym: New file.
 	* sysdeps/arc/nptl/tls.h: New file.
 	* sysdeps/arc/stackinfo.h: New file.
+	* sysdeps/arc/atomic-machine.h: New file.
+	* sysdeps/arc/nptl/bits/pthreadtypes-arch.h: New file.
+	* sysdeps/arc/nptl/bits/semaphore.h: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/atomic-machine.h new file +89 -0

89 lines not on this page · raw message

sysdeps/arc/nptl/bits/pthreadtypes-arch.h new file +72 -0

72 lines not on this page · raw message

sysdeps/arc/nptl/bits/semaphore.h new file +32 -0
new file mode 100644
index 000000000000..1ecc8ab8a65b
@@ -0,0 +1,32 @@
+/* Machine-specific POSIX semaphore type layouts.  ARC version.
+   Copyright (C) 2002-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 _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#define __SIZEOF_SEM_T	16
+
+/* Value returned if `sem_open' failed.  */
+#define SEM_FAILED      ((sem_t *) 0)
+
+typedef union
+{
+  char __size[__SIZEOF_SEM_T];
+  long int __align;
+} sem_t;
Signature · 1 line
2.7.4
#21 lore raw

PATCH 6/21 ARC: Atomics and Locking primitives

Quoted 1 line · Vineet Gupta

+#define USE_ATOMIC_COMPILER_BUILTINS 0

There is a strong preference for new ports to use 1 for this rather than 0 (and not to have any asms in their atomic-machine.h unless there's some reason use of built-in functions is unsuitable) - see the recently posted C-Sky version, for example. If you can't use 1, there should be a good reason, documented in a comment, for using asms instead of compiler built-in functions (e.g. if the compiler built-in functions would result in libatomic dependencies, which are unsuitable for glibc, rather than being expanded inline).

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#22 lore raw

PATCH 6/21 ARC: Atomics and Locking primitives

Quoted 4 lines · Joseph Myers
Quoted 1 line · Vineet Gupta

+#define USE_ATOMIC_COMPILER_BUILTINS 0

Quoted 8 lines

There is a strong preference for new ports to use 1 for this rather than 0 (and not to have any asms in their atomic-machine.h unless there's some reason use of built-in functions is unsuitable) - see the recently posted C-Sky version, for example. If you can't use 1, there should be a good reason, documented in a comment, for using asms instead of compiler built-in functions (e.g. if the compiler built-in functions would result in libatomic dependencies, which are unsuitable for glibc, rather than being expanded inline).

I tried switching to builtins and see the resulting differences in generated code:
there's one snafu to begin with: gcc seems to be generating a DMB 0 for the barriers, which is a no-op, it needs to be DMB {1,2,3} for read, write, control... so that needs fixing there.

#23 lore raw

PATCH 7/21 ARC: math soft float support

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                |  6 +++
 sysdeps/arc/bits/fenv.h                  | 92 ++++++++++++++++++++++++++++++++
 sysdeps/arc/math_private.h               |  6 +++
 sysdeps/arc/nofpu/Implies                |  1 +
 sysdeps/arc/nofpu/math-tests-exception.h | 27 ++++++++++
 sysdeps/arc/nofpu/math-tests-rounding.h  | 27 ++++++++++
 sysdeps/arc/sfp-machine.h                | 51 ++++++++++++++++++
 7 files changed, 210 insertions(+)
 create mode 100644 sysdeps/arc/bits/fenv.h
 create mode 100644 sysdeps/arc/math_private.h
 create mode 100644 sysdeps/arc/nofpu/Implies
 create mode 100644 sysdeps/arc/nofpu/math-tests-exception.h
 create mode 100644 sysdeps/arc/nofpu/math-tests-rounding.h
 create mode 100644 sysdeps/arc/sfp-machine.h
ChangeLog +6 -0
index d2f6cd2d0d09..b946f57204b6 100644
@@ -38,6 +38,12 @@
 	* sysdeps/arc/atomic-machine.h: New file.
 	* sysdeps/arc/nptl/bits/pthreadtypes-arch.h: New file.
 	* sysdeps/arc/nptl/bits/semaphore.h: New file.
+	* sysdeps/arc/bits/fenv.h: New file.
+	* sysdeps/arc/math_private.h: New file.
+	* sysdeps/arc/nofpu/Implies: New file.
+	* sysdeps/arc/nofpu/math-tests-exception.h: New file.
+	* sysdeps/arc/nofpu/math-tests-rounding.h: New file.
+	* sysdeps/arc/sfp-machine.h: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/bits/fenv.h new file +92 -0

92 lines not on this page · raw message

sysdeps/arc/math_private.h new file +6 -0
new file mode 100644
index 000000000000..35046d842533
@@ -0,0 +1,6 @@
+#ifndef ARC_MATH_PRIVATE_H
+#define ARC_MATH_PRIVATE_H
+
+#include_next <math_private.h>
+
+#endif
sysdeps/arc/nofpu/Implies new file +1 -0
new file mode 100644
index 000000000000..abcbadb25f22
@@ -0,0 +1 @@
+ieee754/soft-fp
sysdeps/arc/nofpu/math-tests-exception.h new file +27 -0
new file mode 100644
index 000000000000..bb338388d8af
@@ -0,0 +1,27 @@
+/* Configuration for math tests. exceptions support ARC version.
+   Copyright (C) 2017-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 ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H
+#define ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H 1
+
+/* soft-float doesnot support exceptions */
+#define EXCEPTION_TESTS_float		0
+#define EXCEPTION_TESTS_double		0
+#define EXCEPTION_TESTS_long_double	0
+
+#endif
sysdeps/arc/nofpu/math-tests-rounding.h new file +27 -0
new file mode 100644
index 000000000000..e371e647db13
@@ -0,0 +1,27 @@
+/* Configuration for math tests: rounding mode support.  ARC version.
+   Copyright (C) 2017-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 ARC_NOFPU_MATH_TESTS_ROUNDING_H
+#define ARC_NOFPU_MATH_TESTS_ROUNDING_H 1
+
+/* soft-float only supports to-nearest rounding mode  */
+#define ROUNDING_TESTS_float(MODE)		((MODE) == FE_TONEAREST)
+#define ROUNDING_TESTS_double(MODE)		((MODE) == FE_TONEAREST)
+#define ROUNDING_TESTS_long_double(MODE)	((MODE) == FE_TONEAREST)
+
+#endif
sysdeps/arc/sfp-machine.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.7.4
#24 lore raw

PATCH 7/21 ARC: math soft float support

Quoted 1 line · Vineet Gupta

+#if defined(__ARC_FPU_SP__) || defined(__ARC_FPU_DP__)

Missing spaces before '(' (should have such spaces in most cases between an identifier or keyword and '(' - calls to "defined", calls to functions, calls to macros, __attribute__, etc. - except for a few cases of calls to macros such as ElfW where the result is logically used like an identifier).

sysdeps/arc/bits/fenv.h line 65

Quoted 2 lines
sysdeps/arc/bits/fenv.h new file +2 -0
+/* In the soft-float case, only rounding to nearest is supported, with
+   no exceptions.  */

To confirm: hard-float and soft-float are always different ABIs; you don't support hard-float compilation using the soft-float function calling ABI (like is supported for ARM and RISC-V, for example)? (If you support hard-float compilation with the soft-float ABI, it would be problematic to have different FE_TONEAREST values in the two cases - ARM and RISC-V both define all the FE_* macros independently of whether hard or soft float is used, because they support that case.)

sysdeps/arc/math_private.h

Quoted 1 line
sysdeps/arc/math_private.h +0 -0

This file should not be needed now.

sysdeps/arc/nofpu/math-tests-exception.h

Quoted 1 line
sysdeps/arc/nofpu/math-tests-exception.h +0 -0

This file does nothing (the name is wrong, the name actually used is math-tests-exceptions.h). And it should not be needed unless you support hard-float compilation with the soft-float ABI (and thus define all the FE_* names in bits/fenv.h even for soft-float).

sysdeps/arc/nofpu/math-tests-rounding.h

Quoted 1 line
sysdeps/arc/nofpu/math-tests-rounding.h +0 -0

Again, not needed unless hard-float compilation with the soft-float ABI is supported and bits/fenv.h has corresponding contents.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#25 lore raw

PATCH 7/21 ARC: math soft float support

Quoted 9 lines · Joseph Myers
Quoted 1 line · Vineet Gupta

+#if defined(__ARC_FPU_SP__) || defined(__ARC_FPU_DP__)

Missing spaces before '(' (should have such spaces in most cases between an identifier or keyword and '(' - calls to "defined", calls to functions, calls to macros, __attribute__, etc. - except for a few cases of calls to macros such as ElfW where the result is logically used like an identifier).

Or, of course, just omit the parentheses in the "defined" case, which is very common for calls to "defined" in glibc.

(Function-like macro definitions are a case where you *can't* have the space because the syntax of C requires no space between the name of the macro being defined and the '(' before the list of argument names.)

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#26 lore raw

PATCH 7/21 ARC: math soft float support

Quoted 10 lines · Joseph Myers
Quoted 8 lines · Joseph Myers
Quoted 1 line · Vineet Gupta

+#if defined(__ARC_FPU_SP__) || defined(__ARC_FPU_DP__)

Missing spaces before '(' (should have such spaces in most cases between an identifier or keyword and '(' - calls to "defined", calls to functions, calls to macros, __attribute__, etc. - except for a few cases of calls to macros such as ElfW where the result is logically used like an identifier).

Quoted 6 lines

Or, of course, just omit the parentheses in the "defined" case, which is very common for calls to "defined" in glibc.

(Function-like macro definitions are a case where you *can't* have the space because the syntax of C requires no space between the name of the macro being defined and the '(' before the list of argument names.)

Ok, done !

#27 lore raw

PATCH 7/21 ARC: math soft float support

In reply to Joseph Myers
Quoted 9 lines · Joseph Myers
Quoted 1 line · Vineet Gupta

+#if defined(__ARC_FPU_SP__) || defined(__ARC_FPU_DP__)

Missing spaces before '(' (should have such spaces in most cases between an identifier or keyword and '(' - calls to "defined", calls to functions, calls to macros, __attribute__, etc. - except for a few cases of calls to macros such as ElfW where the result is logically used like an identifier).

OK, I removed the parens in this case (update: removed the guard altogether, see below).

Quoted 6 lines

sysdeps/arc/bits/fenv.h line 65

Quoted 2 lines
sysdeps/arc/bits/fenv.h new file +2 -0
+/* In the soft-float case, only rounding to nearest is supported, with
+   no exceptions.  */

To confirm: hard-float and soft-float are always different ABIs; you don't support hard-float compilation using the soft-float function calling ABI (like is supported for ARM and RISC-V, for example)?

I'm still ramping up on hard-float, so pardon some of my naivety. It seems the function calling convention is no different for soft-float vs. hard-float. We have a single register file (hard FP instructions inherently use an additional accumulator but that isn't really passed around so doesn't affect calling convention). Other than that SP values go normally in a reg, DP go in reg pair just as any 64bit value.

OTOH, the ARC libgcc float emulation code seems likely to be limited in terms of rounding modes supported etc (the current code is dense math implemented in ARC assembly (really not my cup of coffee) so I couldn't be sure :-(

At any rate, assuming it did limit the rounding modes etc, does that also lend into the ABI we are talking about here ? Likely not.

Quoted 5 lines

(If you support
hard-float compilation with the soft-float ABI, it would be problematic to have different FE_TONEAREST values in the two cases - ARM and RISC-V both define all the FE_* macros independently of whether hard or soft float is used, because they support that case.)

I'd much rather have them be the same. The fenv.h I started with didn't distinguish these (well it only had 1 rounding mode: FE_TONEAREST so was bogus at best). When I revered it up, I added the various modes etc w/o the header guard and ho behold all the math tests started failing. My knee jerk response was to segregate them which likely papered over the issue.

Quoted 3 lines

sysdeps/arc/math_private.h

Quoted 1 line
sysdeps/arc/math_private.h +0 -0

This file should not be needed now.

Ok deleted.

Quoted 6 lines

sysdeps/arc/nofpu/math-tests-exception.h

Quoted 1 line
sysdeps/arc/nofpu/math-tests-exception.h +0 -0

This file does nothing (the name is wrong, the name actually used is math-tests-exceptions.h). And it should not be needed unless you support hard-float compilation with the soft-float ABI (and thus define all the FE_* names in bits/fenv.h even for soft-float).

File renamed and retained.

Quoted 4 lines

sysdeps/arc/nofpu/math-tests-rounding.h

Quoted 1 line
sysdeps/arc/nofpu/math-tests-rounding.h +0 -0

Again, not needed unless hard-float compilation with the soft-float ABI is supported and bits/fenv.h has corresponding contents.

ditto !

Now trying a rebuilt with these changes !

#28 lore raw

PATCH 7/21 ARC: math soft float support

Quoted 6 lines · Vineet Gupta

I'm still ramping up on hard-float, so pardon some of my naivety. It seems the function calling convention is no different for soft-float vs. hard-float. We have a single register file (hard FP instructions inherently use an additional accumulator but that isn't really passed around so doesn't affect calling convention). Other than that SP values go normally in a reg, DP go in reg pair just as any 64bit value.

If you have only a single register file and the same calling convention - and all struct layouts etc. are also the same - then indeed that would be a single ABI (meaning that you only need one dynamic linker name for ARC rather than two, if you only support one endianness). (On architectures with separate register files, jmp_buf, ucontext etc. might sometimes differ between hard and soft float, although often the space is still there in the soft-float case, just not used.)

The ARM and RISC-V cases are ones where there are separate hard-float and soft-float calling conventions - but *also* support for using hardware floating point with the soft-float calling convention.

If you do have a single ABI, that indicates having bits/fenv.h contents unconditional (because a soft-float compilation might legitimately end up linking with a hard-float libm) - and thus indeed needing the internal headers to disable certain math tests for soft-float. fpu_control.h contents would still be conditional, however.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#29 lore raw

PATCH 8/21 ARC: Linux Syscall Interface

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                     |  12 ++
 sysdeps/unix/sysv/linux/arc/cacheflush.c      |  29 +++
 sysdeps/unix/sysv/linux/arc/clone.S           | 100 ++++++++++
 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h  |   6 +
 sysdeps/unix/sysv/linux/arc/kernel-features.h |  28 +++
 sysdeps/unix/sysv/linux/arc/mmap_internal.h   |  26 +++
 sysdeps/unix/sysv/linux/arc/profil-counter.h  |   2 +
 sysdeps/unix/sysv/linux/arc/pt-vfork.S        |   1 +
 sysdeps/unix/sysv/linux/arc/sigaction.c       |  69 +++++++
 sysdeps/unix/sysv/linux/arc/syscall.S         |  38 ++++
 sysdeps/unix/sysv/linux/arc/sysdep.c          |  33 ++++
 sysdeps/unix/sysv/linux/arc/sysdep.h          | 259 ++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/vfork.S           |  42 +++++
 13 files changed, 645 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/cacheflush.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/clone.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/kernel-features.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/mmap_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/profil-counter.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/pt-vfork.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigaction.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscall.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/vfork.S
ChangeLog +12 -0
index b946f57204b6..08a3ac7e8064 100644
@@ -44,6 +44,18 @@
 	* sysdeps/arc/nofpu/math-tests-exception.h: New file.
 	* sysdeps/arc/nofpu/math-tests-rounding.h: New file.
 	* sysdeps/arc/sfp-machine.h: New file.
+	* sysdeps/unix/sysv/linux/arc/cacheflush.c: New file.
+	* sysdeps/unix/sysv/linux/arc/clone.S: New file.
+	* sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h: New file.
+	* sysdeps/unix/sysv/linux/arc/kernel-features.h: New file.
+	* sysdeps/unix/sysv/linux/arc/mmap_internal.h: New file.
+	* sysdeps/unix/sysv/linux/arc/profil-counter.h: New file.
+	* sysdeps/unix/sysv/linux/arc/pt-vfork.S: New file.
+	* sysdeps/unix/sysv/linux/arc/sigaction.c: New file.
+	* sysdeps/unix/sysv/linux/arc/syscall.S: New file.
+	* sysdeps/unix/sysv/linux/arc/sysdep.c: New file.
+	* sysdeps/unix/sysv/linux/arc/sysdep.h: New file.
+	* sysdeps/unix/sysv/linux/arc/vfork.S: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/unix/sysv/linux/arc/cacheflush.c new file +29 -0
new file mode 100644
index 000000000000..7b14211eccf7
@@ -0,0 +1,29 @@
+/* cacheflush system call for ARC Linux.
+   Copyright (C) 2017-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/>.  */
+
+#include <sysdep.h>
+#include <stddef.h>
+#include <unistd.h>
+
+/* Flush cache(s).  */
+int
+_flush_cache (char *addr, const int nbytes, const int op)
+{
+  return INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
+}
+weak_alias (_flush_cache, cacheflush)
sysdeps/unix/sysv/linux/arc/clone.S new file +100 -0

100 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h new file +6 -0
new file mode 100644
index 000000000000..2fec69d21657
@@ -0,0 +1,6 @@
+#define JMP_BUF_SIZE		(32 + 1 + 1024/32) * 4
+#define SIGJMP_BUF_SIZE		(32 + 1 + 1024/32) * 4
+#define JMP_BUF_ALIGN		4
+#define SIGJMP_BUF_ALIGN	4
+#define MASK_WAS_SAVED_OFFSET	32 * 4
+#define SAVED_MASK_OFFSET	33 * 4
sysdeps/unix/sysv/linux/arc/kernel-features.h new file +28 -0
new file mode 100644
index 000000000000..d8f667ca4759
@@ -0,0 +1,28 @@
+/* Set flags signalling availability of kernel features based on given
+   kernel version number.
+
+   Copyright (C) 2009-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/>.  */
+
+/* The minimum supported kernel version for ARC is 3.9,
+   guaranteeing many kernel features.  */
+
+#include_next <kernel-features.h>
+
+#undef __ASSUME_CLONE_DEFAULT
+#define __ASSUME_CLONE_BACKWARDS 1
sysdeps/unix/sysv/linux/arc/mmap_internal.h new file +26 -0
new file mode 100644
index 000000000000..3c8c55d57d0e
@@ -0,0 +1,26 @@
+/* mmap - map files or devices into memory.  Linux/ARC version.
+   Copyright (C) 2017-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 MMAP_ARC_INTERNAL_H
+#define MMAP_ARC_INTERNAL_H
+
+#define MMAP2_PAGE_UNIT 8192ULL	/* 8K page is default for ARC */
+
+#include_next <mmap_internal.h>
+
+#endif
sysdeps/unix/sysv/linux/arc/profil-counter.h new file +2 -0
new file mode 100644
index 000000000000..8a6a0bcf3d59
@@ -0,0 +1,2 @@
+/* We can use the ix86 version.  */
+#include <sysdeps/unix/sysv/linux/i386/profil-counter.h>
sysdeps/unix/sysv/linux/arc/pt-vfork.S new file +1 -0
new file mode 100644
index 000000000000..65cc3823ac87
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/alpha/pt-vfork.S>
sysdeps/unix/sysv/linux/arc/sigaction.c new file +69 -0

69 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/syscall.S new file +38 -0
new file mode 100644
index 000000000000..8f76fa43e95f
@@ -0,0 +1,38 @@
+/* syscall - indirect system call.
+   Copyright (C) 2017-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/>.  */
+
+#include <sysdep.h>
+
+ENTRY (syscall)
+	mov_s	r8, r0
+	mov_s	r0, r1
+	mov_s	r1, r2
+	mov_s	r2, r3
+	mov_s	r3, r4
+#ifdef __ARC700__
+	mov	r4, r5
+	mov	r5, r6
+#else
+	mov_s	r4, r5
+	mov_s	r5, r6
+#endif
+
+	ARC_TRAP_INSN
+	brhi	r0, -1024, .Lcall_syscall_err
+	j	[blink]
+PSEUDO_END (syscall)
sysdeps/unix/sysv/linux/arc/sysdep.c new file +33 -0
new file mode 100644
index 000000000000..d9bcc305b846
@@ -0,0 +1,33 @@
+/* ARC wrapper for setting errno
+   Copyright (C) 1997-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/>.  */
+
+#include <sysdep.h>
+#include <errno.h>
+
+/* All syscall handler come here to avoid generated code bloat due to
+ * GOT reference  to errno_location or it's equivalent
+ */
+int __syscall_error(int err_no)
+{
+	__set_errno(-err_no);
+	return -1;
+}
+
+#if IS_IN (libc)
+hidden_def (__syscall_error)
+#endif
sysdeps/unix/sysv/linux/arc/sysdep.h new file +259 -0

259 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/vfork.S new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.7.4
#30 lore raw

PATCH 8/21 ARC: Linux Syscall Interface

sysdeps/unix/sysv/linux/arc/cacheflush.c line 29

Quoted 7 lines · Vineet Gupta
sysdeps/unix/sysv/linux/arc/cacheflush.c new file +7 -0
+/* Flush cache(s).  */
+int
+_flush_cache (char *addr, const int nbytes, const int op)
+{
+  return INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
+}
+weak_alias (_flush_cache, cacheflush)

Can't this use a syscalls.list entry instead of needing its own .c file?

sysdeps/unix/sysv/linux/arc/pt-vfork.S line 1

Quoted 7 lines
sysdeps/unix/sysv/linux/arc/pt-vfork.S new file +1 -0
new file mode 100644
index 000000000000..65cc3823ac87
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/alpha/pt-vfork.S>

This does nothing for a new port (it's just defining compat symbols). I'd expect

/* Not needed. */

instead, as for RISC-V.

sysdeps/unix/sysv/linux/arc/sigaction.c

Quoted 1 line
sysdeps/unix/sysv/linux/arc/sigaction.c +0 -0

Why do you need this, rather than using the unified version (possibly with a few macros defined first)?

sysdeps/unix/sysv/linux/arc/sigaction.c

Quoted 4 lines
sysdeps/unix/sysv/linux/arc/sigaction.c +4 -0
+/* All syscall handler come here to avoid generated code bloat due to
+ * GOT reference  to errno_location or it's equivalent
+ */
+int __syscall_error(int err_no)

Return type goes on a separate line to the function name in a function definition. (This is in addition to the formatting issues that have been noted elsewhere in the patch series, of which this code has at least three
- '*' at start of comment lines, missing '.' at end of comment and missing space before '('.)

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#31 lore raw

PATCH 8/21 ARC: Linux Syscall Interface

Quoted 11 lines · Joseph Myers

sysdeps/unix/sysv/linux/arc/cacheflush.c line 29

Quoted 7 lines · Vineet Gupta
sysdeps/unix/sysv/linux/arc/cacheflush.c new file +7 -0
+/* Flush cache(s).  */
+int
+_flush_cache (char *addr, const int nbytes, const int op)
+{
+  return INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
+}
+weak_alias (_flush_cache, cacheflush)

Can't this use a syscalls.list entry instead of needing its own .c file?

Sure it can ! Done now.

Quoted 11 lines

sysdeps/unix/sysv/linux/arc/pt-vfork.S line 1

Quoted 7 lines
sysdeps/unix/sysv/linux/arc/pt-vfork.S new file +1 -0
new file mode 100644
index 000000000000..65cc3823ac87
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/alpha/pt-vfork.S>

This does nothing for a new port (it's just defining compat symbols). I'd expect

Quoted 3 lines

/* Not needed. */

instead, as for RISC-V.

Done !

Quoted 4 lines

sysdeps/unix/sysv/linux/arc/sigaction.c

Quoted 1 line
sysdeps/unix/sysv/linux/arc/sigaction.c +0 -0

Why do you need this, rather than using the unified version (possibly with a few macros defined first)?

The only syscall ABI requirement is that we pass our our own SA_RESTORER stub (rather than inject one in kernel, and deal with cache sync etc etc). Indeed the common code can be used - likely was not the case when I started with ARC port, or more likely the port that I started ARC port from ;-)

I'll update this.

Quoted 7 lines

sysdeps/unix/sysv/linux/arc/sigaction.c

Quoted 4 lines
sysdeps/unix/sysv/linux/arc/sigaction.c +4 -0
+/* All syscall handler come here to avoid generated code bloat due to
+ * GOT reference  to errno_location or it's equivalent
+ */
+int __syscall_error(int err_no)

Return type goes on a separate line to the function name in a function definition.

Oops sorry fixed.

Quoted 4 lines

(This is in addition to the formatting issues that have been noted elsewhere in the patch series, of which this code has at least three
- '*' at start of comment lines, missing '.' at end of comment and missing space before '('.)

Sorry again. I can sense your valid frustration, but then a lint file or kernel's checkpatch style tools ill go a long way. Anyhow for now I've fixed annoyances (hopefully all of them).

#32 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 10 lines · Vineet Gupta
Quoted 3 lines

sysdeps/unix/sysv/linux/arc/sigaction.c

Quoted 1 line
sysdeps/unix/sysv/linux/arc/sigaction.c +0 -0

Why do you need this, rather than using the unified version (possibly with a few macros defined first)?

The only syscall ABI requirement is that we pass our our own SA_RESTORER stub (rather than inject one in kernel, and deal with cache sync etc etc). Indeed the common code can be used - likely was not the case when I started with ARC port, or more likely the port that I started ARC port from ;-)

I'll update this.

I took a stab at this but not really happy with taking this approach.

(1). Common code assumes disparate kernel and userland sigaction struct even though there's no reason for a *new* port to be: its not like all glibc code is shared/common although I agree it is best to do so as much as possible So this requires explicit copy over of 1 struct into other, when it could have been avoided altogether for some cases atleast (!SA_RESTORER).

(2) Linux kernel asm-generic syscall ABI expects sigset_t to be 2 words

| kernel: include/uapi/asm-generic/signal.h
|
| #define _NSIG		64
| typedef struct {
|	unsigned long sig[_NSIG_WORDS];
| } sigset_t;

And that is what we pretend at the time of syscall itself, e.g. snippet below from generic sigaction()

|     /* XXX The size argument hopefully will have to be changed to the
|     real size of the user-level sigset_t.  */
|   result = INLINE_SYSCALL_CALL (rt_sigaction, sig,
|				act ? &kact : NULL,
|				oact ? &koact : NULL, STUB(act) _NSIG / 8);
                                                                ^^^^^^^^^

However glibc assumes sigset_to to be 128 words which is fine, however the memcpy for 256 words seems pointless when kernel is not supposed to be even looking at beyond 2nd word (although I realize my SA_RESTORE case was doing the implicit copy as well)

(3) Consider me a micro-optimization freak :-) but this memcpy seems waste of cycles and will atleast show up LMBench lat_sig <install> micro-benchmarks.

I don't have strong feelings either ways, but wanted to express my concerns anyways.

Thx,
-Vineet

#33 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 7 lines · Vineet Gupta

I took a stab at this but not really happy with taking this approach.

(1). Common code assumes disparate kernel and userland sigaction struct even though there's no reason for a *new* port to be: its not like all glibc code is shared/common although I agree it is best to do so as much as possible So this requires explicit copy over of 1 struct into other, when it could have been avoided altogether for some cases atleast (!SA_RESTORER).

So make the generic code optimize those cases based on appropriate conditionals (making sure to verify those conditionals are right for every architecture in glibc).

Any new architecture having much architecture-specific code for the kernel interface in glibc, beyond the basic definitions of how to call a syscall, is suspect, given that the kernel structures should be consistent across asm-generic architectures; we ought to make the defaults work so they are genuinely suitable as defaults for new architectures. This may require changes to the sysdeps/unix/sysv/linux/ code if it's currently "generic" to old architectures but not so good for asm-generic ones.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#34 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

In reply to Vineet Gupta
Quoted 44 lines · Vineet Gupta
Quoted 10 lines · Vineet Gupta
Quoted 3 lines

sysdeps/unix/sysv/linux/arc/sigaction.c

Quoted 1 line
sysdeps/unix/sysv/linux/arc/sigaction.c +0 -0

Why do you need this, rather than using the unified version (possibly with a few macros defined first)?

The only syscall ABI requirement is that we pass our our own SA_RESTORER stub (rather than inject one in kernel, and deal with cache sync etc etc). Indeed the common code can be used - likely was not the case when I started with ARC port, or more likely the port that I started ARC port from ;-)

I'll update this.

I took a stab at this but not really happy with taking this approach.

(1). Common code assumes disparate kernel and userland sigaction struct even though there's no reason for a *new* port to be: its not like all glibc code is shared/common although I agree it is best to do so as much as possible So this requires explicit copy over of 1 struct into other, when it could have been avoided altogether for some cases atleast (!SA_RESTORER).

(2) Linux kernel asm-generic syscall ABI expects sigset_t to be 2 words

| kernel: include/uapi/asm-generic/signal.h
|
| #define _NSIG		64
| typedef struct {
|	unsigned long sig[_NSIG_WORDS];
| } sigset_t;

And that is what we pretend at the time of syscall itself, e.g. snippet below from generic sigaction()

|     /* XXX The size argument hopefully will have to be changed to the
|     real size of the user-level sigset_t.  */
|   result = INLINE_SYSCALL_CALL (rt_sigaction, sig,
|				act ? &kact : NULL,
|				oact ? &koact : NULL, STUB(act) _NSIG / 8);
                                                                ^^^^^^^^^

However glibc assumes sigset_to to be 128 words which is fine, however the memcpy for 256 words seems pointless when kernel is not supposed to be even looking at beyond 2nd word (although I realize my SA_RESTORE case was doing the implicit copy as well)

Quoted 6 lines

(3) Consider me a micro-optimization freak :-) but this memcpy seems waste of cycles and will atleast show up LMBench lat_sig <install> micro-benchmarks.

I don't have strong feelings either ways, but wanted to express my concerns anyways.

One possibility is to define an arch-specific __sigset_t.h with a custom _SIGSET_NWORDS value and add an optimization on Linux sigaction.c to check if both kernel_sigaction and glibc sigaction share same size and internal layout to use the struct as-is for syscall instead of copy to a temporary value (similar to what we used to have on getdents). ARC would still have arch-specific code and would be the only ABI to have a different sigset_t though.

However I *hardly* think sigaction is a hotspot in real world cases, usually the signal action is defined once or in a very limited number of times. I am not considering synthetic benchmarks, specially lmbench which in most cases does not measure any useful metric. Even for other sigset_t usage case I still think an arch-specific definition should not make much difference:

1. setcontext: it would incur just in larger ucontext_t (kernel get/set mask is done using kernel expected size). Also, taking in consideration these interfaces were removed from POSIX.1-2008, the inherent performance issues (signal set/restore will most likely dominate the overhead), and some implementation issues (BZ#18135 for instance), I would say to not bother to optimize it.

2. pselect, ppoll, epoll_pwait, posix_spawn (posix_spawnattr_t), sig*:
for functions that accept sigset as an argument it would incur in just larger memory utilization without much performance overhead. Again, runtime for these calls would be mostly dominate by syscall overhead or kernel wait-time for events.

3. raise, etc: for function that might allocate a sigset_t internally it will similar to 2.

Now, if ARC intention is just to follow generic glibc linux ABI definitions, it could just define its sigaction as (not tested):

* sysdeps/unix/sysv/linux/arc/sigaction.c

---
#define SA_RESTORER 0x04000000
#include <kernel_sigaction.h>

extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;

#define SET_SA_RESTORER(kact, act) \
(kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
(kact)->sa_restorer = &__default_rt_sa_restorer

#define RESET_SA_RESTORER(act, kact) \
(act)->sa_restorer = (kact)->sa_restorer

static void __default_rt_sa_restorer(void)
{
INTERNAL_SYSCALL_DECL (err);
INTERNAL_SYSCALL_CALL (__NR_rt_sigreturn, err);
}

#include <sysdeps/unix/sysv/linux/sigaction.c>
---

#35 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 9 lines · Adhemerval Zanella

One possibility is to define an arch-specific __sigset_t.h with a custom _SIGSET_NWORDS value and add an optimization on Linux sigaction.c to check if both kernel_sigaction and glibc sigaction share same size and internal layout to use the struct as-is for syscall instead of copy to a temporary value (similar to what we used to have on getdents). ARC would still have arch-specific code and would be the only ABI to have a different sigset_t though.

I don't like ARC to single out either. But as Joseph suggests could this be starting point for arches of future. Assuming it does, would rather see this or the approach Joseph alluded to earlier [1]

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2018-December/005122.html

Quoted 5 lines

However I *hardly* think sigaction is a hotspot in real world cases, usually the signal action is defined once or in a very limited number of times. I am not considering synthetic benchmarks, specially lmbench which in most cases does not measure any useful metric.

I tend to disagree. Coming from embedded linux background, I've found it immensely useful to compare 2 minimal systems: especially when distos, out-of-box packages, fancy benchmarks don't even exist.

At any rate, my disagreement with status quo is not so much of optimize for ARC, but rather pointless spending of electrons. When we know that there are 64 signals at max, which need 64-bits, why bother shuffling around 1k bits, specially when one is starting afresh and there's no legacy crap getting in the way.

The case of adding more signals in future is indeed theoretically possible but that will be an ABI change anyways.

Quoted 10 lines

Even for other sigset_t usage case I still
think an arch-specific definition should not make much difference:

1. setcontext: it would incur just in larger ucontext_t (kernel get/set mask is done using kernel expected size). Also, taking in consideration these interfaces were removed from POSIX.1-2008, the inherent performance issues (signal set/restore will most likely dominate the overhead), and some implementation issues (BZ#18135 for instance), I would say to not bother to optimize it.

Quoted 8 lines

2. pselect, ppoll, epoll_pwait, posix_spawn (posix_spawnattr_t), sig*:
for functions that accept sigset as an argument it would incur in just larger memory utilization without much performance overhead. Again, runtime for these calls would be mostly dominate by syscall overhead or kernel wait-time for events.

3. raise, etc: for function that might allocate a sigset_t internally it will similar to 2.

I agree that that in libc, pretty much anything will be dominated by syscall overhead, but still...

Quoted 2 lines

Now, if ARC intention is just to follow generic glibc linux ABI definitions, it could just define its sigaction as (not tested):

Indeed the ABI is etched in stone and I have a very similar code now, with slight difference.

Quoted 11 lines

* sysdeps/unix/sysv/linux/arc/sigaction.c

---
#define SA_RESTORER 0x04000000
#include <kernel_sigaction.h>

extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;

#define SET_SA_RESTORER(kact, act) \
(kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
(kact)->sa_restorer = &__default_rt_sa_restorer

+#define SET_SA_RESTORER(kact, act) \
+ ({ \
+ if (!((kact)->sa_flags & SA_RESTORER)) \
+ { \
+ (kact)->sa_restorer = __default_rt_sa_restorer; \
+ (kact)->sa_flags |= SA_RESTORER; \
+ } \
+ else \
+ (kact)->sa_restorer = (act)->sa_restorer; \
+ })

Quoted 11 lines

#define RESET_SA_RESTORER(act, kact) \
(act)->sa_restorer = (kact)->sa_restorer

static void __default_rt_sa_restorer(void)
{
INTERNAL_SYSCALL_DECL (err);
INTERNAL_SYSCALL_CALL (__NR_rt_sigreturn, err);
}

#include <sysdeps/unix/sysv/linux/sigaction.c>

#36 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 27 lines · Vineet Gupta
Quoted 9 lines · Adhemerval Zanella

One possibility is to define an arch-specific __sigset_t.h with a custom _SIGSET_NWORDS value and add an optimization on Linux sigaction.c to check if both kernel_sigaction and glibc sigaction share same size and internal layout to use the struct as-is for syscall instead of copy to a temporary value (similar to what we used to have on getdents). ARC would still have arch-specific code and would be the only ABI to have a different sigset_t though.

I don't like ARC to single out either. But as Joseph suggests could this be starting point for arches of future. Assuming it does, would rather see this or the approach Joseph alluded to earlier [1]

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2018-December/005122.html

Quoted 5 lines

However I *hardly* think sigaction is a hotspot in real world cases, usually the signal action is defined once or in a very limited number of times. I am not considering synthetic benchmarks, specially lmbench which in most cases does not measure any useful metric.

I tend to disagree. Coming from embedded linux background, I've found it immensely useful to compare 2 minimal systems: especially when distos, out-of-box packages, fancy benchmarks don't even exist.

Quoted 7 lines

At any rate, my disagreement with status quo is not so much of optimize for ARC, but rather pointless spending of electrons. When we know that there are 64 signals at max, which need 64-bits, why bother shuffling around 1k bits, specially when one is starting afresh and there's no legacy crap getting in the way.

The case of adding more signals in future is indeed theoretically possible but that will be an ABI change anyways.

The only advantage of using a larger sigset_t from glibc standpoint is if kernel ever change it maximum number of supported signals it would not be a ABI change (it would be if glibc provided sigset_t need to be extended).

My point was that this change would hardly help in performance or memory utilization due the signal set common utilization in exported and internal API. But at the same time the signal set hasn't been changed for a *long* time and I don't see indication that it will any time soon. So a new architecture might indeed assume it won't change and set its default to follow Linux user ABI.

Quoted 42 lines
Quoted 11 lines

Even for other sigset_t usage case I still
think an arch-specific definition should not make much difference:

1. setcontext: it would incur just in larger ucontext_t (kernel get/set mask is done using kernel expected size). Also, taking in consideration these interfaces were removed from POSIX.1-2008, the inherent performance issues (signal set/restore will most likely dominate the overhead), and some implementation issues (BZ#18135 for instance), I would say to not bother to optimize it.

Quoted 8 lines

2. pselect, ppoll, epoll_pwait, posix_spawn (posix_spawnattr_t), sig*:
for functions that accept sigset as an argument it would incur in just larger memory utilization without much performance overhead. Again, runtime for these calls would be mostly dominate by syscall overhead or kernel wait-time for events.

3. raise, etc: for function that might allocate a sigset_t internally it will similar to 2.

I agree that that in libc, pretty much anything will be dominated by syscall overhead, but still...

Quoted 2 lines

Now, if ARC intention is just to follow generic glibc linux ABI definitions, it could just define its sigaction as (not tested):

Indeed the ABI is etched in stone and I have a very similar code now, with slight difference.

Quoted 11 lines

* sysdeps/unix/sysv/linux/arc/sigaction.c

---
#define SA_RESTORER 0x04000000
#include <kernel_sigaction.h>

extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;

#define SET_SA_RESTORER(kact, act) \
(kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
(kact)->sa_restorer = &__default_rt_sa_restorer

Review

Quoted 10 lines
(quoted diff) +10 -0
+#define SET_SA_RESTORER(kact, act)				\
+ ({								\
+   if (!((kact)->sa_flags & SA_RESTORER))			\
+     {								\
+       (kact)->sa_restorer = __default_rt_sa_restorer;		\
+       (kact)->sa_flags |= SA_RESTORER;			\
+     }								\
+   else							\
+     (kact)->sa_restorer = (act)->sa_restorer;			\
+ })

What is so special about ARC sa_restorer that an application should provide an specialized one? Can't it follow other abi where they issue __NR_sigreturn for !SA_SIGINFO or __NR_rt_sigreturn otherwise?

As for other architecture I do think we should hide the sa_restorer usage from application.

Quoted 14 lines
Quoted 12 lines

#define RESET_SA_RESTORER(act, kact) \
(act)->sa_restorer = (kact)->sa_restorer

static void __default_rt_sa_restorer(void)
{
INTERNAL_SYSCALL_DECL (err);
INTERNAL_SYSCALL_CALL (__NR_rt_sigreturn, err);
}

#include <sysdeps/unix/sysv/linux/sigaction.c>

#37 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 38 lines · Adhemerval Zanella
Quoted 25 lines · Vineet Gupta
Quoted 7 lines · Adhemerval Zanella

One possibility is to define an arch-specific __sigset_t.h with a custom _SIGSET_NWORDS value and add an optimization on Linux sigaction.c to check if both kernel_sigaction and glibc sigaction share same size and internal layout to use the struct as-is for syscall instead of copy to a temporary value (similar to what we used to have on getdents). ARC would still have arch-specific code and would be the only ABI to have a different sigset_t though.

I don't like ARC to single out either. But as Joseph suggests could this be starting point for arches of future. Assuming it does, would rather see this or the approach Joseph alluded to earlier [1]

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2018-December/005122.html

Quoted 5 lines

However I *hardly* think sigaction is a hotspot in real world cases, usually the signal action is defined once or in a very limited number of times. I am not considering synthetic benchmarks, specially lmbench which in most cases does not measure any useful metric.

I tend to disagree. Coming from embedded linux background, I've found it immensely useful to compare 2 minimal systems: especially when distos, out-of-box packages, fancy benchmarks don't even exist.

Quoted 7 lines

At any rate, my disagreement with status quo is not so much of optimize for ARC, but rather pointless spending of electrons. When we know that there are 64 signals at max, which need 64-bits, why bother shuffling around 1k bits, specially when one is starting afresh and there's no legacy crap getting in the way.

The case of adding more signals in future is indeed theoretically possible but that will be an ABI change anyways.

The only advantage of using a larger sigset_t from glibc standpoint is if kernel ever change it maximum number of supported signals it would not be a ABI change (it would be if glibc provided sigset_t need to be extended).

Quoted 6 lines

My point was that this change would hardly help in performance or memory utilization due the signal set common utilization in exported and internal API. But at the same time the signal set hasn't been changed for a *long* time and I don't see indication that it will any time soon. So a new architecture might indeed assume it won't change and set its default to follow Linux user ABI.

I just checked again what we actually use in the kernel. With very few exceptions, all architectures in current kernels use

#define _NSIG 64
#define _NSIG_WORDS (_NSIG / _NSIG_BPW)

typedef struct {
    /* this sucks for big-endian 32-bit compat mode */
    unsigned long sig[_NSIG_WORDS];
} sigset_t;

The only two exceptions I see are:

- alpha uses a scalar 'unsigned long' instead of the struct+array, but the effect is the same layout.
- For unknown reasons, all three MIPS ABIs now use _NSIG=128. This changed during linux-2.1.x from 65, to 32 and then the current value...

All users of sigset_t that I could find in the kernel just check the size argument to ensure it matches _NSIG, and return EINVAL otherwise.

Arnd

#38 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 3 lines · Arnd Bergmann

All users of sigset_t that I could find in the kernel just check the size argument to ensure it matches _NSIG, and return EINVAL otherwise.

Indeed that was one of the very first problem ARC glibc port ran into with stock sizeof(sigset_t) passed in sigaction syscall.

#39 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

In reply to Adhemerval Zanella

* Adhemerval Zanella:

Quoted 3 lines

The only advantage of using a larger sigset_t from glibc standpoint is if kernel ever change it maximum number of supported signals it would not be a ABI change (it would be if glibc provided sigset_t need to be extended).

It's not just the kernel. We might want to restore additional state in sigsetjmp, and historically, the excess signal space in sigset_t has provided a way to do that even if there is no other space left in the jump buffer.

Thanks,
Florian

#40 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 9 lines · Florian Weimer

* Adhemerval Zanella:

Quoted 3 lines

The only advantage of using a larger sigset_t from glibc standpoint is if kernel ever change it maximum number of supported signals it would not be a ABI change (it would be if glibc provided sigset_t need to be extended).

It's not just the kernel. We might want to restore additional state in sigsetjmp, and historically, the excess signal space in sigset_t has provided a way to do that even if there is no other space left in the jump buffer.

And that additional state is architectural state (more FPU regs etc etc) or something libc generic. On both counts, that doesn't sound like a clean interface design !

#41 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

* Vineet Gupta:

Quoted 6 lines · Florian Weimer
Quoted 5 lines

* Adhemerval Zanella:

Quoted 3 lines

The only advantage of using a larger sigset_t from glibc standpoint is if kernel ever change it maximum number of supported signals it would not be a ABI change (it would be if glibc provided sigset_t need to be extended).

Quoted 8 lines
Quoted 4 lines

It's not just the kernel. We might want to restore additional state in sigsetjmp, and historically, the excess signal space in sigset_t has provided a way to do that even if there is no other space left in the jump buffer.

And that additional state is architectural state (more FPU regs etc etc) or something libc generic. On both counts, that doesn't sound like a clean interface design !

Sure, setjmp/longjmp is quite horrible as an interface, considering that register files do evolve. But it's what we have in C, and it's good to have at least some extension space there (but it could be expressed in a better way, definitely).

Thanks,
Florian

#42 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

In reply to Adhemerval Zanella
Quoted 13 lines · Adhemerval Zanella

Review

Quoted 13 lines
Quoted 3 lines

#define SET_SA_RESTORER(kact, act) \
(kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
(kact)->sa_restorer = &__default_rt_sa_restorer

(quoted diff) +10 -0
+#define SET_SA_RESTORER(kact, act)				\
+ ({								\
+   if (!((kact)->sa_flags & SA_RESTORER))			\
+     {								\
+       (kact)->sa_restorer = __default_rt_sa_restorer;		\
+       (kact)->sa_flags |= SA_RESTORER;			\
+     }								\
+   else							\
+     (kact)->sa_restorer = (act)->sa_restorer;			\
+ })
Quoted 2 lines

What is so special about ARC sa_restorer that an application should provide an specialized one?

Its the other way around. Only if application provides it's own restorer, we honor it, otherwise default restorer is used. This logic goes back many many years ago to how ARC uClibc did this and likely inherited it from the port it was copied from. But I don't know if say POSIX allows apps to provide their own restorer or not. We could very well remove it; although per other discussion if we intend to use the same struct sigaction for kernel/userland, the placeholder would exist and we could choose to just ignore it.

Quoted 2 lines

Can't it follow other abi where they issue __NR_sigreturn for !SA_SIGINFO or __NR_rt_sigreturn otherwise?

With Linux UAPI ABI, __NR_sigreturn doesn't exist, but your concern is about restorer ?

Quoted 2 lines

As for other architecture I do think we should hide the sa_restorer usage from application.

As mentioned above, the placeholder could exist, we can choose to ignore it.

#43 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 17 lines · Vineet Gupta
Quoted 13 lines · Adhemerval Zanella

Review

Quoted 13 lines
Quoted 3 lines

#define SET_SA_RESTORER(kact, act) \
(kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
(kact)->sa_restorer = &__default_rt_sa_restorer

(quoted diff) +10 -0
+#define SET_SA_RESTORER(kact, act)				\
+ ({								\
+   if (!((kact)->sa_flags & SA_RESTORER))			\
+     {								\
+       (kact)->sa_restorer = __default_rt_sa_restorer;		\
+       (kact)->sa_flags |= SA_RESTORER;			\
+     }								\
+   else							\
+     (kact)->sa_restorer = (act)->sa_restorer;			\
+ })
Quoted 2 lines

What is so special about ARC sa_restorer that an application should provide an specialized one?

Quoted 8 lines

Its the other way around. Only if application provides it's own restorer, we honor it, otherwise default restorer is used. This logic goes back many many years ago to how ARC uClibc did this and likely inherited it from the port it was copied from. But I don't know if say POSIX allows apps to provide their own restorer or not. We could very well remove it; although per other discussion if we intend to use the same struct sigaction for kernel/userland, the placeholder would exist and we could choose to just ignore it.

The 'should' should be indeed 'might' in my question. And SA_RESTORER is a Linux specific ABI not intended to be used by applications, so my question is in fact what kind of specialized sa_restorer applications might provided that would require the libc to honour it.

The placeholder existence is not an issue itself (POSIX states the minimum fields sigaction should provide, not its specific fields neither their layout).

Quoted 6 lines
Quoted 3 lines

Can't it follow other abi where they issue __NR_sigreturn for !SA_SIGINFO or __NR_rt_sigreturn otherwise?

With Linux UAPI ABI, __NR_sigreturn doesn't exist, but your concern is about restorer ?

Right, so ARC at least is not pulling old compat stuff. Is it safe to just zero the sa_restorer for sa_flags without SA_RESTORER?

Quoted 5 lines
Quoted 3 lines

As for other architecture I do think we should hide the sa_restorer usage from application.

As mentioned above, the placeholder could exist, we can choose to ignore it.

#44 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 29 lines · Adhemerval Zanella
Quoted 17 lines · Vineet Gupta
Quoted 13 lines · Adhemerval Zanella

Review

Quoted 13 lines
Quoted 3 lines

#define SET_SA_RESTORER(kact, act) \
(kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
(kact)->sa_restorer = &__default_rt_sa_restorer

(quoted diff) +10 -0
+#define SET_SA_RESTORER(kact, act)				\
+ ({								\
+   if (!((kact)->sa_flags & SA_RESTORER))			\
+     {								\
+       (kact)->sa_restorer = __default_rt_sa_restorer;		\
+       (kact)->sa_flags |= SA_RESTORER;			\
+     }								\
+   else							\
+     (kact)->sa_restorer = (act)->sa_restorer;			\
+ })
Quoted 2 lines

What is so special about ARC sa_restorer that an application should provide an specialized one?

Quoted 8 lines

Its the other way around. Only if application provides it's own restorer, we honor it, otherwise default restorer is used. This logic goes back many many years ago to how ARC uClibc did this and likely inherited it from the port it was copied from. But I don't know if say POSIX allows apps to provide their own restorer or not. We could very well remove it; although per other discussion if we intend to use the same struct sigaction for kernel/userland, the placeholder would exist and we could choose to just ignore it.

Quoted 2 lines

The 'should' should be indeed 'might' in my question. And SA_RESTORER is a Linux specific ABI not intended to be used by applications,

What do u mean here. It is ABI between userspace and kernel, but not necessarily between applications and glibc, although the same "carrier" sa_flags is in play ? IOW, SA_RESTORER is not intended to be set by applications, but only by glibc ?

Quoted 3 lines

so my question is in fact
what kind of specialized sa_restorer applications might provided that would require the libc to honour it.

Indeed, applications should not be allowed to change it. The exact signature of default sigreturn is hardwired in signal unwinding etc etc and any deviation from that is recipe for issues: but like I mentioned I didn't invent that interface for ARC.

Quoted 3 lines

The placeholder existence is not an issue itself (POSIX states the minimum fields sigaction should provide, not its specific fields neither their layout).

OK !

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Can't it follow other abi where they issue __NR_sigreturn for !SA_SIGINFO or __NR_rt_sigreturn otherwise?

With Linux UAPI ABI, __NR_sigreturn doesn't exist, but your concern is about restorer ?

Right, so ARC at least is not pulling old compat stuff. Is it safe to just zero the sa_restorer for sa_flags without SA_RESTORER?

Thing is ARC signal return depends on a restorer. Meaning !SA_RESTORER doesn't effectively exist (between libc and kernel). We currently honor user provided value, instead we could simply overwrite it with default_rt_restorer and on the way out, zero it out to avoid leaking the glibc guts to curious users.

#45 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 30 lines · Vineet Gupta
Quoted 29 lines · Adhemerval Zanella
Quoted 25 lines · Vineet Gupta
Quoted 13 lines · Adhemerval Zanella

Review

Quoted 13 lines
Quoted 3 lines

#define SET_SA_RESTORER(kact, act) \
(kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
(kact)->sa_restorer = &__default_rt_sa_restorer

(quoted diff) +10 -0
+#define SET_SA_RESTORER(kact, act)				\
+ ({								\
+   if (!((kact)->sa_flags & SA_RESTORER))			\
+     {								\
+       (kact)->sa_restorer = __default_rt_sa_restorer;		\
+       (kact)->sa_flags |= SA_RESTORER;			\
+     }								\
+   else							\
+     (kact)->sa_restorer = (act)->sa_restorer;			\
+ })
Quoted 2 lines

What is so special about ARC sa_restorer that an application should provide an specialized one?

Its the other way around. Only if application provides it's own restorer, we honor it, otherwise default restorer is used. This logic goes back many many years ago to how ARC uClibc did this and likely inherited it from the port it was copied from. But I don't know if say POSIX allows apps to provide their own restorer or not. We could very well remove it; although per other discussion if we intend to use the same struct sigaction for kernel/userland, the placeholder would exist and we could choose to just ignore it.

Quoted 6 lines
Quoted 2 lines

The 'should' should be indeed 'might' in my question. And SA_RESTORER is a Linux specific ABI not intended to be used by applications,

What do u mean here. It is ABI between userspace and kernel, but not necessarily between applications and glibc, although the same "carrier" sa_flags is in play ? IOW, SA_RESTORER is not intended to be set by applications, but only by glibc ?

AFAIK SA_RESTORER is meant to be used by libc or alike environments to setup the required code to handle signal handling, it should not be up to programs to mess up with sa_restorer to provide custom routines.

Quoted 9 lines
Quoted 4 lines

so my question is in fact
what kind of specialized sa_restorer applications might provided that would require the libc to honour it.

Indeed, applications should not be allowed to change it. The exact signature of default sigreturn is hardwired in signal unwinding etc etc and any deviation from that is recipe for issues: but like I mentioned I didn't invent that interface for ARC.

So my suggestion is not allow user code to mess with sa_restore regardless if sa_flags contain SA_RESTORER. If kernel allows it to be zero in case of !SA_RESTORER, set it to zero as other architectures. If it requires an special routine, add an arch-specific one within glibc.

Quoted 13 lines
Quoted 4 lines

The placeholder existence is not an issue itself (POSIX states the minimum fields sigaction should provide, not its specific fields neither their layout).

OK !

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Can't it follow other abi where they issue __NR_sigreturn for !SA_SIGINFO or __NR_rt_sigreturn otherwise?

With Linux UAPI ABI, __NR_sigreturn doesn't exist, but your concern is about restorer ?

Quoted 8 lines
Quoted 2 lines

Right, so ARC at least is not pulling old compat stuff. Is it safe to just zero the sa_restorer for sa_flags without SA_RESTORER?

Thing is ARC signal return depends on a restorer. Meaning !SA_RESTORER doesn't effectively exist (between libc and kernel). We currently honor user provided value, instead we could simply overwrite it with default_rt_restorer and on the way out, zero it out to avoid leaking the glibc guts to curious users.

Yes, this is what I suggest ARC should do.

#46 lore raw

ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

Quoted 6 lines · Adhemerval Zanella
Quoted 5 lines

Thing is ARC signal return depends on a restorer. Meaning !SA_RESTORER doesn't effectively exist (between libc and kernel). We currently honor user provided value, instead we could simply overwrite it with default_rt_restorer and on the way out, zero it out to avoid leaking the glibc guts to curious users.

Yes, this is what I suggest ARC should do.

So I was able to

(1) switch ARC to __sigset_t [2] vs. [128]

(2) create a generic patch to breakout struct sigaction into bits/sigaction-arch.h
(3) update generic __libc_sigaction to avoid itemized copy if sa_mask, sa_flags et al offsets matched for struct kernel_signal and struct sigaction
(4) create arc/bits/sigaction-arch.h

However it turned out to be futile as the passthru won't work anyways :-( @act in sigaction(sig, act, oact) is a const and can't be modified in place for sticking in sa_restorer for kernel, thus needs to be copied over anyways.

This means we have [1] but have to drop [2-4]. Oh well !

#47 lore raw

PATCH 9/21 ARC: Linux ABI

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                     | 15 +++++
 sysdeps/arc/nptl/pthread-offsets.h            |  5 ++
 sysdeps/arc/nptl/pthreaddef.h                 | 32 +++++++++
 sysdeps/unix/sysv/linux/arc/bits/procfs-id.h  | 25 +++++++
 sysdeps/unix/sysv/linux/arc/bits/procfs.h     | 35 ++++++++++
 sysdeps/unix/sysv/linux/arc/bits/sigaction.h  | 85 ++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/getcontext.S      | 65 +++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/makecontext.c     | 74 +++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/setcontext.S      | 93 +++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h  | 23 +++++++
 sysdeps/unix/sysv/linux/arc/swapcontext.S     | 92 ++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/sys/cachectl.h    | 36 +++++++++++
 sysdeps/unix/sysv/linux/arc/sys/ucontext.h    | 71 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/sys/user.h        | 32 +++++++++
 sysdeps/unix/sysv/linux/arc/ucontext-macros.h | 29 +++++++++
 sysdeps/unix/sysv/linux/arc/ucontext_i.sym    | 20 ++++++
 16 files changed, 732 insertions(+)
 create mode 100644 sysdeps/arc/nptl/pthread-offsets.h
 create mode 100644 sysdeps/arc/nptl/pthreaddef.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs-id.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/sigaction.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/cachectl.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext_i.sym
ChangeLog +15 -0
index 08a3ac7e8064..ca010c356597 100644
@@ -56,6 +56,21 @@
 	* sysdeps/unix/sysv/linux/arc/sysdep.c: New file.
 	* sysdeps/unix/sysv/linux/arc/sysdep.h: New file.
 	* sysdeps/unix/sysv/linux/arc/vfork.S: New file.
+	* sysdeps/arc/nptl/pthread-offsets.h: New file.
+	* sysdeps/arc/nptl/pthreaddef.h: New file.
+	* sysdeps/unix/sysv/linux/arc/bits/procfs-id.h: New file.
+	* sysdeps/unix/sysv/linux/arc/bits/procfs.h: New file.
+	* sysdeps/unix/sysv/linux/arc/bits/sigaction.h: New file.
+	* sysdeps/unix/sysv/linux/arc/getcontext.S: New file.
+	* sysdeps/unix/sysv/linux/arc/makecontext.c: New file.
+	* sysdeps/unix/sysv/linux/arc/setcontext.S: New file.
+	* sysdeps/unix/sysv/linux/arc/sigcontextinfo.h: New file.
+	* sysdeps/unix/sysv/linux/arc/swapcontext.S: New file.
+	* sysdeps/unix/sysv/linux/arc/sys/cachectl.h: New file.
+	* sysdeps/unix/sysv/linux/arc/sys/ucontext.h: New file.
+	* sysdeps/unix/sysv/linux/arc/sys/user.h: New file.
+	* sysdeps/unix/sysv/linux/arc/ucontext-macros.h: New file.
+	* sysdeps/unix/sysv/linux/arc/ucontext_i.sym: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/nptl/pthread-offsets.h new file +5 -0
new file mode 100644
index 000000000000..9617354dc7e3
@@ -0,0 +1,5 @@
+#define __PTHREAD_MUTEX_NUSERS_OFFSET   16
+#define __PTHREAD_MUTEX_KIND_OFFSET     12
+#define __PTHREAD_MUTEX_SPINS_OFFSET    20
+#define __PTHREAD_MUTEX_ELISION_OFFSET  22
+#define __PTHREAD_MUTEX_LIST_OFFSET     20
sysdeps/arc/nptl/pthreaddef.h new file +32 -0
new file mode 100644
index 000000000000..41e13c53038c
@@ -0,0 +1,32 @@
+/* pthread machine parameter definitions, ARC version.
+   Copyright (C) 2002-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/>.  */
+
+/* Default stack size.  */
+#define ARCH_STACK_DEFAULT_SIZE	(2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning.  */
+#define STACK_ALIGN		4
+
+/* Minimal stack size after allocating thread descriptor and guard size.  */
+#define MINIMAL_REST_STACK	2048
+
+/* Alignment requirement for TCB.  */
+#define TCB_ALIGNMENT		4
+
+/* Location of current stack frame.  */
+#define CURRENT_STACK_FRAME	__builtin_frame_address (0)
sysdeps/unix/sysv/linux/arc/bits/procfs-id.h new file +25 -0
new file mode 100644
index 000000000000..d0192fcbc36e
@@ -0,0 +1,25 @@
+/* Types of pr_uid and pr_gid in struct elf_prpsinfo.  ARC 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 _SYS_PROCFS_H
+# error "Never include <bits/procfs-id.h> directly; use <sys/procfs.h> instead."
+#endif
+
+typedef unsigned short int __pr_uid_t;
+typedef unsigned short int __pr_gid_t;
sysdeps/unix/sysv/linux/arc/bits/procfs.h new file +35 -0
new file mode 100644
index 000000000000..a3315beddb37
@@ -0,0 +1,35 @@
+/* Types for registers for sys/procfs.h.  ARC version.
+   Copyright (C) 1996-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 _SYS_PROCFS_H
+# error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
+#endif
+
+#include <sys/ucontext.h>
+
+/* And the whole bunch of them.  We could have used `struct
+   user_regs' directly in the typedef, but tradition says that
+   the register set is an array, which does have some peculiar
+   semantics, so leave it that way.  */
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+
+typedef unsigned long int elf_greg_t;
+typedef unsigned long int elf_gregset_t[ELF_NGREG];
+
+/* There's no seperate floating point reg file in ARCv2  */
+typedef struct { } elf_fpregset_t;
sysdeps/unix/sysv/linux/arc/bits/sigaction.h new file +85 -0

86 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/getcontext.S new file +65 -0

65 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/makecontext.c new file +74 -0

74 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/setcontext.S new file +93 -0

93 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/sigcontextinfo.h new file +23 -0
new file mode 100644
index 000000000000..852bbd96d47f
@@ -0,0 +1,23 @@
+/* ARC definitions for signal handling calling conventions.
+   Copyright (C) 2017-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/>.  */
+
+#include <sys/ucontext.h>
+#include "kernel-features.h"
+
+#define SIGCONTEXT int _code, struct ucontext_t *
+#define GET_PC(ctx)    ((void *) (ctx)->uc_mcontext.scratch.ret)
sysdeps/unix/sysv/linux/arc/swapcontext.S new file +92 -0

92 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/sys/cachectl.h new file +36 -0
new file mode 100644
index 000000000000..c2ba820e50b7
@@ -0,0 +1,36 @@
+/* cacheflush - flush contents of instruction and/or data cache.
+   Copyright (C) 2017-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 _SYS_CACHECTL_H
+#define _SYS_CACHECTL_H 1
+
+#include <features.h>
+
+/* Get the kernel definition for the op bits.  */
+#include <asm/cachectl.h>
+
+__BEGIN_DECLS
+
+#ifdef __USE_MISC
+extern int cacheflush (void *__addr, const int __nbytes, const int __op) __THROW;
+#endif
+extern int _flush_cache (char *__addr, const int __nbytes, const int __op) __THROW;
+
+__END_DECLS
+
+#endif /* sys/cachectl.h */
sysdeps/unix/sysv/linux/arc/sys/ucontext.h new file +71 -0

71 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/sys/user.h new file +32 -0
new file mode 100644
index 000000000000..1f7129799bf6
@@ -0,0 +1,32 @@
+/* ptrace register data format definitions.
+   Copyright (C) 1998-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 _SYS_USER_H
+#define _SYS_USER_H	1
+
+/* struct user_regs_struct is exported by kernel header
+ * However apps like strace also expect a struct user, so it's better to
+ * have a dummy implementation
+ */
+#include <asm/ptrace.h>
+
+struct user {
+	int dummy;
+};
+
+#endif  /* sys/user.h */
sysdeps/unix/sysv/linux/arc/ucontext-macros.h new file +29 -0
new file mode 100644
index 000000000000..a5d861476f3c
@@ -0,0 +1,29 @@
+/* Macros for ucontext routines - ARC
+   Copyright (C) 2017-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 _LINUX_ARC_UCONTEXT_MACROS_H
+#define _LINUX_ARC_UCONTEXT_MACROS_H
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+#define SAVE_REG(reg, rbase, off)	st  reg, [rbase, UCONTEXT_MCONTEXT + off * 4]
+#define LOAD_REG(reg, rbase, off)	ld  reg, [rbase, UCONTEXT_MCONTEXT + off * 4]
+
+#endif
sysdeps/unix/sysv/linux/arc/ucontext_i.sym new file +20 -0
new file mode 100644
index 000000000000..f0a209e581ab
@@ -0,0 +1,20 @@
+#include <inttypes.h>
+#include <signal.h>
+#include <stddef.h>
+#include <sys/ucontext.h>
+
+SIG_BLOCK
+SIG_SETMASK
+
+-- sizeof(sigset_t) expected by kernel: see comment in ARC sigaction.c for details
+_NSIG8				(_NSIG / 8)
+
+-- Offsets of the fields in the ucontext_t structure.
+#define ucontext(member)	offsetof (ucontext_t, member)
+
+UCONTEXT_FLAGS			ucontext (uc_flags)
+UCONTEXT_LINK			ucontext (uc_link)
+UCONTEXT_STACK			ucontext (uc_stack)
+UCONTEXT_MCONTEXT		ucontext (uc_mcontext)
+UCONTEXT_SIGMASK		ucontext (uc_sigmask)
+UCONTEXT_SIZE			sizeof (ucontext_t)
Signature · 1 line
2.7.4
#48 lore raw

PATCH 9/21 ARC: Linux ABI

sysdeps/unix/sysv/linux/arc/bits/procfs-id.h line 25

Quoted 2 lines · Vineet Gupta
sysdeps/unix/sysv/linux/arc/bits/procfs-id.h new file +2 -0
+typedef unsigned short int __pr_uid_t;
+typedef unsigned short int __pr_gid_t;

Are you sure? I don't see an ARC-specific definition of __kernel_uid_t or __kernel_gid_t in the Linux kernel at all (which would mean unsigned int is actually used and you don't need this header at all).

sysdeps/unix/sysv/linux/arc/bits/sigaction.h

Quoted 1 line
sysdeps/unix/sysv/linux/arc/bits/sigaction.h +0 -0

I wouldn't expect new architectures to have their own bits/sigaction.h. Rather, I'd expect them to use the generic bits/sigaction.h and the generic code to convert from the userspace struct sigaction to the kernel version.

sysdeps/unix/sysv/linux/arc/bits/sigaction.h

Quoted 5 lines
sysdeps/unix/sysv/linux/arc/bits/sigaction.h +5 -0
+#ifdef __USE_MISC
+# define __ctx(fld) fld
+#else
+# define __ctx(fld) __ ## fld
+#endif

New ports should just use namespace-clean field names here unconditionally. The __ctx macros with __USE_MISC conditionals are purely for maximum API-compatibility for existing ports that needed to be fixed to make them namespace-clean.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#49 lore raw

PATCH 9/21 ARC: Linux ABI

Quoted 6 lines · Joseph Myers

sysdeps/unix/sysv/linux/arc/bits/procfs-id.h line 25

Quoted 2 lines · Vineet Gupta
sysdeps/unix/sysv/linux/arc/bits/procfs-id.h new file +2 -0
+typedef unsigned short int __pr_uid_t;
+typedef unsigned short int __pr_gid_t;

Are you sure?

No I'm not :-) There were some interim sweeping changes in this area since when I started so this might indeed be redundant as you say.

Quoted 3 lines

I don't see an ARC-specific definition of __kernel_uid_t or __kernel_gid_t in the Linux kernel at all (which would mean unsigned int is actually used and you don't need this header at all).

I'll check.

Quoted 6 lines

sysdeps/unix/sysv/linux/arc/bits/sigaction.h

Quoted 1 line
sysdeps/unix/sysv/linux/arc/bits/sigaction.h +0 -0

I wouldn't expect new architectures to have their own bits/sigaction.h. Rather, I'd expect them to use the generic bits/sigaction.h and the generic code to convert from the userspace struct sigaction to the kernel version.

So this is further to the other thread about generic sigaction (sorry for cross-post). Indeed with switch to generic sigaction this may not be required. *However* the layouts of generic userspace sigaction are different from kernel's. Just to rehash (notes for myself really)

1. user exported struct

struct sigaction

  {
    __sighandler_t sa_handler;
    __sigset_t sa_mask;
    int sa_flags;
    void (*sa_restorer) (void);

};

2. Linux kernel UAPI struct sigaction / glibc kernel_sigaction

struct sigaction {
	__sighandler_t sa_handler;
	unsigned long sa_flags;
	__sigrestore_t sa_restorer;
	sigset_t sa_mask;  /* mask last for extensibility */
};

Since they don't match and we can't possibly change kernel_sigaction, a future optimization implies changing #1 which has ABI implications at which point it has diminished or NO returns.

So perhaps we keep the ARC header above, with matching layout, while switching to generic sigaction() still. OK ?

Quoted 10 lines

sysdeps/unix/sysv/linux/arc/bits/sigaction.h

Quoted 5 lines
sysdeps/unix/sysv/linux/arc/bits/sigaction.h +5 -0
+#ifdef __USE_MISC
+# define __ctx(fld) fld
+#else
+# define __ctx(fld) __ ## fld
+#endif

New ports should just use namespace-clean field names here unconditionally. The __ctx macros with __USE_MISC conditionals are purely for maximum API-compatibility for existing ports that needed to be fixed to make them namespace-clean.

OK, fixed this.

Thx,
-Vineet

#50 lore raw

PATCH 9/21 ARC: Linux ABI

Quoted 2 lines · Vineet Gupta

So perhaps we keep the ARC header above, with matching layout, while switching to generic sigaction() still. OK ?

If the different userspace layout is better, it should be better for all future ports as well.

Duplicating all the SA_* constants in architecture-specific headers, even when those architectures don't actually have different values of those constants, is bad, especially since there is logic about which __USE_* macros get which SA_* defined which then needs to be duplicated.

So what this suggests to me is a preliminary patch series to unify bits/sigaction.h headers - there might be one header for SA_* constants (architecture-specific variants only when needed), one for SIG_* constants (architecture-specific variants only when needed), and one for the ways in which the layout of the userspace struct sigaction can vary (defining macros that the unified bits/sigaction.h then uses to control the layout - cf. the siginfo unification a while back).

Initially, the default version of that last header would correspond to the existing sysdeps/unix/sysv/linux/bits/sigaction.h header - however, if you get consensus for a different layout as the default for new architectures, the default would change and all existing architectures that use the current default layout would get copies of the new bits/ header configured to keep the old layout. (Variants are possible to reduce the number of architectures needing architecture-specific copies as a result of the changed default. For example, you could have the new default only in sysdeps/unix/sysv/linux/generic not sysdeps/unix/sysv/linux/ and then only existing asm-generic architectures (aarch64 nios2 riscv) would need to override back to the old default layout.)

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#51 lore raw

PATCH 9/21 ARC: Linux ABI

Quoted 5 lines · Joseph Myers
Quoted 2 lines · Vineet Gupta

So perhaps we keep the ARC header above, with matching layout, while switching to generic sigaction() still. OK ?

Quoted 7 lines

If the different userspace layout is better, it should be better for all future ports as well.

Duplicating all the SA_* constants in architecture-specific headers, even when those architectures don't actually have different values of those constants, is bad, especially since there is logic about which __USE_* macros get which SA_* defined which then needs to be duplicated.

Totally agree.

Quoted 7 lines

So what this suggests to me is a preliminary patch series to unify bits/sigaction.h headers - there might be one header for SA_* constants (architecture-specific variants only when needed), one for SIG_* constants (architecture-specific variants only when needed), and one for the ways in which the layout of the userspace struct sigaction can vary (defining macros that the unified bits/sigaction.h then uses to control the layout - cf. the siginfo unification a while back).

Actually this can be simplified. Given the asm-generic syscall ABI, we are anyhow locked into SA_* or SIG_* and kernel side sigaction, the only variant is user facing struct sigaction. I suppose we could leave it at that given that only 1 syscall sigaction is affected. The bigger bang for the buck will the reduction of sizeof(sigset_t) - purely from amount of memory any sig* call needs to read/write/copy.

I'll follow Adhemerval's suggestion of arch-specific __sigset_t.h which seems doable w/o much pain.

Quoted 11 lines

Initially, the default version of that last header would correspond to the existing sysdeps/unix/sysv/linux/bits/sigaction.h header - however, if you get consensus for a different layout as the default for new architectures, the default would change and all existing architectures that use the current default layout would get copies of the new bits/ header configured to keep the old layout. (Variants are possible to reduce the number of architectures needing architecture-specific copies as a result of the changed default. For example, you could have the new default only in sysdeps/unix/sysv/linux/generic not sysdeps/unix/sysv/linux/ and then only existing asm-generic architectures (aarch64 nios2 riscv) would need to override back to the old default layout.)

Yes this will require a needless churn all over, just for 1 syscall.

#52 lore raw

PATCH 10/21 ARC: Linux Startup and Dynamic Loading

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                               |  3 ++
 sysdeps/unix/sysv/linux/arc/dl-static.c | 84 +++++++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/ldconfig.h  | 25 ++++++++++
 sysdeps/unix/sysv/linux/arc/ldsodefs.h  | 32 +++++++++++++
 4 files changed, 144 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/dl-static.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldconfig.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldsodefs.h
ChangeLog +3 -0
index ca010c356597..f6ad5968d7de 100644
@@ -71,6 +71,9 @@
 	* sysdeps/unix/sysv/linux/arc/sys/user.h: New file.
 	* sysdeps/unix/sysv/linux/arc/ucontext-macros.h: New file.
 	* sysdeps/unix/sysv/linux/arc/ucontext_i.sym: New file.
+	* sysdeps/unix/sysv/linux/arc/dl-static.c: New file.
+	* sysdeps/unix/sysv/linux/arc/ldconfig.h: New file.
+	* sysdeps/unix/sysv/linux/arc/ldsodefs.h: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/unix/sysv/linux/arc/dl-static.c new file +84 -0

84 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/ldconfig.h new file +25 -0
new file mode 100644
index 000000000000..c38ce20edaea
@@ -0,0 +1,25 @@
+/* dynamic linker names for ARC
+   Copyright (C) 2001-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/>.  */
+
+#include <sysdeps/generic/ldconfig.h>
+
+#define SYSDEP_KNOWN_INTERPRETER_NAMES \
+  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },
+#define SYSDEP_KNOWN_LIBRARY_NAMES \
+  { "libc.so.6", FLAG_ELF_LIBC6 },	\
+  { "libm.so.6", FLAG_ELF_LIBC6 },
sysdeps/unix/sysv/linux/arc/ldsodefs.h new file +32 -0
new file mode 100644
index 000000000000..005c49a7b7cd
@@ -0,0 +1,32 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects. ARC
+   Copyright (C) 2001-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	_LDSODEFS_H
+
+/* Get the real definitions.  */
+#include_next <ldsodefs.h>
+
+/* Now define our stuff.  */
+
+/* We need special support to initialize DSO loaded for statically linked
+   binaries.  */
+extern void _dl_static_init (struct link_map *map);
+#undef DL_STATIC_INIT
+#define DL_STATIC_INIT(map) _dl_static_init (map)
+
+#endif /* ldsodefs.h */
Signature · 1 line
2.7.4
#53 lore raw

PATCH 10/21 ARC: Linux Startup and Dynamic Loading

sysdeps/unix/sysv/linux/arc/ldconfig.h

Quoted 1 line · Vineet Gupta
sysdeps/unix/sysv/linux/arc/ldconfig.h +0 -0

This header should only be needed if you support multiple ABIs simultaneously on the same system; note most architectures don't have it. Maybe it will be relevant when you add support for the hard-float ABI, but not yet.

sysdeps/unix/sysv/linux/arc/ldconfig.h line 22

Quoted 2 lines
sysdeps/unix/sysv/linux/arc/ldconfig.h +2 -0
+#define SYSDEP_KNOWN_INTERPRETER_NAMES \
+  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },

That's not the dynamic linker name you're using elsewhere.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#54 lore raw

PATCH 10/21 ARC: Linux Startup and Dynamic Loading

Quoted 8 lines · Joseph Myers

sysdeps/unix/sysv/linux/arc/ldconfig.h

Quoted 1 line · Vineet Gupta
sysdeps/unix/sysv/linux/arc/ldconfig.h +0 -0

This header should only be needed if you support multiple ABIs simultaneously on the same system; note most architectures don't have it. Maybe it will be relevant when you add support for the hard-float ABI, but not yet.

Ok removed.

Quoted 4 lines

sysdeps/unix/sysv/linux/arc/ldconfig.h line 22

Quoted 2 lines
sysdeps/unix/sysv/linux/arc/ldconfig.h +2 -0
+#define SYSDEP_KNOWN_INTERPRETER_NAMES \
+  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },

That's not the dynamic linker name you're using elsewhere.

Indeed this is leftover from RFC last year. Per your suggestion we changed the name from ld-linux.so.2 to ld-linux-*arc*.so.2 (reflected in shlib-versions) but missed here. Fixed now.

#55 lore raw

PATCH 11/21 ARC: ABI lists

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                          |   17 +
 sysdeps/arc/nofpu/libm-test-ulps                   |  390 ++++
 sysdeps/arc/nofpu/libm-test-ulps-name              |    1 +
 sysdeps/unix/sysv/linux/arc/c++-types.data         |   67 +
 sysdeps/unix/sysv/linux/arc/ld.abilist             |    9 +
 .../unix/sysv/linux/arc/libBrokenLocale.abilist    |    1 +
 sysdeps/unix/sysv/linux/arc/libanl.abilist         |    4 +
 sysdeps/unix/sysv/linux/arc/libc.abilist           | 2089 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/arc/libcrypt.abilist       |    2 +
 sysdeps/unix/sysv/linux/arc/libdl.abilist          |    9 +
 sysdeps/unix/sysv/linux/arc/libm.abilist           |  753 +++++++
 sysdeps/unix/sysv/linux/arc/libnsl.abilist         |  120 ++
 sysdeps/unix/sysv/linux/arc/libpthread.abilist     |  235 +++
 sysdeps/unix/sysv/linux/arc/libresolv.abilist      |   79 +
 sysdeps/unix/sysv/linux/arc/librt.abilist          |   35 +
 sysdeps/unix/sysv/linux/arc/libthread_db.abilist   |   40 +
 sysdeps/unix/sysv/linux/arc/libutil.abilist        |    6 +
 sysdeps/unix/sysv/linux/arc/localplt.data          |   15 +
 18 files changed, 3872 insertions(+)
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps-name
 create mode 100644 sysdeps/unix/sysv/linux/arc/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/arc/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libnsl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/localplt.data
ChangeLog +17 -0
index f6ad5968d7de..4182e89ccbb3 100644
@@ -74,6 +74,23 @@
 	* sysdeps/unix/sysv/linux/arc/dl-static.c: New file.
 	* sysdeps/unix/sysv/linux/arc/ldconfig.h: New file.
 	* sysdeps/unix/sysv/linux/arc/ldsodefs.h: New file.
+	* sysdeps/arc/nofpu/libm-test-ulps: New file.
+	* sysdeps/arc/nofpu/libm-test-ulps-name: New file.
+	* sysdeps/unix/sysv/linux/arc/c++-types.data: New file.
+	* sysdeps/unix/sysv/linux/arc/ld.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libBrokenLocale.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libanl.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libc.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libcrypt.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libdl.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libm.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libnsl.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libpthread.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libresolv.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/librt.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libthread_db.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/libutil.abilist: New file.
+	* sysdeps/unix/sysv/linux/arc/localplt.data: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/nofpu/libm-test-ulps new file +390 -0

390 lines not on this page · raw message

sysdeps/arc/nofpu/libm-test-ulps-name new file +1 -0
new file mode 100644
index 000000000000..8c4fba4f9ae0
@@ -0,0 +1 @@
+ARC
sysdeps/unix/sysv/linux/arc/c++-types.data new file +67 -0

67 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/ld.abilist new file +9 -0
new file mode 100644
index 000000000000..71576160eddd
@@ -0,0 +1,9 @@
+GLIBC_2.29 __libc_stack_end D 0x4
+GLIBC_2.29 __stack_chk_guard D 0x4
+GLIBC_2.29 __tls_get_addr F
+GLIBC_2.29 _dl_mcount F
+GLIBC_2.29 _r_debug D 0x14
+GLIBC_2.29 calloc F
+GLIBC_2.29 free F
+GLIBC_2.29 malloc F
+GLIBC_2.29 realloc F
sysdeps/unix/sysv/linux/arc/libBrokenLocale.abilist new file +1 -0
new file mode 100644
index 000000000000..96b4163a254a
@@ -0,0 +1 @@
+GLIBC_2.29 __ctype_get_mb_cur_max F
sysdeps/unix/sysv/linux/arc/libanl.abilist new file +4 -0
new file mode 100644
index 000000000000..416a6f8ddb26
@@ -0,0 +1,4 @@
+GLIBC_2.29 gai_cancel F
+GLIBC_2.29 gai_error F
+GLIBC_2.29 gai_suspend F
+GLIBC_2.29 getaddrinfo_a F
sysdeps/unix/sysv/linux/arc/libc.abilist new file +2089 -0

2,089 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/libcrypt.abilist new file +2 -0
new file mode 100644
index 000000000000..da3abbf8fb89
@@ -0,0 +1,2 @@
+GLIBC_2.29 crypt F
+GLIBC_2.29 crypt_r F
sysdeps/unix/sysv/linux/arc/libdl.abilist new file +9 -0
new file mode 100644
index 000000000000..8fcb609ddcfa
@@ -0,0 +1,9 @@
+GLIBC_2.29 dladdr F
+GLIBC_2.29 dladdr1 F
+GLIBC_2.29 dlclose F
+GLIBC_2.29 dlerror F
+GLIBC_2.29 dlinfo F
+GLIBC_2.29 dlmopen F
+GLIBC_2.29 dlopen F
+GLIBC_2.29 dlsym F
+GLIBC_2.29 dlvsym F
sysdeps/unix/sysv/linux/arc/libm.abilist new file +753 -0

405 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/libnsl.abilist new file +120 -0

120 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/libpthread.abilist new file +235 -0

235 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/libresolv.abilist new file +79 -0

79 lines not on this page · raw message

sysdeps/unix/sysv/linux/arc/librt.abilist new file +35 -0
new file mode 100644
index 000000000000..c6690ef7c135

Lines of this file are not shown. View the raw message.

sysdeps/unix/sysv/linux/arc/libthread_db.abilist new file +40 -0
new file mode 100644
index 000000000000..37e9bace5521

Lines of this file are not shown. View the raw message.

sysdeps/unix/sysv/linux/arc/libutil.abilist new file +6 -0
new file mode 100644
index 000000000000..cbd11999a4f1

Lines of this file are not shown. View the raw message.

sysdeps/unix/sysv/linux/arc/localplt.data new file +15 -0
new file mode 100644
index 000000000000..3a9bfb648ac9

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#56 lore raw

PATCH 11/21 ARC: ABI lists

Quoted 1 line · Vineet Gupta
 sysdeps/unix/sysv/linux/arc/libnsl.abilist         |  120 ++

You don't need that any more.

Andreas.

Signature · 3 lines
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
#57 lore raw

PATCH 11/21 ARC: ABI lists

Quoted 2 lines · Andreas Schwab
Quoted 1 line
 sysdeps/unix/sysv/linux/arc/libnsl.abilist         |  120 ++

You don't need that any more.

Ok ! deleted now !

Thx,
-Vineet

#58 lore raw

PATCH 12/21 ARC: Update syscall-names.list for ARC specific syscalls

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                  | 1 +
 sysdeps/unix/sysv/linux/syscall-names.list | 3 +++
 2 files changed, 4 insertions(+)
ChangeLog +1 -0
index 4182e89ccbb3..3735df67a3b2 100644
@@ -91,6 +91,7 @@
 	* sysdeps/unix/sysv/linux/arc/libthread_db.abilist: New file.
 	* sysdeps/unix/sysv/linux/arc/libutil.abilist: New file.
 	* sysdeps/unix/sysv/linux/arc/localplt.data: New file.
+	* sysdeps/unix/sysv/linux/syscall-names.list: Update for ARC.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/unix/sysv/linux/syscall-names.list +3 -0
index f88001c9c38d..62862010600f 100644
@@ -42,6 +42,9 @@ adjtimex
 afs_syscall
 alarm
 alloc_hugepages
+arc_gettls
+arc_settls
+arc_usr_cmpxchg
 arch_prctl
 arm_fadvise64_64
 arm_sync_file_range
Signature · 1 line
2.7.4
#59 lore raw

PATCH 12/21 ARC: Update syscall-names.list for ARC specific syscalls

* Vineet Gupta:

Quoted 5 lines
sysdeps/unix/sysv/linux/syscall-names.list +0 -0
index f88001c9c38d..62862010600f 100644

sysdeps/unix/sysv/linux/syscall-names.list adjtimex · line 50

Quoted 9 lines
sysdeps/unix/sysv/linux/syscall-names.list +3 -0
@@ -42,6 +42,9 @@ adjtimex
 afs_syscall
 alarm
 alloc_hugepages
+arc_gettls
+arc_settls
+arc_usr_cmpxchg
 arch_prctl
 arm_fadvise64_64
 arm_sync_file_range

This should come in with a sync with a released upstream kernel. Will the port be in Linux 4.20?

Thanks,
Florian

#60 lore raw

PATCH 12/21 ARC: Update syscall-names.list for ARC specific syscalls

Quoted 2 lines · Florian Weimer

This should come in with a sync with a released upstream kernel. Will the port be in Linux 4.20?

linux port was upstreamed in 2013 in v3.9

-Vineet

#61 lore raw

PATCH 12/21 ARC: Update syscall-names.list for ARC specific syscalls

* Vineet Gupta:

Quoted 5 lines · Florian Weimer
Quoted 2 lines

This should come in with a sync with a released upstream kernel. Will the port be in Linux 4.20?

linux port was upstreamed in 2013 in v3.9

Ah, right, we add system calls to the lists only for our ports.

Thanks,
Florian

#62 lore raw

PATCH 13/21 ARC: Build Infrastructure

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                  | 13 +++++++++++++
 sysdeps/arc/Implies                        |  3 +++
 sysdeps/arc/Makefile                       | 25 +++++++++++++++++++++++++
 sysdeps/arc/Versions                       | 14 ++++++++++++++
 sysdeps/arc/configure                      | 17 +++++++++++++++++
 sysdeps/arc/configure.ac                   | 13 +++++++++++++
 sysdeps/arc/nptl/Makefile                  | 22 ++++++++++++++++++++++
 sysdeps/arc/preconfigure                   | 14 ++++++++++++++
 sysdeps/unix/sysv/linux/arc/Implies        |  3 +++
 sysdeps/unix/sysv/linux/arc/Makefile       | 16 ++++++++++++++++
 sysdeps/unix/sysv/linux/arc/Versions       | 12 ++++++++++++
 sysdeps/unix/sysv/linux/arc/configure      |  4 ++++
 sysdeps/unix/sysv/linux/arc/configure.ac   |  4 ++++
 sysdeps/unix/sysv/linux/arc/shlib-versions |  2 ++
 14 files changed, 162 insertions(+)
 create mode 100644 sysdeps/arc/Implies
 create mode 100644 sysdeps/arc/Makefile
 create mode 100644 sysdeps/arc/Versions
 create mode 100644 sysdeps/arc/configure
 create mode 100644 sysdeps/arc/configure.ac
 create mode 100644 sysdeps/arc/nptl/Makefile
 create mode 100644 sysdeps/arc/preconfigure
 create mode 100644 sysdeps/unix/sysv/linux/arc/Implies
 create mode 100644 sysdeps/unix/sysv/linux/arc/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/arc/Versions
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions
ChangeLog +13 -0
index 3735df67a3b2..6628960c487e 100644
@@ -92,6 +92,19 @@
 	* sysdeps/unix/sysv/linux/arc/libutil.abilist: New file.
 	* sysdeps/unix/sysv/linux/arc/localplt.data: New file.
 	* sysdeps/unix/sysv/linux/syscall-names.list: Update for ARC.
+	* sysdeps/arc/Implies: New file.
+	* sysdeps/arc/Makefile: New file.
+	* sysdeps/arc/Versions: New file.
+	* sysdeps/arc/configure: New file.
+	* sysdeps/arc/configure.ac: New file.
+	* sysdeps/arc/nptl/Makefile: New file.
+	* sysdeps/arc/preconfigure: New file.
+	* sysdeps/unix/sysv/linux/arc/Implies: New file.
+	* sysdeps/unix/sysv/linux/arc/Makefile: New file.
+	* sysdeps/unix/sysv/linux/arc/Versions: New file.
+	* sysdeps/unix/sysv/linux/arc/configure: New file.
+	* sysdeps/unix/sysv/linux/arc/configure.ac: New file.
+	* sysdeps/unix/sysv/linux/arc/shlib-versions: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/Implies new file +3 -0
new file mode 100644
index 000000000000..387a0ca05204
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/dbl-64
+ieee754/flt-32
sysdeps/arc/Makefile new file +25 -0
new file mode 100644
index 000000000000..a88eda115b95
@@ -0,0 +1,25 @@
+# ARC Makefile
+# Copyright (C) 1993-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/>.
+
+# We don't support long doubles as a distinct type.  We don't need to set
+# this variable; it's here mostly for documentational purposes.
+long-double-fcts = no
+
+ifeq ($(subdir),debug)
+CFLAGS-backtrace.c += -funwind-tables
+endif
sysdeps/arc/Versions new file +14 -0
new file mode 100644
index 000000000000..c088bb27a0e5
@@ -0,0 +1,14 @@
+libc {
+  GLIBC_2.29 {
+    __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2;
+    __fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi;
+    __fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi;
+    __floatdidf; __floatdisf; __floatsidf; __floatsisf;
+    __floatundidf; __floatundisf; __floatunsidf; __floatunsisf;
+    __gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2;
+    __muldf3; __mulsf3; __nedf2; __nesf2; __negdf2; __negsf2;
+    __subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2;
+    __syscall_error;
+    __mcount;
+  }
+}
sysdeps/arc/configure new file +17 -0
new file mode 100644
index 000000000000..2033957d0d9f
@@ -0,0 +1,17 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/arc.
+
+$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
+
+libc_cv_have_sdata_section=no
+
+# For ARC, historically ; was used for comments and not newline
+# Later # also got added to comment list, but ; couldn't be switched to
+# canonical newline as there's lots of code out there which will break
+libc_cv_asm_line_sep='`'
+cat >>confdefs.h <<_ACEOF
+#define ASM_LINE_SEP $libc_cv_asm_line_sep
+_ACEOF
+
+
+libc_cv_fpie=no
sysdeps/arc/configure.ac new file +13 -0
new file mode 100644
index 000000000000..91e58efb35c8
@@ -0,0 +1,13 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/arc.
+
+AC_DEFINE(PI_STATIC_AND_HIDDEN)
+libc_cv_have_sdata_section=no
+
+# For ARC, historically ; was used for comments and not newline
+# Later # also got added to comment list, but ; couldn't be switched to
+# canonical newline as there's lots of code out there which will break
+libc_cv_asm_line_sep='`'
+AC_DEFINE_UNQUOTED(ASM_LINE_SEP, $libc_cv_asm_line_sep)
+
+libc_cv_fpie=no
sysdeps/arc/nptl/Makefile new file +22 -0
new file mode 100644
index 000000000000..afeb58a8c1cb
@@ -0,0 +1,22 @@
+# NPTL makefile fragment for ARC.
+# Copyright (C) 2005-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/>.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
sysdeps/arc/preconfigure new file +14 -0
new file mode 100644
index 000000000000..1152a179c4aa
@@ -0,0 +1,14 @@
+case "$machine" in
+arc*)
+	base_machine=arc
+	machine=arc
+	;;
+esac
+
+gccfloat=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep __ARC_FPU_| wc -l`
+if test "$gccfloat" != "0"; then
+	echo "glibc being configured for double precision floating point"
+	with_fp_cond=1
+else
+	with_fp_cond=0
+fi
sysdeps/unix/sysv/linux/arc/Implies new file +3 -0
new file mode 100644
index 000000000000..7f739a0340b6
@@ -0,0 +1,3 @@
+arc/nptl
+unix/sysv/linux/generic/wordsize-32
+unix/sysv/linux/generic
sysdeps/unix/sysv/linux/arc/Makefile new file +16 -0
new file mode 100644
index 000000000000..76e5d24daea2
@@ -0,0 +1,16 @@
+ifeq ($(subdir),stdlib)
+gen-as-const-headers += ucontext_i.sym
+endif
+
+ifeq ($(subdir),misc)
+# MIPS/Tile-style cacheflush routine
+sysdep_headers += sys/cachectl.h
+sysdep_routines += cacheflush
+endif
+
+ifeq ($(subdir),elf)
+ifeq ($(build-shared),yes)
+# This is needed for DSO loading from static binaries.
+sysdep-dl-routines += dl-static
+endif
+endif
sysdeps/unix/sysv/linux/arc/Versions new file +12 -0
new file mode 100644
index 000000000000..ac3327426360
@@ -0,0 +1,12 @@
+ld {
+  GLIBC_PRIVATE {
+    # used for loading by static libraries
+    _dl_var_init;
+  }
+}
+libc {
+  GLIBC_2.29 {
+    _flush_cache;
+    cacheflush;
+  }
+}
sysdeps/unix/sysv/linux/arc/configure new file +4 -0
new file mode 100644
index 000000000000..f74fa7cb0259
@@ -0,0 +1,4 @@
+# This file is generated from configure.in by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/arc.
+
+arch_minimum_kernel=3.9.0
sysdeps/unix/sysv/linux/arc/configure.ac new file +4 -0
new file mode 100644
index 000000000000..a9528032d32a
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/arc.
+
+arch_minimum_kernel=3.9.0
sysdeps/unix/sysv/linux/arc/shlib-versions new file +2 -0
new file mode 100644
index 000000000000..e527acd77892
@@ -0,0 +1,2 @@
+DEFAULT                 GLIBC_2.29
+ld=ld-linux-arc.so.2
Signature · 1 line
2.7.4
#63 lore raw

PATCH 13/21 ARC: Build Infrastructure

sysdeps/arc/Versions line 10

Quoted 10 lines · Vineet Gupta
sysdeps/arc/Versions new file +10 -0
+libc {
+  GLIBC_2.29 {
+    __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2;
+    __fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi;
+    __fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi;
+    __floatdidf; __floatdisf; __floatsidf; __floatsisf;
+    __floatundidf; __floatundisf; __floatunsidf; __floatunsisf;
+    __gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2;
+    __muldf3; __mulsf3; __nedf2; __nesf2; __negdf2; __negsf2;
+    __subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2;

Exporting soft-fp symbols from glibc is only appropriate if you are also building soft-fp in glibc (as opposed to building it in libgcc) - which might be done with a view to possibly enabling support for exceptions and rounding modes for soft-float, as on powerpc soft-float, for example. I don't see a Subdirs files containing "soft-fp" in this patch series. If you're just linking with libgcc, you should not be re-exporting these functions from libc.so (and indeed I don't see them in your ABI baselines
- libgcc.a has them as hidden symbols to prevent such re-exporting).

Quoted 1 line

+libc_cv_fpie=no

Why? I'd expect -fpie to be working for all glibc architectures with any modern GCC version (I wouldn't expect it to need extra GCC back-end support beyond -fpic).

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#64 lore raw

PATCH 13/21 ARC: Build Infrastructure

Quoted 13 lines · Joseph Myers

sysdeps/arc/Versions line 10

Quoted 10 lines · Vineet Gupta
sysdeps/arc/Versions new file +10 -0
+libc {
+  GLIBC_2.29 {
+    __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2;
+    __fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi;
+    __fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi;
+    __floatdidf; __floatdisf; __floatsidf; __floatsisf;
+    __floatundidf; __floatundisf; __floatunsidf; __floatunsisf;
+    __gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2;
+    __muldf3; __mulsf3; __nedf2; __nesf2; __negdf2; __negsf2;
+    __subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2;
Quoted 8 lines

Exporting soft-fp symbols from glibc is only appropriate if you are also building soft-fp in glibc (as opposed to building it in libgcc) - which might be done with a view to possibly enabling support for exceptions and rounding modes for soft-float, as on powerpc soft-float, for example. I don't see a Subdirs files containing "soft-fp" in this patch series. If you're just linking with libgcc, you should not be re-exporting these functions from libc.so (and indeed I don't see them in your ABI baselines
- libgcc.a has them as hidden symbols to prevent such re-exporting).

Removed now !

Quoted 2 lines
Quoted 1 line

+libc_cv_fpie=no

Why?

This likely goes back to my original work on glibc (started somewhere in 2015), and at the time binutils support for PIE was really shaky (to speak mildly). It was only in ARC GNU 2016.09 release did we have serious pie fixes due to essential rewrite of binutils backend by Cuper and Claudiu.

Quoted 3 lines

I'd expect -fpie to be working for all glibc architectures with any modern GCC version (I wouldn't expect it to need extra GCC back-end support beyond -fpic).

Well at the time there were multiple PIE related issues in binutils rather than gcc.

Indeed with current glibc port, we do build/test/run a bunch of packages relying on PIE (dumpcap, openssh come to mind) successfully. So yes PIE should work in general for ARC now. FWIW this could also explain the following current results.

PASS: gmon/tst-gmon-gprof
FAIL: gmon/tst-gmon-pie-gprof

#65 lore raw

PATCH 13/21 ARC: Build Infrastructure

Quoted 4 lines · Vineet Gupta

Indeed with current glibc port, we do build/test/run a bunch of packages relying on PIE (dumpcap, openssh come to mind) successfully. So yes PIE should work in general for ARC now. FWIW this could also explain the following current results.

I should note a separate issue to consider: that of *static* PIE support. That doesn't need to be working, but if it's not working, or if you don't know whether it's working, when the port goes in you need to update the list at <https://sourceware.org/glibc/wiki/PortStatus> accordingly. (Port maintainers need to make sure
<https://sourceware.org/glibc/wiki/PortStatus> and
<https://sourceware.org/glibc/wiki/ABIList> are up to date for their ports, as well as posting test results on the per-release wiki page during each release cycle's freeze period.)

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#66 lore raw

PATCH 13/21 ARC: Build Infrastructure

Quoted 2 lines · Joseph Myers

I should note a separate issue to consider: that of *static* PIE support. That doesn't need to be working, but if it's not working,

Aren't there directed test cases for that already ?

PASS: elf/tst-tls1-static
PASS: elf/tst-tls1-static-non-pie
FAIL: gmon/tst-gmon-pie-gprof

I vaguely remember binutils folks fixing some pie issues when above became PASS

Quoted 8 lines

or if you don't
know whether it's working, when the port goes in you need to update the list at <https://sourceware.org/glibc/wiki/PortStatus> accordingly. (Port maintainers need to make sure
<https://sourceware.org/glibc/wiki/PortStatus> and
<https://sourceware.org/glibc/wiki/ABIList> are up to date for their ports, as well as posting test results on the per-release wiki page during each release cycle's freeze period.)

Will do when we get there :-)

Thx,
-Vineet

#67 lore raw

PATCH 13/21 ARC: Build Infrastructure

Quoted 9 lines · Vineet Gupta
Quoted 2 lines · Joseph Myers

I should note a separate issue to consider: that of *static* PIE support. That doesn't need to be working, but if it's not working,

Aren't there directed test cases for that already ?

PASS: elf/tst-tls1-static
PASS: elf/tst-tls1-static-non-pie
FAIL: gmon/tst-gmon-pie-gprof

The key point on the PortStatus page is "If linker can correctly generate static PIE, glibc test results should be identical with and without --enable-static-pie.". You need to test a build configured with --enable-static-pie to see if this is fully working.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#68 lore raw

PATCH 13/21 ARC: Build Infrastructure

Quoted 8 lines · Joseph Myers
Quoted 6 lines · Vineet Gupta
Quoted 2 lines · Joseph Myers

I should note a separate issue to consider: that of *static* PIE support. That doesn't need to be working, but if it's not working,

Aren't there directed test cases for that already ?

Quoted 8 lines
Quoted 3 lines

PASS: elf/tst-tls1-static
PASS: elf/tst-tls1-static-non-pie
FAIL: gmon/tst-gmon-pie-gprof

The key point on the PortStatus page is "If linker can correctly generate static PIE, glibc test results should be identical with and without --enable-static-pie.". You need to test a build configured with --enable-static-pie to see if this is fully working.

Unfortunately this doesn't seem to work.

ld bails out when linking elf/sln. It can't seem to resolve the _DYNAMIC at pcl in elf_machine_load_address(). We can look into this but presume it is not a deal breaker.

~/BR/host/bin/arc-buildroot-linux-gnu-gcc
-nostdlib -nostartfiles
*-static*
-o ~/BR/build/glibc-2f9a78f208a7/build/elf/sln
*-static-pie*
~/BR/build/glibc-2f9a78f208a7/build/csu/rcrt1.o ~/BR/build/glibc-2f9a78f208a7/build/csu/crti.o ~/BR/host/bin/arc-buildroot-linux-gnu-gcc --print-file-name=crtbeginS.o ~/BR/build/glibc-2f9a78f208a7/build/elf/sln.o ~/BR/build/glibc-2f9a78f208a7/build/elf/static-stubs.o -Wl,--start-group
~/BR/build/glibc-2f9a78f208a7/build/libc.a -lgcc -Wl,--end-group
~/BR/host/bin/arc-buildroot-linux-gnu-gcc --print-file-name=crtendS.o ~/BR/build/glibc-2f9a78f208a7/build/csu/crtn.o

~/BR/host/lib/gcc/arc-buildroot-linux-gnu/8.2.1/../../../../arc-buildroot-linux-gnu/bin/ld:
~/BR/build/glibc-2f9a78f208a7/build/libc.a(dl-reloc-static-pie.o): in function `elf_machine_load_address':
~/BR/build:/glibc-2f9a78f208a7/elf/../sysdeps/arc/dl-machine.h:115: undefined reference to `_DYNAMIC' ~/BR/host/lib/gcc/arc-buildroot-linux-gnu/8.2.1/../../../../arc-buildroot-linux-gnu/bin/ld:
~/BR/build/glibc-2f9a78f208a7/elf/../sysdeps/arc/dl-machine.h:115: undefined reference to `_DYNAMIC'
collect2: error: ld returned 1 exit status

#69 lore raw

PATCH 14/21 ARC: Enable __start as entry point vs. canonical _start

In reply to Vineet Gupta

ARC linker scripts have defined __start as entry point so to not break ABI for uClibc et al we allow __start for glibc as well

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                |  3 +++
 sysdeps/arc/dl-machine.h | 14 ++++++++++----
 sysdeps/arc/entry.h      |  5 +++++
 sysdeps/arc/start.S      | 14 +++++++++++---
 4 files changed, 29 insertions(+), 7 deletions(-)
 create mode 100644 sysdeps/arc/entry.h
ChangeLog +3 -0
index 6628960c487e..86e4db890850 100644
@@ -105,6 +105,9 @@
 	* sysdeps/unix/sysv/linux/arc/configure: New file.
 	* sysdeps/unix/sysv/linux/arc/configure.ac: New file.
 	* sysdeps/unix/sysv/linux/arc/shlib-versions: New file.
+	* sysdeps/arc/dl-machine.h: replace _start with __start.
+	* sysdeps/arc/start.S: likewise.
+	* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/dl-machine.h +10 -4
index da1aef79152d..02727a3a4d47 100644
@@ -21,6 +21,12 @@
 
 #define ELF_MACHINE_NAME "arc"
 
+#include <entry.h>
+
+#ifndef ENTRY_POINT
+#error ENTRY_POINT needs to be defined for ARC
+#endif
+
 #include <string.h>
 #include <link.h>
 #include <dl-tls.h>
@@ -150,9 +156,9 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 
 #define RTLD_START asm ("\
 .text								\n\
-.globl _start							\n\
-.type _start, @function						\n\
-_start:								\n\
+.globl __start							\n\
+.type __start, @function					\n\
+__start:							\n\
 	; (1). bootstrap ld.so					\n\
 	bl.d    _dl_start                                       \n\
 	mov_s   r0, sp          ; pass ptr to aux vector tbl    \n\
@@ -182,7 +188,7 @@ _start:								\n\
 	add     r0, pcl, _dl_fini at pcl				\n\
 	j	[r13]						\n\
 								\n\
-	.size  _start,.-_start                                  \n\
+	.size  __start,.-__start                                \n\
 	.previous                                               \n\
 ");
 
sysdeps/arc/entry.h new file +5 -0
new file mode 100644
index 000000000000..adb01d981afd
@@ -0,0 +1,5 @@
+#ifndef __ASSEMBLY__
+extern void __start (void) attribute_hidden;
+#endif
+
+#define ENTRY_POINT __start
sysdeps/arc/start.S +11 -3
index 119d596db07f..79e73e27d00d 100644
@@ -34,7 +34,14 @@
    <http://www.gnu.org/licenses/>.  */
 
 
+#define __ASSEMBLY__ 1
+#include <entry.h>
+#ifndef ENTRY_POINT
+#error ENTRY_POINT needs to be defined for ARC
+#endif
+
 /* When we enter this piece of code, the program stack looks like this:
+
         argc            argument counter (integer)
         argv[0]         program name (pointer)
         argv[1...N]     program args (pointers)
@@ -45,9 +52,9 @@
 */
 	.text
 	.align 4
-	.global _start
-	.type _start, at function
-_start:
+	.global __start
+	.type __start, at function
+__start:
 	mov	fp, 0
 	ld_s	r1, [sp]	; argc
 
@@ -71,6 +78,7 @@ _start:
 
 	/* Should never get here....  */
 	flag    1
+	.size  __start,.-__start
 
 /* Define a symbol for the first piece of initialized data.  */
 	.data
Signature · 1 line
2.7.4
#70 lore raw

PATCH 14/21 ARC: Enable __start as entry point vs. canonical _start

* Vineet Gupta:

Quoted 2 lines

ARC linker scripts have defined __start as entry point so to not break ABI for uClibc et al we allow __start for glibc as well

I think this change and the test suite fixes should be folded into the initial addition of these files. Or is there a reason for not doing this?

Thanks,
Florian

#71 lore raw

PATCH 14/21 ARC: Enable __start as entry point vs. canonical _start

Quoted 5 lines · Florian Weimer
Quoted 2 lines

ARC linker scripts have defined __start as entry point so to not break ABI for uClibc et al we allow __start for glibc as well

I think this change and the test suite fixes should be folded into the initial addition of these files. Or is there a reason for not doing this?

I deliberately kept them out to call out the fixes, sometimes these help new ports which stumble into similar issues. And also ~2 years worth of work gets squashed into a single blob is a shame :-)

-Vineet

#72 lore raw

PATCH 14/21 ARC: Enable __start as entry point vs. canonical _start

Quoted 10 lines · Vineet Gupta
Quoted 5 lines · Florian Weimer
Quoted 2 lines

ARC linker scripts have defined __start as entry point so to not break ABI for uClibc et al we allow __start for glibc as well

I think this change and the test suite fixes should be folded into the initial addition of these files. Or is there a reason for not doing this?

I deliberately kept them out to call out the fixes, sometimes these help new ports which stumble into similar issues. And also ~2 years worth of work gets squashed into a single blob is a shame :-)

Postings of a new port should generally post each new file in the form in which it is intended to be committed (and, thus, the form in which it should be reviewed); you should never post a known-buggy version and a subsequent fix to the bug; that wastes reviewers' time. (The actual commit of the port should be a single commit with everything, modulo possible separate earlier commits for changes to architecture-independent files, as the port isn't useful with only a subset of the new files added.)

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#73 lore raw

PATCH 14/21 ARC: Enable __start as entry point vs. canonical _start

Quoted 4 lines · Joseph Myers
Quoted 3 lines

I deliberately kept them out to call out the fixes, sometimes these help new ports which stumble into similar issues. And also ~2 years worth of work gets squashed into a single blob is a shame :-)

Quoted 8 lines

Postings of a new port should generally post each new file in the form in which it is intended to be committed (and, thus, the form in which it should be reviewed); you should never post a known-buggy version and a subsequent fix to the bug; that wastes reviewers' time. (The actual commit of the port should be a single commit with everything, modulo possible separate earlier commits for changes to architecture-independent files, as the port isn't useful with only a subset of the new files added.

Ok I can certainly squash them in next version.

Thx,
-Vineet

#74 lore raw

PATCH 14/21 ARC: Enable __start as entry point vs. canonical _start

In reply to Florian Weimer
Quoted 3 lines · Florian Weimer

I think this change and the test suite fixes should be folded into the initial addition of these files. Or is there a reason for not doing this?

As suggested by other reviewers too, I'm folding all fixes into initial files.

Thx,
-Vineet

#75 lore raw

PATCH 15/21 ARC: testsuite fix: elf/check-initfini

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog          | 1 +
 sysdeps/arc/crti.S | 2 ++
 2 files changed, 3 insertions(+)
ChangeLog +1 -0
index 86e4db890850..909b1af09a31 100644
@@ -108,6 +108,7 @@
 	* sysdeps/arc/dl-machine.h: replace _start with __start.
 	* sysdeps/arc/start.S: likewise.
 	* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
+	* sysdeps/arc/crti.S: add .hidden annotations.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/arc/crti.S +2 -0
index 8b823b54a29d..ea741b30e3cf 100644
@@ -53,6 +53,7 @@
 	.section .init
 	.align 4
 	.global	_init
+	.hidden	_init
 	.type	 _init, at function
 _init:
 	st.a	blink, [sp,-4]
@@ -69,6 +70,7 @@ _init:
 	.section .fini
 	.align 4
 	.global	_fini
+	.hidden	_fini
 	.type	 _fini, at function
 _fini:
 	st.a blink,[sp,-4]
Signature · 1 line
2.7.4
#76 lore raw

PATCH 16/21 ARC: testsuite fix: sysvipc/*

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                              |  1 +
 sysdeps/unix/sysv/linux/arc/ipc_priv.h | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/ipc_priv.h
ChangeLog +1 -0
index 909b1af09a31..d3a979a9236b 100644
@@ -109,6 +109,7 @@
 	* sysdeps/arc/start.S: likewise.
 	* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
 	* sysdeps/arc/crti.S: add .hidden annotations.
+	* sysdeps/unix/sysv/linux/arc/ipc_priv.h: New file.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/unix/sysv/linux/arc/ipc_priv.h new file +21 -0
new file mode 100644
index 000000000000..5f6e9815d169
@@ -0,0 +1,21 @@
+/* Old SysV permission definition for Linux.  ARC version.
+   Copyright (C) 2016-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/>.  */
+
+#include <sys/ipc.h>  /* For __key_t  */
+
+#define __IPC_64	0x0
Signature · 1 line
2.7.4
#77 lore raw

PATCH 17/21 ARC: testsuite fix: stdlib/tst-makecontext

In reply to Vineet Gupta

Terminate the unwinding by telling unwinder to fetch return address (BLINK) from r15 which has been set apriori to 0.

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                                 | 2 ++
 sysdeps/unix/sysv/linux/arc/makecontext.c | 1 +
 sysdeps/unix/sysv/linux/arc/setcontext.S  | 2 ++
 3 files changed, 5 insertions(+)
ChangeLog +2 -0
index d3a979a9236b..39ff298b0091 100644
@@ -110,6 +110,8 @@
 	* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
 	* sysdeps/arc/crti.S: add .hidden annotations.
 	* sysdeps/unix/sysv/linux/arc/ipc_priv.h: New file.
+	* sysdeps/unix/sysv/linux/arc/makecontext.c: clear r15.
+	* sysdeps/unix/sysv/linux/arc/setcontext.S: set blink from r15.
 
 2018-12-17  Joseph Myers  <joseph at codesourcery.com>
 
sysdeps/unix/sysv/linux/arc/makecontext.c +1 -0
index 7018bed9d64a..8d233f83da7e 100644
@@ -45,6 +45,7 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
    */
   ucp->uc_mcontext.callee.r13 = (unsigned long) func;
   ucp->uc_mcontext.callee.r14 = (unsigned long) ucp->uc_link;
+  ucp->uc_mcontext.callee.r15 = 0;
 
   r = &ucp->uc_mcontext.scratch.r0;
 
sysdeps/unix/sysv/linux/arc/setcontext.S +2 -0
index 3f503c661d95..6ec2ec0ddc79 100644
@@ -79,6 +79,8 @@ weak_alias(__setcontext, setcontext)
 
 ENTRY(__startcontext)
 
+	cfi_register (blink, r15)
+
         /* call user @func, loaded in r13 by setcontext() */
         jl   [r13]
 
Signature · 1 line
2.7.4
#78 lore raw

PATCH 17/21 ARC: testsuite fix: stdlib/tst-makecontext

sysdeps/unix/sysv/linux/arc/setcontext.S weak_alias(__setcontext, setcontext) · line 83

Quoted 10 lines · Vineet Gupta
sysdeps/unix/sysv/linux/arc/setcontext.S +2 -0
index 3f503c661d95..6ec2ec0ddc79 100644
@@ -79,6 +79,8 @@ weak_alias(__setcontext, setcontext)
 
 ENTRY(__startcontext)
 
+	cfi_register (blink, r15)
+

You should precede that with a dummy .cfi_label (see sysdeps/riscv/start.S) to force the CFI into the FDE instead of the CIE. Also, can you use cfi_undefined instead?

Andreas.

Signature · 3 lines
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
#79 lore raw

PATCH 17/21 ARC: testsuite fix: stdlib/tst-makecontext

Quoted 7 lines · Andreas Schwab

sysdeps/unix/sysv/linux/arc/setcontext.S weak_alias(__setcontext, setcontext) · line 83

Quoted 4 lines

ENTRY(__startcontext)

sysdeps/unix/sysv/linux/arc/setcontext.S +2 -0
+	cfi_register (blink, r15)
+

You should precede that with a dummy .cfi_label (see sysdeps/riscv/start.S) to force the CFI into the FDE instead of the CIE. Also, can you use cfi_undefined instead?

Yes that works as well.

ENTRY (__startcontext)

-       cfi_register (blink, r15)
+       .cfi_label .Ldummy
+       cfi_undefined (blink)

00035e14 <__startcontext>:
35e14: jl [r13]
35e18: mov r0,r14
35e1c: breq.nt r0,0,8 ;35e24 <__startcontext+0x10>
35e20: bl -168 ;35d78 <setcontext>
35e24: b -38248 ;2c8bc <exit>

New
----
0000058c 00000010 00000590 FDE cie=00000000 pc=00035e14..00035e28
DW_CFA_undefined: r31
DW_CFA_nop

Old
----
00035df4 <__startcontext>:
35df4: jl [r13]
35df8: mov r0,r14
35dfc: breq.nt r0,0,8 ;35e04 <__startcontext+0x10>
35e00: bl -168 ;35d58 <setcontext>
35e04: b -38248 ;2c89c <exit>

0000058c 00000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -4
Return address column: 31
Augmentation data: 1b
DW_CFA_def_cfa: r28 ofs 0
DW_CFA_register: r31 in r15
DW_CFA_nop

000005a4 00000010 0000001c FDE cie=0000058c pc=00035df4..00035e08
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop

#80 lore raw

PATCH 18/21 ARC: testsuite fix: GD TLS issue

In reply to Vineet Gupta

From: Cupertino Miranda <[email protected]>

Offset set by the linker in the GOT entries would be overwritten by the dynamic loader instead of added to the symbol location.
Other target have the same approach on DTSOFF relocs.

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                | 4 ++++
 sysdeps/arc/dl-machine.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
ChangeLog +4 -0
index 39ff298b0091..ec068c7c5925 100644
@@ -1,3 +1,7 @@
+2018-12-17  Cupertino Miranda <cmiranda at synopsys.com>
+
+	* sysdeps/arc/dl-machine.h: Fix relocation.
+
 2018-12-17  Vineet Gupta <vgupta at synopsys.com>
 
 	* sysdeps/unix/make-syscalls.sh: Fix comment referencing
sysdeps/arc/dl-machine.h +1 -1
index 02727a3a4d47..f4757904084a 100644
@@ -290,7 +290,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
         case R_ARC_TLS_DTPOFF:
           if (sym != NULL)
             {
-              *reloc_addr = sym->st_value;
+              *reloc_addr += sym->st_value;
             }
           break;
 
Signature · 1 line
2.7.4
#81 lore raw

PATCH 19/21 ARC: fix several unwining and cancelation tests

In reply to Vineet Gupta

From: Cupertino Miranda <[email protected]>

1. Add dwarf CFI psuedo-ops to various syscall generators

2. Signature of sa_restorer was not what libgcc trampoline parser expects due to an intermediate mov instruction

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
Signed-off-by Cupertino Miranda <cmiranda at synopsys.com>
---
 ChangeLog                                 |  8 ++++++++
 sysdeps/arc/dl-trampoline.S               |  9 +++++++++
 sysdeps/arc/sysdep.h                      |  2 ++
 sysdeps/unix/sysv/linux/arc/Makefile      |  4 ++++
 sysdeps/unix/sysv/linux/arc/Versions      |  4 ++++
 sysdeps/unix/sysv/linux/arc/sigaction.c   |  8 +-------
 sysdeps/unix/sysv/linux/arc/sigrestorer.S | 28 ++++++++++++++++++++++++++++
 7 files changed, 56 insertions(+), 7 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigrestorer.S
ChangeLog +8 -0
index ec068c7c5925..376d0e401117 100644
@@ -1,6 +1,14 @@
 2018-12-17  Cupertino Miranda <cmiranda at synopsys.com>
 
 	* sysdeps/arc/dl-machine.h: Fix relocation.
+	* sysdeps/arc/dl-trampoline.S: Add cfi pseudo-ops.
+	* sysdeps/arc/sysdep.h: likewise.
+	* sysdeps/unix/sysv/linux/arc/sigrestorer.S: Add default sa_restorer
+	in asm.
+	* sysdeps/unix/sysv/linux/arc/sigaction.c: Delete "C" version of
+	restorer.
+	* sysdeps/unix/sysv/linux/arc/Makefile: Enable build.
+	* sysdeps/unix/sysv/linux/arc/Versions: expose default sa_restorer.
 
 2018-12-17  Vineet Gupta <vgupta at synopsys.com>
 
sysdeps/arc/dl-trampoline.S +9 -0
index c704f0ff9a95..0fc9786ec1d3 100644
@@ -37,11 +37,16 @@
 	st.a	r7, [sp, -4]
 	st.a	r8, [sp, -4]
 	st.a	r9, [sp, -4]
+	cfi_adjust_cfa_offset (40)
 	push_s	blink
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (blink, 0)
 .endm
 
 .macro RESTORE_CALLER_SAVED_BUT_R0
 	ld.ab	blink,[sp, 4]
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (blink)
 	ld.ab	r9, [sp, 4]
 	ld.ab	r8, [sp, 4]
 	ld.ab	r7, [sp, 4]
@@ -51,6 +56,7 @@
 	pop_s   r3
 	pop_s   r2
 	pop_s   r1
+	cfi_adjust_cfa_offset (-36)
 .endm
 
 ; Upon entry, PLTn, which led us here, sets up the following regs
@@ -69,4 +75,7 @@ ENTRY(_dl_runtime_resolve)
 	RESTORE_CALLER_SAVED_BUT_R0
 	j_s.d   [r0]    ; r0 has resolved function addr
 	pop_s   r0      ; restore first arg to resolved call
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (r0)
+
 END(_dl_runtime_resolve)
sysdeps/arc/sysdep.h +2 -0
index 5c6e063d03fe..920611277089 100644
@@ -32,10 +32,12 @@
     .globl C_SYMBOL_NAME(name)			ASM_LINE_SEP	\
     .type C_SYMBOL_NAME(name),%function		ASM_LINE_SEP	\
   C_LABEL(name)					ASM_LINE_SEP	\
+    cfi_startproc				ASM_LINE_SEP	\
     CALL_MCOUNT
 
 #undef  END
 #define END(name)						\
+  cfi_endproc					ASM_LINE_SEP	\
   ASM_SIZE_DIRECTIVE(name)
 
 #ifdef SHARED
sysdeps/unix/sysv/linux/arc/Makefile +4 -0
index 76e5d24daea2..a6c6dfc6ec64 100644
@@ -2,6 +2,10 @@ ifeq ($(subdir),stdlib)
 gen-as-const-headers += ucontext_i.sym
 endif
 
+ifeq ($(subdir),signal)
+sysdep_routines += sigrestorer
+endif
+
 ifeq ($(subdir),misc)
 # MIPS/Tile-style cacheflush routine
 sysdep_headers += sys/cachectl.h
sysdeps/unix/sysv/linux/arc/Versions +4 -0
index ac3327426360..3d12161f7fe2 100644
@@ -9,4 +9,8 @@ libc {
     _flush_cache;
     cacheflush;
   }
+  GLIBC_PRIVATE {
+    # A copy of sigaction lives in libpthread, and needs these.
+    __default_rt_sa_restorer;
+  }
 }
sysdeps/unix/sysv/linux/arc/sigaction.c +1 -7
index 0a58e78f8834..b437af677d58 100644
@@ -22,13 +22,7 @@
 #include <string.h>
 #include <sys/syscall.h>
 
-/*
- * Default sigretrun stub if user doesn't specify SA_RESTORER
- */
-static void __default_rt_sa_restorer(void)
-{
-	INTERNAL_SYSCALL_NCS(__NR_rt_sigreturn, , 0);
-}
+extern void __default_rt_sa_restorer(void);
 
 #define SA_RESTORER	0x04000000
 
sysdeps/unix/sysv/linux/arc/sigrestorer.S new file +28 -0
new file mode 100644
index 000000000000..d74cf0ec00e3
@@ -0,0 +1,28 @@
+/* Default sigreturn stub for ARC Linux.
+   Copyright (C) 2005-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/>.  */
+
+#include <sys/syscall.h>
+#include <sysdep.h>
+#include <tcb-offsets.h>
+
+	nop
+ENTRY(__default_rt_sa_restorer)
+	mov r8, __NR_rt_sigreturn
+	ARC_TRAP_INSN
+	j_s     [blink]
+PSEUDO_END_NOERRNO(__default_rt_sa_restorer)
Signature · 1 line
2.7.4
#82 lore raw

PATCH 20/21 build-many-glibcs.py: Enable ARC builds

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog                    | 4 ++++
 scripts/build-many-glibcs.py | 4 ++++
 2 files changed, 8 insertions(+)
ChangeLog +4 -0
index 376d0e401117..46d288808153 100644
@@ -1,3 +1,7 @@
+2018-12-17  Vineet Gupta <vgupta at synopsys.com>
+
+	* scripts/build-many-glibcs.py: Enable building for ARC.
+
 2018-12-17  Cupertino Miranda <cmiranda at synopsys.com>
 
 	* sysdeps/arc/dl-machine.h: Fix relocation.
scripts/build-many-glibcs.py +4 -0
index 9051ff17b19d..97e9bedabe0c 100755
@@ -155,6 +155,9 @@ class Context(object):
                                        'cfg': ['--disable-multi-arch']}])
         self.add_config(arch='aarch64_be',
                         os_name='linux-gnu')
+        self.add_config(arch='arc',
+                        os_name='linux-gnu',
+                        gcc_cfg=['--disable-multilib', '--with-cpu=archs'])
         self.add_config(arch='alpha',
                         os_name='linux-gnu')
         self.add_config(arch='arm',
@@ -1258,6 +1261,7 @@ class Config(object):
     def install_linux_headers(self, cmdlist):
         """Install Linux kernel headers."""
         arch_map = {'aarch64': 'arm64',
+                    'arc': 'arc',
                     'alpha': 'alpha',
                     'arm': 'arm',
                     'hppa': 'parisc',
Signature · 1 line
2.7.4
#83 lore raw

PATCH 21/21 NEWS: mention ARC port

In reply to Vineet Gupta
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 ChangeLog | 1 +
 NEWS      | 2 ++
 2 files changed, 3 insertions(+)
ChangeLog +1 -0
index 46d288808153..92e19ac45df2 100644
@@ -1,6 +1,7 @@
 2018-12-17  Vineet Gupta <vgupta at synopsys.com>
 
 	* scripts/build-many-glibcs.py: Enable building for ARC.
+	* NEW: Mention ARC port.
 
 2018-12-17  Cupertino Miranda <cmiranda at synopsys.com>
 
NEWS +2 -0
index ae80818df4b3..56b21c3b9336 100644
@@ -1078,6 +1078,8 @@ Version 2.26
 
 Major new features:
 
+* Port to ARC HS cores has been contributed by Synopsys.
+
 * A per-thread cache has been added to malloc. Access to the cache requires
   no locks and therefore significantly accelerates the fast path to allocate
   and free small amounts of memory. Refilling an empty cache requires locking
Signature · 1 line
2.7.4
#84 lore raw

PATCH 21/21 NEWS: mention ARC port

NEWS Version 2.26 · line 1082

Quoted 6 lines · Vineet Gupta
NEWS +2 -0
@@ -1078,6 +1078,8 @@ Version 2.26
 
 Major new features:
 
+* Port to ARC HS cores has been contributed by Synopsys.
+

Obviously this belongs under 2.29, or whatever version gets the port, not 2.26.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#85 lore raw

PATCH 21/21 NEWS: mention ARC port

Quoted 2 lines · Joseph Myers

Obviously this belongs under 2.29, or whatever version gets the port, not 2.26.

oops, left over from original code, now fixed and beefed up the details a bit.

#86 lore raw

cover glibc port to ARC processors

In reply to Vineet Gupta
Quoted 3 lines · Vineet Gupta

| FAIL: elf/check-localplt # passes for build-many-glibcs.py

					# buildroot builds with slightly different toggles (-Os)
					# such that gcc generates an extra memcpy PLT call

I fixed lots of such issues with -Os on various architectures; it should be possible to fix this one as well. (I haven't run build-many-glibcs.py with -Os lately, so it's possible more problems have crept in or appear with current compilers. When I was testing it, it failed for m68k - the m68k libm functions don't build with -Os because bits/mathinline.h doesn't get included then, which needs addressing anyway in some way to eliminate bits/mathinline.h from glibc - but worked for most or all other configurations.)

Quoted 2 lines

(d) We currently only support soft float ABI, although I'm working on hard float and hopefully will have it ready sometime during the review of this series

Could you confirm what the ABI entry or entries to go at
<https://sourceware.org/glibc/wiki/ABIList> would look like?

Note that we generally expect new ports to use different dynamic linker names for each ABI. This means separate names for hard float and soft float. Since it appears you support both big and little endian, it also means separate dynamic linker names for each of those (and corresponding GCC changes will be needed to pass the right dynamic linker names to ld's -dynamic-linker option). Then, each supported ABI should have a build in build-many-glibcs.py, and any unsupported ABI variants need to have a configure-time error (to avoid accidentally building a glibc incompatible with the correct ABI for such a port added in future).

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#87 lore raw

cover glibc port to ARC processors

Quoted 6 lines · Joseph Myers
Quoted 3 lines · Vineet Gupta

| FAIL: elf/check-localplt # passes for build-many-glibcs.py

					# buildroot builds with slightly different toggles (-Os)
					# such that gcc generates an extra memcpy PLT call
Quoted 8 lines

I fixed lots of such issues with -Os on various architectures; it should be possible to fix this one as well. (I haven't run build-many-glibcs.py with -Os lately, so it's possible more problems have crept in or appear with current compilers. When I was testing it, it failed for m68k - the m68k libm functions don't build with -Os because bits/mathinline.h doesn't get included then, which needs addressing anyway in some way to eliminate bits/mathinline.h from glibc - but worked for most or all other configurations.)

The actual xcheck runs posted later on have been with buildroot built toolchain which defaults to -Os, so it works for ARC, except for this additional entry.

At any rate, the generated code will likely be different for -Os and otherwise, does that mean entries get added conditionally to localplt.data etc ?

Quoted 5 lines
Quoted 2 lines

(d) We currently only support soft float ABI, although I'm working on hard float and hopefully will have it ready sometime during the review of this series

Could you confirm what the ABI entry or entries to go at
<https://sourceware.org/glibc/wiki/ABIList> would look like?

soft-float LE: ld-linux-arc.so.2
hard-float LE: ld-linux-archf.so.2 (although this is just a preference)

Quoted 6 lines

Note that we generally expect new ports to use different dynamic linker names for each ABI. This means separate names for hard float and soft float. Since it appears you support both big and little endian, it also means separate dynamic linker names for each of those (and corresponding GCC changes will be needed to pass the right dynamic linker names to ld's -dynamic-linker option).

ARC historically has supported both LE/BE, but we are kind of moving away from BE and as far as I know, there's no-one actively working with BE (except 1 specific customer with legact cores). It is safe to assume we won't support BE and this is sort of easier said for ARC processors as they have many many hardware config knobs and not all are supported for Linux usecase, so BE can be considered as such.

Quoted 4 lines

Then, each supported ABI should have a build in build-many-glibcs.py, and any unsupported ABI variants need to have a configure-time error (to avoid accidentally building a glibc incompatible with the correct ABI for such a port added in future).

Right, at this point I only have soft-float and work is ongoing for hard.

Thx for taking a look.
-Vineet

#88 lore raw

cover glibc port to ARC processors

Quoted 2 lines · Vineet Gupta

At any rate, the generated code will likely be different for -Os and otherwise, does that mean entries get added conditionally to localplt.data etc ?

Entries *can* have a "?" to indicate they are optional (although avoiding the PLT reference is better - see how include/string.h does asm redirection of mempcpy and stpcpy, or likewise in sysdeps/wordsize-32/divdi3-symbol-hacks.h, for example).

Quoted 6 lines

ARC historically has supported both LE/BE, but we are kind of moving away from BE and as far as I know, there's no-one actively working with BE (except 1 specific customer with legact cores). It is safe to assume we won't support BE and this is sort of easier said for ARC processors as they have many many hardware config knobs and not all are supported for Linux usecase, so BE can be considered as such.

In that case, there should be a #error in bits/endian.h, or a configure-time error, or something like that, to make clear the glibc port does not support BE.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#89 lore raw

cover glibc port to ARC processors

Quoted 6 lines · Joseph Myers
Quoted 2 lines · Vineet Gupta

At any rate, the generated code will likely be different for -Os and otherwise, does that mean entries get added conditionally to localplt.data etc ?

Entries *can* have a "?" to indicate they are optional

OK.

Quoted 4 lines

(although avoiding
the PLT reference is better - see how include/string.h does asm redirection of mempcpy and stpcpy, or likewise in sysdeps/wordsize-32/divdi3-symbol-hacks.h, for example).

In libc.so, the extra PLT entry for memcpy

| 00106034 00047837 R_ARC_JMP_SLOT 00066d5c memcpy@@GLIBC_2.27 + 0
|
...

|   1bec8:	ld	r12,[pcl,0xea16c] ;106034 <memcpy@@GLIBC_2.27+0x9f2d8>
|   1bed0:	j.d	[r12]
|   1bed4:	mov	r12,pcl

is due to linkage of a generic libgcc routine fp-bit.c

| 000d79c4 <_fpadd_parts>:
|...
|   d7a1a:	bl	-768848	;1bec8 <.plt+0xd0>
|

that in turn is likely due to struct assignment in the routine

|static const fp_number_type *
|_fpadd_parts (fp_number_type * a,
|	      fp_number_type * b,
|	      fp_number_type * tmp)
|{
|   ...
|      if (iszero (a))
|	{
|	  *tmp = *a;

So this is classic case of gcc -Os in action, generating a memcpy vs. in-place LD/ST based copy.

So I guess we just add "?" to localplt.data

Quoted 10 lines
Quoted 6 lines

ARC historically has supported both LE/BE, but we are kind of moving away from BE and as far as I know, there's no-one actively working with BE (except 1 specific customer with legact cores). It is safe to assume we won't support BE and this is sort of easier said for ARC processors as they have many many hardware config knobs and not all are supported for Linux usecase, so BE can be considered as such.

In that case, there should be a #error in bits/endian.h, or a configure-time error, or something like that, to make clear the glibc port does not support BE.

OK, I'll add that.

#90 lore raw

cover glibc port to ARC processors

Quoted 1 line · Vineet Gupta

is due to linkage of a generic libgcc routine fp-bit.c

I'd suggest moving from fp-bit to soft-fp in libgcc (soft-fp is a lot faster, see the 2006 GCC Summit proceedings, though of course you may wish to do your own benchmarking on ARC), which would probably avoid that issue (though if very concerned about about code size, soft-fp is a bit larger). But the "?" in localplt.data would still make sense as long as the GCC versions using fp-bit there are supported for building the ARC glibc port.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#91 lore raw

cover glibc port to ARC processors

Quoted 7 lines · Joseph Myers
Quoted 1 line · Vineet Gupta

is due to linkage of a generic libgcc routine fp-bit.c

I'd suggest moving from fp-bit to soft-fp in libgcc (soft-fp is a lot faster, see the 2006 GCC Summit proceedings, though of course you may wish to do your own benchmarking on ARC), which would probably avoid that issue

It seems the we have "assisted" soft-fp: hand tweaked assembler written originally by Joern, so he and/or Claudiu can advise on that. Although the asm was tweaked for prev core/micro-architecture it should likely be faster than generic "C" code I presume.

Quoted 1 line

(though if very concerned about about code size, soft-fp is a bit larger).

Not for glibc :-) (uClibc is a different story, but it seems with largers RAMs and disks size is kind of becoming moot unless deeply embedded.

Quoted 2 lines

But the "?" in localplt.data would still make sense as long as the GCC versions using fp-bit there are supported for building the ARC glibc port.

Right, added that already.

#92 lore raw

cover glibc port to ARC processors

In reply to Vineet Gupta

Another general point: when posting a new port, could you include pointers to architecture and ABI reference manuals in case those are of relevance to the review? (URLs going directly to PDFs of those manuals are preferred.)

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#93 lore raw

cover glibc port to ARC processors

Quoted 4 lines · Joseph Myers

Another general point: when posting a new port, could you include pointers to architecture and ABI reference manuals in case those are of relevance to the review? (URLs going directly to PDFs of those manuals are preferred.)

The PRM (Programmer's Reference Manual) is not open source and per corporate policy requires license agreement, signing NDA...

The ABI doc as of today is not open as well, although I'm checking if we could share it and if not create equivalent content like some of the other guys on github etc.

Thx for your understanding.

-Vineet

#94 lore raw

cover glibc port to ARC processors

Quoted 8 lines · Vineet Gupta
Quoted 4 lines · Joseph Myers

Another general point: when posting a new port, could you include pointers to architecture and ABI reference manuals in case those are of relevance to the review? (URLs going directly to PDFs of those manuals are preferred.)

The PRM (Programmer's Reference Manual) is not open source and per corporate policy requires license agreement, signing NDA...

It's very questionable whether we should consider a port for inclusion in glibc at all without public architecture documentation (that is, documentation of instruction semantics; not necessarily documentation of microarchitectural performance characteristics etc.). Various kinds of changes can require a developer to refer to documentation across the range of architectures supported by glibc, if something requires assembly implementations across architectures (e.g. some of Adhemerval's changes to thread cancellation; or when I added fegetmode / fesetmode, that required referring to various architecture documentation to identify what bits should be considered mode bits, on each architecture where floating-point status and control bits occupy a single register).

(Non-NDA click-throughs, like the Arm one agreeing not to use the manual to find if Arm implementations violate any patents, are OK, presuming there is nothing to restrict public discussion of the contents and using the information therein to develop free software, although having a direct URL to the manual without needing such a click-through is certainly preferred.)

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#95 lore raw

cover glibc port to ARC processors

Quoted 8 lines · Joseph Myers
Quoted 6 lines · Vineet Gupta
Quoted 4 lines · Joseph Myers

Another general point: when posting a new port, could you include pointers to architecture and ABI reference manuals in case those are of relevance to the review? (URLs going directly to PDFs of those manuals are preferred.)

Quoted 5 lines
Quoted 2 lines

The PRM (Programmer's Reference Manual) is not open source and per corporate policy requires license agreement, signing NDA...

It's very questionable whether we should consider a port for inclusion in glibc at all without public architecture documentation

IMHO this seems excessive. We've successfully open-sourced significant ports such as Linux kernel, gcc, binutils etc. gcc atleast deals with instruction semantics at a much closer level than glibc perse and that didn't get in the way then.

Being an open source developer myself I agree with your reservations, but the reality is what Ted Tso so nicely put in at [1]

| "It's something I do worry about; and I do share your concern.  At the
| same time, the reality is that we are a little like the Old Dutch
| Masters, who had take into account the preference of their patrons
| (i.e., in our case, those who pay our paychecks :-)"

[1] https://lwn.net/Articles/446626/

Quoted 3 lines

(that is,
documentation of instruction semantics; not necessarily documentation of microarchitectural performance characteristics etc.).

I understand the intent is all good faith and justified...

Quoted 8 lines

Various kinds of
changes can require a developer to refer to documentation across the range of architectures supported by glibc, if something requires assembly implementations across architectures (e.g. some of Adhemerval's changes to thread cancellation; or when I added fegetmode / fesetmode, that required referring to various architecture documentation to identify what bits should be considered mode bits, on each architecture where floating-point status and control bits occupy a single register).

To be honest folks on lkml do sweeping arch changes, PeterZ is one good example and he has infact changed ARC assembly at times w/o access to PRM. Given the arrangement we have now, perhaps such changes can call in for review from port maintainer etc.

Quoted 2 lines

(Non-NDA click-throughs, like the Arm one agreeing not to use the manual to find if Arm implementations violate any patents, are OK

No that is not possible: I've discussed this with power may-be in the past and again today and this is not going to happen.

Thx,
-Vineet

#96 lore raw

test related questions (was Re: [PATCH 00/21] glibc port to ARC processors)

In reply to Vineet Gupta
Quoted 7 lines · Vineet Gupta

(a) build-many-glibcs.py check results are clean

| Summary of test results:
|   1173 PASS
|      15 XFAIL
|
| PASS: glibcs-arc-linux-gnu check

One of the issues in running build-many incrementally, i.e. "host-libraries", "compilers" only once but "glibcs" again to quickly test fixes is that for 2nd run, target c++ compiler is picked up for support/links-dso-program vs. links-dso-program-c which fails as the cpp headers are not present. Is there a solution to that ?

Quoted 8 lines

(b) Full testsuite ran in a cross compile setup using buildroot on HSDK development platform.

Summary of test results:

     24 FAIL

5124 PASS
27 UNSUPPORTED
19 XFAIL

One of the pesky issues with cross testing is localedata/gen-locale.sh kicking on
target, which despite being 1GHz gets in the way of quick iterations. Is there a
way to build those on host and simply reference/install them on target. I understand this is more of a buildsystem question (buildroot), but any pointers would be appreciated.

#97 lore raw

test related questions (was Re: [PATCH 00/21] glibc port to ARC processors)

Quoted 9 lines · Vineet Gupta
Quoted 7 lines · Vineet Gupta

(a) build-many-glibcs.py check results are clean

| Summary of test results:
|   1173 PASS
|      15 XFAIL
|
| PASS: glibcs-arc-linux-gnu check
Quoted 5 lines

One of the issues in running build-many incrementally, i.e. "host-libraries", "compilers" only once but "glibcs" again to quickly test fixes is that for 2nd run, target c++ compiler is picked up for support/links-dso-program vs. links-dso-program-c which fails as the cpp headers are not present. Is there a solution to that ?

I'm not aware of that problem. The C++ headers certainly should be available in the compilers installed by the "compilers" step. My bots using GCC 7 and 8 branches only rebuild the compilers once a week unless build-many-glibcs.py itself changes.

Quoted 5 lines

One of the pesky issues with cross testing is localedata/gen-locale.sh kicking on target, which despite being 1GHz gets in the way of quick iterations. Is there a way to build those on host and simply reference/install them on target. I understand this is more of a buildsystem question (buildroot), but any pointers would be appreciated.

It's possible to set up an external build system that extracts the list of locales for testing from localedata/Makefile, builds them using the same version of localedef built for the build system and appropriate options for endianness and uint32_t alignment (if necessary) and copies them into the right places in the glibc build tree before running the glibc tests. It does have to be the same version of localedef since the binary locale format can change depending on the glibc version.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com