public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 00/13] Glibc OpenRISC port
@ 2021-12-10 23:34 Stafford Horne
  2021-12-10 23:34 ` [PATCH v3 01/13] elf: Add reloc for OpenRISC Stafford Horne
                   ` (13 more replies)
  0 siblings, 14 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

This is the OpenRISC port for glibc that I have been working on.

Changes since v2:
 - Fixed suggestions from Joseph Myers:
   - Fix comment style, and description on top of each file
   - Make sure macros have parentheses when needed,
   - Bump required kernel down to 5.4.0 and document
   - Regenerate arch-syscall.h
 - Fixed suggestions from Adhemerval:
   - Remove kernel_stat.h
   - Just set MMAP2_PAGE_UNIT to 8K
   - Remove ioctl.c and syscall.c files
 - Update TCB alignment to 32 bytes

Changes since v1:
 - Update api's as suggested by Florian
 - Remove hard float support
 - Updates to get all tests passing
 - Split patch into managable bits similar to recent ARC port

Documentation:

  Architecture / ABI docs:
   https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf

Test Results:

  build-many-glibcs.py:

   PASS with mainline ang gcc-11.

  Full test suite:

   The full suite is running using the gcc-11 branch of GCC, mainline shows
   issues with math soft-fp.

   Note, there are a few more failures compared to before, this is due to me
   running with a timeout of 30 vs usual 300.  It allows the tests to complete
   faster, but I get a few more timeouts.  There were 15 timeouts which I
   confirm do work if I increase the timeoutfactor. The 2 real failures marked
   with * below.

    # test start:    2021-12-08T19:59:00+09:00

    # failures
    FAIL:*elf/tst-bz15311
    FAIL: locale/tst-localedef-path-norm
    FAIL: malloc/tst-dynarray-fail
    FAIL: malloc/tst-dynarray-fail-mem
    FAIL: nptl/tst-mutex10
    FAIL: nss/tst-nss-files-hosts-getent
    FAIL: nss/tst-nss-files-hosts-multi
    FAIL: posix/tst-regcomp-truncated
    FAIL: stdio-common/tst-vfprintf-width-prec
    FAIL: stdio-common/tst-vfprintf-width-prec-alloc
    FAIL: stdio-common/tst-vfprintf-width-prec-mem
    FAIL: string/test-memcpy
    FAIL: string/test-memcpy-large
    FAIL: string/test-mempcpy
    FAIL: string/tst-cmp
    FAIL: support/tst-support_blob_repeat
    FAIL:*timezone/tst-tzset

    # test finish:   2021-12-10T22:04:56+09:00
    # test duration: 2 days 2 hours 5 minutes and 56 seconds
    # test for file: tests.sum
    # test wrapper:  /home/shorne/work/gnu-toolchain/glibc/scripts/cross-test-ssh.sh --timeoutfactor 30 10.0.0.5

    # summary
	 17 FAIL
       4063 PASS
	 28 UNSUPPORTED
	 18 XFAIL

    tst-bz15311.out: https://gist.github.com/5a5dacaeef1eac1f2f5d89701d14c0ad
    tst-tzset.out: https://gist.github.com/b3a548d82cfc9367905e115821a52754
    tests.sum:     https://gist.github.com/f85a81012c8329b9a95370a30c7b27fe

Stafford Horne (13):
  elf: Add reloc for OpenRISC
  linux/syscalls: Add or1k_atomic syscall for OpenRISC
  or1k: ABI Implementation
  or1k: startup and dynamic linking code
  or1k: Thread Local Storage support
  or1k: Atomics and Locking primitives
  or1k: math soft float support
  or1k: Linux Syscall Interface
  or1k: Linux ABI
  or1k: ABI lists
  or1k: Build Infrastructure
  build-many-glibcs.py: add OpenRISC support
  Documentation for OpenRISC port

 NEWS                                          |    4 +
 README                                        |    1 +
 elf/elf.h                                     |   37 +
 scripts/build-many-glibcs.py                  |    5 +
 sysdeps/or1k/Implies                          |    3 +
 sysdeps/or1k/Makefile                         |    7 +
 sysdeps/or1k/__longjmp.S                      |   55 +
 sysdeps/or1k/atomic-machine.h                 |   79 +
 sysdeps/or1k/bits/endianness.h                |   11 +
 sysdeps/or1k/bits/fenv.h                      |   69 +
 sysdeps/or1k/bits/link.h                      |   51 +
 sysdeps/or1k/bits/setjmp.h                    |   32 +
 sysdeps/or1k/bsd-_setjmp.S                    |    1 +
 sysdeps/or1k/bsd-setjmp.S                     |    1 +
 sysdeps/or1k/dl-machine.h                     |  323 +++
 sysdeps/or1k/dl-start.S                       |   98 +
 sysdeps/or1k/dl-tls.h                         |   27 +
 sysdeps/or1k/dl-trampoline.S                  |   79 +
 sysdeps/or1k/jmpbuf-offsets.h                 |   23 +
 sysdeps/or1k/jmpbuf-unwind.h                  |   36 +
 sysdeps/or1k/ldsodefs.h                       |   40 +
 sysdeps/or1k/libc-tls.c                       |   34 +
 sysdeps/or1k/libm-test-ulps                   | 1112 +++++++++
 sysdeps/or1k/libm-test-ulps-name              |    1 +
 sysdeps/or1k/machine-gmon.h                   |   35 +
 sysdeps/or1k/memusage.h                       |   21 +
 sysdeps/or1k/nofpu/Implies                    |    1 +
 sysdeps/or1k/nofpu/math-tests-exceptions.h    |   29 +
 sysdeps/or1k/nofpu/math-tests-rounding.h      |   28 +
 sysdeps/or1k/nptl/Makefile                    |   21 +
 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h    |   48 +
 sysdeps/or1k/nptl/pthreaddef.h                |   36 +
 sysdeps/or1k/nptl/tcb-offsets.sym             |    6 +
 sysdeps/or1k/nptl/tls.h                       |  189 ++
 sysdeps/or1k/preconfigure                     |   34 +
 sysdeps/or1k/setjmp.S                         |   56 +
 sysdeps/or1k/sfp-machine.h                    |   93 +
 sysdeps/or1k/sotruss-lib.c                    |   51 +
 sysdeps/or1k/stackinfo.h                      |   34 +
 sysdeps/or1k/start.S                          |   99 +
 sysdeps/or1k/sysdep.h                         |   83 +
 sysdeps/or1k/tininess.h                       |    1 +
 sysdeps/or1k/tst-audit.h                      |   24 +
 sysdeps/unix/sysv/linux/or1k/Implies          |    3 +
 sysdeps/unix/sysv/linux/or1k/Makefile         |   12 +
 sysdeps/unix/sysv/linux/or1k/arch-syscall.h   |  325 +++
 sysdeps/unix/sysv/linux/or1k/bits/procfs.h    |   38 +
 sysdeps/unix/sysv/linux/or1k/bits/timesize.h  |   19 +
 sysdeps/unix/sysv/linux/or1k/c++-types.data   |   67 +
 sysdeps/unix/sysv/linux/or1k/clone.c          |   61 +
 sysdeps/unix/sysv/linux/or1k/configure        |    4 +
 sysdeps/unix/sysv/linux/or1k/configure.ac     |    4 +
 sysdeps/unix/sysv/linux/or1k/getcontext.S     |   72 +
 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h |   41 +
 sysdeps/unix/sysv/linux/or1k/ld.abilist       |    5 +
 .../sysv/linux/or1k/libBrokenLocale.abilist   |    1 +
 sysdeps/unix/sysv/linux/or1k/libanl.abilist   |    1 +
 sysdeps/unix/sysv/linux/or1k/libc.abilist     | 2122 +++++++++++++++++
 .../sysv/linux/or1k/libc_malloc_debug.abilist |   26 +
 sysdeps/unix/sysv/linux/or1k/libcrypt.abilist |    2 +
 sysdeps/unix/sysv/linux/or1k/libdl.abilist    |    0
 sysdeps/unix/sysv/linux/or1k/libm.abilist     |  759 ++++++
 sysdeps/unix/sysv/linux/or1k/libnsl.abilist   |  121 +
 .../unix/sysv/linux/or1k/libpthread.abilist   |    0
 .../unix/sysv/linux/or1k/libresolv.abilist    |   55 +
 sysdeps/unix/sysv/linux/or1k/librt.abilist    |    0
 .../unix/sysv/linux/or1k/libthread_db.abilist |   40 +
 sysdeps/unix/sysv/linux/or1k/libutil.abilist  |    1 +
 sysdeps/unix/sysv/linux/or1k/localplt.data    |   14 +
 sysdeps/unix/sysv/linux/or1k/makecontext.c    |   77 +
 sysdeps/unix/sysv/linux/or1k/mmap_internal.h  |   28 +
 sysdeps/unix/sysv/linux/or1k/or1k_clone.S     |   89 +
 sysdeps/unix/sysv/linux/or1k/setcontext.S     |  108 +
 sysdeps/unix/sysv/linux/or1k/shlib-versions   |    2 +
 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h |   28 +
 sysdeps/unix/sysv/linux/or1k/swapcontext.S    |  116 +
 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h   |   53 +
 sysdeps/unix/sysv/linux/or1k/sys/user.h       |    1 +
 sysdeps/unix/sysv/linux/or1k/sysdep.c         |   34 +
 sysdeps/unix/sysv/linux/or1k/sysdep.h         |  201 ++
 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym   |   26 +
 sysdeps/unix/sysv/linux/syscall-names.list    |    1 +
 82 files changed, 7575 insertions(+)
 create mode 100644 sysdeps/or1k/Implies
 create mode 100644 sysdeps/or1k/Makefile
 create mode 100644 sysdeps/or1k/__longjmp.S
 create mode 100644 sysdeps/or1k/atomic-machine.h
 create mode 100644 sysdeps/or1k/bits/endianness.h
 create mode 100644 sysdeps/or1k/bits/fenv.h
 create mode 100644 sysdeps/or1k/bits/link.h
 create mode 100644 sysdeps/or1k/bits/setjmp.h
 create mode 100644 sysdeps/or1k/bsd-_setjmp.S
 create mode 100644 sysdeps/or1k/bsd-setjmp.S
 create mode 100644 sysdeps/or1k/dl-machine.h
 create mode 100644 sysdeps/or1k/dl-start.S
 create mode 100644 sysdeps/or1k/dl-tls.h
 create mode 100644 sysdeps/or1k/dl-trampoline.S
 create mode 100644 sysdeps/or1k/jmpbuf-offsets.h
 create mode 100644 sysdeps/or1k/jmpbuf-unwind.h
 create mode 100644 sysdeps/or1k/ldsodefs.h
 create mode 100644 sysdeps/or1k/libc-tls.c
 create mode 100644 sysdeps/or1k/libm-test-ulps
 create mode 100644 sysdeps/or1k/libm-test-ulps-name
 create mode 100644 sysdeps/or1k/machine-gmon.h
 create mode 100644 sysdeps/or1k/memusage.h
 create mode 100644 sysdeps/or1k/nofpu/Implies
 create mode 100644 sysdeps/or1k/nofpu/math-tests-exceptions.h
 create mode 100644 sysdeps/or1k/nofpu/math-tests-rounding.h
 create mode 100644 sysdeps/or1k/nptl/Makefile
 create mode 100644 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
 create mode 100644 sysdeps/or1k/nptl/pthreaddef.h
 create mode 100644 sysdeps/or1k/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/or1k/nptl/tls.h
 create mode 100644 sysdeps/or1k/preconfigure
 create mode 100644 sysdeps/or1k/setjmp.S
 create mode 100644 sysdeps/or1k/sfp-machine.h
 create mode 100644 sysdeps/or1k/sotruss-lib.c
 create mode 100644 sysdeps/or1k/stackinfo.h
 create mode 100644 sysdeps/or1k/start.S
 create mode 100644 sysdeps/or1k/sysdep.h
 create mode 100644 sysdeps/or1k/tininess.h
 create mode 100644 sysdeps/or1k/tst-audit.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/Implies
 create mode 100644 sysdeps/unix/sysv/linux/or1k/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/or1k/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/timesize.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/or1k/clone.c
 create mode 100644 sysdeps/unix/sysv/linux/or1k/configure
 create mode 100644 sysdeps/unix/sysv/linux/or1k/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/or1k/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libc_malloc_debug.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libnsl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/localplt.data
 create mode 100644 sysdeps/unix/sysv/linux/or1k/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/or1k/mmap_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/or1k_clone.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/shlib-versions
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.c
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym

-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 01/13] elf: Add reloc for OpenRISC
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-14 20:28   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 02/13] linux/syscalls: Add or1k_atomic syscall " Stafford Horne
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

---
 elf/elf.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/elf/elf.h b/elf/elf.h
index baa6c6693e..18458e4d04 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -4125,4 +4125,41 @@ enum
 #define R_ARC_TLS_LE_S9		0x4a
 #define R_ARC_TLS_LE_32		0x4b
 
+/* OpenRISC 1000 specific relocs.  */
+#define R_OR1K_NONE		0
+#define R_OR1K_32		1
+#define R_OR1K_16		2
+#define R_OR1K_8		3
+#define R_OR1K_LO_16_IN_INSN	4
+#define R_OR1K_HI_16_IN_INSN	5
+#define R_OR1K_INSN_REL_26	6
+#define R_OR1K_GNU_VTENTRY	7
+#define R_OR1K_GNU_VTINHERIT	8
+#define R_OR1K_32_PCREL		9
+#define R_OR1K_16_PCREL		10
+#define R_OR1K_8_PCREL		11
+#define R_OR1K_GOTPC_HI16	12
+#define R_OR1K_GOTPC_LO16	13
+#define R_OR1K_GOT16		14
+#define R_OR1K_PLT26		15
+#define R_OR1K_GOTOFF_HI16	16
+#define R_OR1K_GOTOFF_LO16	17
+#define R_OR1K_COPY		18
+#define R_OR1K_GLOB_DAT		19
+#define R_OR1K_JMP_SLOT		20
+#define R_OR1K_RELATIVE		21
+#define R_OR1K_TLS_GD_HI16	22
+#define R_OR1K_TLS_GD_LO16	23
+#define R_OR1K_TLS_LDM_HI16	24
+#define R_OR1K_TLS_LDM_LO16	25
+#define R_OR1K_TLS_LDO_HI16	26
+#define R_OR1K_TLS_LDO_LO16	27
+#define R_OR1K_TLS_IE_HI16	28
+#define R_OR1K_TLS_IE_LO16	29
+#define R_OR1K_TLS_LE_HI16	30
+#define R_OR1K_TLS_LE_LO16	31
+#define R_OR1K_TLS_TPOFF	32
+#define R_OR1K_TLS_DTPOFF	33
+#define R_OR1K_TLS_DTPMOD	34
+
 #endif	/* elf.h */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 02/13] linux/syscalls: Add or1k_atomic syscall for OpenRISC
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
  2021-12-10 23:34 ` [PATCH v3 01/13] elf: Add reloc for OpenRISC Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-14 20:29   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 03/13] or1k: ABI Implementation Stafford Horne
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

---
 sysdeps/unix/sysv/linux/syscall-names.list | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sysdeps/unix/sysv/linux/syscall-names.list b/sysdeps/unix/sysv/linux/syscall-names.list
index 1a74d090b7..a72dee6275 100644
--- a/sysdeps/unix/sysv/linux/syscall-names.list
+++ b/sysdeps/unix/sysv/linux/syscall-names.list
@@ -304,6 +304,7 @@ open_by_handle_at
 open_tree
 openat
 openat2
+or1k_atomic
 osf_adjtime
 osf_afs_syscall
 osf_alt_plock
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 03/13] or1k: ABI Implementation
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
  2021-12-10 23:34 ` [PATCH v3 01/13] elf: Add reloc for OpenRISC Stafford Horne
  2021-12-10 23:34 ` [PATCH v3 02/13] linux/syscalls: Add or1k_atomic syscall " Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-14 20:53   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 04/13] or1k: startup and dynamic linking code Stafford Horne
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

This code deals with the OpenRISC ABI.
---
 sysdeps/or1k/__longjmp.S       | 55 ++++++++++++++++++++++
 sysdeps/or1k/bits/endianness.h | 11 +++++
 sysdeps/or1k/bits/setjmp.h     | 32 +++++++++++++
 sysdeps/or1k/bsd-_setjmp.S     |  1 +
 sysdeps/or1k/bsd-setjmp.S      |  1 +
 sysdeps/or1k/dl-trampoline.S   | 79 ++++++++++++++++++++++++++++++++
 sysdeps/or1k/jmpbuf-offsets.h  | 23 ++++++++++
 sysdeps/or1k/jmpbuf-unwind.h   | 36 +++++++++++++++
 sysdeps/or1k/machine-gmon.h    | 35 ++++++++++++++
 sysdeps/or1k/memusage.h        | 21 +++++++++
 sysdeps/or1k/setjmp.S          | 56 +++++++++++++++++++++++
 sysdeps/or1k/sysdep.h          | 83 ++++++++++++++++++++++++++++++++++
 12 files changed, 433 insertions(+)
 create mode 100644 sysdeps/or1k/__longjmp.S
 create mode 100644 sysdeps/or1k/bits/endianness.h
 create mode 100644 sysdeps/or1k/bits/setjmp.h
 create mode 100644 sysdeps/or1k/bsd-_setjmp.S
 create mode 100644 sysdeps/or1k/bsd-setjmp.S
 create mode 100644 sysdeps/or1k/dl-trampoline.S
 create mode 100644 sysdeps/or1k/jmpbuf-offsets.h
 create mode 100644 sysdeps/or1k/jmpbuf-unwind.h
 create mode 100644 sysdeps/or1k/machine-gmon.h
 create mode 100644 sysdeps/or1k/memusage.h
 create mode 100644 sysdeps/or1k/setjmp.S
 create mode 100644 sysdeps/or1k/sysdep.h

diff --git a/sysdeps/or1k/__longjmp.S b/sysdeps/or1k/__longjmp.S
new file mode 100644
index 0000000000..f8aa5dda8f
--- /dev/null
+++ b/sysdeps/or1k/__longjmp.S
@@ -0,0 +1,55 @@
+/* longjmp, OpenRISC version.
+   Copyright (C) 2021 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <features.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+	.globl	__longjmp;
+	.type	__longjmp, @function;
+	.align	4;
+
+__longjmp:
+	l.lwz	r1, 0(r3)
+	l.lwz	r2, 4(r3)
+
+	/* if r4 is 0, something wrong, so set it to 1 */
+	l.sfeqi	r4, 0x0
+	l.bnf	1f		/* r4 != 0, longjmp value sensible */
+	 l.nop
+	l.ori	r4, r0, 0x1	/* make nonzero */
+1:
+	l.addi	r11, r4, 0
+	l.lwz	r9, 8(r3)
+	l.lwz	r10, 12(r3)
+	l.lwz	r14, 16(r3)
+	l.lwz	r16, 20(r3)
+	l.lwz	r18, 24(r3)
+	l.lwz	r20, 28(r3)
+	l.lwz	r22, 32(r3)
+	l.lwz	r24, 36(r3)
+	l.lwz	r26, 40(r3)
+	l.lwz	r28, 44(r3)
+	l.lwz	r30, 48(r3)
+	l.jr	r9
+	 l.nop
+	.size	__longjmp, . - __longjmp
+
+libc_hidden_def(__longjmp)
diff --git a/sysdeps/or1k/bits/endianness.h b/sysdeps/or1k/bits/endianness.h
new file mode 100644
index 0000000000..7b61d8adb7
--- /dev/null
+++ b/sysdeps/or1k/bits/endianness.h
@@ -0,0 +1,11 @@
+#ifndef _BITS_ENDIANNESS_H
+#define _BITS_ENDIANNESS_H 1
+
+#ifndef _BITS_ENDIAN_H
+# error "Never use <bits/endianness.h> directly; include <endian.h> instead."
+#endif
+
+/* OpenRISC is big-endian.  */
+#define __BYTE_ORDER __BIG_ENDIAN
+
+#endif /* bits/endianness.h */
diff --git a/sysdeps/or1k/bits/setjmp.h b/sysdeps/or1k/bits/setjmp.h
new file mode 100644
index 0000000000..dac511c904
--- /dev/null
+++ b/sysdeps/or1k/bits/setjmp.h
@@ -0,0 +1,32 @@
+/* Define the machine-dependent type `jmp_buf'.  OpenRISC version.
+   Copyright (C) 2021 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+
+#ifndef _OR1K_BITS_SETJMP_H
+#define _OR1K_BITS_SETJMP_H  1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+typedef long int __jmp_buf[13];
+#endif
+
+#endif /* _OR1K_BITS_SETJMP_H */
diff --git a/sysdeps/or1k/bsd-_setjmp.S b/sysdeps/or1k/bsd-_setjmp.S
new file mode 100644
index 0000000000..4e6a2da560
--- /dev/null
+++ b/sysdeps/or1k/bsd-_setjmp.S
@@ -0,0 +1 @@
+/* _setjmp is in setjmp.S  */
diff --git a/sysdeps/or1k/bsd-setjmp.S b/sysdeps/or1k/bsd-setjmp.S
new file mode 100644
index 0000000000..1da848d2f1
--- /dev/null
+++ b/sysdeps/or1k/bsd-setjmp.S
@@ -0,0 +1 @@
+/* setjmp is in setjmp.S  */
diff --git a/sysdeps/or1k/dl-trampoline.S b/sysdeps/or1k/dl-trampoline.S
new file mode 100644
index 0000000000..9ebc68f525
--- /dev/null
+++ b/sysdeps/or1k/dl-trampoline.S
@@ -0,0 +1,79 @@
+/* Machine-dependent ELF runtime symbol resolution, OpenRISC version.
+   Copyright (C) 2021 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This code is used to call _dl_linux_resolver (dl-runtime.c).
+
+   We assume that R11 contains the relocation offset and R12 contains
+   link_map (_DYNAMIC).  This must be consistent with the JUMP_SLOT
+   layout generated by binutils.  */
+
+	.section .text
+	.align 4
+
+	.global	_dl_runtime_resolve
+	.type	_dl_runtime_resolve, @function
+
+_dl_runtime_resolve:
+	.cfi_startproc
+	l.sw	-4(r1), r9
+	l.sw	-8(r1), r1
+
+	/* save function arguments.  */
+	l.sw	-12(r1), r3
+	l.sw	-16(r1), r4
+	l.sw	-20(r1), r5
+	l.sw	-24(r1), r6
+	l.sw	-28(r1), r7
+	l.sw	-32(r1), r8
+
+	.cfi_offset 9, -4
+	.cfi_offset 1, -8
+	.cfi_offset 3, -12
+	.cfi_offset 4, -16
+	.cfi_offset 5, -20
+	.cfi_offset 6, -24
+	.cfi_offset 7, -28
+	.cfi_offset 8, -32
+
+	l.addi	r1,r1, -32
+	.cfi_def_cfa_offset 32
+
+	l.ori	r3, r12, 0
+	l.ori	r4, r11, 0
+
+	l.jal	_dl_fixup
+	 l.nop
+
+	/* Restore function arguments.  */
+	l.addi	r1,r1, 32
+	l.lwz	r8, -32(r1)
+	l.lwz	r7, -28(r1)
+	l.lwz	r6, -24(r1)
+	l.lwz	r5, -20(r1)
+	l.lwz	r4, -16(r1)
+	l.lwz	r3, -12(r1)
+
+	/* restore return address.  */
+	l.lwz	r9, -4(r1)
+
+	l.jr	r11
+	 l.nop
+
+	.cfi_endproc
+	.size	_dl_runtime_resolve, . - _dl_runtime_resolve
diff --git a/sysdeps/or1k/jmpbuf-offsets.h b/sysdeps/or1k/jmpbuf-offsets.h
new file mode 100644
index 0000000000..e33105cc03
--- /dev/null
+++ b/sysdeps/or1k/jmpbuf-offsets.h
@@ -0,0 +1,23 @@
+/* Private macros for accessing __jmp_buf contents.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#define __JMP_BUF_SP    0
+
+/* Helper for generic function ____longjmp_chk.  */
+#define JB_FRAME_ADDRESS(buf) \
+    ((void *) (unsigned long) (buf[__JMP_BUF_SP]))
diff --git a/sysdeps/or1k/jmpbuf-unwind.h b/sysdeps/or1k/jmpbuf-unwind.h
new file mode 100644
index 0000000000..6710dea989
--- /dev/null
+++ b/sysdeps/or1k/jmpbuf-unwind.h
@@ -0,0 +1,36 @@
+/* Macros to help frame unwinding using jmpbuf.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+#include <stdint.h>
+#include <unwind.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+   containing a local variable at ADDRESS.  */
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+  ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+  _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+  ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
+
+/* We use the normal longjmp for unwinding.  */
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/sysdeps/or1k/machine-gmon.h b/sysdeps/or1k/machine-gmon.h
new file mode 100644
index 0000000000..7152105eec
--- /dev/null
+++ b/sysdeps/or1k/machine-gmon.h
@@ -0,0 +1,35 @@
+/* Machine-dependent definitions for profiling support.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+#define _MCOUNT_DECL(frompc, selfpc)					\
+static void								\
+__mcount_internal (unsigned long int frompc, unsigned long int selfpc)
+
+/* This is very simple as gcc does all the heavy lifting at the _mcount
+   call site.  GCC passes in the return address of the function calling
+   _mcount.  */
+
+#define MCOUNT								\
+void									\
+_mcount (void *frompc)							\
+{									\
+  __mcount_internal ((unsigned long int) frompc,			\
+		     (unsigned long int) __builtin_return_address (0));	\
+}
diff --git a/sysdeps/or1k/memusage.h b/sysdeps/or1k/memusage.h
new file mode 100644
index 0000000000..a62da17e61
--- /dev/null
+++ b/sysdeps/or1k/memusage.h
@@ -0,0 +1,21 @@
+/* Definitions for memory usage profiling.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#define GETSP() ({ register uintptr_t stack_ptr asm ("r1"); stack_ptr; })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/or1k/setjmp.S b/sysdeps/or1k/setjmp.S
new file mode 100644
index 0000000000..660995b493
--- /dev/null
+++ b/sysdeps/or1k/setjmp.S
@@ -0,0 +1,56 @@
+/* setjmp, OpenRISC version.
+   Copyright (C) 2021 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+ENTRY (_setjmp)
+	l.addi	r4, r0, 0     /* Set second argument to 0.  */
+	l.j	.Local__sigsetjmp
+	 l.nop
+END (_setjmp)
+libc_hidden_def (_setjmp)
+
+ENTRY (setjmp)
+	l.addi	r4, r0, 1     /* Set second argument to 1.  */
+	l.j	.Local__sigsetjmp
+	 l.nop
+END (setjmp)
+
+ENTRY (__sigsetjmp)
+.Local__sigsetjmp:
+	l.sw	0(r3), r1
+	l.sw	4(r3), r2
+	l.sw	8(r3), r9
+	l.sw	12(r3), r10
+	l.sw	16(r3), r14
+	l.sw	20(r3), r16
+	l.sw	24(r3), r18
+	l.sw	28(r3), r20
+	l.sw	32(r3), r22
+	l.sw	36(r3), r24
+	l.sw	40(r3), r26
+	l.sw	44(r3), r28
+	l.sw	48(r3), r30
+	l.j	__sigjmp_save
+	 l.nop
+END (__sigsetjmp)
+hidden_def (__sigsetjmp)
diff --git a/sysdeps/or1k/sysdep.h b/sysdeps/or1k/sysdep.h
new file mode 100644
index 0000000000..61a135afe7
--- /dev/null
+++ b/sysdeps/or1k/sysdep.h
@@ -0,0 +1,83 @@
+/* Assembler macro definitions.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdeps/generic/sysdep.h>
+#include <features.h>
+
+#if defined __ASSEMBLER__ || defined REQUEST_ASSEMBLER_MACROS
+
+/* Make use of .size directive.  */
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
+
+/* Define an entry point visible from C.  */
+#define ENTRY(name)                                                           \
+  .globl C_SYMBOL_NAME(name);                                                 \
+  .type C_SYMBOL_NAME(name),@function;                                        \
+  .align 4;                                                                   \
+  C_LABEL(name)                                                               \
+  cfi_startproc;                                                              \
+  CALL_MCOUNT
+
+#undef  END
+#define END(name)                                                             \
+  cfi_endproc;                                                                \
+  ASM_SIZE_DIRECTIVE(name)
+
+/* Since C identifiers are not normally prefixed with an underscore
+   on this system, the asm identifier `syscall_error' intrudes on the
+   C name space.  Make sure we use an innocuous name.  */
+#define syscall_error   __syscall_error
+
+/* If compiled for profiling, call `mcount' at the start of each function.  */
+#ifdef  PROF
+# ifdef __PIC__
+#  define CALL_MCOUNT						\
+	l.addi	r1, r1, -8;					\
+	l.sw	0(r1), r9;					\
+	l.sw	4(r1), r3;					\
+	l.ori	r3, r9, 0;					\
+	l.j	plt(_mcount);					\
+	 l.nop;							\
+	l.lwz	r9, 0(r1);					\
+	l.lwz	r3, 4(r1);					\
+	l.addi	r1, r1, 8;
+# else
+#  define CALL_MCOUNT						\
+	l.addi	r1, r1, -8;					\
+	l.sw	0(r1), r9;					\
+	l.sw	4(r1), r3;					\
+	l.ori	r3, r9, 0;					\
+	l.movhi r15, hi(_mcount);				\
+	l.ori	r15, r15, lo(_mcount);				\
+	l.jr	r15;						\
+	 l.nop;							\
+	l.lwz	r9, 0(r1);					\
+	l.lwz	r3, 4(r1);					\
+	l.addi	r1, r1, 8;
+# endif
+#else
+# define CALL_MCOUNT             /* Do nothing.  */
+#endif
+
+/* Local label name for asm code.  */
+#define L(name)         .L##name
+
+/* Specify the size in bytes of a machine register.  */
+#define REGSIZE         4
+
+#endif /* __ASSEMBLER__ */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 04/13] or1k: startup and dynamic linking code
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (2 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 03/13] or1k: ABI Implementation Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-16 10:42   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 05/13] or1k: Thread Local Storage support Stafford Horne
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

Code for C runtime startup and dynamic loading including PLT layout.
---
 sysdeps/or1k/bits/link.h   |  51 ++++++
 sysdeps/or1k/dl-machine.h  | 323 +++++++++++++++++++++++++++++++++++++
 sysdeps/or1k/dl-start.S    |  98 +++++++++++
 sysdeps/or1k/ldsodefs.h    |  40 +++++
 sysdeps/or1k/sotruss-lib.c |  51 ++++++
 sysdeps/or1k/start.S       |  99 ++++++++++++
 sysdeps/or1k/tst-audit.h   |  24 +++
 7 files changed, 686 insertions(+)
 create mode 100644 sysdeps/or1k/bits/link.h
 create mode 100644 sysdeps/or1k/dl-machine.h
 create mode 100644 sysdeps/or1k/dl-start.S
 create mode 100644 sysdeps/or1k/ldsodefs.h
 create mode 100644 sysdeps/or1k/sotruss-lib.c
 create mode 100644 sysdeps/or1k/start.S
 create mode 100644 sysdeps/or1k/tst-audit.h

diff --git a/sysdeps/or1k/bits/link.h b/sysdeps/or1k/bits/link.h
new file mode 100644
index 0000000000..ad183c9625
--- /dev/null
+++ b/sysdeps/or1k/bits/link.h
@@ -0,0 +1,51 @@
+/* Declarations for dynamic linker interface. OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> instead."
+#endif
+
+/* Registers for entry into PLT.  */
+typedef struct La_or1k_regs
+{
+  uint32_t lr_reg[31];
+} La_or1k_regs;
+
+/* Return values for calls from PLT.  */
+typedef struct La_or1k_retval
+{
+  uint32_t lrv_r3;
+} La_or1k_retval;
+
+__BEGIN_DECLS
+
+extern ElfW(Addr) la_or1k_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
+					uintptr_t *__refcook,
+					uintptr_t *__defcook,
+					La_or1k_regs *__regs,
+					unsigned int *__flags,
+					const char *__symname,
+					long int *__framesizep);
+extern unsigned int la_or1k_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
+					 uintptr_t *__refcook,
+					 uintptr_t *__defcook,
+					 const La_or1k_regs *__inregs,
+					 La_or1k_retval *__outregs,
+					 const char *__symname);
+
+__END_DECLS
diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h
new file mode 100644
index 0000000000..d41554769e
--- /dev/null
+++ b/sysdeps/or1k/dl-machine.h
@@ -0,0 +1,323 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "or1k"
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <tls.h>
+#include <dl-irel.h>
+#include <dl-static-tls.h>
+#include <dl-machine-rel.h>
+
+/* Return nonzero iff ELF header is compatible with the running host.  */
+static inline int __attribute__ ((unused))
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+  return ehdr->e_machine == EM_OPENRISC;
+}
+
+static inline Elf32_Addr *
+or1k_get_got (void)
+{
+  Elf32_Addr *got;
+  register long int linkreg asm ("r9");
+  asm ("l.jal    0x8\n"
+       " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
+       "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
+       "l.add    %0, %0, %1\n"
+       : "=r" (got), "=r" (linkreg));
+
+  return got;
+}
+
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+  Elf32_Addr *got = or1k_get_got();
+  return *got;
+}
+
+
+/* Return the run-time load address of the shared object.  */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+  /* Compute the difference between the runtime address of _DYNAMIC as seen
+     by a GOTOFF reference, and the link-time address found in the special
+     unrelocated first GOT entry.  */
+  Elf32_Addr dyn;
+  Elf32_Addr *got = or1k_get_got();
+
+  asm ("l.movhi %0, gotoffhi(_DYNAMIC);"
+       "l.ori   %0, %0, gotofflo(_DYNAMIC);"
+       "l.add   %0, %0, %1;"
+       : "=&r"(dyn) : "r"(got));
+
+  return dyn - *got;
+}
+
+/* Initial entry point code for the dynamic linker.  The function _dl_start
+   is the real entry point; it's return value is the user program's entry
+   point.
+
+   Code is really located in dl-start.S, just tell the linker that it
+   exists.  */
+#define RTLD_START asm (".globl _dl_start");
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+   TLS variable, so undefined references should not be allowed to
+   define the value.
+   ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+   of the main executable's symbols, as for a COPY reloc.  */
+
+#define elf_machine_type_class(type) \
+  (((type) == R_OR1K_JMP_SLOT \
+   || (type) == R_OR1K_TLS_DTPMOD \
+   || (type) == R_OR1K_TLS_DTPOFF \
+   || (type) == R_OR1K_TLS_TPOFF) * ELF_RTYPE_CLASS_PLT \
+   | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY)
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
+#define ELF_MACHINE_JMP_SLOT    R_OR1K_JMP_SLOT
+
+#define ARCH_LA_PLTENTER or1k_gnu_pltenter
+#define ARCH_LA_PLTEXIT or1k_gnu_pltexit
+
+/* Set up the loaded object described by L so its unrelocated PLT
+   entries will jump to the on-demand fixup code in dl-runtime.c.  */
+static inline int __attribute__ ((unused, always_inline))
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
+			   int lazy, int profile)
+{
+  ElfW(Addr) *pltgot;
+  extern void _dl_runtime_resolve (ElfW(Word));
+  extern void _dl_runtime_profile (ElfW(Word));
+
+  if (l->l_info[DT_JMPREL] && lazy)
+    {
+      pltgot = (ElfW(Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
+
+      /* Fill in initial entrys of the plt */
+
+      /* Register the link_map address in the plt at pltgot[1].
+	 This will also be used in the resolver for accessing the
+	 link_map structure.  */
+      pltgot[1] = (ElfW(Addr)) l;
+
+      /* The pltgot[2] entry contains the address of a function which gets
+	 called to get the address of a so far unresolved function and
+	 jump to it.  The profiling extension of the dynamic linker allows
+	 to intercept the calls to collect information.  In this case we
+	 don't store the address in the GOT so that all future calls also
+	 end in this function.  */
+#if 0 /* Profiling not supported in OpenRISC yet (need to implement
+	 _dl_runtime_profile).  */
+      if ( profile)
+	{
+	   pltgot[2] = (ElfW(Addr)) &_dl_runtime_profile;
+
+	  if (GLRO(dl_profile) != NULL
+	      && _dl_name_match_p (GLRO(dl_profile), l))
+	    /* Say that we really want profiling and the timers are
+	       started.  */
+	    GL(dl_profile_map) = l;
+	}
+      else
+#endif
+	{
+	  /* This function will get called to fix up the GOT entry
+	     indicated by the offset on the stack, and then jump to
+	     the resolved address.  */
+	  pltgot[2] = (ElfW(Addr)) &_dl_runtime_resolve;
+	}
+
+    }
+
+  return lazy;
+}
+
+/* Mask identifying addresses reserved for the user program,
+   where the dynamic linker should not map anything.  */
+#define ELF_MACHINE_USER_ADDRESS_MASK   0xf8000000UL
+
+/* We define an initialization functions.  This is called very early in
+   _dl_sysdep_start.  */
+#define DL_PLATFORM_INIT dl_platform_init ()
+
+static inline void __attribute__ ((unused))
+dl_platform_init (void)
+{
+  if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
+    /* Avoid an empty string which would disturb us.  */
+    GLRO(dl_platform) = NULL;
+}
+
+static inline ElfW(Addr)
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+		       const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
+		       const ElfW(Rela) *reloc,
+		       ElfW(Addr) *reloc_addr, ElfW(Addr) value)
+{
+  return *reloc_addr = value;
+}
+
+/* Return the final value of a plt relocation.  */
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
+		       Elf32_Addr value)
+{
+  return value + reloc->r_addend;
+}
+
+
+#endif /* !dl_machine_h */
+
+#ifdef RESOLVE_MAP
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+   MAP is the object containing the reloc.  */
+
+static inline void
+__attribute ((always_inline))
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
+		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
+		  const struct r_found_version *version,
+		  void *const reloc_addr_arg, int skip_ifunc)
+{
+  Elf32_Addr *const reloc_addr = reloc_addr_arg;
+  const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+
+  if (__glibc_unlikely (r_type == R_OR1K_NONE))
+    return;
+  else
+    {
+# ifndef RESOLVE_CONFLICT_FIND_MAP
+      const Elf32_Sym *const refsym = sym;
+# endif
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
+					      r_type);
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
+
+      if (sym != NULL
+	  && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)
+	  && __glibc_likely (sym->st_shndx != SHN_UNDEF)
+	  && __glibc_likely (!skip_ifunc))
+	value = elf_ifunc_invoke (value);
+
+      switch (r_type)
+	{
+# ifndef RESOLVE_CONFLICT_FIND_MAP
+	  case R_OR1K_COPY:
+	    if (sym == NULL)
+	      /* This can happen in trace mode if an object could not be
+		 found.  */
+	      break;
+	    if (__glibc_unlikely (sym->st_size > refsym->st_size)
+		|| (__glibc_unlikely (sym->st_size < refsym->st_size)
+		  && GLRO(dl_verbose)))
+	    {
+	      const char *strtab;
+
+	      strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
+	      _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+		  rtld_progname ?: "<program name unknown>",
+		  strtab + refsym->st_name);
+	    }
+	    memcpy (reloc_addr_arg, (void *) value,
+		MIN (sym->st_size, refsym->st_size));
+	    break;
+# endif /* !RESOLVE_CONFLICT_FIND_MAP */
+	  case R_OR1K_32:
+	    /* Support relocations on mis-aligned offsets.  */
+	    value += reloc->r_addend;
+	    memcpy (reloc_addr_arg, &value, 4);
+	    break;
+	  case R_OR1K_GLOB_DAT:
+	  case R_OR1K_JMP_SLOT:
+	    *reloc_addr = value + reloc->r_addend;
+	    break;
+	  case R_OR1K_TLS_DTPMOD:
+# ifdef RTLD_BOOTSTRAP
+	    /* During startup the dynamic linker is always the module
+	       with index 1.  */
+	    *reloc_addr = 1;
+# else
+	    if (sym_map != NULL)
+	      *reloc_addr = sym_map->l_tls_modid;
+# endif
+	    break;
+	  case R_OR1K_TLS_DTPOFF:
+# ifndef RTLD_BOOTSTRAP
+	    *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
+# endif
+	    break;
+
+	  case R_OR1K_TLS_TPOFF:
+# ifdef RTLD_BOOTSTRAP
+	    *reloc_addr = sym->st_value + reloc->r_addend +
+	      map->l_tls_offset - TLS_TCB_SIZE;
+# else
+	    if (sym_map != NULL)
+	      {
+		CHECK_STATIC_TLS (map, sym_map);
+		*reloc_addr = sym->st_value + reloc->r_addend +
+		  sym_map->l_tls_offset - TLS_TCB_SIZE;
+	      }
+# endif
+	    break;
+	  default:
+	    _dl_reloc_bad_type (map, r_type, 0);
+	    break;
+	}
+    }
+}
+
+static inline void
+__attribute__ ((always_inline))
+elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
+			   void *const reloc_addr_arg)
+{
+  Elf32_Addr *const reloc_addr = reloc_addr_arg;
+  *reloc_addr = l_addr + reloc->r_addend;
+}
+
+static inline void
+__attribute__ ((always_inline))
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
+		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
+		      int skip_ifunc)
+{
+  Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
+  const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+
+  if (__glibc_likely (r_type == R_OR1K_JMP_SLOT))
+      *reloc_addr += l_addr;
+  else if (__glibc_unlikely (r_type == R_OR1K_NONE))
+    return;
+  else
+    _dl_reloc_bad_type (map, r_type, 1);
+}
+
+#endif /* RESOLVE_MAP */
diff --git a/sysdeps/or1k/dl-start.S b/sysdeps/or1k/dl-start.S
new file mode 100644
index 0000000000..ecb1505427
--- /dev/null
+++ b/sysdeps/or1k/dl-start.S
@@ -0,0 +1,98 @@
+/* Machine-dependent ELF startup code.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+/* Initial entry point code for the dynamic linker.
+   The function _dl_start is the real entry point;
+   it's return value is the user program's entry point.  */
+ENTRY (_start)
+	/* Count arguments in r11 */
+	l.ori	r3, r1, 0
+	l.movhi	r11, 0
+1:
+	l.addi	r3, r3, 4
+	l.lwz	r12, 0(r3)
+	l.sfnei	r12, 0
+	l.addi	r11, r11, 1
+	l.bf	1b
+	 l.nop
+	l.addi	r11, r11, -1
+	/* store argument counter to stack.  */
+	l.sw	0(r1), r11
+
+	/* Load the PIC register.  */
+	l.jal	0x8
+	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
+	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
+	l.add	r16, r16, r9
+
+	l.ori	r3, r1, 0
+
+	l.jal	_dl_start
+	 l.nop
+	/* Save user entry in a call saved reg.  */
+	l.ori	r22, r11, 0
+	/* Fall through to _dl_start_user.  */
+
+_dl_start_user:
+	/* Set up for _dl_init.  */
+
+	/* Load _rtld_local (a.k.a _dl_loaded).  */
+	l.lwz	r12, got(_rtld_local)(r16)
+	l.lwz	r3, 0(r12)
+
+	/* Load argc */
+	l.lwz	r18, got(_dl_argc)(r16)
+	l.lwz	r4, 0(r18)
+
+	/* Load argv */
+	l.lwz	r20, got(_dl_argv)(r16)
+	l.lwz	r5, 0(r20)
+
+	/* Load envp = &argv[argc + 1].  */
+	l.slli	r6, r4, 2
+	l.addi	r6, r6, 4
+	l.add	r6, r6, r5
+
+	l.jal	plt(_dl_init)
+	 l.nop
+
+	/* Now set up for user entry.
+	   The already defined ABI loads argc and argv from the stack.
+
+	   argc = 0(r1)
+	   argv = r1 + 4
+	*/
+
+	/* Load SP as argv - 4.  */
+	l.lwz	r3, 0(r20)
+	l.addi	r1, r3, -4
+
+	/* Save argc.  */
+	l.lwz	r3, 0(r18)
+	l.sw	0(r1), r3
+
+	/* Pass _dl_fini function address to _start.
+	   Next start.S will then pass this as rtld_fini to __libc_start_main.  */
+	l.lwz	r3, got(_dl_fini)(r16)
+
+	l.jr	r22
+	 l.nop
+
+END (_start)
diff --git a/sysdeps/or1k/ldsodefs.h b/sysdeps/or1k/ldsodefs.h
new file mode 100644
index 0000000000..89713fcc70
--- /dev/null
+++ b/sysdeps/or1k/ldsodefs.h
@@ -0,0 +1,40 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef	_OR1K_LDSODEFS_H
+#define	_OR1K_LDSODEFS_H	1
+
+#include <elf.h>
+
+struct La_or1k_regs;
+struct La_or1k_retval;
+
+#define ARCH_PLTENTER_MEMBERS						\
+    uintptr_t (*or1k_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *, \
+				  uintptr_t *, struct La_or1k_regs *, \
+				  unsigned int *, const char *name,	\
+				  long int *framesizep)
+
+#define ARCH_PLTEXIT_MEMBERS						\
+    unsigned int (*or1k_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *, \
+				    uintptr_t *, const struct La_or1k_regs *, \
+				    struct La_or1k_retval *, const char *)
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/sysdeps/or1k/sotruss-lib.c b/sysdeps/or1k/sotruss-lib.c
new file mode 100644
index 0000000000..ee16f84456
--- /dev/null
+++ b/sysdeps/or1k/sotruss-lib.c
@@ -0,0 +1,51 @@
+/* Override generic sotruss-lib.c to define actual functions for OpenRISC.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#define HAVE_ARCH_PLTENTER
+#define HAVE_ARCH_PLTEXIT
+
+#include <elf/sotruss-lib.c>
+
+ElfW(Addr)
+la_or1k_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
+		       unsigned int ndx __attribute__ ((unused)),
+		       uintptr_t *refcook, uintptr_t *defcook,
+		       La_or1k_regs *regs, unsigned int *flags,
+		       const char *symname, long int *framesizep)
+{
+  print_enter (refcook, defcook, symname,
+	       regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
+	       *flags);
+
+  /* No need to copy anything, we will not need the parameters in any case.  */
+  *framesizep = 0;
+
+  return sym->st_value;
+}
+
+unsigned int
+la_or1k_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
+		      uintptr_t *defcook,
+		      const struct La_or1k_regs *inregs,
+		      struct La_or1k_retval *outregs,
+		      const char *symname)
+{
+  print_exit (refcook, defcook, symname, outregs->lrv_r3);
+
+  return 0;
+}
diff --git a/sysdeps/or1k/start.S b/sysdeps/or1k/start.S
new file mode 100644
index 0000000000..0424355f36
--- /dev/null
+++ b/sysdeps/or1k/start.S
@@ -0,0 +1,99 @@
+/* start, OpenRISC version.
+   Copyright (C) 2021 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This is the canonical entry point, usually the first thing in the text
+   segment.
+
+   sp   The stack contains the arguments and environment:
+    0(sp)     argc
+    4(sp)     argv[0]
+    ...
+    (4*argc)(sp)    NULL
+    (4*(argc+1))(sp)  envp[0]
+    ...
+    NULL
+ */
+
+#define __ASSEMBLY__
+#include <sysdep.h>
+#include <entry.h>
+
+ENTRY (ENTRY_POINT)
+
+	/* Setup Arguments to the __libc_start_main function.  */
+
+	/* Take values for argc and argv off the stack.
+	   These will be passed as arguments two and three to main
+	   and thus go in registers r4 and r5, respectively.  */
+	l.lwz	r4, 0(r1)
+	l.addi	r5, r1, 4
+
+	/* Pass in rtld_fini from dl-start.S.  */
+	l.or	r8, r3, r3
+
+#ifdef PIC
+	/* Obtain a pointer to .got in r16 */
+	l.jal	0x8
+	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
+	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
+	l.add	r16, r16, r9
+
+	/* Pass in the the main symbol.  */
+	l.lwz	r3, got(main)(r16)
+#else
+	/* Pass in the the main symbol.  */
+	l.movhi r3, hi(main)
+	l.ori	r3, r3, lo(main)
+#endif
+	/* Used to be init and fini.  */
+	l.movhi	r6, 0x0
+	l.movhi	r7, 0x0
+
+	/* Push stack limit onto the stack.
+	   This provides the highest stack address to user code (as stack grows
+	   downwards.
+	   This is the seventh argument to __libc_start_main and thus needs to
+	   be passed on the stack.  */
+	l.sw	-4(r1), r1
+
+	/* Adjust stack to account for a total of 7 args (i.e. the last one is
+	   on the stack.  */
+	l.addi	r1, r1, -4
+
+	/* Clear the frame pointer and link register since this is the
+	   outermost frame.  */
+	l.movhi	r2, 0x0
+	l.movhi	r9, 0x0
+
+	/* Let the libc call main and exit with its return code.  */
+#ifdef PIC
+	l.j	plt(__libc_start_main)
+#else
+	l.j	__libc_start_main
+#endif
+	 l.nop
+END (ENTRY_POINT)
+
+	/* Define a symbol for the first piece of initialized data.  */
+	.data
+	.globl __data_start
+__data_start:
+	.long 0
+	.weak data_start
+	data_start = __data_start
diff --git a/sysdeps/or1k/tst-audit.h b/sysdeps/or1k/tst-audit.h
new file mode 100644
index 0000000000..79ee1b7b02
--- /dev/null
+++ b/sysdeps/or1k/tst-audit.h
@@ -0,0 +1,24 @@
+/* Definitions for testing PLT entry/exit auditing.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#define pltenter la_or1k_gnu_pltenter
+#define pltexit la_or1k_gnu_pltexit
+#define La_regs La_or1k_regs
+#define La_retval La_or1k_retval
+#define int_retval lrv_r3
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 05/13] or1k: Thread Local Storage support
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (3 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 04/13] or1k: startup and dynamic linking code Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-16 11:35   ` Adhemerval Zanella
  2021-12-16 12:37   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 06/13] or1k: Atomics and Locking primitives Stafford Horne
                   ` (8 subsequent siblings)
  13 siblings, 2 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

OpenRISC includes 3 TLS addressing models.  Local Dynamic optimizations
are not done in the linker and therefore use the same code sequences as
Global Dynamic.
---
 sysdeps/or1k/dl-tls.h             |  27 +++++
 sysdeps/or1k/libc-tls.c           |  34 ++++++
 sysdeps/or1k/nptl/tcb-offsets.sym |   6 +
 sysdeps/or1k/nptl/tls.h           | 189 ++++++++++++++++++++++++++++++
 sysdeps/or1k/stackinfo.h          |  34 ++++++
 5 files changed, 290 insertions(+)
 create mode 100644 sysdeps/or1k/dl-tls.h
 create mode 100644 sysdeps/or1k/libc-tls.c
 create mode 100644 sysdeps/or1k/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/or1k/nptl/tls.h
 create mode 100644 sysdeps/or1k/stackinfo.h

diff --git a/sysdeps/or1k/dl-tls.h b/sysdeps/or1k/dl-tls.h
new file mode 100644
index 0000000000..382588d504
--- /dev/null
+++ b/sysdeps/or1k/dl-tls.h
@@ -0,0 +1,27 @@
+/* TLS definitions for the ELF dynamic linker.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://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);
diff --git a/sysdeps/or1k/libc-tls.c b/sysdeps/or1k/libc-tls.c
new file mode 100644
index 0000000000..1524855e88
--- /dev/null
+++ b/sysdeps/or1k/libc-tls.c
@@ -0,0 +1,34 @@
+/* Thread-local storage handling in the ELF dynamic linker.
+   OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+/* On OpenRISC, linker optimizations are not required, so __tls_get_addr
+   can be called even in statically linked binaries.  In this case module
+   must be always 1 and PT_TLS segment exist in the binary, otherwise it
+   would not link.  */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+  dtv_t *dtv = THREAD_DTV ();
+  return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
diff --git a/sysdeps/or1k/nptl/tcb-offsets.sym b/sysdeps/or1k/nptl/tcb-offsets.sym
new file mode 100644
index 0000000000..86025a402d
--- /dev/null
+++ b/sysdeps/or1k/nptl/tcb-offsets.sym
@@ -0,0 +1,6 @@
+#include <sysdep.h>
+#include <tls.h>
+
+MULTIPLE_THREADS_OFFSET         offsetof (struct pthread, header.multiple_threads)
+TID_OFFSET                      offsetof (struct pthread, tid)
+TP_TO_PTHREAD_OFFSET            -(sizeof (struct pthread) + sizeof (tcbhead_t))
diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
new file mode 100644
index 0000000000..dc11610920
--- /dev/null
+++ b/sysdeps/or1k/nptl/tls.h
@@ -0,0 +1,189 @@
+/* Definition for thread-local data handling.  NPTL/OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _TLS_H
+#define _TLS_H  1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <dl-dtv.h>
+
+typedef struct
+{
+  dtv_t *dtv;
+  void *__padding[3]; /* To maintain 16 byte padding, needed by STACK_ALIGN.  */
+} tcbhead_t;
+
+register tcbhead_t *__thread_self __asm__("r10");
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information.  */
+# include <sysdep.h>
+
+/* The TP points to the start of the TLS block.
+   As I understand it, this isn't strictly that "TP points to DTV" - it's
+   more where to place the TCB in the TLS block.  This will place it in
+   the beginning.
+
+   Layout:
+    +-----+-----+----------------------+
+    | PRE | TCB | TLS MEMORY ..        |
+    +-----+-----+----------------------+
+		 ^ r10 / TP
+
+   PRE is the struct pthread described below
+   TCB is tcbhead_t
+   TLS memory is where the TLS program sections are loaded
+
+   See _dl_allocate_tls_storage and __libc_setup_tls for more information.  */
+
+# define TLS_DTV_AT_TP  1
+# define TLS_TCB_AT_TP  0
+
+/* Get the thread descriptor definition.  */
+# include <nptl/descr.h>
+
+/* Requirements for the TCB.  */
+# define TLS_INIT_TCB_SIZE    sizeof (tcbhead_t)
+# define TLS_INIT_TCB_ALIGN   __alignof__ (struct pthread)
+
+# define TLS_TCB_SIZE         sizeof (tcbhead_t)
+# define TLS_TCB_ALIGN        __alignof__ (struct pthread)
+
+/* This is the size of the TCB.  */
+
+/* This is the size we need before TCB.
+   To support THREAD_GETMEM with friends we want to have a
+   struct pthread available.
+   Yank it in infront of everything, I'm sure nobody will mind.
+
+   This memory is really allocated PRE the TLS block, so it's possible
+   to do ((char*)tlsblock) - TLS_PRE_TCB_SIZE to access it.
+   This is done for THREAD_SELF.  */
+
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+
+/* Install the dtv pointer.
+   When called, dtvp is a pointer not the DTV per say (which should start
+   with the generation counter) but to the length of the DTV.
+   We can always index with -1, so we store dtvp[1].  */
+
+# define INSTALL_DTV(tcbp, dtvp) \
+  (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread
+   In a logicial world dtv here would also point to the length of the DTV.
+   However it does not, this time it points to the generation counter,
+   so just store it.
+
+   Note: -1 is still valid and contains the length.  */
+
+# define INSTALL_NEW_DTV(dtv) (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor.  */
+# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer.
+
+   Set TP to the address _after_ tcbhead_t.  This will allow us
+   to change the size of tcbhead_t without having to re-link everything.
+
+   This has to return NULL on success (or a string with the failure text).
+   It's hard to fail this, so return NULL always.  */
+
+# define TLS_INIT_TP(tcbp) \
+  ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;})
+
+/* Value passed to 'clone' for initialization of the thread register.  */
+# define TLS_DEFINE_INIT_TP(tp, pd) \
+  void *tp = ((char *) pd + TLS_PRE_TCB_SIZE + TLS_INIT_TCB_SIZE)
+
+/* Return the address of the dtv for the current thread.
+
+   Dereference TP, offset to dtv - really straightforward.
+   Remember that we made TP point to after tcb, so we need to reverse that.  */
+
+#  define THREAD_DTV() \
+  ((((tcbhead_t *)__thread_self)-1)->dtv)
+
+/* Return the thread descriptor for the current thread.
+
+   Return a pointer to the TLS_PRE area where we allocated space for
+   a struct pthread.  Again, TP points to after tcbhead_t, compensate with
+   TLS_INIT_TCB_SIZE.
+
+   I regard this is a seperate system from the "normal" TLS.  */
+
+# define THREAD_SELF \
+  ((struct pthread *) ((char *) __thread_self - TLS_INIT_TCB_SIZE \
+    - TLS_PRE_TCB_SIZE))
+
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+
+# define DB_THREAD_SELF \
+  REGISTER (32, 32, 10 * 4, - TLS_INIT_TCB_SIZE - TLS_PRE_TCB_SIZE)
+
+/* Access to data in the thread descriptor is easy.  */
+
+#define THREAD_GETMEM(descr, member) \
+  descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+  descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+  descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+  descr->member[idx] = (value)
+
+/* Get and set the global scope generation counter in struct pthread.  */
+
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED   1
+#define THREAD_GSCOPE_FLAG_WAIT   2
+#define THREAD_GSCOPE_RESET_FLAG()					\
+  do									\
+    {									\
+      int __res = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,\
+				       THREAD_GSCOPE_FLAG_UNUSED);	\
+      if (__res == THREAD_GSCOPE_FLAG_WAIT)				\
+	  lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1,		\
+			  LLL_PRIVATE);					\
+    }									\
+  while (0)
+#define THREAD_GSCOPE_SET_FLAG()					\
+  do									\
+    {									\
+      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	\
+      atomic_write_barrier ();						\
+    }									\
+  while (0)
+
+#endif /* __ASSEMBLER__ */
+
+#endif  /* tls.h */
diff --git a/sysdeps/or1k/stackinfo.h b/sysdeps/or1k/stackinfo.h
new file mode 100644
index 0000000000..9273e709bd
--- /dev/null
+++ b/sysdeps/or1k/stackinfo.h
@@ -0,0 +1,34 @@
+/* Stack definitions for OpenRISC.
+   Copyright (C) 2021 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
+   <https://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 or1k the stack grows down.  */
+#define _STACK_GROWS_DOWN	1
+
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+   present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R | PF_W | PF_X)
+
+#endif /* stackinfo.h */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 06/13] or1k: Atomics and Locking primitives
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (4 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 05/13] or1k: Thread Local Storage support Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-16 12:52   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 07/13] or1k: math soft float support Stafford Horne
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

---
 sysdeps/or1k/atomic-machine.h | 79 +++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 sysdeps/or1k/atomic-machine.h

diff --git a/sysdeps/or1k/atomic-machine.h b/sysdeps/or1k/atomic-machine.h
new file mode 100644
index 0000000000..1e306ae4ef
--- /dev/null
+++ b/sysdeps/or1k/atomic-machine.h
@@ -0,0 +1,79 @@
+/* Atomic operations.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef __OR1K_ATOMIC_H_
+#define __OR1K_ATOMIC_H_
+
+#include <stdint.h>
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+#define __HAVE_64B_ATOMICS 0
+#define USE_ATOMIC_COMPILER_BUILTINS 1
+#define ATOMIC_EXCHANGE_USES_CAS 1
+
+#define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \
+  (abort (), 0)
+
+#define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \
+  (abort (), 0)
+
+#define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \
+  ({                                                                    \
+    typeof (*mem) __oldval = (oldval);                                  \
+    !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   \
+				  model, __ATOMIC_RELAXED);             \
+  })
+
+#define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \
+  (abort (), 0)
+
+#define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \
+  (abort (), (__typeof (*mem)) 0)
+
+#define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \
+  (abort (), (__typeof (*mem)) 0)
+
+#define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \
+  ({                                                                    \
+    typeof (*mem) __oldval = (oldval);                                  \
+    __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,    \
+				 model, __ATOMIC_RELAXED);              \
+    __oldval;                                                           \
+  })
+
+#define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \
+  (abort (), (__typeof (*mem)) 0)
+
+#define atomic_compare_and_exchange_bool_acq(mem, new, old)		\
+  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int,		\
+			mem, new, old, __ATOMIC_ACQUIRE)
+
+#define atomic_compare_and_exchange_val_acq(mem, new, old)		\
+  __atomic_val_bysize (__arch_compare_and_exchange_val, int,		\
+		       mem, new, old, __ATOMIC_ACQUIRE)
+
+#define atomic_full_barrier() ({ asm volatile ("l.msync" ::: "memory"); })
+
+#endif /* atomic-machine.h */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 07/13] or1k: math soft float support
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (5 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 06/13] or1k: Atomics and Locking primitives Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-16 19:48   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 08/13] or1k: Linux Syscall Interface Stafford Horne
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

OpenRISC support hard float but I will like to submit that after glibc
soft float goes upstream.  The hard float support depends on adding user
access to the FPCSR, which is not supported by the kernel yet.
---
 sysdeps/or1k/bits/fenv.h                   |   69 ++
 sysdeps/or1k/libm-test-ulps                | 1112 ++++++++++++++++++++
 sysdeps/or1k/libm-test-ulps-name           |    1 +
 sysdeps/or1k/nofpu/math-tests-exceptions.h |   29 +
 sysdeps/or1k/nofpu/math-tests-rounding.h   |   28 +
 sysdeps/or1k/sfp-machine.h                 |   93 ++
 sysdeps/or1k/tininess.h                    |    1 +
 7 files changed, 1333 insertions(+)
 create mode 100644 sysdeps/or1k/bits/fenv.h
 create mode 100644 sysdeps/or1k/libm-test-ulps
 create mode 100644 sysdeps/or1k/libm-test-ulps-name
 create mode 100644 sysdeps/or1k/nofpu/math-tests-exceptions.h
 create mode 100644 sysdeps/or1k/nofpu/math-tests-rounding.h
 create mode 100644 sysdeps/or1k/sfp-machine.h
 create mode 100644 sysdeps/or1k/tininess.h

diff --git a/sysdeps/or1k/bits/fenv.h b/sysdeps/or1k/bits/fenv.h
new file mode 100644
index 0000000000..721136a57d
--- /dev/null
+++ b/sysdeps/or1k/bits/fenv.h
@@ -0,0 +1,69 @@
+/* Floating point environment, OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+/* Define bits representing exceptions in the FPCSR status word.  */
+enum
+  {
+    FE_OVERFLOW =
+#define FE_OVERFLOW	(1 << 3)
+      FE_OVERFLOW,
+    FE_UNDERFLOW =
+#define FE_UNDERFLOW	(1 << 4)
+      FE_UNDERFLOW,
+    FE_INEXACT =
+#define FE_INEXACT	(1 << 8)
+      FE_INEXACT,
+    FE_INVALID =
+#define FE_INVALID	(1 << 9)
+      FE_INVALID,
+    FE_DIVBYZERO =
+#define FE_DIVBYZERO	(1 << 11)
+      FE_DIVBYZERO,
+  };
+
+/* All supported exceptions.  */
+#define FE_ALL_EXCEPT	\
+	(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
+
+/* Define bits representing rounding modes in the FPCSR Rmode field.  */
+#define FE_TONEAREST  (0x0 << 1)
+#define FE_TOWARDZERO (0x1 << 1)
+#define FE_UPWARD     (0x2 << 1)
+#define FE_DOWNWARD   (0x3 << 1)
+
+/* Type representing exception flags.  */
+typedef unsigned int fexcept_t;
+
+/* Type representing floating-point environment.  */
+typedef unsigned int fenv_t;
+
+/* If the default argument is used we use this value.  */
+#define FE_DFL_ENV	((const fenv_t *) -1l)
+
+#if __GLIBC_USE (IEC_60559_BFP_EXT)
+/* Type representing floating-point control modes.  */
+typedef unsigned int femode_t;
+
+/* Default floating-point control modes.  */
+# define FE_DFL_MODE	((const femode_t *) -1L)
+#endif
diff --git a/sysdeps/or1k/libm-test-ulps b/sysdeps/or1k/libm-test-ulps
new file mode 100644
index 0000000000..94b383669d
--- /dev/null
+++ b/sysdeps/or1k/libm-test-ulps
@@ -0,0 +1,1112 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acos":
+double: 1
+float: 1
+
+Function: "acos_downward":
+double: 1
+float: 1
+
+Function: "acos_towardzero":
+double: 1
+float: 1
+
+Function: "acos_upward":
+double: 1
+float: 1
+
+Function: "acosh":
+double: 2
+float: 2
+
+Function: "acosh_downward":
+double: 2
+float: 2
+
+Function: "acosh_towardzero":
+double: 2
+float: 2
+
+Function: "acosh_upward":
+double: 2
+float: 2
+
+Function: "asin":
+double: 1
+float: 1
+
+Function: "asin_downward":
+double: 1
+float: 1
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+
+Function: "asin_upward":
+double: 1
+float: 1
+
+Function: "asinh":
+double: 2
+float: 2
+
+Function: "asinh_downward":
+double: 3
+float: 3
+
+Function: "asinh_towardzero":
+double: 2
+float: 2
+
+Function: "asinh_upward":
+double: 3
+float: 3
+
+Function: "atan":
+double: 1
+float: 1
+
+Function: "atan2":
+float: 2
+
+Function: "atan2_downward":
+double: 5
+float: 2
+
+Function: "atan2_towardzero":
+double: 5
+float: 2
+
+Function: "atan2_upward":
+double: 8
+float: 2
+
+Function: "atan_downward":
+double: 1
+float: 2
+
+Function: "atan_towardzero":
+double: 1
+float: 1
+
+Function: "atan_upward":
+double: 1
+float: 2
+
+Function: "atanh":
+double: 2
+float: 2
+
+Function: "atanh_downward":
+double: 3
+float: 3
+
+Function: "atanh_towardzero":
+double: 2
+float: 2
+
+Function: "atanh_upward":
+double: 3
+float: 3
+
+Function: "cabs":
+double: 1
+
+Function: "cabs_downward":
+double: 1
+
+Function: "cabs_towardzero":
+double: 1
+
+Function: "cabs_upward":
+double: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+
+Function: Imaginary part of "cacos":
+double: 2
+float: 2
+
+Function: Real part of "cacos_downward":
+double: 3
+float: 2
+
+Function: Imaginary part of "cacos_downward":
+double: 5
+float: 3
+
+Function: Real part of "cacos_towardzero":
+double: 3
+float: 2
+
+Function: Imaginary part of "cacos_towardzero":
+double: 4
+float: 2
+
+Function: Real part of "cacos_upward":
+double: 2
+float: 2
+
+Function: Imaginary part of "cacos_upward":
+double: 5
+float: 7
+
+Function: Real part of "cacosh":
+double: 2
+float: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+
+Function: Real part of "cacosh_downward":
+double: 4
+float: 2
+
+Function: Imaginary part of "cacosh_downward":
+double: 3
+float: 3
+
+Function: Real part of "cacosh_towardzero":
+double: 4
+float: 2
+
+Function: Imaginary part of "cacosh_towardzero":
+double: 3
+float: 2
+
+Function: Real part of "cacosh_upward":
+double: 4
+float: 3
+
+Function: Imaginary part of "cacosh_upward":
+double: 3
+float: 2
+
+Function: "carg":
+float: 1
+
+Function: "carg_downward":
+double: 5
+float: 2
+
+Function: "carg_towardzero":
+double: 5
+float: 2
+
+Function: "carg_upward":
+double: 8
+float: 2
+
+Function: Real part of "casin":
+double: 1
+float: 1
+
+Function: Imaginary part of "casin":
+double: 2
+float: 2
+
+Function: Real part of "casin_downward":
+double: 3
+float: 2
+
+Function: Imaginary part of "casin_downward":
+double: 5
+float: 3
+
+Function: Real part of "casin_towardzero":
+double: 3
+float: 1
+
+Function: Imaginary part of "casin_towardzero":
+double: 4
+float: 2
+
+Function: Real part of "casin_upward":
+double: 3
+float: 2
+
+Function: Imaginary part of "casin_upward":
+double: 5
+float: 7
+
+Function: Real part of "casinh":
+double: 2
+float: 2
+
+Function: Imaginary part of "casinh":
+double: 1
+float: 1
+
+Function: Real part of "casinh_downward":
+double: 5
+float: 3
+
+Function: Imaginary part of "casinh_downward":
+double: 3
+float: 2
+
+Function: Real part of "casinh_towardzero":
+double: 4
+float: 2
+
+Function: Imaginary part of "casinh_towardzero":
+double: 3
+float: 1
+
+Function: Real part of "casinh_upward":
+double: 5
+float: 7
+
+Function: Imaginary part of "casinh_upward":
+double: 3
+float: 2
+
+Function: Real part of "catan":
+double: 1
+float: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+
+Function: Real part of "catan_downward":
+double: 1
+float: 2
+
+Function: Imaginary part of "catan_downward":
+double: 2
+float: 2
+
+Function: Real part of "catan_towardzero":
+double: 1
+float: 2
+
+Function: Imaginary part of "catan_towardzero":
+double: 2
+float: 2
+
+Function: Real part of "catan_upward":
+double: 2
+float: 1
+
+Function: Imaginary part of "catan_upward":
+double: 2
+float: 2
+
+Function: Real part of "catanh":
+double: 1
+float: 1
+
+Function: Imaginary part of "catanh":
+double: 1
+float: 1
+
+Function: Real part of "catanh_downward":
+double: 2
+float: 2
+
+Function: Imaginary part of "catanh_downward":
+double: 1
+float: 2
+
+Function: Real part of "catanh_towardzero":
+double: 2
+float: 2
+
+Function: Imaginary part of "catanh_towardzero":
+double: 1
+float: 2
+
+Function: Real part of "catanh_upward":
+double: 4
+float: 4
+
+Function: Imaginary part of "catanh_upward":
+double: 2
+float: 1
+
+Function: "cbrt":
+double: 4
+float: 1
+
+Function: "cbrt_downward":
+double: 4
+float: 1
+
+Function: "cbrt_towardzero":
+double: 3
+float: 1
+
+Function: "cbrt_upward":
+double: 5
+float: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+
+Function: Real part of "ccos_downward":
+double: 3
+float: 1
+
+Function: Imaginary part of "ccos_downward":
+double: 3
+float: 3
+
+Function: Real part of "ccos_towardzero":
+double: 3
+float: 2
+
+Function: Imaginary part of "ccos_towardzero":
+double: 3
+float: 3
+
+Function: Real part of "ccos_upward":
+double: 1
+float: 2
+
+Function: Imaginary part of "ccos_upward":
+double: 2
+float: 2
+
+Function: Real part of "ccosh":
+double: 2
+float: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+
+Function: Real part of "ccosh_downward":
+double: 3
+float: 2
+
+Function: Imaginary part of "ccosh_downward":
+double: 3
+float: 3
+
+Function: Real part of "ccosh_towardzero":
+double: 3
+float: 3
+
+Function: Imaginary part of "ccosh_towardzero":
+double: 3
+float: 3
+
+Function: Real part of "ccosh_upward":
+double: 1
+float: 2
+
+Function: Imaginary part of "ccosh_upward":
+double: 2
+float: 2
+
+Function: Real part of "cexp":
+double: 2
+float: 1
+
+Function: Imaginary part of "cexp":
+double: 1
+float: 2
+
+Function: Real part of "cexp_downward":
+double: 4
+float: 2
+
+Function: Imaginary part of "cexp_downward":
+double: 3
+float: 3
+
+Function: Real part of "cexp_towardzero":
+double: 4
+float: 2
+
+Function: Imaginary part of "cexp_towardzero":
+double: 3
+float: 3
+
+Function: Real part of "cexp_upward":
+double: 2
+float: 2
+
+Function: Imaginary part of "cexp_upward":
+double: 3
+float: 2
+
+Function: Real part of "clog":
+double: 3
+float: 3
+
+Function: Imaginary part of "clog":
+double: 1
+float: 1
+
+Function: Real part of "clog10":
+double: 3
+float: 4
+
+Function: Imaginary part of "clog10":
+double: 2
+float: 2
+
+Function: Real part of "clog10_downward":
+double: 7
+float: 5
+
+Function: Imaginary part of "clog10_downward":
+double: 8
+float: 4
+
+Function: Real part of "clog10_towardzero":
+double: 5
+float: 5
+
+Function: Imaginary part of "clog10_towardzero":
+double: 8
+float: 4
+
+Function: Real part of "clog10_upward":
+double: 6
+float: 5
+
+Function: Imaginary part of "clog10_upward":
+double: 5
+float: 4
+
+Function: Real part of "clog_downward":
+double: 4
+float: 3
+
+Function: Imaginary part of "clog_downward":
+double: 5
+float: 2
+
+Function: Real part of "clog_towardzero":
+double: 8
+float: 4
+
+Function: Imaginary part of "clog_towardzero":
+double: 5
+float: 3
+
+Function: Real part of "clog_upward":
+double: 8
+float: 3
+
+Function: Imaginary part of "clog_upward":
+double: 8
+float: 2
+
+Function: "cos":
+double: 1
+float: 1
+
+Function: "cos_downward":
+double: 1
+float: 1
+
+Function: "cos_towardzero":
+double: 4
+float: 1
+
+Function: "cos_upward":
+double: 4
+float: 1
+
+Function: "cosh":
+double: 2
+float: 2
+
+Function: "cosh_downward":
+double: 2
+float: 1
+
+Function: "cosh_towardzero":
+double: 2
+float: 1
+
+Function: "cosh_upward":
+double: 2
+float: 2
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+
+Function: Imaginary part of "cpow":
+float: 2
+
+Function: Real part of "cpow_downward":
+double: 5
+float: 8
+
+Function: Imaginary part of "cpow_downward":
+double: 2
+float: 2
+
+Function: Real part of "cpow_towardzero":
+double: 5
+float: 8
+
+Function: Imaginary part of "cpow_towardzero":
+double: 2
+float: 2
+
+Function: Real part of "cpow_upward":
+double: 4
+float: 1
+
+Function: Imaginary part of "cpow_upward":
+double: 2
+float: 2
+
+Function: Real part of "csin":
+double: 1
+float: 1
+
+Function: Real part of "csin_downward":
+double: 3
+float: 3
+
+Function: Imaginary part of "csin_downward":
+double: 3
+float: 1
+
+Function: Real part of "csin_towardzero":
+double: 3
+float: 3
+
+Function: Imaginary part of "csin_towardzero":
+double: 3
+float: 1
+
+Function: Real part of "csin_upward":
+double: 2
+float: 2
+
+Function: Imaginary part of "csin_upward":
+double: 1
+float: 2
+
+Function: Real part of "csinh":
+float: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+
+Function: Real part of "csinh_downward":
+double: 3
+float: 1
+
+Function: Imaginary part of "csinh_downward":
+double: 3
+float: 3
+
+Function: Real part of "csinh_towardzero":
+double: 3
+float: 2
+
+Function: Imaginary part of "csinh_towardzero":
+double: 3
+float: 3
+
+Function: Real part of "csinh_upward":
+double: 1
+float: 2
+
+Function: Imaginary part of "csinh_upward":
+double: 2
+float: 2
+
+Function: Real part of "csqrt":
+double: 2
+float: 2
+
+Function: Imaginary part of "csqrt":
+double: 2
+float: 2
+
+Function: Real part of "csqrt_downward":
+double: 5
+float: 4
+
+Function: Imaginary part of "csqrt_downward":
+double: 4
+float: 3
+
+Function: Real part of "csqrt_towardzero":
+double: 4
+float: 3
+
+Function: Imaginary part of "csqrt_towardzero":
+double: 4
+float: 3
+
+Function: Real part of "csqrt_upward":
+double: 5
+float: 4
+
+Function: Imaginary part of "csqrt_upward":
+double: 3
+float: 3
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+
+Function: Imaginary part of "ctan":
+double: 2
+float: 2
+
+Function: Real part of "ctan_downward":
+double: 6
+float: 5
+
+Function: Imaginary part of "ctan_downward":
+double: 3
+float: 2
+
+Function: Real part of "ctan_towardzero":
+double: 5
+float: 3
+
+Function: Imaginary part of "ctan_towardzero":
+double: 3
+float: 2
+
+Function: Real part of "ctan_upward":
+double: 2
+float: 4
+
+Function: Imaginary part of "ctan_upward":
+double: 2
+float: 1
+
+Function: Real part of "ctanh":
+double: 2
+float: 2
+
+Function: Imaginary part of "ctanh":
+double: 2
+float: 2
+
+Function: Real part of "ctanh_downward":
+double: 3
+float: 2
+
+Function: Imaginary part of "ctanh_downward":
+double: 6
+float: 5
+
+Function: Real part of "ctanh_towardzero":
+double: 3
+float: 2
+
+Function: Imaginary part of "ctanh_towardzero":
+double: 5
+float: 3
+
+Function: Real part of "ctanh_upward":
+double: 2
+float: 2
+
+Function: Imaginary part of "ctanh_upward":
+double: 2
+float: 3
+
+Function: "erf":
+double: 1
+float: 1
+
+Function: "erf_downward":
+double: 1
+float: 1
+
+Function: "erf_towardzero":
+double: 1
+float: 1
+
+Function: "erf_upward":
+double: 1
+float: 1
+
+Function: "erfc":
+double: 5
+float: 3
+
+Function: "erfc_downward":
+double: 5
+float: 6
+
+Function: "erfc_towardzero":
+double: 3
+float: 4
+
+Function: "erfc_upward":
+double: 5
+float: 6
+
+Function: "exp":
+double: 1
+float: 1
+
+Function: "exp10":
+double: 2
+float: 1
+
+Function: "exp10_downward":
+double: 3
+
+Function: "exp10_towardzero":
+double: 3
+
+Function: "exp10_upward":
+double: 2
+float: 1
+
+Function: "exp2":
+double: 1
+
+Function: "exp2_downward":
+double: 1
+
+Function: "exp2_towardzero":
+double: 1
+
+Function: "exp2_upward":
+double: 1
+float: 1
+
+Function: "exp_downward":
+double: 1
+float: 1
+
+Function: "exp_towardzero":
+double: 1
+float: 1
+
+Function: "exp_upward":
+double: 1
+float: 1
+
+Function: "expm1":
+double: 1
+float: 1
+
+Function: "expm1_downward":
+double: 1
+float: 1
+
+Function: "expm1_towardzero":
+double: 1
+float: 2
+
+Function: "expm1_upward":
+double: 1
+float: 1
+
+Function: "gamma":
+double: 4
+float: 7
+
+Function: "gamma_downward":
+double: 7
+float: 7
+
+Function: "gamma_towardzero":
+double: 7
+float: 7
+
+Function: "gamma_upward":
+double: 5
+float: 6
+
+Function: "hypot":
+double: 1
+
+Function: "hypot_downward":
+double: 1
+
+Function: "hypot_towardzero":
+double: 1
+
+Function: "hypot_upward":
+double: 1
+
+Function: "j0":
+double: 2
+float: 9
+
+Function: "j0_downward":
+double: 2
+float: 4
+
+Function: "j0_towardzero":
+double: 4
+float: 5
+
+Function: "j0_upward":
+double: 4
+float: 5
+
+Function: "j1":
+double: 4
+float: 9
+
+Function: "j1_downward":
+double: 4
+float: 5
+
+Function: "j1_towardzero":
+double: 4
+float: 2
+
+Function: "j1_upward":
+double: 3
+float: 5
+
+Function: "jn":
+double: 4
+float: 4
+
+Function: "jn_downward":
+double: 7
+float: 9
+
+Function: "jn_towardzero":
+double: 7
+float: 9
+
+Function: "jn_upward":
+double: 7
+float: 9
+
+Function: "lgamma":
+double: 4
+float: 7
+
+Function: "lgamma_downward":
+double: 7
+float: 7
+
+Function: "lgamma_towardzero":
+double: 7
+float: 7
+
+Function: "lgamma_upward":
+double: 5
+float: 6
+
+Function: "log10":
+double: 2
+float: 2
+
+Function: "log10_downward":
+double: 2
+float: 3
+
+Function: "log10_towardzero":
+double: 2
+float: 1
+
+Function: "log10_upward":
+double: 2
+float: 2
+
+Function: "log1p":
+double: 1
+float: 1
+
+Function: "log1p_downward":
+double: 2
+float: 2
+
+Function: "log1p_towardzero":
+double: 2
+float: 2
+
+Function: "log1p_upward":
+double: 2
+float: 2
+
+Function: "log2":
+float: 1
+
+Function: "log2_downward":
+double: 1
+
+Function: "log2_towardzero":
+double: 1
+
+Function: "log2_upward":
+double: 1
+
+Function: "pow":
+double: 1
+
+Function: "pow_downward":
+double: 1
+float: 1
+
+Function: "pow_towardzero":
+double: 1
+float: 1
+
+Function: "pow_upward":
+double: 1
+float: 1
+
+Function: "sin":
+double: 1
+float: 1
+
+Function: "sin_downward":
+double: 4
+float: 1
+
+Function: "sin_towardzero":
+double: 3
+float: 1
+
+Function: "sin_upward":
+double: 7
+float: 1
+
+Function: "sincos":
+double: 1
+
+Function: "sincos_downward":
+double: 1
+float: 1
+
+Function: "sincos_towardzero":
+double: 4
+float: 1
+
+Function: "sincos_upward":
+double: 1
+float: 1
+
+Function: "sinh":
+double: 2
+float: 2
+
+Function: "sinh_downward":
+double: 3
+float: 3
+
+Function: "sinh_towardzero":
+double: 2
+float: 2
+
+Function: "sinh_upward":
+double: 3
+float: 3
+
+Function: "tan":
+float: 1
+
+Function: "tan_downward":
+double: 1
+float: 2
+
+Function: "tan_towardzero":
+double: 1
+float: 1
+
+Function: "tan_upward":
+double: 1
+float: 1
+
+Function: "tanh":
+double: 2
+float: 2
+
+Function: "tanh_downward":
+double: 3
+float: 3
+
+Function: "tanh_towardzero":
+double: 2
+float: 2
+
+Function: "tanh_upward":
+double: 3
+float: 3
+
+Function: "tgamma":
+double: 9
+float: 8
+
+Function: "tgamma_downward":
+double: 9
+float: 9
+
+Function: "tgamma_towardzero":
+double: 9
+float: 8
+
+Function: "tgamma_upward":
+double: 9
+float: 8
+
+Function: "y0":
+double: 3
+float: 9
+
+Function: "y0_downward":
+double: 3
+float: 6
+
+Function: "y0_towardzero":
+double: 3
+float: 3
+
+Function: "y0_upward":
+double: 3
+float: 6
+
+Function: "y1":
+double: 3
+float: 9
+
+Function: "y1_downward":
+double: 6
+float: 7
+
+Function: "y1_towardzero":
+double: 3
+float: 3
+
+Function: "y1_upward":
+double: 7
+float: 5
+
+Function: "yn":
+double: 3
+float: 3
+
+Function: "yn_downward":
+double: 6
+float: 8
+
+Function: "yn_towardzero":
+double: 8
+float: 8
+
+Function: "yn_upward":
+double: 8
+float: 8
+
+# end of automatic generation
diff --git a/sysdeps/or1k/libm-test-ulps-name b/sysdeps/or1k/libm-test-ulps-name
new file mode 100644
index 0000000000..0af6591fd9
--- /dev/null
+++ b/sysdeps/or1k/libm-test-ulps-name
@@ -0,0 +1 @@
+OpenRISC
diff --git a/sysdeps/or1k/nofpu/math-tests-exceptions.h b/sysdeps/or1k/nofpu/math-tests-exceptions.h
new file mode 100644
index 0000000000..cf4ed98279
--- /dev/null
+++ b/sysdeps/or1k/nofpu/math-tests-exceptions.h
@@ -0,0 +1,29 @@
+/* Configuration for math tests: support for exceptions.  OpenRISC no-FPU
+   version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef OR1K_NOFPU_MATH_TESTS_EXCEPTIONS_H
+#define OR1K_NOFPU_MATH_TESTS_EXCEPTIONS_H 1
+
+/* We support setting floating-point exception flags on hard-float
+   targets.  These are not supported on soft-float targets.  */
+#define EXCEPTION_TESTS_float 0
+#define EXCEPTION_TESTS_double        0
+#define EXCEPTION_TESTS_long_double   0
+
+#endif /* math-tests-exceptions.h.  */
diff --git a/sysdeps/or1k/nofpu/math-tests-rounding.h b/sysdeps/or1k/nofpu/math-tests-rounding.h
new file mode 100644
index 0000000000..2b69a541a3
--- /dev/null
+++ b/sysdeps/or1k/nofpu/math-tests-rounding.h
@@ -0,0 +1,28 @@
+/* Configuration for math tests: rounding mode support.  OpenRISC no-FPU
+   version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef OR1K_NOFPU_MATH_TESTS_ROUNDING_H
+#define OR1K_NOFPU_MATH_TESTS_ROUNDING_H 1
+
+/* On soft-float targets we only support the "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 /* math-tests-rounding.h.  */
diff --git a/sysdeps/or1k/sfp-machine.h b/sysdeps/or1k/sfp-machine.h
new file mode 100644
index 0000000000..18f2676510
--- /dev/null
+++ b/sysdeps/or1k/sfp-machine.h
@@ -0,0 +1,93 @@
+/* OpenRISC softfloat definitions.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#define _FP_W_TYPE_SIZE		32
+#define _FP_W_TYPE		unsigned long
+#define _FP_WS_TYPE		signed long
+#define _FP_I_TYPE		long
+
+#define _FP_MUL_MEAT_S(R,X,Y)				\
+  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y)				\
+  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y)				\
+  _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_MUL_MEAT_DW_S(R,X,Y)				\
+  _FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_DW_D(R,X,Y)				\
+  _FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_DW_Q(R,X,Y)				\
+  _FP_MUL_MEAT_DW_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+
+#define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_loop(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S		0
+#define _FP_NANSIGN_D		0
+#define _FP_NANSIGN_Q		0
+
+#define _FP_KEEPNANFRACP 1
+#define _FP_QNANNEGATEDP 0
+
+/* Someone please check this.  */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
+  do {								\
+    if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)		\
+	&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))	\
+      {								\
+	R##_s = Y##_s;						\
+	_FP_FRAC_COPY_##wc(R,Y);				\
+      }								\
+    else							\
+      {								\
+	R##_s = X##_s;						\
+	_FP_FRAC_COPY_##wc(R,X);				\
+      }								\
+    R##_c = FP_CLS_NAN;						\
+  } while (0)
+
+/* Handle getting and setting rounding mode for soft fp operations.  */
+
+#define FP_RND_NEAREST		(0x0 << 1)
+#define FP_RND_ZERO		(0x1 << 1)
+#define FP_RND_PINF		(0x2 << 1)
+#define FP_RND_MINF		(0x3 << 1)
+#define FP_RND_MASK		(0x3 << 1)
+
+#define FP_EX_OVERFLOW		(1 << 3)
+#define FP_EX_UNDERFLOW		(1 << 4)
+#define FP_EX_INEXACT		(1 << 8)
+#define FP_EX_INVALID		(1 << 9)
+#define FP_EX_DIVZERO		(1 << 11)
+#define FP_EX_ALL \
+	(FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \
+	 | FP_EX_INEXACT)
+
+#define _FP_DECL_EX \
+  unsigned int _fpcsr __attribute__ ((unused)) = FP_RND_NEAREST
+
+#define FP_ROUNDMODE (_fpcsr & FP_RND_MASK)
+
+#define _FP_TININESS_AFTER_ROUNDING 0
diff --git a/sysdeps/or1k/tininess.h b/sysdeps/or1k/tininess.h
new file mode 100644
index 0000000000..dafbc6cad5
--- /dev/null
+++ b/sysdeps/or1k/tininess.h
@@ -0,0 +1 @@
+#define TININESS_AFTER_ROUNDING	0
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 08/13] or1k: Linux Syscall Interface
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (6 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 07/13] or1k: math soft float support Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-16 21:17   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 09/13] or1k: Linux ABI Stafford Horne
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

---
 sysdeps/unix/sysv/linux/or1k/arch-syscall.h   | 325 ++++++++++++++++++
 sysdeps/unix/sysv/linux/or1k/bits/timesize.h  |  19 +
 sysdeps/unix/sysv/linux/or1k/clone.c          |  61 ++++
 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h |  41 +++
 sysdeps/unix/sysv/linux/or1k/mmap_internal.h  |  28 ++
 sysdeps/unix/sysv/linux/or1k/or1k_clone.S     |  89 +++++
 sysdeps/unix/sysv/linux/or1k/sysdep.c         |  34 ++
 sysdeps/unix/sysv/linux/or1k/sysdep.h         | 201 +++++++++++
 8 files changed, 798 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/or1k/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/timesize.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/clone.c
 create mode 100644 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/mmap_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/or1k_clone.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.c
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.h

diff --git a/sysdeps/unix/sysv/linux/or1k/arch-syscall.h b/sysdeps/unix/sysv/linux/or1k/arch-syscall.h
new file mode 100644
index 0000000000..c6c3556137
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/arch-syscall.h
@@ -0,0 +1,325 @@
+/* AUTOGENERATED by update-syscall-lists.py.  */
+#define __NR_accept 202
+#define __NR_accept4 242
+#define __NR_acct 89
+#define __NR_add_key 217
+#define __NR_adjtimex 171
+#define __NR_bind 200
+#define __NR_bpf 280
+#define __NR_brk 214
+#define __NR_capget 90
+#define __NR_capset 91
+#define __NR_chdir 49
+#define __NR_chroot 51
+#define __NR_clock_adjtime 266
+#define __NR_clock_adjtime64 405
+#define __NR_clock_getres 114
+#define __NR_clock_getres_time64 406
+#define __NR_clock_gettime 113
+#define __NR_clock_gettime64 403
+#define __NR_clock_nanosleep 115
+#define __NR_clock_nanosleep_time64 407
+#define __NR_clock_settime 112
+#define __NR_clock_settime64 404
+#define __NR_clone 220
+#define __NR_clone3 435
+#define __NR_close 57
+#define __NR_close_range 436
+#define __NR_connect 203
+#define __NR_copy_file_range 285
+#define __NR_delete_module 106
+#define __NR_dup 23
+#define __NR_dup3 24
+#define __NR_epoll_create1 20
+#define __NR_epoll_ctl 21
+#define __NR_epoll_pwait 22
+#define __NR_epoll_pwait2 441
+#define __NR_eventfd2 19
+#define __NR_execve 221
+#define __NR_execveat 281
+#define __NR_exit 93
+#define __NR_exit_group 94
+#define __NR_faccessat 48
+#define __NR_faccessat2 439
+#define __NR_fadvise64_64 223
+#define __NR_fallocate 47
+#define __NR_fanotify_init 262
+#define __NR_fanotify_mark 263
+#define __NR_fchdir 50
+#define __NR_fchmod 52
+#define __NR_fchmodat 53
+#define __NR_fchown 55
+#define __NR_fchownat 54
+#define __NR_fcntl64 25
+#define __NR_fdatasync 83
+#define __NR_fgetxattr 10
+#define __NR_finit_module 273
+#define __NR_flistxattr 13
+#define __NR_flock 32
+#define __NR_fremovexattr 16
+#define __NR_fsconfig 431
+#define __NR_fsetxattr 7
+#define __NR_fsmount 432
+#define __NR_fsopen 430
+#define __NR_fspick 433
+#define __NR_fstat64 80
+#define __NR_fstatat64 79
+#define __NR_fstatfs64 44
+#define __NR_fsync 82
+#define __NR_ftruncate64 46
+#define __NR_futex 98
+#define __NR_futex_time64 422
+#define __NR_get_mempolicy 236
+#define __NR_get_robust_list 100
+#define __NR_getcpu 168
+#define __NR_getcwd 17
+#define __NR_getdents64 61
+#define __NR_getegid 177
+#define __NR_geteuid 175
+#define __NR_getgid 176
+#define __NR_getgroups 158
+#define __NR_getitimer 102
+#define __NR_getpeername 205
+#define __NR_getpgid 155
+#define __NR_getpid 172
+#define __NR_getppid 173
+#define __NR_getpriority 141
+#define __NR_getrandom 278
+#define __NR_getresgid 150
+#define __NR_getresuid 148
+#define __NR_getrlimit 163
+#define __NR_getrusage 165
+#define __NR_getsid 156
+#define __NR_getsockname 204
+#define __NR_getsockopt 209
+#define __NR_gettid 178
+#define __NR_gettimeofday 169
+#define __NR_getuid 174
+#define __NR_getxattr 8
+#define __NR_init_module 105
+#define __NR_inotify_add_watch 27
+#define __NR_inotify_init1 26
+#define __NR_inotify_rm_watch 28
+#define __NR_io_cancel 3
+#define __NR_io_destroy 1
+#define __NR_io_getevents 4
+#define __NR_io_pgetevents 292
+#define __NR_io_pgetevents_time64 416
+#define __NR_io_setup 0
+#define __NR_io_submit 2
+#define __NR_io_uring_enter 426
+#define __NR_io_uring_register 427
+#define __NR_io_uring_setup 425
+#define __NR_ioctl 29
+#define __NR_ioprio_get 31
+#define __NR_ioprio_set 30
+#define __NR_kcmp 272
+#define __NR_kexec_file_load 294
+#define __NR_kexec_load 104
+#define __NR_keyctl 219
+#define __NR_kill 129
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_create_ruleset 444
+#define __NR_landlock_restrict_self 446
+#define __NR_lgetxattr 9
+#define __NR_linkat 37
+#define __NR_listen 201
+#define __NR_listxattr 11
+#define __NR_llistxattr 12
+#define __NR_llseek 62
+#define __NR_lookup_dcookie 18
+#define __NR_lremovexattr 15
+#define __NR_lsetxattr 6
+#define __NR_madvise 233
+#define __NR_mbind 235
+#define __NR_membarrier 283
+#define __NR_memfd_create 279
+#define __NR_migrate_pages 238
+#define __NR_mincore 232
+#define __NR_mkdirat 34
+#define __NR_mknodat 33
+#define __NR_mlock 228
+#define __NR_mlock2 284
+#define __NR_mlockall 230
+#define __NR_mmap2 222
+#define __NR_mount 40
+#define __NR_mount_setattr 442
+#define __NR_move_mount 429
+#define __NR_move_pages 239
+#define __NR_mprotect 226
+#define __NR_mq_getsetattr 185
+#define __NR_mq_notify 184
+#define __NR_mq_open 180
+#define __NR_mq_timedreceive 183
+#define __NR_mq_timedreceive_time64 419
+#define __NR_mq_timedsend 182
+#define __NR_mq_timedsend_time64 418
+#define __NR_mq_unlink 181
+#define __NR_mremap 216
+#define __NR_msgctl 187
+#define __NR_msgget 186
+#define __NR_msgrcv 188
+#define __NR_msgsnd 189
+#define __NR_msync 227
+#define __NR_munlock 229
+#define __NR_munlockall 231
+#define __NR_munmap 215
+#define __NR_name_to_handle_at 264
+#define __NR_nanosleep 101
+#define __NR_nfsservctl 42
+#define __NR_open_by_handle_at 265
+#define __NR_open_tree 428
+#define __NR_openat 56
+#define __NR_openat2 437
+#define __NR_or1k_atomic 244
+#define __NR_perf_event_open 241
+#define __NR_personality 92
+#define __NR_pidfd_getfd 438
+#define __NR_pidfd_open 434
+#define __NR_pidfd_send_signal 424
+#define __NR_pipe2 59
+#define __NR_pivot_root 41
+#define __NR_pkey_alloc 289
+#define __NR_pkey_free 290
+#define __NR_pkey_mprotect 288
+#define __NR_ppoll 73
+#define __NR_ppoll_time64 414
+#define __NR_prctl 167
+#define __NR_pread64 67
+#define __NR_preadv 69
+#define __NR_preadv2 286
+#define __NR_prlimit64 261
+#define __NR_process_madvise 440
+#define __NR_process_mrelease 448
+#define __NR_process_vm_readv 270
+#define __NR_process_vm_writev 271
+#define __NR_pselect6 72
+#define __NR_pselect6_time64 413
+#define __NR_ptrace 117
+#define __NR_pwrite64 68
+#define __NR_pwritev 70
+#define __NR_pwritev2 287
+#define __NR_quotactl 60
+#define __NR_quotactl_fd 443
+#define __NR_read 63
+#define __NR_readahead 213
+#define __NR_readlinkat 78
+#define __NR_readv 65
+#define __NR_reboot 142
+#define __NR_recvfrom 207
+#define __NR_recvmmsg 243
+#define __NR_recvmmsg_time64 417
+#define __NR_recvmsg 212
+#define __NR_remap_file_pages 234
+#define __NR_removexattr 14
+#define __NR_renameat 38
+#define __NR_renameat2 276
+#define __NR_request_key 218
+#define __NR_restart_syscall 128
+#define __NR_rseq 293
+#define __NR_rt_sigaction 134
+#define __NR_rt_sigpending 136
+#define __NR_rt_sigprocmask 135
+#define __NR_rt_sigqueueinfo 138
+#define __NR_rt_sigreturn 139
+#define __NR_rt_sigsuspend 133
+#define __NR_rt_sigtimedwait 137
+#define __NR_rt_sigtimedwait_time64 421
+#define __NR_rt_tgsigqueueinfo 240
+#define __NR_sched_get_priority_max 125
+#define __NR_sched_get_priority_min 126
+#define __NR_sched_getaffinity 123
+#define __NR_sched_getattr 275
+#define __NR_sched_getparam 121
+#define __NR_sched_getscheduler 120
+#define __NR_sched_rr_get_interval 127
+#define __NR_sched_rr_get_interval_time64 423
+#define __NR_sched_setaffinity 122
+#define __NR_sched_setattr 274
+#define __NR_sched_setparam 118
+#define __NR_sched_setscheduler 119
+#define __NR_sched_yield 124
+#define __NR_seccomp 277
+#define __NR_semctl 191
+#define __NR_semget 190
+#define __NR_semop 193
+#define __NR_semtimedop 192
+#define __NR_semtimedop_time64 420
+#define __NR_sendfile64 71
+#define __NR_sendmmsg 269
+#define __NR_sendmsg 211
+#define __NR_sendto 206
+#define __NR_set_mempolicy 237
+#define __NR_set_robust_list 99
+#define __NR_set_tid_address 96
+#define __NR_setdomainname 162
+#define __NR_setfsgid 152
+#define __NR_setfsuid 151
+#define __NR_setgid 144
+#define __NR_setgroups 159
+#define __NR_sethostname 161
+#define __NR_setitimer 103
+#define __NR_setns 268
+#define __NR_setpgid 154
+#define __NR_setpriority 140
+#define __NR_setregid 143
+#define __NR_setresgid 149
+#define __NR_setresuid 147
+#define __NR_setreuid 145
+#define __NR_setrlimit 164
+#define __NR_setsid 157
+#define __NR_setsockopt 208
+#define __NR_settimeofday 170
+#define __NR_setuid 146
+#define __NR_setxattr 5
+#define __NR_shmat 196
+#define __NR_shmctl 195
+#define __NR_shmdt 197
+#define __NR_shmget 194
+#define __NR_shutdown 210
+#define __NR_sigaltstack 132
+#define __NR_signalfd4 74
+#define __NR_socket 198
+#define __NR_socketpair 199
+#define __NR_splice 76
+#define __NR_statfs64 43
+#define __NR_statx 291
+#define __NR_swapoff 225
+#define __NR_swapon 224
+#define __NR_symlinkat 36
+#define __NR_sync 81
+#define __NR_sync_file_range 84
+#define __NR_syncfs 267
+#define __NR_sysinfo 179
+#define __NR_syslog 116
+#define __NR_tee 77
+#define __NR_tgkill 131
+#define __NR_timer_create 107
+#define __NR_timer_delete 111
+#define __NR_timer_getoverrun 109
+#define __NR_timer_gettime 108
+#define __NR_timer_gettime64 408
+#define __NR_timer_settime 110
+#define __NR_timer_settime64 409
+#define __NR_timerfd_create 85
+#define __NR_timerfd_gettime 87
+#define __NR_timerfd_gettime64 410
+#define __NR_timerfd_settime 86
+#define __NR_timerfd_settime64 411
+#define __NR_times 153
+#define __NR_tkill 130
+#define __NR_truncate64 45
+#define __NR_umask 166
+#define __NR_umount2 39
+#define __NR_uname 160
+#define __NR_unlinkat 35
+#define __NR_unshare 97
+#define __NR_userfaultfd 282
+#define __NR_utimensat 88
+#define __NR_utimensat_time64 412
+#define __NR_vhangup 58
+#define __NR_vmsplice 75
+#define __NR_wait4 260
+#define __NR_waitid 95
+#define __NR_write 64
+#define __NR_writev 66
diff --git a/sysdeps/unix/sysv/linux/or1k/bits/timesize.h b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
new file mode 100644
index 0000000000..3ab388da7f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
@@ -0,0 +1,19 @@
+/* Bit size of the time_t type at glibc build time, OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#define __TIMESIZE	64
diff --git a/sysdeps/unix/sysv/linux/or1k/clone.c b/sysdeps/unix/sysv/linux/or1k/clone.c
new file mode 100644
index 0000000000..531fd17e29
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/clone.c
@@ -0,0 +1,61 @@
+/* OpenRISC helper for the clone syscall.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <sysdep.h>
+
+extern int __or1k_clone (int (*fn)(void *), void *child_stack,
+			 int flags, void *arg, pid_t *ptid,
+			 void *tls, pid_t *ctid);
+
+
+/* The OpenRISC ABI uses the stack for varargs like those using in clone
+   but the linux syscall ABI uses registers.
+   This function moves from varargs to regs.  */
+int
+__clone (int (*fn)(void *), void *child_stack,
+	 int flags, void *arg, ...
+	 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ )
+{
+  void *ptid;
+  void *tls;
+  void *ctid;
+  va_list ap;
+  int err;
+
+  va_start (ap, arg);
+  ptid = va_arg (ap, void *);
+  tls = va_arg (ap, void *);
+  ctid = va_arg (ap, void *);
+  va_end (ap);
+
+  /* Sanity check the arguments */
+  err = -EINVAL;
+  if (!fn)
+    goto syscall_error;
+  if (!child_stack)
+    goto syscall_error;
+
+  return __or1k_clone (fn, child_stack, flags, arg, ptid, tls, ctid);
+
+syscall_error:
+  __set_errno (-err);
+  return -1;
+}
+libc_hidden_def (__clone)
+weak_alias (__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
new file mode 100644
index 0000000000..3c5c1826ab
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
@@ -0,0 +1,41 @@
+/* jump buffer constants, OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+/* Produced by this program:
+
+   #include <stdio.h>
+   #include <unistd.h>
+   #include <setjmp.h>
+   #include <stddef.h>
+
+   int main (int argc, char **argv)
+   {
+       printf ("#define JMP_BUF_SIZE %d\n", sizeof (jmp_buf));
+       printf ("#define JMP_BUF_ALIGN %d\n", __alignof__ (jmp_buf));
+       printf ("#define SIGJMP_BUF_SIZE %d\n", sizeof (sigjmp_buf));
+       printf ("#define SIGJMP_BUF_ALIGN %d\n", __alignof__ (sigjmp_buf));
+       printf ("#define MASK_WAS_SAVED_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __mask_was_saved));
+       printf ("#define SAVED_MASK_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __saved_mask));
+   } */
+
+#define JMP_BUF_SIZE 184
+#define JMP_BUF_ALIGN 4
+#define SIGJMP_BUF_SIZE 184
+#define SIGJMP_BUF_ALIGN 4
+#define MASK_WAS_SAVED_OFFSET 52
+#define SAVED_MASK_OFFSET 56
diff --git a/sysdeps/unix/sysv/linux/or1k/mmap_internal.h b/sysdeps/unix/sysv/linux/or1k/mmap_internal.h
new file mode 100644
index 0000000000..817b841e5b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/mmap_internal.h
@@ -0,0 +1,28 @@
+/* Common mmap definition for Linux implementation.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef MMAP_OR1K_INTERNAL_LINUX_H
+#define MMAP_OR1K_INTERNAL_LINUX_H
+
+/* OpenRISC Linux sets the page shift to 13 and mmap2 expects
+   offsets to be provided in 8K pages.  */
+#define MMAP2_PAGE_UNIT 8192ULL
+
+#include_next <mmap_internal.h>
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/or1k/or1k_clone.S b/sysdeps/unix/sysv/linux/or1k/or1k_clone.S
new file mode 100644
index 0000000000..337eb17d06
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/or1k_clone.S
@@ -0,0 +1,89 @@
+/* clone helper __or1k_clone for OpenRISC.
+   Copyright (C) 2021 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+#include <tls.h>
+#define __ASSEMBLY__
+#include <linux/sched.h>
+
+	.text
+ENTRY(__or1k_clone)
+
+	/* To handle GCC varargs we need to use our __clone wrapper to pop
+	   everything from the stack for us.
+	   Now everything is placed in the registers which saves us a lot
+	   of trouble.
+
+	   The userland implementation is:
+
+	     int clone (int (*fn)(void *), void *child_stack,
+			int flags, void *arg, pid_t *ptid,
+			struct user_desc *tls, pid_t *ctid);
+	   The kernel entry is:
+
+	     int clone (long flags, void *child_stack, int *parent_tid,
+			int *child_tid, struct void *tls)
+
+	     NB: tls isn't really an argument, it is read from r7 directly.  */
+
+	/* First, align the stack to 4 bytes.  */
+	l.xori	r11, r0, -4
+	l.and	r4, r4, r11
+
+	/* Put 'fn', 'arg' and 'flags' on the child stack.  */
+	l.addi	r4, r4, -12
+	l.sw	8(r4), r3
+	l.sw	4(r4), r6
+	l.sw	0(r4), r5
+
+	l.ori	r3, r5, 0
+	/* The child_stack is already in r4.  */
+	l.ori	r5, r7, 0
+	l.lwz	r6, 0(r1)
+	l.ori	r7, r8, 0
+
+	DO_CALL (clone)
+
+	l.sfgeui r11, 0xf001
+	l.bf	L(error)
+	 l.nop
+
+	/* If we are not the child, return the pid.  */
+	l.sfeqi	r11, 0
+	l.bf	L(thread_start)
+	 l.nop
+
+	l.jr	r9
+	 l.nop
+
+L(thread_start):
+	/* Load function from stack.  */
+	l.lwz	r11, 8(r1)
+	l.jalr	r11
+	 l.lwz	r3, 4(r1)
+
+	/* Exit the child thread.  */
+	l.ori	r3, r11, 0
+	DO_CALL (exit)
+
+L(error):
+	l.j	SYSCALL_ERROR_NAME
+	 l.ori	r3, r11, 0
+
+PSEUDO_END (__or1k_clone)
diff --git a/sysdeps/unix/sysv/linux/or1k/sysdep.c b/sysdeps/unix/sysv/linux/or1k/sysdep.c
new file mode 100644
index 0000000000..1130cba687
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/sysdep.c
@@ -0,0 +1,34 @@
+/* OpenRISC wrapper for setting errno.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include <errno.h>
+
+long int __syscall_error (long int err);
+hidden_proto (__syscall_error)
+
+/* This routine is jumped to by all the syscall handlers, to stash
+   an error number into errno.  */
+long int
+__syscall_error (long int err)
+{
+  __set_errno (- err);
+  return -1;
+}
+hidden_def (__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/or1k/sysdep.h b/sysdeps/unix/sysv/linux/or1k/sysdep.h
new file mode 100644
index 0000000000..5dd6da48a1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/sysdep.h
@@ -0,0 +1,201 @@
+/* Assembler and syscall macros.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _LINUX_OR1K_SYSDEP_H
+#define _LINUX_OR1K_SYSDEP_H 1
+
+#include <sysdeps/or1k/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
+#include <tls.h>
+
+/* "workarounds" for generic code needing to handle 64-bit time_t.  */
+
+#undef __NR_clock_getres
+#undef __NR_futex
+#undef __NR_ppoll
+#undef __NR_pselect6
+#undef __NR_recvmmsg
+#undef __NR_rt_sigtimedwait
+#undef __NR_semtimedop
+#undef __NR_utimensat
+
+/* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c.  */
+#define __NR_clock_getres	__NR_clock_getres_time64
+/* Fix sysdeps/nptl/lowlevellock-futex.h.  */
+#define __NR_futex		__NR_futex_time64
+/* Fix sysdeps/unix/sysv/linux/pause.c.  */
+#define __NR_ppoll		__NR_ppoll_time64
+/* Fix sysdeps/unix/sysv/linux/select.c.  */
+#define __NR_pselect6		__NR_pselect6_time64
+/* Fix sysdeps/unix/sysv/linux/recvmmsg.c.  */
+#define __NR_recvmmsg		__NR_recvmmsg_time64
+/* Fix sysdeps/unix/sysv/linux/sigtimedwait.c.  */
+#define __NR_rt_sigtimedwait	__NR_rt_sigtimedwait_time64
+/* Fix sysdeps/unix/sysv/linux/semtimedop.c.  */
+#define __NR_semtimedop		__NR_semtimedop_time64
+/* Hack sysdeps/unix/sysv/linux/generic/utimes.c.  */
+#define __NR_utimensat		__NR_utimensat_time64
+
+#undef SYS_ify
+#define SYS_ify(syscall_name)   (__NR_##syscall_name)
+
+/* Linux uses a negative return value to indicate syscall errors,
+   unlike most Unices, which use the condition codes' carry flag.
+
+   Since version 2.1 the return value of a system call might be
+   negative even if the call succeeded.  E.g., the lseek system call
+   might return a large offset.  Therefore we must not anymore test
+   for < 0, but test for a real error by making sure the value in R0
+   is a real error number.  Linus said he will make sure the no syscall
+   returns a value in -1 .. -4095 as a valid result so we can safely
+   test with -4095.  */
+
+#ifdef __ASSEMBLER__
+
+/* Macros used in syscall-template.S */
+#define ret          l.jr r9; l.nop
+#define ret_NOERRNO  l.jr r9; l.nop
+
+#undef	DO_CALL
+#define DO_CALL(syscall_name) \
+  l.addi r11, r0, SYS_ify (syscall_name); \
+  l.sys 1; \
+   l.nop
+
+#undef	PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+  ENTRY (name); \
+  DO_CALL(syscall_name); \
+  /* if -4096 < ret < 0 holds, it's an error */ \
+  l.sfgeui r11, 0xf001; \
+  l.bf L(pseudo_end); \
+   l.nop
+
+#undef	PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args)  \
+  ENTRY (name);           \
+  DO_CALL(syscall_name)
+
+#undef	PSEUDO_END
+#define PSEUDO_END(name) \
+L(pseudo_end): \
+  l.j SYSCALL_ERROR_NAME; \
+  l.ori r3,r11,0; \
+  END (name)
+
+#undef	PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+  END (name)
+
+#ifndef PIC
+/* For static code, on error jump to __syscall_error directly.  */
+# define SYSCALL_ERROR_NAME __syscall_error
+#elif !IS_IN (libc)
+/* Use the internal name for libc shared objects.  */
+# define SYSCALL_ERROR_NAME __GI___syscall_error
+#else
+/* Otherwise, on error do a full PLT jump.  */
+# define SYSCALL_ERROR_NAME plt(__syscall_error)
+#endif
+
+#else /* not __ASSEMBLER__ */
+
+#include <errno.h>
+
+extern long int __syscall_error (long int neg_errno);
+
+/* Pointer mangling is not yet supported for or1k.  */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, nr, args...) \
+	INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
+
+/* The _NCS variant allows non-constant syscall numbers.  */
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
+        ({ unsigned long int __sys_result;                                     \
+          {                                                                    \
+            long int _sc_ret = (long int) number;                              \
+            LOAD_ARGS_##nr (args)                                              \
+            register long int __sc_ret __asm__ ("r11") = _sc_ret;              \
+            __asm__ __volatile__ ("l.sys 1\n\t"                                \
+				  " l.nop\n\t"                                 \
+                                  : "+r" (__sc_ret)                            \
+                                  : ASM_ARGS_##nr                              \
+                                  : ASM_CLOBBERS_##nr                          \
+                                    "r12", "r13", "r15", "r17", "r19",         \
+                                    "r21", "r23", "r25", "r27", "r29",         \
+                                    "r31", "memory");                          \
+            __sys_result = __sc_ret;                                           \
+          }                                                                    \
+          (long int) __sys_result; })
+
+/* From here on we have nested macros that generate code for
+   setting up syscall arguments.  */
+
+#define LOAD_ARGS_0()
+
+#define ASM_ARGS_0
+#define ASM_CLOBBERS_0  "r3", ASM_CLOBBERS_1
+
+#define LOAD_ARGS_1(a) \
+  long int _a = (long int)(a);                             \
+  register long int __a __asm__ ("r3") = _a;
+#define ASM_ARGS_1 "r" (__a)
+#define ASM_CLOBBERS_1  "r4", ASM_CLOBBERS_2
+
+#define LOAD_ARGS_2(a, b) \
+  long int _b = (long int)(b);                             \
+  LOAD_ARGS_1 (a)                                          \
+  register long int __b __asm__ ("r4") = _b;
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (__b)
+#define ASM_CLOBBERS_2  "r5", ASM_CLOBBERS_3
+
+#define LOAD_ARGS_3(a, b, c) \
+  long int _c = (long int)(c);                             \
+  LOAD_ARGS_2 (a, b)                                       \
+  register long int __c __asm__ ("r5") = _c;
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (__c)
+#define ASM_CLOBBERS_3  "r6", ASM_CLOBBERS_4
+
+#define LOAD_ARGS_4(a, b, c, d) \
+    LOAD_ARGS_3 (a, b, c)                                  \
+  long int _d = (long int)(d);                             \
+  register long int __d __asm__ ("r6") = _d;
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (__d)
+#define ASM_CLOBBERS_4  "r7", ASM_CLOBBERS_5
+
+#define LOAD_ARGS_5(a, b, c, d, e) \
+  long int _e = (long int)(e);                             \
+  LOAD_ARGS_4 (a, b, c, d)                                 \
+  register long int __e __asm__ ("r7") = _e;
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (__e)
+#define ASM_CLOBBERS_5  "r8", ASM_CLOBBERS_6
+
+#define LOAD_ARGS_6(a, b, c, d, e, f) \
+  long int _f = (long int)(f);                             \
+  LOAD_ARGS_5 (a, b, c, d, e)                              \
+  register long int __f __asm__ ("r8") = _f;
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (__f)
+#define ASM_CLOBBERS_6
+
+#endif /* not __ASSEMBLER__ */
+
+#endif /* linux/or1k/sysdep.h */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 09/13] or1k: Linux ABI
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (7 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 08/13] or1k: Linux Syscall Interface Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-21 13:41   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 10/13] or1k: ABI lists Stafford Horne
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

---
 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h    |  48 ++++++++
 sysdeps/or1k/nptl/pthreaddef.h                |  36 ++++++
 sysdeps/unix/sysv/linux/or1k/bits/procfs.h    |  38 ++++++
 sysdeps/unix/sysv/linux/or1k/getcontext.S     |  72 +++++++++++
 sysdeps/unix/sysv/linux/or1k/makecontext.c    |  77 ++++++++++++
 sysdeps/unix/sysv/linux/or1k/setcontext.S     | 108 ++++++++++++++++
 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h |  28 +++++
 sysdeps/unix/sysv/linux/or1k/swapcontext.S    | 116 ++++++++++++++++++
 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h   |  53 ++++++++
 sysdeps/unix/sysv/linux/or1k/sys/user.h       |   1 +
 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym   |  26 ++++
 11 files changed, 603 insertions(+)
 create mode 100644 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
 create mode 100644 sysdeps/or1k/nptl/pthreaddef.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/or1k/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym

diff --git a/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
new file mode 100644
index 0000000000..56a62a7161
--- /dev/null
+++ b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
@@ -0,0 +1,48 @@
+/* Machine-specific pthread type layouts.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H	1
+
+#include <bits/wordsize.h>
+
+/* Opaque union sizes for:
+     pthread_attr_t - internally pthread_attr
+     pthread_mutex_t - internally __pthread_mutex_s
+     pthread_mutexattr_t - internally pthread_mutexattr
+     pthread_cond_t - internally __pthread_cond_s
+     pthread_condattr_t - internally pthread_condattr
+     pthread_rwlock_t - internally __pthread_rwlock_arch_t
+     pthread_rwlockattr_t - internally pthread_rwlockattr
+     pthread_barrier_t - internally pthread_barrier
+     pthread_barrierattr_t - internally pthread_barrierattr  */
+
+#define __SIZEOF_PTHREAD_ATTR_T 32
+#define __SIZEOF_PTHREAD_MUTEX_T 32
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 44
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+#define __LOCK_ALIGNMENT
+#define __ONCE_ALIGNMENT
+
+#endif	/* bits/pthreadtypes.h */
diff --git a/sysdeps/or1k/nptl/pthreaddef.h b/sysdeps/or1k/nptl/pthreaddef.h
new file mode 100644
index 0000000000..d17918ea11
--- /dev/null
+++ b/sysdeps/or1k/nptl/pthreaddef.h
@@ -0,0 +1,36 @@
+/* pthread machine parameter definitions.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+/* Default stack size.  */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Minimum guard size.  */
+#define ARCH_MIN_GUARD_SIZE 0
+
+/* Required stack pointer alignment at beginning.  */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size.  */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB.  Needs to be >= to STACK_ALIGN.  */
+#define TCB_ALIGNMENT 32
+
+/* Location of current stack frame.  */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
diff --git a/sysdeps/unix/sysv/linux/or1k/bits/procfs.h b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
new file mode 100644
index 0000000000..b50c92efb1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
@@ -0,0 +1,38 @@
+/* Types for registers for sys/procfs.h.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://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>
+
+#define ELF_NGREG __NGREG
+
+/* Type for a general-purpose register.  */
+typedef unsigned long int elf_greg_t;
+
+/* And the array of general-purpose registers.  We could have used `struct
+   user_regs' directly, but tradition says that the register set is an array,
+   which does have some peculiar semantics, so leave it that way.
+   GDB uses this for prtrace GETREGSET, on OpenRISC the regset contains 32
+   gprs the PC and the SR, 34 longs.  */
+typedef elf_greg_t elf_gregset_t[34];
+
+/* Register set for the floating-point registers.  */
+typedef elf_greg_t elf_fpregset_t[32];
diff --git a/sysdeps/unix/sysv/linux/or1k/getcontext.S b/sysdeps/unix/sysv/linux/or1k/getcontext.S
new file mode 100644
index 0000000000..4c2e64db7a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/getcontext.S
@@ -0,0 +1,72 @@
+/* Save current context.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include "ucontext_i.h"
+
+/* int getcontext (ucontext_t *ucp)
+
+   Returns 0 on success -1 and errno on failure.
+ */
+	.text
+ENTRY(__getcontext)
+	/* Store r1, the stack pointer.  */
+	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
+	/* Store r2, the frame pointer.  */
+	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
+	/* Store r9, the link register.  */
+	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
+	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
+	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
+	/* Store r10, the TLS register.  */
+	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
+	/* Store r14-r30 even, callee saved registers.  */
+	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
+	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
+	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
+	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
+	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
+	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
+	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
+	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
+	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
+
+	/* Get signal mask.  */
+	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
+	l.ori	r6, r0, _NSIG8
+	l.addi	r5, r3, UCONTEXT_SIGMASK
+	l.ori	r4, r0, 0
+	l.ori	r3, r0, SIG_BLOCK
+	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
+	/* Do the syscall.  */
+	l.sys	1
+	 l.nop
+
+	/* if -4096 < ret < 0 holds, it's an error */
+	l.sfgeui r11, 0xf001
+	l.bf	1f
+	 l.nop
+
+	l.jr	r9
+	 l.ori r11, r0, 0
+
+1:	l.j	__syscall_error
+	 l.ori	r3, r11, 0
+
+END(__getcontext)
+weak_alias(__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/or1k/makecontext.c b/sysdeps/unix/sysv/linux/or1k/makecontext.c
new file mode 100644
index 0000000000..3dd4134a6b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/makecontext.c
@@ -0,0 +1,77 @@
+/* Create new context.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <ucontext.h>
+
+/* makecontext sets up a stack and the registers for the
+   user context.  The stack looks like this:
+
+		+-----------------------+
+		| padding as required   |
+		+-----------------------+
+    sp ->       | parameters 7 to n     |
+		+-----------------------+
+
+   The registers are set up like this:
+     r3-r8  : parameters 1 to 6
+     r14    : uc_link
+     r1     : stack pointer
+     r2     : frame pointer, set to NULL
+*/
+void
+__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
+{
+  extern void __startcontext (void);
+  unsigned long int *sp;
+  va_list ap;
+  int i;
+
+  sp = (unsigned long int *)
+    ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
+
+  /* Allocate stack arguments.  */
+  sp -= argc < 6 ? 0 : argc - 6;
+
+  /* Keep the stack aligned.  */
+  sp = (unsigned long int *) (((uintptr_t) sp) & -4L);
+
+  /* Keep uc_link in r14.  */
+  ucp->uc_mcontext.__gprs[14] = (uintptr_t) ucp->uc_link;
+  /* Return address points to function __startcontext.  */
+  ucp->uc_mcontext.__gprs[9] = (uintptr_t) &__startcontext;
+  /* Frame pointer is null.  */
+  ucp->uc_mcontext.__gprs[2] = (uintptr_t) 0;
+  /* Restart in user-space starting at 'func'.  */
+  ucp->uc_mcontext.__gprs[11] = (uintptr_t) func;
+  /* Set stack pointer.  */
+  ucp->uc_mcontext.__gprs[1] = (uintptr_t) sp;
+
+  va_start (ap, argc);
+  for (i = 0; i < argc; ++i)
+    if (i < 6)
+      ucp->uc_mcontext.__gprs[i + 3] = va_arg (ap, unsigned long int);
+    else
+      sp[i - 6] = va_arg (ap, unsigned long int);
+
+  va_end (ap);
+}
+
+weak_alias (__makecontext, makecontext)
diff --git a/sysdeps/unix/sysv/linux/or1k/setcontext.S b/sysdeps/unix/sysv/linux/or1k/setcontext.S
new file mode 100644
index 0000000000..b4808d5422
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/setcontext.S
@@ -0,0 +1,108 @@
+/* Set current context.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include "ucontext_i.h"
+
+/* int setcontext (const ucontext_t *ucp) */
+	.text
+ENTRY(__setcontext)
+	l.ori	r30, r3, 0
+
+	/* Restore signal mask.  */
+	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
+	l.ori	r6, r0, _NSIG8
+	l.ori	r5, r0, 0
+	l.addi	r4, r3, UCONTEXT_SIGMASK
+	l.ori	r3, r0, SIG_SETMASK
+	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
+	/* Do the syscall.  */
+	l.sys 1
+	 l.nop
+
+	/* if -4096 < ret < 0 holds, it's an error */
+	l.sfgeui r11, 0xf001
+	l.bf	1f
+	 l.nop
+
+	/* Restore argument registers, for the makecontext case.  */
+	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
+	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
+	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
+	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
+	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
+	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
+
+	/* Restore registers stored in getcontext.  */
+	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
+	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
+	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
+	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
+	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
+	/* Restore r14-r30 even, callee saved registers.  */
+	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
+	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
+	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
+	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
+	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
+	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
+	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
+	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
+	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
+
+	l.jr	r11
+	 l.ori	r11, r0, 0
+
+1:	l.j	__syscall_error
+	 l.ori	r3, r11, 0
+
+END (__setcontext)
+weak_alias (__setcontext, setcontext)
+
+	/* We add a NOP here because when the unwinder is looking for the
+	   enclosing function of the link register (r9) address FDE lookup will
+	   use '$r9 - 1' finding setcontext which is wrong.  This is because in
+	   makecontext we have set r9 to the start of &__startcontext.
+
+	   If this NOP did not exist the unwinder would repeatedly find
+	   __setcontext's FDE in an infinite loop.  Modifiying/deleting the below
+	   __startcontext's FDE has no help on this.  */
+	l.nop
+
+ENTRY(__startcontext)
+
+	l.ori	r3, r14, 0
+	l.sfeq	r3, r0
+	/* If uc_link is not 0 resume there, otherwise exit.  */
+	l.bnf	__setcontext
+	 l.nop
+
+#ifdef SHARED
+	/* Obtain a pointer to .got in r16 */
+	l.jal	0x8
+	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
+	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
+	l.add	r16, r16, r9
+	l.lwz	r16, got(exit)(r16)
+	l.jr	r16
+#else
+	l.j	exit
+#endif
+	 l.nop
+
+END(__startcontext)
diff --git a/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
new file mode 100644
index 0000000000..de94b59578
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
@@ -0,0 +1,28 @@
+/* Profile counter helper to get PC from sigcontext.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SIGCONTEXTINFO_H
+#define _SIGCONTEXTINFO_H
+
+static inline uintptr_t
+sigcontext_get_pc (const ucontext_t *ctx)
+{
+  return ctx->uc_mcontext.__pc;
+}
+
+#endif /* _SIGCONTEXTINFO_H */
diff --git a/sysdeps/unix/sysv/linux/or1k/swapcontext.S b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
new file mode 100644
index 0000000000..2acdc6d9bd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
@@ -0,0 +1,116 @@
+/* Swap two contexts.  OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include "ucontext_i.h"
+
+/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
+	.text
+ENTRY(__swapcontext)
+
+	/* Same as getcontext.  */
+	/* Store r1, the stack pointer.  */
+	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
+	/* Store r2, the frame pointer.  */
+	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
+	/* Store r9, the link register.  */
+	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
+	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
+	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
+	/* Store r10, the TLS register.  */
+	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
+	/* Store r14-r30 even, callee saved registers.  */
+	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
+	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
+	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
+	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
+	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
+	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
+	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
+	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
+	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
+
+	/* Store ucp to non-argument syscall preserved register.  */
+	l.ori	r30, r4, 0
+
+	/* Get signal mask.  */
+	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
+	l.ori	r6, r0, _NSIG8
+	l.addi	r5, r3, UCONTEXT_SIGMASK
+	l.ori	r4, r0, 0
+	l.ori	r3, r0, SIG_BLOCK
+	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
+	/* Do the syscall.  */
+	l.sys	1
+	 l.nop
+
+	/* if -4096 < ret < 0 holds, it's an error */
+	l.sfgeui r11, 0xf001
+	l.bf	1f
+	 l.nop
+
+	/* Same as setcontext.  */
+
+	/* Restore signal mask.  */
+	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
+	l.ori	r6, r0, _NSIG8
+	l.ori	r5, r0, 0
+	l.addi	r4, r30, UCONTEXT_SIGMASK
+	l.ori	r3, r0, SIG_SETMASK
+	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
+	/* Do the syscall.  */
+	l.sys 1
+	 l.nop
+
+	/* if -4096 < ret < 0 holds, it's an error */
+	l.sfgeui r11, 0xf001
+	l.bf	1f
+	 l.nop
+
+	/* Restore argument registers, for the makecontext case.  */
+	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
+	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
+	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
+	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
+	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
+	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
+
+	/* Restore registers stored in getcontext.  */
+	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
+	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
+	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
+	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
+	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
+	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
+	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
+	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
+	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
+	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
+	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
+	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
+	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
+	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
+
+	l.jr	r11
+	 l.ori	r11, r0, 0
+
+1:	l.j	__syscall_error
+	 l.ori	r3, r11, 0
+
+END (__swapcontext)
+weak_alias (__swapcontext, swapcontext)
diff --git a/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
new file mode 100644
index 0000000000..c4aead8f93
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
@@ -0,0 +1,53 @@
+/* ucontext_t definition, OpenRISC version.
+   Copyright (C) 2021 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
+   <https://www.gnu.org/licenses/>.  */
+
+/* System V/OpenRISC compliant context switching support.  */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H	1
+
+#include <features.h>
+
+#include <bits/types/sigset_t.h>
+#include <bits/types/stack_t.h>
+
+/* Number of general registers.  */
+#define __NGREG	32
+#ifdef __USE_MISC
+# define NGREG	__NGREG
+#endif
+
+/* Context to describe whole processor state.  */
+typedef struct
+  {
+    unsigned long int __gprs[__NGREG];
+    unsigned long int __pc;
+    unsigned long int __sr;
+  } mcontext_t;
+
+/* Userlevel context.  */
+typedef struct ucontext_t
+  {
+    unsigned long int __uc_flags;
+    struct ucontext_t *uc_link;
+    stack_t uc_stack;
+    mcontext_t uc_mcontext;
+    sigset_t uc_sigmask;
+  } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/sysdeps/unix/sysv/linux/or1k/sys/user.h b/sysdeps/unix/sysv/linux/or1k/sys/user.h
new file mode 100644
index 0000000000..c871f1a03d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/sys/user.h
@@ -0,0 +1 @@
+/* This file is not needed, but in practice gdb might try to include it.  */
diff --git a/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
new file mode 100644
index 0000000000..a8d4db080f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
@@ -0,0 +1,26 @@
+#include <inttypes.h>
+#include <signal.h>
+#include <stddef.h>
+#include <sys/ucontext.h>
+
+-- Constants used by the rt_sigprocmask call.
+
+SIG_BLOCK
+SIG_SETMASK
+
+_NSIG8				(_NSIG / 8)
+
+-- Offsets of the fields in the ucontext_t structure.
+#define ucontext(member)	offsetof (ucontext_t, member)
+#define stack(member)		ucontext (uc_stack.member)
+
+UCONTEXT_LINK			ucontext (uc_link)
+UCONTEXT_STACK			ucontext (uc_stack)
+UCONTEXT_MCONTEXT		ucontext (uc_mcontext)
+UCONTEXT_SIGMASK		ucontext (uc_sigmask)
+
+STACK_SP			stack (ss_sp)
+STACK_SIZE			stack (ss_size)
+STACK_FLAGS			stack (ss_flags)
+
+UCONTEXT_SIZE			sizeof (ucontext_t)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 10/13] or1k: ABI lists
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (8 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 09/13] or1k: Linux ABI Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-22 20:20   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 11/13] or1k: Build Infrastructure Stafford Horne
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

---
 sysdeps/unix/sysv/linux/or1k/c++-types.data   |   67 +
 sysdeps/unix/sysv/linux/or1k/ld.abilist       |    5 +
 .../sysv/linux/or1k/libBrokenLocale.abilist   |    1 +
 sysdeps/unix/sysv/linux/or1k/libanl.abilist   |    1 +
 sysdeps/unix/sysv/linux/or1k/libc.abilist     | 2122 +++++++++++++++++
 .../sysv/linux/or1k/libc_malloc_debug.abilist |   26 +
 sysdeps/unix/sysv/linux/or1k/libcrypt.abilist |    2 +
 sysdeps/unix/sysv/linux/or1k/libdl.abilist    |    0
 sysdeps/unix/sysv/linux/or1k/libm.abilist     |  759 ++++++
 sysdeps/unix/sysv/linux/or1k/libnsl.abilist   |  121 +
 .../unix/sysv/linux/or1k/libpthread.abilist   |    0
 .../unix/sysv/linux/or1k/libresolv.abilist    |   55 +
 sysdeps/unix/sysv/linux/or1k/librt.abilist    |    0
 .../unix/sysv/linux/or1k/libthread_db.abilist |   40 +
 sysdeps/unix/sysv/linux/or1k/libutil.abilist  |    1 +
 sysdeps/unix/sysv/linux/or1k/localplt.data    |   14 +
 16 files changed, 3214 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/or1k/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/or1k/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libc_malloc_debug.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libnsl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/or1k/localplt.data

diff --git a/sysdeps/unix/sysv/linux/or1k/c++-types.data b/sysdeps/unix/sysv/linux/or1k/c++-types.data
new file mode 100644
index 0000000000..0fb0143ae7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/c++-types.data
@@ -0,0 +1,67 @@
+blkcnt64_t:x
+blkcnt_t:x
+blksize_t:i
+caddr_t:Pc
+clockid_t:i
+clock_t:l
+daddr_t:i
+dev_t:y
+fd_mask:l
+fsblkcnt64_t:y
+fsblkcnt_t:y
+fsfilcnt64_t:y
+fsfilcnt_t:y
+fsid_t:8__fsid_t
+gid_t:j
+id_t:j
+ino64_t:y
+ino_t:y
+int16_t:s
+int32_t:i
+int64_t:x
+int8_t:a
+intptr_t:i
+key_t:i
+loff_t:x
+mode_t:j
+nlink_t:j
+off64_t:x
+off_t:x
+pid_t:i
+pthread_attr_t:14pthread_attr_t
+pthread_barrier_t:17pthread_barrier_t
+pthread_barrierattr_t:21pthread_barrierattr_t
+pthread_cond_t:14pthread_cond_t
+pthread_condattr_t:18pthread_condattr_t
+pthread_key_t:j
+pthread_mutex_t:15pthread_mutex_t
+pthread_mutexattr_t:19pthread_mutexattr_t
+pthread_once_t:i
+pthread_rwlock_t:16pthread_rwlock_t
+pthread_rwlockattr_t:20pthread_rwlockattr_t
+pthread_spinlock_t:i
+pthread_t:m
+quad_t:x
+register_t:i
+rlim64_t:y
+rlim_t:y
+sigset_t:10__sigset_t
+size_t:j
+socklen_t:j
+ssize_t:i
+suseconds_t:x
+time_t:x
+u_char:h
+uid_t:j
+uint:j
+u_int:j
+u_int16_t:t
+u_int32_t:j
+u_int64_t:y
+u_int8_t:h
+ulong:m
+u_long:m
+u_quad_t:y
+useconds_t:j
+ushort:t
+u_short:t
diff --git a/sysdeps/unix/sysv/linux/or1k/ld.abilist b/sysdeps/unix/sysv/linux/or1k/ld.abilist
new file mode 100644
index 0000000000..c4b85c8a33
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/ld.abilist
@@ -0,0 +1,5 @@
+GLIBC_2.35 __libc_stack_end D 0x4
+GLIBC_2.35 __stack_chk_guard D 0x4
+GLIBC_2.35 __tls_get_addr F
+GLIBC_2.35 _dl_mcount F
+GLIBC_2.35 _r_debug D 0x14
diff --git a/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist b/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
new file mode 100644
index 0000000000..366c393274
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
@@ -0,0 +1 @@
+GLIBC_2.35 __ctype_get_mb_cur_max F
diff --git a/sysdeps/unix/sysv/linux/or1k/libanl.abilist b/sysdeps/unix/sysv/linux/or1k/libanl.abilist
new file mode 100644
index 0000000000..c6437809db
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libanl.abilist
@@ -0,0 +1 @@
+GLIBC_2.35 __libanl_version_placeholder F
diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist
new file mode 100644
index 0000000000..2e177b0811
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
@@ -0,0 +1,2122 @@
+GLIBC_2.35 _Exit F
+GLIBC_2.35 _Fork F
+GLIBC_2.35 _IO_2_1_stderr_ D 0x9c
+GLIBC_2.35 _IO_2_1_stdin_ D 0x9c
+GLIBC_2.35 _IO_2_1_stdout_ D 0x9c
+GLIBC_2.35 _IO_adjust_column F
+GLIBC_2.35 _IO_adjust_wcolumn F
+GLIBC_2.35 _IO_default_doallocate F
+GLIBC_2.35 _IO_default_finish F
+GLIBC_2.35 _IO_default_pbackfail F
+GLIBC_2.35 _IO_default_uflow F
+GLIBC_2.35 _IO_default_xsgetn F
+GLIBC_2.35 _IO_default_xsputn F
+GLIBC_2.35 _IO_do_write F
+GLIBC_2.35 _IO_doallocbuf F
+GLIBC_2.35 _IO_fclose F
+GLIBC_2.35 _IO_fdopen F
+GLIBC_2.35 _IO_feof F
+GLIBC_2.35 _IO_ferror F
+GLIBC_2.35 _IO_fflush F
+GLIBC_2.35 _IO_fgetpos F
+GLIBC_2.35 _IO_fgetpos64 F
+GLIBC_2.35 _IO_fgets F
+GLIBC_2.35 _IO_file_attach F
+GLIBC_2.35 _IO_file_close F
+GLIBC_2.35 _IO_file_close_it F
+GLIBC_2.35 _IO_file_doallocate F
+GLIBC_2.35 _IO_file_finish F
+GLIBC_2.35 _IO_file_fopen F
+GLIBC_2.35 _IO_file_init F
+GLIBC_2.35 _IO_file_jumps D 0x54
+GLIBC_2.35 _IO_file_open F
+GLIBC_2.35 _IO_file_overflow F
+GLIBC_2.35 _IO_file_read F
+GLIBC_2.35 _IO_file_seek F
+GLIBC_2.35 _IO_file_seekoff F
+GLIBC_2.35 _IO_file_setbuf F
+GLIBC_2.35 _IO_file_stat F
+GLIBC_2.35 _IO_file_sync F
+GLIBC_2.35 _IO_file_underflow F
+GLIBC_2.35 _IO_file_write F
+GLIBC_2.35 _IO_file_xsputn F
+GLIBC_2.35 _IO_flockfile F
+GLIBC_2.35 _IO_flush_all F
+GLIBC_2.35 _IO_flush_all_linebuffered F
+GLIBC_2.35 _IO_fopen F
+GLIBC_2.35 _IO_fprintf F
+GLIBC_2.35 _IO_fputs F
+GLIBC_2.35 _IO_fread F
+GLIBC_2.35 _IO_free_backup_area F
+GLIBC_2.35 _IO_free_wbackup_area F
+GLIBC_2.35 _IO_fsetpos F
+GLIBC_2.35 _IO_fsetpos64 F
+GLIBC_2.35 _IO_ftell F
+GLIBC_2.35 _IO_ftrylockfile F
+GLIBC_2.35 _IO_funlockfile F
+GLIBC_2.35 _IO_fwrite F
+GLIBC_2.35 _IO_getc F
+GLIBC_2.35 _IO_getline F
+GLIBC_2.35 _IO_getline_info F
+GLIBC_2.35 _IO_gets F
+GLIBC_2.35 _IO_init F
+GLIBC_2.35 _IO_init_marker F
+GLIBC_2.35 _IO_init_wmarker F
+GLIBC_2.35 _IO_iter_begin F
+GLIBC_2.35 _IO_iter_end F
+GLIBC_2.35 _IO_iter_file F
+GLIBC_2.35 _IO_iter_next F
+GLIBC_2.35 _IO_least_wmarker F
+GLIBC_2.35 _IO_link_in F
+GLIBC_2.35 _IO_list_all D 0x4
+GLIBC_2.35 _IO_list_lock F
+GLIBC_2.35 _IO_list_resetlock F
+GLIBC_2.35 _IO_list_unlock F
+GLIBC_2.35 _IO_marker_delta F
+GLIBC_2.35 _IO_marker_difference F
+GLIBC_2.35 _IO_padn F
+GLIBC_2.35 _IO_peekc_locked F
+GLIBC_2.35 _IO_popen F
+GLIBC_2.35 _IO_printf F
+GLIBC_2.35 _IO_proc_close F
+GLIBC_2.35 _IO_proc_open F
+GLIBC_2.35 _IO_putc F
+GLIBC_2.35 _IO_puts F
+GLIBC_2.35 _IO_remove_marker F
+GLIBC_2.35 _IO_seekmark F
+GLIBC_2.35 _IO_seekoff F
+GLIBC_2.35 _IO_seekpos F
+GLIBC_2.35 _IO_seekwmark F
+GLIBC_2.35 _IO_setb F
+GLIBC_2.35 _IO_setbuffer F
+GLIBC_2.35 _IO_setvbuf F
+GLIBC_2.35 _IO_sgetn F
+GLIBC_2.35 _IO_sprintf F
+GLIBC_2.35 _IO_sputbackc F
+GLIBC_2.35 _IO_sputbackwc F
+GLIBC_2.35 _IO_sscanf F
+GLIBC_2.35 _IO_str_init_readonly F
+GLIBC_2.35 _IO_str_init_static F
+GLIBC_2.35 _IO_str_overflow F
+GLIBC_2.35 _IO_str_pbackfail F
+GLIBC_2.35 _IO_str_seekoff F
+GLIBC_2.35 _IO_str_underflow F
+GLIBC_2.35 _IO_sungetc F
+GLIBC_2.35 _IO_sungetwc F
+GLIBC_2.35 _IO_switch_to_get_mode F
+GLIBC_2.35 _IO_switch_to_main_wget_area F
+GLIBC_2.35 _IO_switch_to_wbackup_area F
+GLIBC_2.35 _IO_switch_to_wget_mode F
+GLIBC_2.35 _IO_un_link F
+GLIBC_2.35 _IO_ungetc F
+GLIBC_2.35 _IO_unsave_markers F
+GLIBC_2.35 _IO_unsave_wmarkers F
+GLIBC_2.35 _IO_vfprintf F
+GLIBC_2.35 _IO_vsprintf F
+GLIBC_2.35 _IO_wdefault_doallocate F
+GLIBC_2.35 _IO_wdefault_finish F
+GLIBC_2.35 _IO_wdefault_pbackfail F
+GLIBC_2.35 _IO_wdefault_uflow F
+GLIBC_2.35 _IO_wdefault_xsgetn F
+GLIBC_2.35 _IO_wdefault_xsputn F
+GLIBC_2.35 _IO_wdo_write F
+GLIBC_2.35 _IO_wdoallocbuf F
+GLIBC_2.35 _IO_wfile_jumps D 0x54
+GLIBC_2.35 _IO_wfile_overflow F
+GLIBC_2.35 _IO_wfile_seekoff F
+GLIBC_2.35 _IO_wfile_sync F
+GLIBC_2.35 _IO_wfile_underflow F
+GLIBC_2.35 _IO_wfile_xsputn F
+GLIBC_2.35 _IO_wmarker_delta F
+GLIBC_2.35 _IO_wsetb F
+GLIBC_2.35 __adjtimex F
+GLIBC_2.35 __argz_count F
+GLIBC_2.35 __argz_next F
+GLIBC_2.35 __argz_stringify F
+GLIBC_2.35 __asprintf F
+GLIBC_2.35 __asprintf_chk F
+GLIBC_2.35 __assert F
+GLIBC_2.35 __assert_fail F
+GLIBC_2.35 __assert_perror_fail F
+GLIBC_2.35 __backtrace F
+GLIBC_2.35 __backtrace_symbols F
+GLIBC_2.35 __backtrace_symbols_fd F
+GLIBC_2.35 __bsd_getpgrp F
+GLIBC_2.35 __bzero F
+GLIBC_2.35 __check_rhosts_file D 0x4
+GLIBC_2.35 __chk_fail F
+GLIBC_2.35 __clone F
+GLIBC_2.35 __close F
+GLIBC_2.35 __cmsg_nxthdr F
+GLIBC_2.35 __confstr_chk F
+GLIBC_2.35 __connect F
+GLIBC_2.35 __ctype_b_loc F
+GLIBC_2.35 __ctype_get_mb_cur_max F
+GLIBC_2.35 __ctype_tolower_loc F
+GLIBC_2.35 __ctype_toupper_loc F
+GLIBC_2.35 __curbrk D 0x4
+GLIBC_2.35 __cxa_at_quick_exit F
+GLIBC_2.35 __cxa_atexit F
+GLIBC_2.35 __cxa_finalize F
+GLIBC_2.35 __cxa_thread_atexit_impl F
+GLIBC_2.35 __cyg_profile_func_enter F
+GLIBC_2.35 __cyg_profile_func_exit F
+GLIBC_2.35 __daylight D 0x4
+GLIBC_2.35 __dcgettext F
+GLIBC_2.35 __dgettext F
+GLIBC_2.35 __dprintf_chk F
+GLIBC_2.35 __dup2 F
+GLIBC_2.35 __duplocale F
+GLIBC_2.35 __endmntent F
+GLIBC_2.35 __environ D 0x4
+GLIBC_2.35 __errno_location F
+GLIBC_2.35 __explicit_bzero_chk F
+GLIBC_2.35 __fbufsize F
+GLIBC_2.35 __fcntl F
+GLIBC_2.35 __fdelt_chk F
+GLIBC_2.35 __fdelt_warn F
+GLIBC_2.35 __ffs F
+GLIBC_2.35 __fgets_chk F
+GLIBC_2.35 __fgets_unlocked_chk F
+GLIBC_2.35 __fgetws_chk F
+GLIBC_2.35 __fgetws_unlocked_chk F
+GLIBC_2.35 __finite F
+GLIBC_2.35 __finitef F
+GLIBC_2.35 __flbf F
+GLIBC_2.35 __fork F
+GLIBC_2.35 __fpending F
+GLIBC_2.35 __fprintf_chk F
+GLIBC_2.35 __fpu_control D 0x4
+GLIBC_2.35 __fpurge F
+GLIBC_2.35 __fread_chk F
+GLIBC_2.35 __fread_unlocked_chk F
+GLIBC_2.35 __freadable F
+GLIBC_2.35 __freading F
+GLIBC_2.35 __freelocale F
+GLIBC_2.35 __fsetlocking F
+GLIBC_2.35 __fwprintf_chk F
+GLIBC_2.35 __fwritable F
+GLIBC_2.35 __fwriting F
+GLIBC_2.35 __getauxval F
+GLIBC_2.35 __getcwd_chk F
+GLIBC_2.35 __getdelim F
+GLIBC_2.35 __getdomainname_chk F
+GLIBC_2.35 __getgroups_chk F
+GLIBC_2.35 __gethostname_chk F
+GLIBC_2.35 __getlogin_r_chk F
+GLIBC_2.35 __getmntent_r F
+GLIBC_2.35 __getpagesize F
+GLIBC_2.35 __getpgid F
+GLIBC_2.35 __getpid F
+GLIBC_2.35 __gets_chk F
+GLIBC_2.35 __gettimeofday F
+GLIBC_2.35 __getwd_chk F
+GLIBC_2.35 __gmtime_r F
+GLIBC_2.35 __h_errno_location F
+GLIBC_2.35 __isalnum_l F
+GLIBC_2.35 __isalpha_l F
+GLIBC_2.35 __isascii_l F
+GLIBC_2.35 __isblank_l F
+GLIBC_2.35 __iscntrl_l F
+GLIBC_2.35 __isctype F
+GLIBC_2.35 __isdigit_l F
+GLIBC_2.35 __isgraph_l F
+GLIBC_2.35 __isinf F
+GLIBC_2.35 __isinff F
+GLIBC_2.35 __islower_l F
+GLIBC_2.35 __isnan F
+GLIBC_2.35 __isnanf F
+GLIBC_2.35 __isoc99_fscanf F
+GLIBC_2.35 __isoc99_fwscanf F
+GLIBC_2.35 __isoc99_scanf F
+GLIBC_2.35 __isoc99_sscanf F
+GLIBC_2.35 __isoc99_swscanf F
+GLIBC_2.35 __isoc99_vfscanf F
+GLIBC_2.35 __isoc99_vfwscanf F
+GLIBC_2.35 __isoc99_vscanf F
+GLIBC_2.35 __isoc99_vsscanf F
+GLIBC_2.35 __isoc99_vswscanf F
+GLIBC_2.35 __isoc99_vwscanf F
+GLIBC_2.35 __isoc99_wscanf F
+GLIBC_2.35 __isprint_l F
+GLIBC_2.35 __ispunct_l F
+GLIBC_2.35 __isspace_l F
+GLIBC_2.35 __isupper_l F
+GLIBC_2.35 __iswalnum_l F
+GLIBC_2.35 __iswalpha_l F
+GLIBC_2.35 __iswblank_l F
+GLIBC_2.35 __iswcntrl_l F
+GLIBC_2.35 __iswctype F
+GLIBC_2.35 __iswctype_l F
+GLIBC_2.35 __iswdigit_l F
+GLIBC_2.35 __iswgraph_l F
+GLIBC_2.35 __iswlower_l F
+GLIBC_2.35 __iswprint_l F
+GLIBC_2.35 __iswpunct_l F
+GLIBC_2.35 __iswspace_l F
+GLIBC_2.35 __iswupper_l F
+GLIBC_2.35 __iswxdigit_l F
+GLIBC_2.35 __isxdigit_l F
+GLIBC_2.35 __ivaliduser F
+GLIBC_2.35 __libc_allocate_rtsig F
+GLIBC_2.35 __libc_calloc F
+GLIBC_2.35 __libc_current_sigrtmax F
+GLIBC_2.35 __libc_current_sigrtmin F
+GLIBC_2.35 __libc_free F
+GLIBC_2.35 __libc_freeres F
+GLIBC_2.35 __libc_init_first F
+GLIBC_2.35 __libc_mallinfo F
+GLIBC_2.35 __libc_malloc F
+GLIBC_2.35 __libc_mallopt F
+GLIBC_2.35 __libc_memalign F
+GLIBC_2.35 __libc_pvalloc F
+GLIBC_2.35 __libc_realloc F
+GLIBC_2.35 __libc_sa_len F
+GLIBC_2.35 __libc_single_threaded D 0x1
+GLIBC_2.35 __libc_start_main F
+GLIBC_2.35 __libc_valloc F
+GLIBC_2.35 __longjmp_chk F
+GLIBC_2.35 __lseek F
+GLIBC_2.35 __mbrlen F
+GLIBC_2.35 __mbrtowc F
+GLIBC_2.35 __mbsnrtowcs_chk F
+GLIBC_2.35 __mbsrtowcs_chk F
+GLIBC_2.35 __mbstowcs_chk F
+GLIBC_2.35 __memcmpeq F
+GLIBC_2.35 __memcpy_chk F
+GLIBC_2.35 __memmove_chk F
+GLIBC_2.35 __mempcpy F
+GLIBC_2.35 __mempcpy_chk F
+GLIBC_2.35 __memset_chk F
+GLIBC_2.35 __monstartup F
+GLIBC_2.35 __mq_open_2 F
+GLIBC_2.35 __nanosleep F
+GLIBC_2.35 __newlocale F
+GLIBC_2.35 __nl_langinfo_l F
+GLIBC_2.35 __nss_configure_lookup F
+GLIBC_2.35 __nss_hostname_digits_dots F
+GLIBC_2.35 __obstack_printf_chk F
+GLIBC_2.35 __obstack_vprintf_chk F
+GLIBC_2.35 __open F
+GLIBC_2.35 __open64 F
+GLIBC_2.35 __open64_2 F
+GLIBC_2.35 __open_2 F
+GLIBC_2.35 __openat64_2 F
+GLIBC_2.35 __openat_2 F
+GLIBC_2.35 __overflow F
+GLIBC_2.35 __pipe F
+GLIBC_2.35 __poll F
+GLIBC_2.35 __poll_chk F
+GLIBC_2.35 __posix_getopt F
+GLIBC_2.35 __ppoll_chk F
+GLIBC_2.35 __pread64 F
+GLIBC_2.35 __pread64_chk F
+GLIBC_2.35 __pread_chk F
+GLIBC_2.35 __printf_chk F
+GLIBC_2.35 __printf_fp F
+GLIBC_2.35 __profile_frequency F
+GLIBC_2.35 __progname D 0x4
+GLIBC_2.35 __progname_full D 0x4
+GLIBC_2.35 __pthread_cleanup_routine F
+GLIBC_2.35 __pthread_key_create F
+GLIBC_2.35 __pthread_register_cancel F
+GLIBC_2.35 __pthread_register_cancel_defer F
+GLIBC_2.35 __pthread_rwlock_unlock F
+GLIBC_2.35 __pthread_unregister_cancel F
+GLIBC_2.35 __pthread_unregister_cancel_restore F
+GLIBC_2.35 __pthread_unwind_next F
+GLIBC_2.35 __ptsname_r_chk F
+GLIBC_2.35 __pwrite64 F
+GLIBC_2.35 __rawmemchr F
+GLIBC_2.35 __rcmd_errstr D 0x4
+GLIBC_2.35 __read F
+GLIBC_2.35 __read_chk F
+GLIBC_2.35 __readlink_chk F
+GLIBC_2.35 __readlinkat_chk F
+GLIBC_2.35 __realpath_chk F
+GLIBC_2.35 __recv_chk F
+GLIBC_2.35 __recvfrom_chk F
+GLIBC_2.35 __register_atfork F
+GLIBC_2.35 __res_init F
+GLIBC_2.35 __res_nclose F
+GLIBC_2.35 __res_ninit F
+GLIBC_2.35 __res_randomid F
+GLIBC_2.35 __res_state F
+GLIBC_2.35 __sbrk F
+GLIBC_2.35 __sched_cpualloc F
+GLIBC_2.35 __sched_cpucount F
+GLIBC_2.35 __sched_cpufree F
+GLIBC_2.35 __sched_get_priority_max F
+GLIBC_2.35 __sched_get_priority_min F
+GLIBC_2.35 __sched_getparam F
+GLIBC_2.35 __sched_getscheduler F
+GLIBC_2.35 __sched_setscheduler F
+GLIBC_2.35 __sched_yield F
+GLIBC_2.35 __select F
+GLIBC_2.35 __send F
+GLIBC_2.35 __setmntent F
+GLIBC_2.35 __setpgid F
+GLIBC_2.35 __sigaction F
+GLIBC_2.35 __signbit F
+GLIBC_2.35 __signbitf F
+GLIBC_2.35 __sigpause F
+GLIBC_2.35 __sigsetjmp F
+GLIBC_2.35 __sigsuspend F
+GLIBC_2.35 __snprintf_chk F
+GLIBC_2.35 __sprintf_chk F
+GLIBC_2.35 __stack_chk_fail F
+GLIBC_2.35 __statfs F
+GLIBC_2.35 __stpcpy F
+GLIBC_2.35 __stpcpy_chk F
+GLIBC_2.35 __stpncpy F
+GLIBC_2.35 __stpncpy_chk F
+GLIBC_2.35 __strcasecmp F
+GLIBC_2.35 __strcasecmp_l F
+GLIBC_2.35 __strcasestr F
+GLIBC_2.35 __strcat_chk F
+GLIBC_2.35 __strcoll_l F
+GLIBC_2.35 __strcpy_chk F
+GLIBC_2.35 __strdup F
+GLIBC_2.35 __strerror_r F
+GLIBC_2.35 __strfmon_l F
+GLIBC_2.35 __strftime_l F
+GLIBC_2.35 __strncasecmp_l F
+GLIBC_2.35 __strncat_chk F
+GLIBC_2.35 __strncpy_chk F
+GLIBC_2.35 __strndup F
+GLIBC_2.35 __strsep_g F
+GLIBC_2.35 __strtod_internal F
+GLIBC_2.35 __strtod_l F
+GLIBC_2.35 __strtof_internal F
+GLIBC_2.35 __strtof_l F
+GLIBC_2.35 __strtok_r F
+GLIBC_2.35 __strtol_internal F
+GLIBC_2.35 __strtol_l F
+GLIBC_2.35 __strtold_internal F
+GLIBC_2.35 __strtold_l F
+GLIBC_2.35 __strtoll_internal F
+GLIBC_2.35 __strtoll_l F
+GLIBC_2.35 __strtoul_internal F
+GLIBC_2.35 __strtoul_l F
+GLIBC_2.35 __strtoull_internal F
+GLIBC_2.35 __strtoull_l F
+GLIBC_2.35 __strverscmp F
+GLIBC_2.35 __strxfrm_l F
+GLIBC_2.35 __swprintf_chk F
+GLIBC_2.35 __sysconf F
+GLIBC_2.35 __syslog_chk F
+GLIBC_2.35 __sysv_signal F
+GLIBC_2.35 __timezone D 0x4
+GLIBC_2.35 __toascii_l F
+GLIBC_2.35 __tolower_l F
+GLIBC_2.35 __toupper_l F
+GLIBC_2.35 __towctrans F
+GLIBC_2.35 __towctrans_l F
+GLIBC_2.35 __towlower_l F
+GLIBC_2.35 __towupper_l F
+GLIBC_2.35 __ttyname_r_chk F
+GLIBC_2.35 __tzname D 0x8
+GLIBC_2.35 __uflow F
+GLIBC_2.35 __underflow F
+GLIBC_2.35 __uselocale F
+GLIBC_2.35 __vasprintf_chk F
+GLIBC_2.35 __vdprintf_chk F
+GLIBC_2.35 __vfork F
+GLIBC_2.35 __vfprintf_chk F
+GLIBC_2.35 __vfscanf F
+GLIBC_2.35 __vfwprintf_chk F
+GLIBC_2.35 __vprintf_chk F
+GLIBC_2.35 __vsnprintf F
+GLIBC_2.35 __vsnprintf_chk F
+GLIBC_2.35 __vsprintf_chk F
+GLIBC_2.35 __vsscanf F
+GLIBC_2.35 __vswprintf_chk F
+GLIBC_2.35 __vsyslog_chk F
+GLIBC_2.35 __vwprintf_chk F
+GLIBC_2.35 __wait F
+GLIBC_2.35 __waitpid F
+GLIBC_2.35 __wcpcpy_chk F
+GLIBC_2.35 __wcpncpy_chk F
+GLIBC_2.35 __wcrtomb_chk F
+GLIBC_2.35 __wcscasecmp_l F
+GLIBC_2.35 __wcscat_chk F
+GLIBC_2.35 __wcscoll_l F
+GLIBC_2.35 __wcscpy_chk F
+GLIBC_2.35 __wcsftime_l F
+GLIBC_2.35 __wcsncasecmp_l F
+GLIBC_2.35 __wcsncat_chk F
+GLIBC_2.35 __wcsncpy_chk F
+GLIBC_2.35 __wcsnrtombs_chk F
+GLIBC_2.35 __wcsrtombs_chk F
+GLIBC_2.35 __wcstod_internal F
+GLIBC_2.35 __wcstod_l F
+GLIBC_2.35 __wcstof_internal F
+GLIBC_2.35 __wcstof_l F
+GLIBC_2.35 __wcstol_internal F
+GLIBC_2.35 __wcstol_l F
+GLIBC_2.35 __wcstold_internal F
+GLIBC_2.35 __wcstold_l F
+GLIBC_2.35 __wcstoll_internal F
+GLIBC_2.35 __wcstoll_l F
+GLIBC_2.35 __wcstombs_chk F
+GLIBC_2.35 __wcstoul_internal F
+GLIBC_2.35 __wcstoul_l F
+GLIBC_2.35 __wcstoull_internal F
+GLIBC_2.35 __wcstoull_l F
+GLIBC_2.35 __wcsxfrm_l F
+GLIBC_2.35 __wctomb_chk F
+GLIBC_2.35 __wctrans_l F
+GLIBC_2.35 __wctype_l F
+GLIBC_2.35 __wmemcpy_chk F
+GLIBC_2.35 __wmemmove_chk F
+GLIBC_2.35 __wmempcpy_chk F
+GLIBC_2.35 __wmemset_chk F
+GLIBC_2.35 __woverflow F
+GLIBC_2.35 __wprintf_chk F
+GLIBC_2.35 __write F
+GLIBC_2.35 __wuflow F
+GLIBC_2.35 __wunderflow F
+GLIBC_2.35 __xpg_basename F
+GLIBC_2.35 __xpg_sigpause F
+GLIBC_2.35 __xpg_strerror_r F
+GLIBC_2.35 _dl_mcount_wrapper F
+GLIBC_2.35 _dl_mcount_wrapper_check F
+GLIBC_2.35 _environ D 0x4
+GLIBC_2.35 _exit F
+GLIBC_2.35 _flushlbf F
+GLIBC_2.35 _libc_intl_domainname D 0x5
+GLIBC_2.35 _longjmp F
+GLIBC_2.35 _mcleanup F
+GLIBC_2.35 _mcount F
+GLIBC_2.35 _nl_default_dirname D 0x12
+GLIBC_2.35 _nl_domain_bindings D 0x4
+GLIBC_2.35 _nl_msg_cat_cntr D 0x4
+GLIBC_2.35 _obstack_allocated_p F
+GLIBC_2.35 _obstack_begin F
+GLIBC_2.35 _obstack_begin_1 F
+GLIBC_2.35 _obstack_free F
+GLIBC_2.35 _obstack_memory_used F
+GLIBC_2.35 _obstack_newchunk F
+GLIBC_2.35 _pthread_cleanup_pop F
+GLIBC_2.35 _pthread_cleanup_push F
+GLIBC_2.35 _res D 0x200
+GLIBC_2.35 _res_hconf D 0x30
+GLIBC_2.35 _setjmp F
+GLIBC_2.35 _tolower F
+GLIBC_2.35 _toupper F
+GLIBC_2.35 a64l F
+GLIBC_2.35 abort F
+GLIBC_2.35 abs F
+GLIBC_2.35 accept F
+GLIBC_2.35 accept4 F
+GLIBC_2.35 access F
+GLIBC_2.35 acct F
+GLIBC_2.35 addmntent F
+GLIBC_2.35 addseverity F
+GLIBC_2.35 adjtime F
+GLIBC_2.35 adjtimex F
+GLIBC_2.35 aio_cancel F
+GLIBC_2.35 aio_cancel64 F
+GLIBC_2.35 aio_error F
+GLIBC_2.35 aio_error64 F
+GLIBC_2.35 aio_fsync F
+GLIBC_2.35 aio_fsync64 F
+GLIBC_2.35 aio_init F
+GLIBC_2.35 aio_read F
+GLIBC_2.35 aio_read64 F
+GLIBC_2.35 aio_return F
+GLIBC_2.35 aio_return64 F
+GLIBC_2.35 aio_suspend F
+GLIBC_2.35 aio_suspend64 F
+GLIBC_2.35 aio_write F
+GLIBC_2.35 aio_write64 F
+GLIBC_2.35 alarm F
+GLIBC_2.35 aligned_alloc F
+GLIBC_2.35 alphasort F
+GLIBC_2.35 alphasort64 F
+GLIBC_2.35 argp_err_exit_status D 0x4
+GLIBC_2.35 argp_error F
+GLIBC_2.35 argp_failure F
+GLIBC_2.35 argp_help F
+GLIBC_2.35 argp_parse F
+GLIBC_2.35 argp_program_bug_address D 0x4
+GLIBC_2.35 argp_program_version D 0x4
+GLIBC_2.35 argp_program_version_hook D 0x4
+GLIBC_2.35 argp_state_help F
+GLIBC_2.35 argp_usage F
+GLIBC_2.35 argz_add F
+GLIBC_2.35 argz_add_sep F
+GLIBC_2.35 argz_append F
+GLIBC_2.35 argz_count F
+GLIBC_2.35 argz_create F
+GLIBC_2.35 argz_create_sep F
+GLIBC_2.35 argz_delete F
+GLIBC_2.35 argz_extract F
+GLIBC_2.35 argz_insert F
+GLIBC_2.35 argz_next F
+GLIBC_2.35 argz_replace F
+GLIBC_2.35 argz_stringify F
+GLIBC_2.35 asctime F
+GLIBC_2.35 asctime_r F
+GLIBC_2.35 asprintf F
+GLIBC_2.35 atof F
+GLIBC_2.35 atoi F
+GLIBC_2.35 atol F
+GLIBC_2.35 atoll F
+GLIBC_2.35 backtrace F
+GLIBC_2.35 backtrace_symbols F
+GLIBC_2.35 backtrace_symbols_fd F
+GLIBC_2.35 basename F
+GLIBC_2.35 bcmp F
+GLIBC_2.35 bcopy F
+GLIBC_2.35 bind F
+GLIBC_2.35 bind_textdomain_codeset F
+GLIBC_2.35 bindresvport F
+GLIBC_2.35 bindtextdomain F
+GLIBC_2.35 brk F
+GLIBC_2.35 bsd_signal F
+GLIBC_2.35 bsearch F
+GLIBC_2.35 btowc F
+GLIBC_2.35 bzero F
+GLIBC_2.35 c16rtomb F
+GLIBC_2.35 c32rtomb F
+GLIBC_2.35 call_once F
+GLIBC_2.35 calloc F
+GLIBC_2.35 canonicalize_file_name F
+GLIBC_2.35 capget F
+GLIBC_2.35 capset F
+GLIBC_2.35 catclose F
+GLIBC_2.35 catgets F
+GLIBC_2.35 catopen F
+GLIBC_2.35 cfgetispeed F
+GLIBC_2.35 cfgetospeed F
+GLIBC_2.35 cfmakeraw F
+GLIBC_2.35 cfsetispeed F
+GLIBC_2.35 cfsetospeed F
+GLIBC_2.35 cfsetspeed F
+GLIBC_2.35 chdir F
+GLIBC_2.35 chflags F
+GLIBC_2.35 chmod F
+GLIBC_2.35 chown F
+GLIBC_2.35 chroot F
+GLIBC_2.35 clearenv F
+GLIBC_2.35 clearerr F
+GLIBC_2.35 clearerr_unlocked F
+GLIBC_2.35 clock F
+GLIBC_2.35 clock_adjtime F
+GLIBC_2.35 clock_getcpuclockid F
+GLIBC_2.35 clock_getres F
+GLIBC_2.35 clock_gettime F
+GLIBC_2.35 clock_nanosleep F
+GLIBC_2.35 clock_settime F
+GLIBC_2.35 clone F
+GLIBC_2.35 close F
+GLIBC_2.35 close_range F
+GLIBC_2.35 closedir F
+GLIBC_2.35 closefrom F
+GLIBC_2.35 closelog F
+GLIBC_2.35 cnd_broadcast F
+GLIBC_2.35 cnd_destroy F
+GLIBC_2.35 cnd_init F
+GLIBC_2.35 cnd_signal F
+GLIBC_2.35 cnd_timedwait F
+GLIBC_2.35 cnd_wait F
+GLIBC_2.35 confstr F
+GLIBC_2.35 connect F
+GLIBC_2.35 copy_file_range F
+GLIBC_2.35 copysign F
+GLIBC_2.35 copysignf F
+GLIBC_2.35 copysignl F
+GLIBC_2.35 creat F
+GLIBC_2.35 creat64 F
+GLIBC_2.35 ctermid F
+GLIBC_2.35 ctime F
+GLIBC_2.35 ctime_r F
+GLIBC_2.35 cuserid F
+GLIBC_2.35 daemon F
+GLIBC_2.35 daylight D 0x4
+GLIBC_2.35 dcgettext F
+GLIBC_2.35 dcngettext F
+GLIBC_2.35 delete_module F
+GLIBC_2.35 dgettext F
+GLIBC_2.35 difftime F
+GLIBC_2.35 dirfd F
+GLIBC_2.35 dirname F
+GLIBC_2.35 div F
+GLIBC_2.35 dl_iterate_phdr F
+GLIBC_2.35 dladdr F
+GLIBC_2.35 dladdr1 F
+GLIBC_2.35 dlclose F
+GLIBC_2.35 dlerror F
+GLIBC_2.35 dlinfo F
+GLIBC_2.35 dlmopen F
+GLIBC_2.35 dlopen F
+GLIBC_2.35 dlsym F
+GLIBC_2.35 dlvsym F
+GLIBC_2.35 dn_comp F
+GLIBC_2.35 dn_expand F
+GLIBC_2.35 dn_skipname F
+GLIBC_2.35 dngettext F
+GLIBC_2.35 dprintf F
+GLIBC_2.35 drand48 F
+GLIBC_2.35 drand48_r F
+GLIBC_2.35 dup F
+GLIBC_2.35 dup2 F
+GLIBC_2.35 dup3 F
+GLIBC_2.35 duplocale F
+GLIBC_2.35 dysize F
+GLIBC_2.35 eaccess F
+GLIBC_2.35 ecvt F
+GLIBC_2.35 ecvt_r F
+GLIBC_2.35 endaliasent F
+GLIBC_2.35 endfsent F
+GLIBC_2.35 endgrent F
+GLIBC_2.35 endhostent F
+GLIBC_2.35 endmntent F
+GLIBC_2.35 endnetent F
+GLIBC_2.35 endnetgrent F
+GLIBC_2.35 endprotoent F
+GLIBC_2.35 endpwent F
+GLIBC_2.35 endrpcent F
+GLIBC_2.35 endservent F
+GLIBC_2.35 endsgent F
+GLIBC_2.35 endspent F
+GLIBC_2.35 endttyent F
+GLIBC_2.35 endusershell F
+GLIBC_2.35 endutent F
+GLIBC_2.35 endutxent F
+GLIBC_2.35 environ D 0x4
+GLIBC_2.35 envz_add F
+GLIBC_2.35 envz_entry F
+GLIBC_2.35 envz_get F
+GLIBC_2.35 envz_merge F
+GLIBC_2.35 envz_remove F
+GLIBC_2.35 envz_strip F
+GLIBC_2.35 epoll_create F
+GLIBC_2.35 epoll_create1 F
+GLIBC_2.35 epoll_ctl F
+GLIBC_2.35 epoll_pwait F
+GLIBC_2.35 epoll_wait F
+GLIBC_2.35 erand48 F
+GLIBC_2.35 erand48_r F
+GLIBC_2.35 err F
+GLIBC_2.35 error F
+GLIBC_2.35 error_at_line F
+GLIBC_2.35 error_message_count D 0x4
+GLIBC_2.35 error_one_per_line D 0x4
+GLIBC_2.35 error_print_progname D 0x4
+GLIBC_2.35 errx F
+GLIBC_2.35 ether_aton F
+GLIBC_2.35 ether_aton_r F
+GLIBC_2.35 ether_hostton F
+GLIBC_2.35 ether_line F
+GLIBC_2.35 ether_ntoa F
+GLIBC_2.35 ether_ntoa_r F
+GLIBC_2.35 ether_ntohost F
+GLIBC_2.35 euidaccess F
+GLIBC_2.35 eventfd F
+GLIBC_2.35 eventfd_read F
+GLIBC_2.35 eventfd_write F
+GLIBC_2.35 execl F
+GLIBC_2.35 execle F
+GLIBC_2.35 execlp F
+GLIBC_2.35 execv F
+GLIBC_2.35 execve F
+GLIBC_2.35 execveat F
+GLIBC_2.35 execvp F
+GLIBC_2.35 execvpe F
+GLIBC_2.35 exit F
+GLIBC_2.35 explicit_bzero F
+GLIBC_2.35 faccessat F
+GLIBC_2.35 fallocate F
+GLIBC_2.35 fallocate64 F
+GLIBC_2.35 fanotify_init F
+GLIBC_2.35 fanotify_mark F
+GLIBC_2.35 fchdir F
+GLIBC_2.35 fchflags F
+GLIBC_2.35 fchmod F
+GLIBC_2.35 fchmodat F
+GLIBC_2.35 fchown F
+GLIBC_2.35 fchownat F
+GLIBC_2.35 fclose F
+GLIBC_2.35 fcloseall F
+GLIBC_2.35 fcntl F
+GLIBC_2.35 fcntl64 F
+GLIBC_2.35 fcvt F
+GLIBC_2.35 fcvt_r F
+GLIBC_2.35 fdatasync F
+GLIBC_2.35 fdopen F
+GLIBC_2.35 fdopendir F
+GLIBC_2.35 feof F
+GLIBC_2.35 feof_unlocked F
+GLIBC_2.35 ferror F
+GLIBC_2.35 ferror_unlocked F
+GLIBC_2.35 fexecve F
+GLIBC_2.35 fflush F
+GLIBC_2.35 fflush_unlocked F
+GLIBC_2.35 ffs F
+GLIBC_2.35 ffsl F
+GLIBC_2.35 ffsll F
+GLIBC_2.35 fgetc F
+GLIBC_2.35 fgetc_unlocked F
+GLIBC_2.35 fgetgrent F
+GLIBC_2.35 fgetgrent_r F
+GLIBC_2.35 fgetpos F
+GLIBC_2.35 fgetpos64 F
+GLIBC_2.35 fgetpwent F
+GLIBC_2.35 fgetpwent_r F
+GLIBC_2.35 fgets F
+GLIBC_2.35 fgets_unlocked F
+GLIBC_2.35 fgetsgent F
+GLIBC_2.35 fgetsgent_r F
+GLIBC_2.35 fgetspent F
+GLIBC_2.35 fgetspent_r F
+GLIBC_2.35 fgetwc F
+GLIBC_2.35 fgetwc_unlocked F
+GLIBC_2.35 fgetws F
+GLIBC_2.35 fgetws_unlocked F
+GLIBC_2.35 fgetxattr F
+GLIBC_2.35 fileno F
+GLIBC_2.35 fileno_unlocked F
+GLIBC_2.35 finite F
+GLIBC_2.35 finitef F
+GLIBC_2.35 finitel F
+GLIBC_2.35 flistxattr F
+GLIBC_2.35 flock F
+GLIBC_2.35 flockfile F
+GLIBC_2.35 fmemopen F
+GLIBC_2.35 fmtmsg F
+GLIBC_2.35 fnmatch F
+GLIBC_2.35 fopen F
+GLIBC_2.35 fopen64 F
+GLIBC_2.35 fopencookie F
+GLIBC_2.35 fork F
+GLIBC_2.35 forkpty F
+GLIBC_2.35 fpathconf F
+GLIBC_2.35 fprintf F
+GLIBC_2.35 fputc F
+GLIBC_2.35 fputc_unlocked F
+GLIBC_2.35 fputs F
+GLIBC_2.35 fputs_unlocked F
+GLIBC_2.35 fputwc F
+GLIBC_2.35 fputwc_unlocked F
+GLIBC_2.35 fputws F
+GLIBC_2.35 fputws_unlocked F
+GLIBC_2.35 fread F
+GLIBC_2.35 fread_unlocked F
+GLIBC_2.35 free F
+GLIBC_2.35 freeaddrinfo F
+GLIBC_2.35 freeifaddrs F
+GLIBC_2.35 freelocale F
+GLIBC_2.35 fremovexattr F
+GLIBC_2.35 freopen F
+GLIBC_2.35 freopen64 F
+GLIBC_2.35 frexp F
+GLIBC_2.35 frexpf F
+GLIBC_2.35 frexpl F
+GLIBC_2.35 fscanf F
+GLIBC_2.35 fseek F
+GLIBC_2.35 fseeko F
+GLIBC_2.35 fseeko64 F
+GLIBC_2.35 fsetpos F
+GLIBC_2.35 fsetpos64 F
+GLIBC_2.35 fsetxattr F
+GLIBC_2.35 fstat F
+GLIBC_2.35 fstat64 F
+GLIBC_2.35 fstatat F
+GLIBC_2.35 fstatat64 F
+GLIBC_2.35 fstatfs F
+GLIBC_2.35 fstatfs64 F
+GLIBC_2.35 fstatvfs F
+GLIBC_2.35 fstatvfs64 F
+GLIBC_2.35 fsync F
+GLIBC_2.35 ftell F
+GLIBC_2.35 ftello F
+GLIBC_2.35 ftello64 F
+GLIBC_2.35 ftime F
+GLIBC_2.35 ftok F
+GLIBC_2.35 ftruncate F
+GLIBC_2.35 ftruncate64 F
+GLIBC_2.35 ftrylockfile F
+GLIBC_2.35 fts64_children F
+GLIBC_2.35 fts64_close F
+GLIBC_2.35 fts64_open F
+GLIBC_2.35 fts64_read F
+GLIBC_2.35 fts64_set F
+GLIBC_2.35 fts_children F
+GLIBC_2.35 fts_close F
+GLIBC_2.35 fts_open F
+GLIBC_2.35 fts_read F
+GLIBC_2.35 fts_set F
+GLIBC_2.35 ftw F
+GLIBC_2.35 ftw64 F
+GLIBC_2.35 funlockfile F
+GLIBC_2.35 futimens F
+GLIBC_2.35 futimes F
+GLIBC_2.35 futimesat F
+GLIBC_2.35 fwide F
+GLIBC_2.35 fwprintf F
+GLIBC_2.35 fwrite F
+GLIBC_2.35 fwrite_unlocked F
+GLIBC_2.35 fwscanf F
+GLIBC_2.35 gai_cancel F
+GLIBC_2.35 gai_error F
+GLIBC_2.35 gai_strerror F
+GLIBC_2.35 gai_suspend F
+GLIBC_2.35 gcvt F
+GLIBC_2.35 get_avphys_pages F
+GLIBC_2.35 get_current_dir_name F
+GLIBC_2.35 get_nprocs F
+GLIBC_2.35 get_nprocs_conf F
+GLIBC_2.35 get_phys_pages F
+GLIBC_2.35 getaddrinfo F
+GLIBC_2.35 getaddrinfo_a F
+GLIBC_2.35 getaliasbyname F
+GLIBC_2.35 getaliasbyname_r F
+GLIBC_2.35 getaliasent F
+GLIBC_2.35 getaliasent_r F
+GLIBC_2.35 getauxval F
+GLIBC_2.35 getc F
+GLIBC_2.35 getc_unlocked F
+GLIBC_2.35 getchar F
+GLIBC_2.35 getchar_unlocked F
+GLIBC_2.35 getcontext F
+GLIBC_2.35 getcpu F
+GLIBC_2.35 getcwd F
+GLIBC_2.35 getdate F
+GLIBC_2.35 getdate_err D 0x4
+GLIBC_2.35 getdate_r F
+GLIBC_2.35 getdelim F
+GLIBC_2.35 getdents64 F
+GLIBC_2.35 getdirentries F
+GLIBC_2.35 getdirentries64 F
+GLIBC_2.35 getdomainname F
+GLIBC_2.35 getdtablesize F
+GLIBC_2.35 getegid F
+GLIBC_2.35 getentropy F
+GLIBC_2.35 getenv F
+GLIBC_2.35 geteuid F
+GLIBC_2.35 getfsent F
+GLIBC_2.35 getfsfile F
+GLIBC_2.35 getfsspec F
+GLIBC_2.35 getgid F
+GLIBC_2.35 getgrent F
+GLIBC_2.35 getgrent_r F
+GLIBC_2.35 getgrgid F
+GLIBC_2.35 getgrgid_r F
+GLIBC_2.35 getgrnam F
+GLIBC_2.35 getgrnam_r F
+GLIBC_2.35 getgrouplist F
+GLIBC_2.35 getgroups F
+GLIBC_2.35 gethostbyaddr F
+GLIBC_2.35 gethostbyaddr_r F
+GLIBC_2.35 gethostbyname F
+GLIBC_2.35 gethostbyname2 F
+GLIBC_2.35 gethostbyname2_r F
+GLIBC_2.35 gethostbyname_r F
+GLIBC_2.35 gethostent F
+GLIBC_2.35 gethostent_r F
+GLIBC_2.35 gethostid F
+GLIBC_2.35 gethostname F
+GLIBC_2.35 getifaddrs F
+GLIBC_2.35 getipv4sourcefilter F
+GLIBC_2.35 getitimer F
+GLIBC_2.35 getline F
+GLIBC_2.35 getloadavg F
+GLIBC_2.35 getlogin F
+GLIBC_2.35 getlogin_r F
+GLIBC_2.35 getmntent F
+GLIBC_2.35 getmntent_r F
+GLIBC_2.35 getnameinfo F
+GLIBC_2.35 getnetbyaddr F
+GLIBC_2.35 getnetbyaddr_r F
+GLIBC_2.35 getnetbyname F
+GLIBC_2.35 getnetbyname_r F
+GLIBC_2.35 getnetent F
+GLIBC_2.35 getnetent_r F
+GLIBC_2.35 getnetgrent F
+GLIBC_2.35 getnetgrent_r F
+GLIBC_2.35 getopt F
+GLIBC_2.35 getopt_long F
+GLIBC_2.35 getopt_long_only F
+GLIBC_2.35 getpagesize F
+GLIBC_2.35 getpass F
+GLIBC_2.35 getpeername F
+GLIBC_2.35 getpgid F
+GLIBC_2.35 getpgrp F
+GLIBC_2.35 getpid F
+GLIBC_2.35 getppid F
+GLIBC_2.35 getpriority F
+GLIBC_2.35 getprotobyname F
+GLIBC_2.35 getprotobyname_r F
+GLIBC_2.35 getprotobynumber F
+GLIBC_2.35 getprotobynumber_r F
+GLIBC_2.35 getprotoent F
+GLIBC_2.35 getprotoent_r F
+GLIBC_2.35 getpt F
+GLIBC_2.35 getpw F
+GLIBC_2.35 getpwent F
+GLIBC_2.35 getpwent_r F
+GLIBC_2.35 getpwnam F
+GLIBC_2.35 getpwnam_r F
+GLIBC_2.35 getpwuid F
+GLIBC_2.35 getpwuid_r F
+GLIBC_2.35 getrandom F
+GLIBC_2.35 getresgid F
+GLIBC_2.35 getresuid F
+GLIBC_2.35 getrlimit F
+GLIBC_2.35 getrlimit64 F
+GLIBC_2.35 getrpcbyname F
+GLIBC_2.35 getrpcbyname_r F
+GLIBC_2.35 getrpcbynumber F
+GLIBC_2.35 getrpcbynumber_r F
+GLIBC_2.35 getrpcent F
+GLIBC_2.35 getrpcent_r F
+GLIBC_2.35 getrusage F
+GLIBC_2.35 gets F
+GLIBC_2.35 getservbyname F
+GLIBC_2.35 getservbyname_r F
+GLIBC_2.35 getservbyport F
+GLIBC_2.35 getservbyport_r F
+GLIBC_2.35 getservent F
+GLIBC_2.35 getservent_r F
+GLIBC_2.35 getsgent F
+GLIBC_2.35 getsgent_r F
+GLIBC_2.35 getsgnam F
+GLIBC_2.35 getsgnam_r F
+GLIBC_2.35 getsid F
+GLIBC_2.35 getsockname F
+GLIBC_2.35 getsockopt F
+GLIBC_2.35 getsourcefilter F
+GLIBC_2.35 getspent F
+GLIBC_2.35 getspent_r F
+GLIBC_2.35 getspnam F
+GLIBC_2.35 getspnam_r F
+GLIBC_2.35 getsubopt F
+GLIBC_2.35 gettext F
+GLIBC_2.35 gettid F
+GLIBC_2.35 gettimeofday F
+GLIBC_2.35 getttyent F
+GLIBC_2.35 getttynam F
+GLIBC_2.35 getuid F
+GLIBC_2.35 getusershell F
+GLIBC_2.35 getutent F
+GLIBC_2.35 getutent_r F
+GLIBC_2.35 getutid F
+GLIBC_2.35 getutid_r F
+GLIBC_2.35 getutline F
+GLIBC_2.35 getutline_r F
+GLIBC_2.35 getutmp F
+GLIBC_2.35 getutmpx F
+GLIBC_2.35 getutxent F
+GLIBC_2.35 getutxid F
+GLIBC_2.35 getutxline F
+GLIBC_2.35 getw F
+GLIBC_2.35 getwc F
+GLIBC_2.35 getwc_unlocked F
+GLIBC_2.35 getwchar F
+GLIBC_2.35 getwchar_unlocked F
+GLIBC_2.35 getwd F
+GLIBC_2.35 getxattr F
+GLIBC_2.35 glob F
+GLIBC_2.35 glob64 F
+GLIBC_2.35 glob_pattern_p F
+GLIBC_2.35 globfree F
+GLIBC_2.35 globfree64 F
+GLIBC_2.35 gmtime F
+GLIBC_2.35 gmtime_r F
+GLIBC_2.35 gnu_dev_major F
+GLIBC_2.35 gnu_dev_makedev F
+GLIBC_2.35 gnu_dev_minor F
+GLIBC_2.35 gnu_get_libc_release F
+GLIBC_2.35 gnu_get_libc_version F
+GLIBC_2.35 grantpt F
+GLIBC_2.35 group_member F
+GLIBC_2.35 gsignal F
+GLIBC_2.35 gtty F
+GLIBC_2.35 h_errlist D 0x14
+GLIBC_2.35 h_nerr D 0x4
+GLIBC_2.35 hasmntopt F
+GLIBC_2.35 hcreate F
+GLIBC_2.35 hcreate_r F
+GLIBC_2.35 hdestroy F
+GLIBC_2.35 hdestroy_r F
+GLIBC_2.35 herror F
+GLIBC_2.35 hsearch F
+GLIBC_2.35 hsearch_r F
+GLIBC_2.35 hstrerror F
+GLIBC_2.35 htonl F
+GLIBC_2.35 htons F
+GLIBC_2.35 iconv F
+GLIBC_2.35 iconv_close F
+GLIBC_2.35 iconv_open F
+GLIBC_2.35 if_freenameindex F
+GLIBC_2.35 if_indextoname F
+GLIBC_2.35 if_nameindex F
+GLIBC_2.35 if_nametoindex F
+GLIBC_2.35 imaxabs F
+GLIBC_2.35 imaxdiv F
+GLIBC_2.35 in6addr_any D 0x10
+GLIBC_2.35 in6addr_loopback D 0x10
+GLIBC_2.35 index F
+GLIBC_2.35 inet6_opt_append F
+GLIBC_2.35 inet6_opt_find F
+GLIBC_2.35 inet6_opt_finish F
+GLIBC_2.35 inet6_opt_get_val F
+GLIBC_2.35 inet6_opt_init F
+GLIBC_2.35 inet6_opt_next F
+GLIBC_2.35 inet6_opt_set_val F
+GLIBC_2.35 inet6_option_alloc F
+GLIBC_2.35 inet6_option_append F
+GLIBC_2.35 inet6_option_find F
+GLIBC_2.35 inet6_option_init F
+GLIBC_2.35 inet6_option_next F
+GLIBC_2.35 inet6_option_space F
+GLIBC_2.35 inet6_rth_add F
+GLIBC_2.35 inet6_rth_getaddr F
+GLIBC_2.35 inet6_rth_init F
+GLIBC_2.35 inet6_rth_reverse F
+GLIBC_2.35 inet6_rth_segments F
+GLIBC_2.35 inet6_rth_space F
+GLIBC_2.35 inet_addr F
+GLIBC_2.35 inet_aton F
+GLIBC_2.35 inet_lnaof F
+GLIBC_2.35 inet_makeaddr F
+GLIBC_2.35 inet_netof F
+GLIBC_2.35 inet_network F
+GLIBC_2.35 inet_nsap_addr F
+GLIBC_2.35 inet_nsap_ntoa F
+GLIBC_2.35 inet_ntoa F
+GLIBC_2.35 inet_ntop F
+GLIBC_2.35 inet_pton F
+GLIBC_2.35 init_module F
+GLIBC_2.35 initgroups F
+GLIBC_2.35 initstate F
+GLIBC_2.35 initstate_r F
+GLIBC_2.35 innetgr F
+GLIBC_2.35 inotify_add_watch F
+GLIBC_2.35 inotify_init F
+GLIBC_2.35 inotify_init1 F
+GLIBC_2.35 inotify_rm_watch F
+GLIBC_2.35 insque F
+GLIBC_2.35 ioctl F
+GLIBC_2.35 iruserok F
+GLIBC_2.35 iruserok_af F
+GLIBC_2.35 isalnum F
+GLIBC_2.35 isalnum_l F
+GLIBC_2.35 isalpha F
+GLIBC_2.35 isalpha_l F
+GLIBC_2.35 isascii F
+GLIBC_2.35 isatty F
+GLIBC_2.35 isblank F
+GLIBC_2.35 isblank_l F
+GLIBC_2.35 iscntrl F
+GLIBC_2.35 iscntrl_l F
+GLIBC_2.35 isctype F
+GLIBC_2.35 isdigit F
+GLIBC_2.35 isdigit_l F
+GLIBC_2.35 isfdtype F
+GLIBC_2.35 isgraph F
+GLIBC_2.35 isgraph_l F
+GLIBC_2.35 isinf F
+GLIBC_2.35 isinff F
+GLIBC_2.35 isinfl F
+GLIBC_2.35 islower F
+GLIBC_2.35 islower_l F
+GLIBC_2.35 isnan F
+GLIBC_2.35 isnanf F
+GLIBC_2.35 isnanl F
+GLIBC_2.35 isprint F
+GLIBC_2.35 isprint_l F
+GLIBC_2.35 ispunct F
+GLIBC_2.35 ispunct_l F
+GLIBC_2.35 isspace F
+GLIBC_2.35 isspace_l F
+GLIBC_2.35 isupper F
+GLIBC_2.35 isupper_l F
+GLIBC_2.35 iswalnum F
+GLIBC_2.35 iswalnum_l F
+GLIBC_2.35 iswalpha F
+GLIBC_2.35 iswalpha_l F
+GLIBC_2.35 iswblank F
+GLIBC_2.35 iswblank_l F
+GLIBC_2.35 iswcntrl F
+GLIBC_2.35 iswcntrl_l F
+GLIBC_2.35 iswctype F
+GLIBC_2.35 iswctype_l F
+GLIBC_2.35 iswdigit F
+GLIBC_2.35 iswdigit_l F
+GLIBC_2.35 iswgraph F
+GLIBC_2.35 iswgraph_l F
+GLIBC_2.35 iswlower F
+GLIBC_2.35 iswlower_l F
+GLIBC_2.35 iswprint F
+GLIBC_2.35 iswprint_l F
+GLIBC_2.35 iswpunct F
+GLIBC_2.35 iswpunct_l F
+GLIBC_2.35 iswspace F
+GLIBC_2.35 iswspace_l F
+GLIBC_2.35 iswupper F
+GLIBC_2.35 iswupper_l F
+GLIBC_2.35 iswxdigit F
+GLIBC_2.35 iswxdigit_l F
+GLIBC_2.35 isxdigit F
+GLIBC_2.35 isxdigit_l F
+GLIBC_2.35 jrand48 F
+GLIBC_2.35 jrand48_r F
+GLIBC_2.35 kill F
+GLIBC_2.35 killpg F
+GLIBC_2.35 klogctl F
+GLIBC_2.35 l64a F
+GLIBC_2.35 labs F
+GLIBC_2.35 lchmod F
+GLIBC_2.35 lchown F
+GLIBC_2.35 lckpwdf F
+GLIBC_2.35 lcong48 F
+GLIBC_2.35 lcong48_r F
+GLIBC_2.35 ldexp F
+GLIBC_2.35 ldexpf F
+GLIBC_2.35 ldexpl F
+GLIBC_2.35 ldiv F
+GLIBC_2.35 lfind F
+GLIBC_2.35 lgetxattr F
+GLIBC_2.35 link F
+GLIBC_2.35 linkat F
+GLIBC_2.35 lio_listio F
+GLIBC_2.35 lio_listio64 F
+GLIBC_2.35 listen F
+GLIBC_2.35 listxattr F
+GLIBC_2.35 llabs F
+GLIBC_2.35 lldiv F
+GLIBC_2.35 llistxattr F
+GLIBC_2.35 localeconv F
+GLIBC_2.35 localtime F
+GLIBC_2.35 localtime_r F
+GLIBC_2.35 lockf F
+GLIBC_2.35 lockf64 F
+GLIBC_2.35 login F
+GLIBC_2.35 login_tty F
+GLIBC_2.35 logout F
+GLIBC_2.35 logwtmp F
+GLIBC_2.35 longjmp F
+GLIBC_2.35 lrand48 F
+GLIBC_2.35 lrand48_r F
+GLIBC_2.35 lremovexattr F
+GLIBC_2.35 lsearch F
+GLIBC_2.35 lseek F
+GLIBC_2.35 lseek64 F
+GLIBC_2.35 lsetxattr F
+GLIBC_2.35 lstat F
+GLIBC_2.35 lstat64 F
+GLIBC_2.35 lutimes F
+GLIBC_2.35 madvise F
+GLIBC_2.35 makecontext F
+GLIBC_2.35 mallinfo F
+GLIBC_2.35 mallinfo2 F
+GLIBC_2.35 malloc F
+GLIBC_2.35 malloc_info F
+GLIBC_2.35 malloc_stats F
+GLIBC_2.35 malloc_trim F
+GLIBC_2.35 malloc_usable_size F
+GLIBC_2.35 mallopt F
+GLIBC_2.35 mblen F
+GLIBC_2.35 mbrlen F
+GLIBC_2.35 mbrtoc16 F
+GLIBC_2.35 mbrtoc32 F
+GLIBC_2.35 mbrtowc F
+GLIBC_2.35 mbsinit F
+GLIBC_2.35 mbsnrtowcs F
+GLIBC_2.35 mbsrtowcs F
+GLIBC_2.35 mbstowcs F
+GLIBC_2.35 mbtowc F
+GLIBC_2.35 mcheck F
+GLIBC_2.35 mcheck_check_all F
+GLIBC_2.35 mcheck_pedantic F
+GLIBC_2.35 memalign F
+GLIBC_2.35 memccpy F
+GLIBC_2.35 memchr F
+GLIBC_2.35 memcmp F
+GLIBC_2.35 memcpy F
+GLIBC_2.35 memfd_create F
+GLIBC_2.35 memfrob F
+GLIBC_2.35 memmem F
+GLIBC_2.35 memmove F
+GLIBC_2.35 mempcpy F
+GLIBC_2.35 memrchr F
+GLIBC_2.35 memset F
+GLIBC_2.35 mincore F
+GLIBC_2.35 mkdir F
+GLIBC_2.35 mkdirat F
+GLIBC_2.35 mkdtemp F
+GLIBC_2.35 mkfifo F
+GLIBC_2.35 mkfifoat F
+GLIBC_2.35 mknod F
+GLIBC_2.35 mknodat F
+GLIBC_2.35 mkostemp F
+GLIBC_2.35 mkostemp64 F
+GLIBC_2.35 mkostemps F
+GLIBC_2.35 mkostemps64 F
+GLIBC_2.35 mkstemp F
+GLIBC_2.35 mkstemp64 F
+GLIBC_2.35 mkstemps F
+GLIBC_2.35 mkstemps64 F
+GLIBC_2.35 mktemp F
+GLIBC_2.35 mktime F
+GLIBC_2.35 mlock F
+GLIBC_2.35 mlock2 F
+GLIBC_2.35 mlockall F
+GLIBC_2.35 mmap F
+GLIBC_2.35 mmap64 F
+GLIBC_2.35 modf F
+GLIBC_2.35 modff F
+GLIBC_2.35 modfl F
+GLIBC_2.35 moncontrol F
+GLIBC_2.35 monstartup F
+GLIBC_2.35 mount F
+GLIBC_2.35 mprobe F
+GLIBC_2.35 mprotect F
+GLIBC_2.35 mq_close F
+GLIBC_2.35 mq_getattr F
+GLIBC_2.35 mq_notify F
+GLIBC_2.35 mq_open F
+GLIBC_2.35 mq_receive F
+GLIBC_2.35 mq_send F
+GLIBC_2.35 mq_setattr F
+GLIBC_2.35 mq_timedreceive F
+GLIBC_2.35 mq_timedsend F
+GLIBC_2.35 mq_unlink F
+GLIBC_2.35 mrand48 F
+GLIBC_2.35 mrand48_r F
+GLIBC_2.35 mremap F
+GLIBC_2.35 msgctl F
+GLIBC_2.35 msgget F
+GLIBC_2.35 msgrcv F
+GLIBC_2.35 msgsnd F
+GLIBC_2.35 msync F
+GLIBC_2.35 mtrace F
+GLIBC_2.35 mtx_destroy F
+GLIBC_2.35 mtx_init F
+GLIBC_2.35 mtx_lock F
+GLIBC_2.35 mtx_timedlock F
+GLIBC_2.35 mtx_trylock F
+GLIBC_2.35 mtx_unlock F
+GLIBC_2.35 munlock F
+GLIBC_2.35 munlockall F
+GLIBC_2.35 munmap F
+GLIBC_2.35 muntrace F
+GLIBC_2.35 name_to_handle_at F
+GLIBC_2.35 nanosleep F
+GLIBC_2.35 newlocale F
+GLIBC_2.35 nftw F
+GLIBC_2.35 nftw64 F
+GLIBC_2.35 ngettext F
+GLIBC_2.35 nice F
+GLIBC_2.35 nl_langinfo F
+GLIBC_2.35 nl_langinfo_l F
+GLIBC_2.35 nrand48 F
+GLIBC_2.35 nrand48_r F
+GLIBC_2.35 ns_name_compress F
+GLIBC_2.35 ns_name_ntop F
+GLIBC_2.35 ns_name_pack F
+GLIBC_2.35 ns_name_pton F
+GLIBC_2.35 ns_name_skip F
+GLIBC_2.35 ns_name_uncompress F
+GLIBC_2.35 ns_name_unpack F
+GLIBC_2.35 ntohl F
+GLIBC_2.35 ntohs F
+GLIBC_2.35 ntp_adjtime F
+GLIBC_2.35 ntp_gettime F
+GLIBC_2.35 ntp_gettimex F
+GLIBC_2.35 obstack_alloc_failed_handler D 0x4
+GLIBC_2.35 obstack_exit_failure D 0x4
+GLIBC_2.35 obstack_free F
+GLIBC_2.35 obstack_printf F
+GLIBC_2.35 obstack_vprintf F
+GLIBC_2.35 on_exit F
+GLIBC_2.35 open F
+GLIBC_2.35 open64 F
+GLIBC_2.35 open_by_handle_at F
+GLIBC_2.35 open_memstream F
+GLIBC_2.35 open_wmemstream F
+GLIBC_2.35 openat F
+GLIBC_2.35 openat64 F
+GLIBC_2.35 opendir F
+GLIBC_2.35 openlog F
+GLIBC_2.35 openpty F
+GLIBC_2.35 optarg D 0x4
+GLIBC_2.35 opterr D 0x4
+GLIBC_2.35 optind D 0x4
+GLIBC_2.35 optopt D 0x4
+GLIBC_2.35 parse_printf_format F
+GLIBC_2.35 pathconf F
+GLIBC_2.35 pause F
+GLIBC_2.35 pclose F
+GLIBC_2.35 perror F
+GLIBC_2.35 personality F
+GLIBC_2.35 pipe F
+GLIBC_2.35 pipe2 F
+GLIBC_2.35 pivot_root F
+GLIBC_2.35 pkey_alloc F
+GLIBC_2.35 pkey_free F
+GLIBC_2.35 pkey_get F
+GLIBC_2.35 pkey_mprotect F
+GLIBC_2.35 pkey_set F
+GLIBC_2.35 poll F
+GLIBC_2.35 popen F
+GLIBC_2.35 posix_fadvise F
+GLIBC_2.35 posix_fadvise64 F
+GLIBC_2.35 posix_fallocate F
+GLIBC_2.35 posix_fallocate64 F
+GLIBC_2.35 posix_madvise F
+GLIBC_2.35 posix_memalign F
+GLIBC_2.35 posix_openpt F
+GLIBC_2.35 posix_spawn F
+GLIBC_2.35 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.35 posix_spawn_file_actions_addclose F
+GLIBC_2.35 posix_spawn_file_actions_addclosefrom_np F
+GLIBC_2.35 posix_spawn_file_actions_adddup2 F
+GLIBC_2.35 posix_spawn_file_actions_addfchdir_np F
+GLIBC_2.35 posix_spawn_file_actions_addopen F
+GLIBC_2.35 posix_spawn_file_actions_destroy F
+GLIBC_2.35 posix_spawn_file_actions_init F
+GLIBC_2.35 posix_spawnattr_destroy F
+GLIBC_2.35 posix_spawnattr_getflags F
+GLIBC_2.35 posix_spawnattr_getpgroup F
+GLIBC_2.35 posix_spawnattr_getschedparam F
+GLIBC_2.35 posix_spawnattr_getschedpolicy F
+GLIBC_2.35 posix_spawnattr_getsigdefault F
+GLIBC_2.35 posix_spawnattr_getsigmask F
+GLIBC_2.35 posix_spawnattr_init F
+GLIBC_2.35 posix_spawnattr_setflags F
+GLIBC_2.35 posix_spawnattr_setpgroup F
+GLIBC_2.35 posix_spawnattr_setschedparam F
+GLIBC_2.35 posix_spawnattr_setschedpolicy F
+GLIBC_2.35 posix_spawnattr_setsigdefault F
+GLIBC_2.35 posix_spawnattr_setsigmask F
+GLIBC_2.35 posix_spawnp F
+GLIBC_2.35 ppoll F
+GLIBC_2.35 prctl F
+GLIBC_2.35 pread F
+GLIBC_2.35 pread64 F
+GLIBC_2.35 preadv F
+GLIBC_2.35 preadv2 F
+GLIBC_2.35 preadv64 F
+GLIBC_2.35 preadv64v2 F
+GLIBC_2.35 printf F
+GLIBC_2.35 printf_size F
+GLIBC_2.35 printf_size_info F
+GLIBC_2.35 prlimit F
+GLIBC_2.35 prlimit64 F
+GLIBC_2.35 process_vm_readv F
+GLIBC_2.35 process_vm_writev F
+GLIBC_2.35 profil F
+GLIBC_2.35 program_invocation_name D 0x4
+GLIBC_2.35 program_invocation_short_name D 0x4
+GLIBC_2.35 pselect F
+GLIBC_2.35 psiginfo F
+GLIBC_2.35 psignal F
+GLIBC_2.35 pthread_attr_destroy F
+GLIBC_2.35 pthread_attr_getaffinity_np F
+GLIBC_2.35 pthread_attr_getdetachstate F
+GLIBC_2.35 pthread_attr_getguardsize F
+GLIBC_2.35 pthread_attr_getinheritsched F
+GLIBC_2.35 pthread_attr_getschedparam F
+GLIBC_2.35 pthread_attr_getschedpolicy F
+GLIBC_2.35 pthread_attr_getscope F
+GLIBC_2.35 pthread_attr_getsigmask_np F
+GLIBC_2.35 pthread_attr_getstack F
+GLIBC_2.35 pthread_attr_getstackaddr F
+GLIBC_2.35 pthread_attr_getstacksize F
+GLIBC_2.35 pthread_attr_init F
+GLIBC_2.35 pthread_attr_setaffinity_np F
+GLIBC_2.35 pthread_attr_setdetachstate F
+GLIBC_2.35 pthread_attr_setguardsize F
+GLIBC_2.35 pthread_attr_setinheritsched F
+GLIBC_2.35 pthread_attr_setschedparam F
+GLIBC_2.35 pthread_attr_setschedpolicy F
+GLIBC_2.35 pthread_attr_setscope F
+GLIBC_2.35 pthread_attr_setsigmask_np F
+GLIBC_2.35 pthread_attr_setstack F
+GLIBC_2.35 pthread_attr_setstackaddr F
+GLIBC_2.35 pthread_attr_setstacksize F
+GLIBC_2.35 pthread_barrier_destroy F
+GLIBC_2.35 pthread_barrier_init F
+GLIBC_2.35 pthread_barrier_wait F
+GLIBC_2.35 pthread_barrierattr_destroy F
+GLIBC_2.35 pthread_barrierattr_getpshared F
+GLIBC_2.35 pthread_barrierattr_init F
+GLIBC_2.35 pthread_barrierattr_setpshared F
+GLIBC_2.35 pthread_cancel F
+GLIBC_2.35 pthread_clockjoin_np F
+GLIBC_2.35 pthread_cond_broadcast F
+GLIBC_2.35 pthread_cond_clockwait F
+GLIBC_2.35 pthread_cond_destroy F
+GLIBC_2.35 pthread_cond_init F
+GLIBC_2.35 pthread_cond_signal F
+GLIBC_2.35 pthread_cond_timedwait F
+GLIBC_2.35 pthread_cond_wait F
+GLIBC_2.35 pthread_condattr_destroy F
+GLIBC_2.35 pthread_condattr_getclock F
+GLIBC_2.35 pthread_condattr_getpshared F
+GLIBC_2.35 pthread_condattr_init F
+GLIBC_2.35 pthread_condattr_setclock F
+GLIBC_2.35 pthread_condattr_setpshared F
+GLIBC_2.35 pthread_create F
+GLIBC_2.35 pthread_detach F
+GLIBC_2.35 pthread_equal F
+GLIBC_2.35 pthread_exit F
+GLIBC_2.35 pthread_getaffinity_np F
+GLIBC_2.35 pthread_getattr_default_np F
+GLIBC_2.35 pthread_getattr_np F
+GLIBC_2.35 pthread_getconcurrency F
+GLIBC_2.35 pthread_getcpuclockid F
+GLIBC_2.35 pthread_getname_np F
+GLIBC_2.35 pthread_getschedparam F
+GLIBC_2.35 pthread_getspecific F
+GLIBC_2.35 pthread_join F
+GLIBC_2.35 pthread_key_create F
+GLIBC_2.35 pthread_key_delete F
+GLIBC_2.35 pthread_kill F
+GLIBC_2.35 pthread_mutex_clocklock F
+GLIBC_2.35 pthread_mutex_consistent F
+GLIBC_2.35 pthread_mutex_destroy F
+GLIBC_2.35 pthread_mutex_getprioceiling F
+GLIBC_2.35 pthread_mutex_init F
+GLIBC_2.35 pthread_mutex_lock F
+GLIBC_2.35 pthread_mutex_setprioceiling F
+GLIBC_2.35 pthread_mutex_timedlock F
+GLIBC_2.35 pthread_mutex_trylock F
+GLIBC_2.35 pthread_mutex_unlock F
+GLIBC_2.35 pthread_mutexattr_destroy F
+GLIBC_2.35 pthread_mutexattr_getprioceiling F
+GLIBC_2.35 pthread_mutexattr_getprotocol F
+GLIBC_2.35 pthread_mutexattr_getpshared F
+GLIBC_2.35 pthread_mutexattr_getrobust F
+GLIBC_2.35 pthread_mutexattr_gettype F
+GLIBC_2.35 pthread_mutexattr_init F
+GLIBC_2.35 pthread_mutexattr_setprioceiling F
+GLIBC_2.35 pthread_mutexattr_setprotocol F
+GLIBC_2.35 pthread_mutexattr_setpshared F
+GLIBC_2.35 pthread_mutexattr_setrobust F
+GLIBC_2.35 pthread_mutexattr_settype F
+GLIBC_2.35 pthread_once F
+GLIBC_2.35 pthread_rwlock_clockrdlock F
+GLIBC_2.35 pthread_rwlock_clockwrlock F
+GLIBC_2.35 pthread_rwlock_destroy F
+GLIBC_2.35 pthread_rwlock_init F
+GLIBC_2.35 pthread_rwlock_rdlock F
+GLIBC_2.35 pthread_rwlock_timedrdlock F
+GLIBC_2.35 pthread_rwlock_timedwrlock F
+GLIBC_2.35 pthread_rwlock_tryrdlock F
+GLIBC_2.35 pthread_rwlock_trywrlock F
+GLIBC_2.35 pthread_rwlock_unlock F
+GLIBC_2.35 pthread_rwlock_wrlock F
+GLIBC_2.35 pthread_rwlockattr_destroy F
+GLIBC_2.35 pthread_rwlockattr_getkind_np F
+GLIBC_2.35 pthread_rwlockattr_getpshared F
+GLIBC_2.35 pthread_rwlockattr_init F
+GLIBC_2.35 pthread_rwlockattr_setkind_np F
+GLIBC_2.35 pthread_rwlockattr_setpshared F
+GLIBC_2.35 pthread_self F
+GLIBC_2.35 pthread_setaffinity_np F
+GLIBC_2.35 pthread_setattr_default_np F
+GLIBC_2.35 pthread_setcancelstate F
+GLIBC_2.35 pthread_setcanceltype F
+GLIBC_2.35 pthread_setconcurrency F
+GLIBC_2.35 pthread_setname_np F
+GLIBC_2.35 pthread_setschedparam F
+GLIBC_2.35 pthread_setschedprio F
+GLIBC_2.35 pthread_setspecific F
+GLIBC_2.35 pthread_sigmask F
+GLIBC_2.35 pthread_sigqueue F
+GLIBC_2.35 pthread_spin_destroy F
+GLIBC_2.35 pthread_spin_init F
+GLIBC_2.35 pthread_spin_lock F
+GLIBC_2.35 pthread_spin_trylock F
+GLIBC_2.35 pthread_spin_unlock F
+GLIBC_2.35 pthread_testcancel F
+GLIBC_2.35 pthread_timedjoin_np F
+GLIBC_2.35 pthread_tryjoin_np F
+GLIBC_2.35 ptrace F
+GLIBC_2.35 ptsname F
+GLIBC_2.35 ptsname_r F
+GLIBC_2.35 putc F
+GLIBC_2.35 putc_unlocked F
+GLIBC_2.35 putchar F
+GLIBC_2.35 putchar_unlocked F
+GLIBC_2.35 putenv F
+GLIBC_2.35 putgrent F
+GLIBC_2.35 putpwent F
+GLIBC_2.35 puts F
+GLIBC_2.35 putsgent F
+GLIBC_2.35 putspent F
+GLIBC_2.35 pututline F
+GLIBC_2.35 pututxline F
+GLIBC_2.35 putw F
+GLIBC_2.35 putwc F
+GLIBC_2.35 putwc_unlocked F
+GLIBC_2.35 putwchar F
+GLIBC_2.35 putwchar_unlocked F
+GLIBC_2.35 pvalloc F
+GLIBC_2.35 pwrite F
+GLIBC_2.35 pwrite64 F
+GLIBC_2.35 pwritev F
+GLIBC_2.35 pwritev2 F
+GLIBC_2.35 pwritev64 F
+GLIBC_2.35 pwritev64v2 F
+GLIBC_2.35 qecvt F
+GLIBC_2.35 qecvt_r F
+GLIBC_2.35 qfcvt F
+GLIBC_2.35 qfcvt_r F
+GLIBC_2.35 qgcvt F
+GLIBC_2.35 qsort F
+GLIBC_2.35 qsort_r F
+GLIBC_2.35 quick_exit F
+GLIBC_2.35 quotactl F
+GLIBC_2.35 raise F
+GLIBC_2.35 rand F
+GLIBC_2.35 rand_r F
+GLIBC_2.35 random F
+GLIBC_2.35 random_r F
+GLIBC_2.35 rawmemchr F
+GLIBC_2.35 rcmd F
+GLIBC_2.35 rcmd_af F
+GLIBC_2.35 re_comp F
+GLIBC_2.35 re_compile_fastmap F
+GLIBC_2.35 re_compile_pattern F
+GLIBC_2.35 re_exec F
+GLIBC_2.35 re_match F
+GLIBC_2.35 re_match_2 F
+GLIBC_2.35 re_search F
+GLIBC_2.35 re_search_2 F
+GLIBC_2.35 re_set_registers F
+GLIBC_2.35 re_set_syntax F
+GLIBC_2.35 re_syntax_options D 0x4
+GLIBC_2.35 read F
+GLIBC_2.35 readahead F
+GLIBC_2.35 readdir F
+GLIBC_2.35 readdir64 F
+GLIBC_2.35 readdir64_r F
+GLIBC_2.35 readdir_r F
+GLIBC_2.35 readlink F
+GLIBC_2.35 readlinkat F
+GLIBC_2.35 readv F
+GLIBC_2.35 realloc F
+GLIBC_2.35 reallocarray F
+GLIBC_2.35 realpath F
+GLIBC_2.35 reboot F
+GLIBC_2.35 recv F
+GLIBC_2.35 recvfrom F
+GLIBC_2.35 recvmmsg F
+GLIBC_2.35 recvmsg F
+GLIBC_2.35 regcomp F
+GLIBC_2.35 regerror F
+GLIBC_2.35 regexec F
+GLIBC_2.35 regfree F
+GLIBC_2.35 register_printf_function F
+GLIBC_2.35 register_printf_modifier F
+GLIBC_2.35 register_printf_specifier F
+GLIBC_2.35 register_printf_type F
+GLIBC_2.35 remap_file_pages F
+GLIBC_2.35 remove F
+GLIBC_2.35 removexattr F
+GLIBC_2.35 remque F
+GLIBC_2.35 rename F
+GLIBC_2.35 renameat F
+GLIBC_2.35 renameat2 F
+GLIBC_2.35 res_dnok F
+GLIBC_2.35 res_hnok F
+GLIBC_2.35 res_mailok F
+GLIBC_2.35 res_mkquery F
+GLIBC_2.35 res_nmkquery F
+GLIBC_2.35 res_nquery F
+GLIBC_2.35 res_nquerydomain F
+GLIBC_2.35 res_nsearch F
+GLIBC_2.35 res_nsend F
+GLIBC_2.35 res_ownok F
+GLIBC_2.35 res_query F
+GLIBC_2.35 res_querydomain F
+GLIBC_2.35 res_search F
+GLIBC_2.35 res_send F
+GLIBC_2.35 revoke F
+GLIBC_2.35 rewind F
+GLIBC_2.35 rewinddir F
+GLIBC_2.35 rexec F
+GLIBC_2.35 rexec_af F
+GLIBC_2.35 rexecoptions D 0x4
+GLIBC_2.35 rindex F
+GLIBC_2.35 rmdir F
+GLIBC_2.35 rpmatch F
+GLIBC_2.35 rresvport F
+GLIBC_2.35 rresvport_af F
+GLIBC_2.35 ruserok F
+GLIBC_2.35 ruserok_af F
+GLIBC_2.35 ruserpass F
+GLIBC_2.35 sbrk F
+GLIBC_2.35 scalbn F
+GLIBC_2.35 scalbnf F
+GLIBC_2.35 scalbnl F
+GLIBC_2.35 scandir F
+GLIBC_2.35 scandir64 F
+GLIBC_2.35 scandirat F
+GLIBC_2.35 scandirat64 F
+GLIBC_2.35 scanf F
+GLIBC_2.35 sched_get_priority_max F
+GLIBC_2.35 sched_get_priority_min F
+GLIBC_2.35 sched_getaffinity F
+GLIBC_2.35 sched_getcpu F
+GLIBC_2.35 sched_getparam F
+GLIBC_2.35 sched_getscheduler F
+GLIBC_2.35 sched_rr_get_interval F
+GLIBC_2.35 sched_setaffinity F
+GLIBC_2.35 sched_setparam F
+GLIBC_2.35 sched_setscheduler F
+GLIBC_2.35 sched_yield F
+GLIBC_2.35 secure_getenv F
+GLIBC_2.35 seed48 F
+GLIBC_2.35 seed48_r F
+GLIBC_2.35 seekdir F
+GLIBC_2.35 select F
+GLIBC_2.35 sem_clockwait F
+GLIBC_2.35 sem_close F
+GLIBC_2.35 sem_destroy F
+GLIBC_2.35 sem_getvalue F
+GLIBC_2.35 sem_init F
+GLIBC_2.35 sem_open F
+GLIBC_2.35 sem_post F
+GLIBC_2.35 sem_timedwait F
+GLIBC_2.35 sem_trywait F
+GLIBC_2.35 sem_unlink F
+GLIBC_2.35 sem_wait F
+GLIBC_2.35 semctl F
+GLIBC_2.35 semget F
+GLIBC_2.35 semop F
+GLIBC_2.35 semtimedop F
+GLIBC_2.35 send F
+GLIBC_2.35 sendfile F
+GLIBC_2.35 sendfile64 F
+GLIBC_2.35 sendmmsg F
+GLIBC_2.35 sendmsg F
+GLIBC_2.35 sendto F
+GLIBC_2.35 setaliasent F
+GLIBC_2.35 setbuf F
+GLIBC_2.35 setbuffer F
+GLIBC_2.35 setcontext F
+GLIBC_2.35 setdomainname F
+GLIBC_2.35 setegid F
+GLIBC_2.35 setenv F
+GLIBC_2.35 seteuid F
+GLIBC_2.35 setfsent F
+GLIBC_2.35 setfsgid F
+GLIBC_2.35 setfsuid F
+GLIBC_2.35 setgid F
+GLIBC_2.35 setgrent F
+GLIBC_2.35 setgroups F
+GLIBC_2.35 sethostent F
+GLIBC_2.35 sethostid F
+GLIBC_2.35 sethostname F
+GLIBC_2.35 setipv4sourcefilter F
+GLIBC_2.35 setitimer F
+GLIBC_2.35 setjmp F
+GLIBC_2.35 setlinebuf F
+GLIBC_2.35 setlocale F
+GLIBC_2.35 setlogin F
+GLIBC_2.35 setlogmask F
+GLIBC_2.35 setmntent F
+GLIBC_2.35 setnetent F
+GLIBC_2.35 setnetgrent F
+GLIBC_2.35 setns F
+GLIBC_2.35 setpgid F
+GLIBC_2.35 setpgrp F
+GLIBC_2.35 setpriority F
+GLIBC_2.35 setprotoent F
+GLIBC_2.35 setpwent F
+GLIBC_2.35 setregid F
+GLIBC_2.35 setresgid F
+GLIBC_2.35 setresuid F
+GLIBC_2.35 setreuid F
+GLIBC_2.35 setrlimit F
+GLIBC_2.35 setrlimit64 F
+GLIBC_2.35 setrpcent F
+GLIBC_2.35 setservent F
+GLIBC_2.35 setsgent F
+GLIBC_2.35 setsid F
+GLIBC_2.35 setsockopt F
+GLIBC_2.35 setsourcefilter F
+GLIBC_2.35 setspent F
+GLIBC_2.35 setstate F
+GLIBC_2.35 setstate_r F
+GLIBC_2.35 settimeofday F
+GLIBC_2.35 setttyent F
+GLIBC_2.35 setuid F
+GLIBC_2.35 setusershell F
+GLIBC_2.35 setutent F
+GLIBC_2.35 setutxent F
+GLIBC_2.35 setvbuf F
+GLIBC_2.35 setxattr F
+GLIBC_2.35 sgetsgent F
+GLIBC_2.35 sgetsgent_r F
+GLIBC_2.35 sgetspent F
+GLIBC_2.35 sgetspent_r F
+GLIBC_2.35 shm_open F
+GLIBC_2.35 shm_unlink F
+GLIBC_2.35 shmat F
+GLIBC_2.35 shmctl F
+GLIBC_2.35 shmdt F
+GLIBC_2.35 shmget F
+GLIBC_2.35 shutdown F
+GLIBC_2.35 sigabbrev_np F
+GLIBC_2.35 sigaction F
+GLIBC_2.35 sigaddset F
+GLIBC_2.35 sigaltstack F
+GLIBC_2.35 sigandset F
+GLIBC_2.35 sigblock F
+GLIBC_2.35 sigdelset F
+GLIBC_2.35 sigdescr_np F
+GLIBC_2.35 sigemptyset F
+GLIBC_2.35 sigfillset F
+GLIBC_2.35 siggetmask F
+GLIBC_2.35 sighold F
+GLIBC_2.35 sigignore F
+GLIBC_2.35 siginterrupt F
+GLIBC_2.35 sigisemptyset F
+GLIBC_2.35 sigismember F
+GLIBC_2.35 siglongjmp F
+GLIBC_2.35 signal F
+GLIBC_2.35 signalfd F
+GLIBC_2.35 sigorset F
+GLIBC_2.35 sigpause F
+GLIBC_2.35 sigpending F
+GLIBC_2.35 sigprocmask F
+GLIBC_2.35 sigqueue F
+GLIBC_2.35 sigrelse F
+GLIBC_2.35 sigreturn F
+GLIBC_2.35 sigset F
+GLIBC_2.35 sigsetmask F
+GLIBC_2.35 sigstack F
+GLIBC_2.35 sigsuspend F
+GLIBC_2.35 sigtimedwait F
+GLIBC_2.35 sigwait F
+GLIBC_2.35 sigwaitinfo F
+GLIBC_2.35 sleep F
+GLIBC_2.35 snprintf F
+GLIBC_2.35 sockatmark F
+GLIBC_2.35 socket F
+GLIBC_2.35 socketpair F
+GLIBC_2.35 splice F
+GLIBC_2.35 sprintf F
+GLIBC_2.35 sprofil F
+GLIBC_2.35 srand F
+GLIBC_2.35 srand48 F
+GLIBC_2.35 srand48_r F
+GLIBC_2.35 srandom F
+GLIBC_2.35 srandom_r F
+GLIBC_2.35 sscanf F
+GLIBC_2.35 ssignal F
+GLIBC_2.35 stat F
+GLIBC_2.35 stat64 F
+GLIBC_2.35 statfs F
+GLIBC_2.35 statfs64 F
+GLIBC_2.35 statvfs F
+GLIBC_2.35 statvfs64 F
+GLIBC_2.35 statx F
+GLIBC_2.35 stderr D 0x4
+GLIBC_2.35 stdin D 0x4
+GLIBC_2.35 stdout D 0x4
+GLIBC_2.35 stpcpy F
+GLIBC_2.35 stpncpy F
+GLIBC_2.35 strcasecmp F
+GLIBC_2.35 strcasecmp_l F
+GLIBC_2.35 strcasestr F
+GLIBC_2.35 strcat F
+GLIBC_2.35 strchr F
+GLIBC_2.35 strchrnul F
+GLIBC_2.35 strcmp F
+GLIBC_2.35 strcoll F
+GLIBC_2.35 strcoll_l F
+GLIBC_2.35 strcpy F
+GLIBC_2.35 strcspn F
+GLIBC_2.35 strdup F
+GLIBC_2.35 strerror F
+GLIBC_2.35 strerror_l F
+GLIBC_2.35 strerror_r F
+GLIBC_2.35 strerrordesc_np F
+GLIBC_2.35 strerrorname_np F
+GLIBC_2.35 strfmon F
+GLIBC_2.35 strfmon_l F
+GLIBC_2.35 strfromd F
+GLIBC_2.35 strfromf F
+GLIBC_2.35 strfromf32 F
+GLIBC_2.35 strfromf32x F
+GLIBC_2.35 strfromf64 F
+GLIBC_2.35 strfroml F
+GLIBC_2.35 strfry F
+GLIBC_2.35 strftime F
+GLIBC_2.35 strftime_l F
+GLIBC_2.35 strlen F
+GLIBC_2.35 strncasecmp F
+GLIBC_2.35 strncasecmp_l F
+GLIBC_2.35 strncat F
+GLIBC_2.35 strncmp F
+GLIBC_2.35 strncpy F
+GLIBC_2.35 strndup F
+GLIBC_2.35 strnlen F
+GLIBC_2.35 strpbrk F
+GLIBC_2.35 strptime F
+GLIBC_2.35 strptime_l F
+GLIBC_2.35 strrchr F
+GLIBC_2.35 strsep F
+GLIBC_2.35 strsignal F
+GLIBC_2.35 strspn F
+GLIBC_2.35 strstr F
+GLIBC_2.35 strtod F
+GLIBC_2.35 strtod_l F
+GLIBC_2.35 strtof F
+GLIBC_2.35 strtof32 F
+GLIBC_2.35 strtof32_l F
+GLIBC_2.35 strtof32x F
+GLIBC_2.35 strtof32x_l F
+GLIBC_2.35 strtof64 F
+GLIBC_2.35 strtof64_l F
+GLIBC_2.35 strtof_l F
+GLIBC_2.35 strtoimax F
+GLIBC_2.35 strtok F
+GLIBC_2.35 strtok_r F
+GLIBC_2.35 strtol F
+GLIBC_2.35 strtol_l F
+GLIBC_2.35 strtold F
+GLIBC_2.35 strtold_l F
+GLIBC_2.35 strtoll F
+GLIBC_2.35 strtoll_l F
+GLIBC_2.35 strtoq F
+GLIBC_2.35 strtoul F
+GLIBC_2.35 strtoul_l F
+GLIBC_2.35 strtoull F
+GLIBC_2.35 strtoull_l F
+GLIBC_2.35 strtoumax F
+GLIBC_2.35 strtouq F
+GLIBC_2.35 strverscmp F
+GLIBC_2.35 strxfrm F
+GLIBC_2.35 strxfrm_l F
+GLIBC_2.35 stty F
+GLIBC_2.35 swab F
+GLIBC_2.35 swapcontext F
+GLIBC_2.35 swapoff F
+GLIBC_2.35 swapon F
+GLIBC_2.35 swprintf F
+GLIBC_2.35 swscanf F
+GLIBC_2.35 symlink F
+GLIBC_2.35 symlinkat F
+GLIBC_2.35 sync F
+GLIBC_2.35 sync_file_range F
+GLIBC_2.35 syncfs F
+GLIBC_2.35 syscall F
+GLIBC_2.35 sysconf F
+GLIBC_2.35 sysinfo F
+GLIBC_2.35 syslog F
+GLIBC_2.35 system F
+GLIBC_2.35 sysv_signal F
+GLIBC_2.35 tcdrain F
+GLIBC_2.35 tcflow F
+GLIBC_2.35 tcflush F
+GLIBC_2.35 tcgetattr F
+GLIBC_2.35 tcgetpgrp F
+GLIBC_2.35 tcgetsid F
+GLIBC_2.35 tcsendbreak F
+GLIBC_2.35 tcsetattr F
+GLIBC_2.35 tcsetpgrp F
+GLIBC_2.35 tdelete F
+GLIBC_2.35 tdestroy F
+GLIBC_2.35 tee F
+GLIBC_2.35 telldir F
+GLIBC_2.35 tempnam F
+GLIBC_2.35 textdomain F
+GLIBC_2.35 tfind F
+GLIBC_2.35 tgkill F
+GLIBC_2.35 thrd_create F
+GLIBC_2.35 thrd_current F
+GLIBC_2.35 thrd_detach F
+GLIBC_2.35 thrd_equal F
+GLIBC_2.35 thrd_exit F
+GLIBC_2.35 thrd_join F
+GLIBC_2.35 thrd_sleep F
+GLIBC_2.35 thrd_yield F
+GLIBC_2.35 time F
+GLIBC_2.35 timegm F
+GLIBC_2.35 timelocal F
+GLIBC_2.35 timer_create F
+GLIBC_2.35 timer_delete F
+GLIBC_2.35 timer_getoverrun F
+GLIBC_2.35 timer_gettime F
+GLIBC_2.35 timer_settime F
+GLIBC_2.35 timerfd_create F
+GLIBC_2.35 timerfd_gettime F
+GLIBC_2.35 timerfd_settime F
+GLIBC_2.35 times F
+GLIBC_2.35 timespec_get F
+GLIBC_2.35 timespec_getres F
+GLIBC_2.35 timezone D 0x4
+GLIBC_2.35 tmpfile F
+GLIBC_2.35 tmpfile64 F
+GLIBC_2.35 tmpnam F
+GLIBC_2.35 tmpnam_r F
+GLIBC_2.35 toascii F
+GLIBC_2.35 tolower F
+GLIBC_2.35 tolower_l F
+GLIBC_2.35 toupper F
+GLIBC_2.35 toupper_l F
+GLIBC_2.35 towctrans F
+GLIBC_2.35 towctrans_l F
+GLIBC_2.35 towlower F
+GLIBC_2.35 towlower_l F
+GLIBC_2.35 towupper F
+GLIBC_2.35 towupper_l F
+GLIBC_2.35 truncate F
+GLIBC_2.35 truncate64 F
+GLIBC_2.35 tsearch F
+GLIBC_2.35 tss_create F
+GLIBC_2.35 tss_delete F
+GLIBC_2.35 tss_get F
+GLIBC_2.35 tss_set F
+GLIBC_2.35 ttyname F
+GLIBC_2.35 ttyname_r F
+GLIBC_2.35 ttyslot F
+GLIBC_2.35 twalk F
+GLIBC_2.35 twalk_r F
+GLIBC_2.35 tzname D 0x8
+GLIBC_2.35 tzset F
+GLIBC_2.35 ualarm F
+GLIBC_2.35 ulckpwdf F
+GLIBC_2.35 ulimit F
+GLIBC_2.35 umask F
+GLIBC_2.35 umount F
+GLIBC_2.35 umount2 F
+GLIBC_2.35 uname F
+GLIBC_2.35 ungetc F
+GLIBC_2.35 ungetwc F
+GLIBC_2.35 unlink F
+GLIBC_2.35 unlinkat F
+GLIBC_2.35 unlockpt F
+GLIBC_2.35 unsetenv F
+GLIBC_2.35 unshare F
+GLIBC_2.35 updwtmp F
+GLIBC_2.35 updwtmpx F
+GLIBC_2.35 uselocale F
+GLIBC_2.35 usleep F
+GLIBC_2.35 utime F
+GLIBC_2.35 utimensat F
+GLIBC_2.35 utimes F
+GLIBC_2.35 utmpname F
+GLIBC_2.35 utmpxname F
+GLIBC_2.35 valloc F
+GLIBC_2.35 vasprintf F
+GLIBC_2.35 vdprintf F
+GLIBC_2.35 verr F
+GLIBC_2.35 verrx F
+GLIBC_2.35 versionsort F
+GLIBC_2.35 versionsort64 F
+GLIBC_2.35 vfork F
+GLIBC_2.35 vfprintf F
+GLIBC_2.35 vfscanf F
+GLIBC_2.35 vfwprintf F
+GLIBC_2.35 vfwscanf F
+GLIBC_2.35 vhangup F
+GLIBC_2.35 vlimit F
+GLIBC_2.35 vmsplice F
+GLIBC_2.35 vprintf F
+GLIBC_2.35 vscanf F
+GLIBC_2.35 vsnprintf F
+GLIBC_2.35 vsprintf F
+GLIBC_2.35 vsscanf F
+GLIBC_2.35 vswprintf F
+GLIBC_2.35 vswscanf F
+GLIBC_2.35 vsyslog F
+GLIBC_2.35 vwarn F
+GLIBC_2.35 vwarnx F
+GLIBC_2.35 vwprintf F
+GLIBC_2.35 vwscanf F
+GLIBC_2.35 wait F
+GLIBC_2.35 wait3 F
+GLIBC_2.35 wait4 F
+GLIBC_2.35 waitid F
+GLIBC_2.35 waitpid F
+GLIBC_2.35 warn F
+GLIBC_2.35 warnx F
+GLIBC_2.35 wcpcpy F
+GLIBC_2.35 wcpncpy F
+GLIBC_2.35 wcrtomb F
+GLIBC_2.35 wcscasecmp F
+GLIBC_2.35 wcscasecmp_l F
+GLIBC_2.35 wcscat F
+GLIBC_2.35 wcschr F
+GLIBC_2.35 wcschrnul F
+GLIBC_2.35 wcscmp F
+GLIBC_2.35 wcscoll F
+GLIBC_2.35 wcscoll_l F
+GLIBC_2.35 wcscpy F
+GLIBC_2.35 wcscspn F
+GLIBC_2.35 wcsdup F
+GLIBC_2.35 wcsftime F
+GLIBC_2.35 wcsftime_l F
+GLIBC_2.35 wcslen F
+GLIBC_2.35 wcsncasecmp F
+GLIBC_2.35 wcsncasecmp_l F
+GLIBC_2.35 wcsncat F
+GLIBC_2.35 wcsncmp F
+GLIBC_2.35 wcsncpy F
+GLIBC_2.35 wcsnlen F
+GLIBC_2.35 wcsnrtombs F
+GLIBC_2.35 wcspbrk F
+GLIBC_2.35 wcsrchr F
+GLIBC_2.35 wcsrtombs F
+GLIBC_2.35 wcsspn F
+GLIBC_2.35 wcsstr F
+GLIBC_2.35 wcstod F
+GLIBC_2.35 wcstod_l F
+GLIBC_2.35 wcstof F
+GLIBC_2.35 wcstof32 F
+GLIBC_2.35 wcstof32_l F
+GLIBC_2.35 wcstof32x F
+GLIBC_2.35 wcstof32x_l F
+GLIBC_2.35 wcstof64 F
+GLIBC_2.35 wcstof64_l F
+GLIBC_2.35 wcstof_l F
+GLIBC_2.35 wcstoimax F
+GLIBC_2.35 wcstok F
+GLIBC_2.35 wcstol F
+GLIBC_2.35 wcstol_l F
+GLIBC_2.35 wcstold F
+GLIBC_2.35 wcstold_l F
+GLIBC_2.35 wcstoll F
+GLIBC_2.35 wcstoll_l F
+GLIBC_2.35 wcstombs F
+GLIBC_2.35 wcstoq F
+GLIBC_2.35 wcstoul F
+GLIBC_2.35 wcstoul_l F
+GLIBC_2.35 wcstoull F
+GLIBC_2.35 wcstoull_l F
+GLIBC_2.35 wcstoumax F
+GLIBC_2.35 wcstouq F
+GLIBC_2.35 wcswcs F
+GLIBC_2.35 wcswidth F
+GLIBC_2.35 wcsxfrm F
+GLIBC_2.35 wcsxfrm_l F
+GLIBC_2.35 wctob F
+GLIBC_2.35 wctomb F
+GLIBC_2.35 wctrans F
+GLIBC_2.35 wctrans_l F
+GLIBC_2.35 wctype F
+GLIBC_2.35 wctype_l F
+GLIBC_2.35 wcwidth F
+GLIBC_2.35 wmemchr F
+GLIBC_2.35 wmemcmp F
+GLIBC_2.35 wmemcpy F
+GLIBC_2.35 wmemmove F
+GLIBC_2.35 wmempcpy F
+GLIBC_2.35 wmemset F
+GLIBC_2.35 wordexp F
+GLIBC_2.35 wordfree F
+GLIBC_2.35 wprintf F
+GLIBC_2.35 write F
+GLIBC_2.35 writev F
+GLIBC_2.35 wscanf F
diff --git a/sysdeps/unix/sysv/linux/or1k/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/or1k/libc_malloc_debug.abilist
new file mode 100644
index 0000000000..0acf98fc6f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libc_malloc_debug.abilist
@@ -0,0 +1,26 @@
+GLIBC_2.35 __free_hook D 0x4
+GLIBC_2.35 __malloc_hook D 0x4
+GLIBC_2.35 __memalign_hook D 0x4
+GLIBC_2.35 __realloc_hook D 0x4
+GLIBC_2.35 aligned_alloc F
+GLIBC_2.35 calloc F
+GLIBC_2.35 free F
+GLIBC_2.35 mallinfo F
+GLIBC_2.35 mallinfo2 F
+GLIBC_2.35 malloc F
+GLIBC_2.35 malloc_info F
+GLIBC_2.35 malloc_stats F
+GLIBC_2.35 malloc_trim F
+GLIBC_2.35 malloc_usable_size F
+GLIBC_2.35 mallopt F
+GLIBC_2.35 mcheck F
+GLIBC_2.35 mcheck_check_all F
+GLIBC_2.35 mcheck_pedantic F
+GLIBC_2.35 memalign F
+GLIBC_2.35 mprobe F
+GLIBC_2.35 mtrace F
+GLIBC_2.35 muntrace F
+GLIBC_2.35 posix_memalign F
+GLIBC_2.35 pvalloc F
+GLIBC_2.35 realloc F
+GLIBC_2.35 valloc F
diff --git a/sysdeps/unix/sysv/linux/or1k/libcrypt.abilist b/sysdeps/unix/sysv/linux/or1k/libcrypt.abilist
new file mode 100644
index 0000000000..fc9c3d5428
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libcrypt.abilist
@@ -0,0 +1,2 @@
+GLIBC_2.35 crypt F
+GLIBC_2.35 crypt_r F
diff --git a/sysdeps/unix/sysv/linux/or1k/libdl.abilist b/sysdeps/unix/sysv/linux/or1k/libdl.abilist
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/sysdeps/unix/sysv/linux/or1k/libm.abilist b/sysdeps/unix/sysv/linux/or1k/libm.abilist
new file mode 100644
index 0000000000..9d26508ff5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libm.abilist
@@ -0,0 +1,759 @@
+GLIBC_2.35 __clog10 F
+GLIBC_2.35 __clog10f F
+GLIBC_2.35 __clog10l F
+GLIBC_2.35 __finite F
+GLIBC_2.35 __finitef F
+GLIBC_2.35 __fpclassify F
+GLIBC_2.35 __fpclassifyf F
+GLIBC_2.35 __iseqsig F
+GLIBC_2.35 __iseqsigf F
+GLIBC_2.35 __issignaling F
+GLIBC_2.35 __issignalingf F
+GLIBC_2.35 __signbit F
+GLIBC_2.35 __signbitf F
+GLIBC_2.35 __signgam D 0x4
+GLIBC_2.35 acos F
+GLIBC_2.35 acosf F
+GLIBC_2.35 acosf32 F
+GLIBC_2.35 acosf32x F
+GLIBC_2.35 acosf64 F
+GLIBC_2.35 acosh F
+GLIBC_2.35 acoshf F
+GLIBC_2.35 acoshf32 F
+GLIBC_2.35 acoshf32x F
+GLIBC_2.35 acoshf64 F
+GLIBC_2.35 acoshl F
+GLIBC_2.35 acosl F
+GLIBC_2.35 asin F
+GLIBC_2.35 asinf F
+GLIBC_2.35 asinf32 F
+GLIBC_2.35 asinf32x F
+GLIBC_2.35 asinf64 F
+GLIBC_2.35 asinh F
+GLIBC_2.35 asinhf F
+GLIBC_2.35 asinhf32 F
+GLIBC_2.35 asinhf32x F
+GLIBC_2.35 asinhf64 F
+GLIBC_2.35 asinhl F
+GLIBC_2.35 asinl F
+GLIBC_2.35 atan F
+GLIBC_2.35 atan2 F
+GLIBC_2.35 atan2f F
+GLIBC_2.35 atan2f32 F
+GLIBC_2.35 atan2f32x F
+GLIBC_2.35 atan2f64 F
+GLIBC_2.35 atan2l F
+GLIBC_2.35 atanf F
+GLIBC_2.35 atanf32 F
+GLIBC_2.35 atanf32x F
+GLIBC_2.35 atanf64 F
+GLIBC_2.35 atanh F
+GLIBC_2.35 atanhf F
+GLIBC_2.35 atanhf32 F
+GLIBC_2.35 atanhf32x F
+GLIBC_2.35 atanhf64 F
+GLIBC_2.35 atanhl F
+GLIBC_2.35 atanl F
+GLIBC_2.35 cabs F
+GLIBC_2.35 cabsf F
+GLIBC_2.35 cabsf32 F
+GLIBC_2.35 cabsf32x F
+GLIBC_2.35 cabsf64 F
+GLIBC_2.35 cabsl F
+GLIBC_2.35 cacos F
+GLIBC_2.35 cacosf F
+GLIBC_2.35 cacosf32 F
+GLIBC_2.35 cacosf32x F
+GLIBC_2.35 cacosf64 F
+GLIBC_2.35 cacosh F
+GLIBC_2.35 cacoshf F
+GLIBC_2.35 cacoshf32 F
+GLIBC_2.35 cacoshf32x F
+GLIBC_2.35 cacoshf64 F
+GLIBC_2.35 cacoshl F
+GLIBC_2.35 cacosl F
+GLIBC_2.35 canonicalize F
+GLIBC_2.35 canonicalizef F
+GLIBC_2.35 canonicalizef32 F
+GLIBC_2.35 canonicalizef32x F
+GLIBC_2.35 canonicalizef64 F
+GLIBC_2.35 canonicalizel F
+GLIBC_2.35 carg F
+GLIBC_2.35 cargf F
+GLIBC_2.35 cargf32 F
+GLIBC_2.35 cargf32x F
+GLIBC_2.35 cargf64 F
+GLIBC_2.35 cargl F
+GLIBC_2.35 casin F
+GLIBC_2.35 casinf F
+GLIBC_2.35 casinf32 F
+GLIBC_2.35 casinf32x F
+GLIBC_2.35 casinf64 F
+GLIBC_2.35 casinh F
+GLIBC_2.35 casinhf F
+GLIBC_2.35 casinhf32 F
+GLIBC_2.35 casinhf32x F
+GLIBC_2.35 casinhf64 F
+GLIBC_2.35 casinhl F
+GLIBC_2.35 casinl F
+GLIBC_2.35 catan F
+GLIBC_2.35 catanf F
+GLIBC_2.35 catanf32 F
+GLIBC_2.35 catanf32x F
+GLIBC_2.35 catanf64 F
+GLIBC_2.35 catanh F
+GLIBC_2.35 catanhf F
+GLIBC_2.35 catanhf32 F
+GLIBC_2.35 catanhf32x F
+GLIBC_2.35 catanhf64 F
+GLIBC_2.35 catanhl F
+GLIBC_2.35 catanl F
+GLIBC_2.35 cbrt F
+GLIBC_2.35 cbrtf F
+GLIBC_2.35 cbrtf32 F
+GLIBC_2.35 cbrtf32x F
+GLIBC_2.35 cbrtf64 F
+GLIBC_2.35 cbrtl F
+GLIBC_2.35 ccos F
+GLIBC_2.35 ccosf F
+GLIBC_2.35 ccosf32 F
+GLIBC_2.35 ccosf32x F
+GLIBC_2.35 ccosf64 F
+GLIBC_2.35 ccosh F
+GLIBC_2.35 ccoshf F
+GLIBC_2.35 ccoshf32 F
+GLIBC_2.35 ccoshf32x F
+GLIBC_2.35 ccoshf64 F
+GLIBC_2.35 ccoshl F
+GLIBC_2.35 ccosl F
+GLIBC_2.35 ceil F
+GLIBC_2.35 ceilf F
+GLIBC_2.35 ceilf32 F
+GLIBC_2.35 ceilf32x F
+GLIBC_2.35 ceilf64 F
+GLIBC_2.35 ceill F
+GLIBC_2.35 cexp F
+GLIBC_2.35 cexpf F
+GLIBC_2.35 cexpf32 F
+GLIBC_2.35 cexpf32x F
+GLIBC_2.35 cexpf64 F
+GLIBC_2.35 cexpl F
+GLIBC_2.35 cimag F
+GLIBC_2.35 cimagf F
+GLIBC_2.35 cimagf32 F
+GLIBC_2.35 cimagf32x F
+GLIBC_2.35 cimagf64 F
+GLIBC_2.35 cimagl F
+GLIBC_2.35 clog F
+GLIBC_2.35 clog10 F
+GLIBC_2.35 clog10f F
+GLIBC_2.35 clog10f32 F
+GLIBC_2.35 clog10f32x F
+GLIBC_2.35 clog10f64 F
+GLIBC_2.35 clog10l F
+GLIBC_2.35 clogf F
+GLIBC_2.35 clogf32 F
+GLIBC_2.35 clogf32x F
+GLIBC_2.35 clogf64 F
+GLIBC_2.35 clogl F
+GLIBC_2.35 conj F
+GLIBC_2.35 conjf F
+GLIBC_2.35 conjf32 F
+GLIBC_2.35 conjf32x F
+GLIBC_2.35 conjf64 F
+GLIBC_2.35 conjl F
+GLIBC_2.35 copysign F
+GLIBC_2.35 copysignf F
+GLIBC_2.35 copysignf32 F
+GLIBC_2.35 copysignf32x F
+GLIBC_2.35 copysignf64 F
+GLIBC_2.35 copysignl F
+GLIBC_2.35 cos F
+GLIBC_2.35 cosf F
+GLIBC_2.35 cosf32 F
+GLIBC_2.35 cosf32x F
+GLIBC_2.35 cosf64 F
+GLIBC_2.35 cosh F
+GLIBC_2.35 coshf F
+GLIBC_2.35 coshf32 F
+GLIBC_2.35 coshf32x F
+GLIBC_2.35 coshf64 F
+GLIBC_2.35 coshl F
+GLIBC_2.35 cosl F
+GLIBC_2.35 cpow F
+GLIBC_2.35 cpowf F
+GLIBC_2.35 cpowf32 F
+GLIBC_2.35 cpowf32x F
+GLIBC_2.35 cpowf64 F
+GLIBC_2.35 cpowl F
+GLIBC_2.35 cproj F
+GLIBC_2.35 cprojf F
+GLIBC_2.35 cprojf32 F
+GLIBC_2.35 cprojf32x F
+GLIBC_2.35 cprojf64 F
+GLIBC_2.35 cprojl F
+GLIBC_2.35 creal F
+GLIBC_2.35 crealf F
+GLIBC_2.35 crealf32 F
+GLIBC_2.35 crealf32x F
+GLIBC_2.35 crealf64 F
+GLIBC_2.35 creall F
+GLIBC_2.35 csin F
+GLIBC_2.35 csinf F
+GLIBC_2.35 csinf32 F
+GLIBC_2.35 csinf32x F
+GLIBC_2.35 csinf64 F
+GLIBC_2.35 csinh F
+GLIBC_2.35 csinhf F
+GLIBC_2.35 csinhf32 F
+GLIBC_2.35 csinhf32x F
+GLIBC_2.35 csinhf64 F
+GLIBC_2.35 csinhl F
+GLIBC_2.35 csinl F
+GLIBC_2.35 csqrt F
+GLIBC_2.35 csqrtf F
+GLIBC_2.35 csqrtf32 F
+GLIBC_2.35 csqrtf32x F
+GLIBC_2.35 csqrtf64 F
+GLIBC_2.35 csqrtl F
+GLIBC_2.35 ctan F
+GLIBC_2.35 ctanf F
+GLIBC_2.35 ctanf32 F
+GLIBC_2.35 ctanf32x F
+GLIBC_2.35 ctanf64 F
+GLIBC_2.35 ctanh F
+GLIBC_2.35 ctanhf F
+GLIBC_2.35 ctanhf32 F
+GLIBC_2.35 ctanhf32x F
+GLIBC_2.35 ctanhf64 F
+GLIBC_2.35 ctanhl F
+GLIBC_2.35 ctanl F
+GLIBC_2.35 daddl F
+GLIBC_2.35 ddivl F
+GLIBC_2.35 dfmal F
+GLIBC_2.35 dmull F
+GLIBC_2.35 drem F
+GLIBC_2.35 dremf F
+GLIBC_2.35 dreml F
+GLIBC_2.35 dsqrtl F
+GLIBC_2.35 dsubl F
+GLIBC_2.35 erf F
+GLIBC_2.35 erfc F
+GLIBC_2.35 erfcf F
+GLIBC_2.35 erfcf32 F
+GLIBC_2.35 erfcf32x F
+GLIBC_2.35 erfcf64 F
+GLIBC_2.35 erfcl F
+GLIBC_2.35 erff F
+GLIBC_2.35 erff32 F
+GLIBC_2.35 erff32x F
+GLIBC_2.35 erff64 F
+GLIBC_2.35 erfl F
+GLIBC_2.35 exp F
+GLIBC_2.35 exp10 F
+GLIBC_2.35 exp10f F
+GLIBC_2.35 exp10f32 F
+GLIBC_2.35 exp10f32x F
+GLIBC_2.35 exp10f64 F
+GLIBC_2.35 exp10l F
+GLIBC_2.35 exp2 F
+GLIBC_2.35 exp2f F
+GLIBC_2.35 exp2f32 F
+GLIBC_2.35 exp2f32x F
+GLIBC_2.35 exp2f64 F
+GLIBC_2.35 exp2l F
+GLIBC_2.35 expf F
+GLIBC_2.35 expf32 F
+GLIBC_2.35 expf32x F
+GLIBC_2.35 expf64 F
+GLIBC_2.35 expl F
+GLIBC_2.35 expm1 F
+GLIBC_2.35 expm1f F
+GLIBC_2.35 expm1f32 F
+GLIBC_2.35 expm1f32x F
+GLIBC_2.35 expm1f64 F
+GLIBC_2.35 expm1l F
+GLIBC_2.35 f32addf32x F
+GLIBC_2.35 f32addf64 F
+GLIBC_2.35 f32divf32x F
+GLIBC_2.35 f32divf64 F
+GLIBC_2.35 f32fmaf32x F
+GLIBC_2.35 f32fmaf64 F
+GLIBC_2.35 f32mulf32x F
+GLIBC_2.35 f32mulf64 F
+GLIBC_2.35 f32sqrtf32x F
+GLIBC_2.35 f32sqrtf64 F
+GLIBC_2.35 f32subf32x F
+GLIBC_2.35 f32subf64 F
+GLIBC_2.35 f32xaddf64 F
+GLIBC_2.35 f32xdivf64 F
+GLIBC_2.35 f32xfmaf64 F
+GLIBC_2.35 f32xmulf64 F
+GLIBC_2.35 f32xsqrtf64 F
+GLIBC_2.35 f32xsubf64 F
+GLIBC_2.35 fabs F
+GLIBC_2.35 fabsf F
+GLIBC_2.35 fabsf32 F
+GLIBC_2.35 fabsf32x F
+GLIBC_2.35 fabsf64 F
+GLIBC_2.35 fabsl F
+GLIBC_2.35 fadd F
+GLIBC_2.35 faddl F
+GLIBC_2.35 fdim F
+GLIBC_2.35 fdimf F
+GLIBC_2.35 fdimf32 F
+GLIBC_2.35 fdimf32x F
+GLIBC_2.35 fdimf64 F
+GLIBC_2.35 fdiml F
+GLIBC_2.35 fdiv F
+GLIBC_2.35 fdivl F
+GLIBC_2.35 feclearexcept F
+GLIBC_2.35 fedisableexcept F
+GLIBC_2.35 feenableexcept F
+GLIBC_2.35 fegetenv F
+GLIBC_2.35 fegetexcept F
+GLIBC_2.35 fegetexceptflag F
+GLIBC_2.35 fegetmode F
+GLIBC_2.35 fegetround F
+GLIBC_2.35 feholdexcept F
+GLIBC_2.35 feraiseexcept F
+GLIBC_2.35 fesetenv F
+GLIBC_2.35 fesetexcept F
+GLIBC_2.35 fesetexceptflag F
+GLIBC_2.35 fesetmode F
+GLIBC_2.35 fesetround F
+GLIBC_2.35 fetestexcept F
+GLIBC_2.35 fetestexceptflag F
+GLIBC_2.35 feupdateenv F
+GLIBC_2.35 ffma F
+GLIBC_2.35 ffmal F
+GLIBC_2.35 finite F
+GLIBC_2.35 finitef F
+GLIBC_2.35 finitel F
+GLIBC_2.35 floor F
+GLIBC_2.35 floorf F
+GLIBC_2.35 floorf32 F
+GLIBC_2.35 floorf32x F
+GLIBC_2.35 floorf64 F
+GLIBC_2.35 floorl F
+GLIBC_2.35 fma F
+GLIBC_2.35 fmaf F
+GLIBC_2.35 fmaf32 F
+GLIBC_2.35 fmaf32x F
+GLIBC_2.35 fmaf64 F
+GLIBC_2.35 fmal F
+GLIBC_2.35 fmax F
+GLIBC_2.35 fmaxf F
+GLIBC_2.35 fmaxf32 F
+GLIBC_2.35 fmaxf32x F
+GLIBC_2.35 fmaxf64 F
+GLIBC_2.35 fmaximum F
+GLIBC_2.35 fmaximum_mag F
+GLIBC_2.35 fmaximum_mag_num F
+GLIBC_2.35 fmaximum_mag_numf F
+GLIBC_2.35 fmaximum_mag_numf32 F
+GLIBC_2.35 fmaximum_mag_numf32x F
+GLIBC_2.35 fmaximum_mag_numf64 F
+GLIBC_2.35 fmaximum_mag_numl F
+GLIBC_2.35 fmaximum_magf F
+GLIBC_2.35 fmaximum_magf32 F
+GLIBC_2.35 fmaximum_magf32x F
+GLIBC_2.35 fmaximum_magf64 F
+GLIBC_2.35 fmaximum_magl F
+GLIBC_2.35 fmaximum_num F
+GLIBC_2.35 fmaximum_numf F
+GLIBC_2.35 fmaximum_numf32 F
+GLIBC_2.35 fmaximum_numf32x F
+GLIBC_2.35 fmaximum_numf64 F
+GLIBC_2.35 fmaximum_numl F
+GLIBC_2.35 fmaximumf F
+GLIBC_2.35 fmaximumf32 F
+GLIBC_2.35 fmaximumf32x F
+GLIBC_2.35 fmaximumf64 F
+GLIBC_2.35 fmaximuml F
+GLIBC_2.35 fmaxl F
+GLIBC_2.35 fmaxmag F
+GLIBC_2.35 fmaxmagf F
+GLIBC_2.35 fmaxmagf32 F
+GLIBC_2.35 fmaxmagf32x F
+GLIBC_2.35 fmaxmagf64 F
+GLIBC_2.35 fmaxmagl F
+GLIBC_2.35 fmin F
+GLIBC_2.35 fminf F
+GLIBC_2.35 fminf32 F
+GLIBC_2.35 fminf32x F
+GLIBC_2.35 fminf64 F
+GLIBC_2.35 fminimum F
+GLIBC_2.35 fminimum_mag F
+GLIBC_2.35 fminimum_mag_num F
+GLIBC_2.35 fminimum_mag_numf F
+GLIBC_2.35 fminimum_mag_numf32 F
+GLIBC_2.35 fminimum_mag_numf32x F
+GLIBC_2.35 fminimum_mag_numf64 F
+GLIBC_2.35 fminimum_mag_numl F
+GLIBC_2.35 fminimum_magf F
+GLIBC_2.35 fminimum_magf32 F
+GLIBC_2.35 fminimum_magf32x F
+GLIBC_2.35 fminimum_magf64 F
+GLIBC_2.35 fminimum_magl F
+GLIBC_2.35 fminimum_num F
+GLIBC_2.35 fminimum_numf F
+GLIBC_2.35 fminimum_numf32 F
+GLIBC_2.35 fminimum_numf32x F
+GLIBC_2.35 fminimum_numf64 F
+GLIBC_2.35 fminimum_numl F
+GLIBC_2.35 fminimumf F
+GLIBC_2.35 fminimumf32 F
+GLIBC_2.35 fminimumf32x F
+GLIBC_2.35 fminimumf64 F
+GLIBC_2.35 fminimuml F
+GLIBC_2.35 fminl F
+GLIBC_2.35 fminmag F
+GLIBC_2.35 fminmagf F
+GLIBC_2.35 fminmagf32 F
+GLIBC_2.35 fminmagf32x F
+GLIBC_2.35 fminmagf64 F
+GLIBC_2.35 fminmagl F
+GLIBC_2.35 fmod F
+GLIBC_2.35 fmodf F
+GLIBC_2.35 fmodf32 F
+GLIBC_2.35 fmodf32x F
+GLIBC_2.35 fmodf64 F
+GLIBC_2.35 fmodl F
+GLIBC_2.35 fmul F
+GLIBC_2.35 fmull F
+GLIBC_2.35 frexp F
+GLIBC_2.35 frexpf F
+GLIBC_2.35 frexpf32 F
+GLIBC_2.35 frexpf32x F
+GLIBC_2.35 frexpf64 F
+GLIBC_2.35 frexpl F
+GLIBC_2.35 fromfp F
+GLIBC_2.35 fromfpf F
+GLIBC_2.35 fromfpf32 F
+GLIBC_2.35 fromfpf32x F
+GLIBC_2.35 fromfpf64 F
+GLIBC_2.35 fromfpl F
+GLIBC_2.35 fromfpx F
+GLIBC_2.35 fromfpxf F
+GLIBC_2.35 fromfpxf32 F
+GLIBC_2.35 fromfpxf32x F
+GLIBC_2.35 fromfpxf64 F
+GLIBC_2.35 fromfpxl F
+GLIBC_2.35 fsqrt F
+GLIBC_2.35 fsqrtl F
+GLIBC_2.35 fsub F
+GLIBC_2.35 fsubl F
+GLIBC_2.35 gamma F
+GLIBC_2.35 gammaf F
+GLIBC_2.35 gammal F
+GLIBC_2.35 getpayload F
+GLIBC_2.35 getpayloadf F
+GLIBC_2.35 getpayloadf32 F
+GLIBC_2.35 getpayloadf32x F
+GLIBC_2.35 getpayloadf64 F
+GLIBC_2.35 getpayloadl F
+GLIBC_2.35 hypot F
+GLIBC_2.35 hypotf F
+GLIBC_2.35 hypotf32 F
+GLIBC_2.35 hypotf32x F
+GLIBC_2.35 hypotf64 F
+GLIBC_2.35 hypotl F
+GLIBC_2.35 ilogb F
+GLIBC_2.35 ilogbf F
+GLIBC_2.35 ilogbf32 F
+GLIBC_2.35 ilogbf32x F
+GLIBC_2.35 ilogbf64 F
+GLIBC_2.35 ilogbl F
+GLIBC_2.35 j0 F
+GLIBC_2.35 j0f F
+GLIBC_2.35 j0f32 F
+GLIBC_2.35 j0f32x F
+GLIBC_2.35 j0f64 F
+GLIBC_2.35 j0l F
+GLIBC_2.35 j1 F
+GLIBC_2.35 j1f F
+GLIBC_2.35 j1f32 F
+GLIBC_2.35 j1f32x F
+GLIBC_2.35 j1f64 F
+GLIBC_2.35 j1l F
+GLIBC_2.35 jn F
+GLIBC_2.35 jnf F
+GLIBC_2.35 jnf32 F
+GLIBC_2.35 jnf32x F
+GLIBC_2.35 jnf64 F
+GLIBC_2.35 jnl F
+GLIBC_2.35 ldexp F
+GLIBC_2.35 ldexpf F
+GLIBC_2.35 ldexpf32 F
+GLIBC_2.35 ldexpf32x F
+GLIBC_2.35 ldexpf64 F
+GLIBC_2.35 ldexpl F
+GLIBC_2.35 lgamma F
+GLIBC_2.35 lgamma_r F
+GLIBC_2.35 lgammaf F
+GLIBC_2.35 lgammaf32 F
+GLIBC_2.35 lgammaf32_r F
+GLIBC_2.35 lgammaf32x F
+GLIBC_2.35 lgammaf32x_r F
+GLIBC_2.35 lgammaf64 F
+GLIBC_2.35 lgammaf64_r F
+GLIBC_2.35 lgammaf_r F
+GLIBC_2.35 lgammal F
+GLIBC_2.35 lgammal_r F
+GLIBC_2.35 llogb F
+GLIBC_2.35 llogbf F
+GLIBC_2.35 llogbf32 F
+GLIBC_2.35 llogbf32x F
+GLIBC_2.35 llogbf64 F
+GLIBC_2.35 llogbl F
+GLIBC_2.35 llrint F
+GLIBC_2.35 llrintf F
+GLIBC_2.35 llrintf32 F
+GLIBC_2.35 llrintf32x F
+GLIBC_2.35 llrintf64 F
+GLIBC_2.35 llrintl F
+GLIBC_2.35 llround F
+GLIBC_2.35 llroundf F
+GLIBC_2.35 llroundf32 F
+GLIBC_2.35 llroundf32x F
+GLIBC_2.35 llroundf64 F
+GLIBC_2.35 llroundl F
+GLIBC_2.35 log F
+GLIBC_2.35 log10 F
+GLIBC_2.35 log10f F
+GLIBC_2.35 log10f32 F
+GLIBC_2.35 log10f32x F
+GLIBC_2.35 log10f64 F
+GLIBC_2.35 log10l F
+GLIBC_2.35 log1p F
+GLIBC_2.35 log1pf F
+GLIBC_2.35 log1pf32 F
+GLIBC_2.35 log1pf32x F
+GLIBC_2.35 log1pf64 F
+GLIBC_2.35 log1pl F
+GLIBC_2.35 log2 F
+GLIBC_2.35 log2f F
+GLIBC_2.35 log2f32 F
+GLIBC_2.35 log2f32x F
+GLIBC_2.35 log2f64 F
+GLIBC_2.35 log2l F
+GLIBC_2.35 logb F
+GLIBC_2.35 logbf F
+GLIBC_2.35 logbf32 F
+GLIBC_2.35 logbf32x F
+GLIBC_2.35 logbf64 F
+GLIBC_2.35 logbl F
+GLIBC_2.35 logf F
+GLIBC_2.35 logf32 F
+GLIBC_2.35 logf32x F
+GLIBC_2.35 logf64 F
+GLIBC_2.35 logl F
+GLIBC_2.35 lrint F
+GLIBC_2.35 lrintf F
+GLIBC_2.35 lrintf32 F
+GLIBC_2.35 lrintf32x F
+GLIBC_2.35 lrintf64 F
+GLIBC_2.35 lrintl F
+GLIBC_2.35 lround F
+GLIBC_2.35 lroundf F
+GLIBC_2.35 lroundf32 F
+GLIBC_2.35 lroundf32x F
+GLIBC_2.35 lroundf64 F
+GLIBC_2.35 lroundl F
+GLIBC_2.35 modf F
+GLIBC_2.35 modff F
+GLIBC_2.35 modff32 F
+GLIBC_2.35 modff32x F
+GLIBC_2.35 modff64 F
+GLIBC_2.35 modfl F
+GLIBC_2.35 nan F
+GLIBC_2.35 nanf F
+GLIBC_2.35 nanf32 F
+GLIBC_2.35 nanf32x F
+GLIBC_2.35 nanf64 F
+GLIBC_2.35 nanl F
+GLIBC_2.35 nearbyint F
+GLIBC_2.35 nearbyintf F
+GLIBC_2.35 nearbyintf32 F
+GLIBC_2.35 nearbyintf32x F
+GLIBC_2.35 nearbyintf64 F
+GLIBC_2.35 nearbyintl F
+GLIBC_2.35 nextafter F
+GLIBC_2.35 nextafterf F
+GLIBC_2.35 nextafterf32 F
+GLIBC_2.35 nextafterf32x F
+GLIBC_2.35 nextafterf64 F
+GLIBC_2.35 nextafterl F
+GLIBC_2.35 nextdown F
+GLIBC_2.35 nextdownf F
+GLIBC_2.35 nextdownf32 F
+GLIBC_2.35 nextdownf32x F
+GLIBC_2.35 nextdownf64 F
+GLIBC_2.35 nextdownl F
+GLIBC_2.35 nexttoward F
+GLIBC_2.35 nexttowardf F
+GLIBC_2.35 nexttowardl F
+GLIBC_2.35 nextup F
+GLIBC_2.35 nextupf F
+GLIBC_2.35 nextupf32 F
+GLIBC_2.35 nextupf32x F
+GLIBC_2.35 nextupf64 F
+GLIBC_2.35 nextupl F
+GLIBC_2.35 pow F
+GLIBC_2.35 powf F
+GLIBC_2.35 powf32 F
+GLIBC_2.35 powf32x F
+GLIBC_2.35 powf64 F
+GLIBC_2.35 powl F
+GLIBC_2.35 remainder F
+GLIBC_2.35 remainderf F
+GLIBC_2.35 remainderf32 F
+GLIBC_2.35 remainderf32x F
+GLIBC_2.35 remainderf64 F
+GLIBC_2.35 remainderl F
+GLIBC_2.35 remquo F
+GLIBC_2.35 remquof F
+GLIBC_2.35 remquof32 F
+GLIBC_2.35 remquof32x F
+GLIBC_2.35 remquof64 F
+GLIBC_2.35 remquol F
+GLIBC_2.35 rint F
+GLIBC_2.35 rintf F
+GLIBC_2.35 rintf32 F
+GLIBC_2.35 rintf32x F
+GLIBC_2.35 rintf64 F
+GLIBC_2.35 rintl F
+GLIBC_2.35 round F
+GLIBC_2.35 roundeven F
+GLIBC_2.35 roundevenf F
+GLIBC_2.35 roundevenf32 F
+GLIBC_2.35 roundevenf32x F
+GLIBC_2.35 roundevenf64 F
+GLIBC_2.35 roundevenl F
+GLIBC_2.35 roundf F
+GLIBC_2.35 roundf32 F
+GLIBC_2.35 roundf32x F
+GLIBC_2.35 roundf64 F
+GLIBC_2.35 roundl F
+GLIBC_2.35 scalb F
+GLIBC_2.35 scalbf F
+GLIBC_2.35 scalbl F
+GLIBC_2.35 scalbln F
+GLIBC_2.35 scalblnf F
+GLIBC_2.35 scalblnf32 F
+GLIBC_2.35 scalblnf32x F
+GLIBC_2.35 scalblnf64 F
+GLIBC_2.35 scalblnl F
+GLIBC_2.35 scalbn F
+GLIBC_2.35 scalbnf F
+GLIBC_2.35 scalbnf32 F
+GLIBC_2.35 scalbnf32x F
+GLIBC_2.35 scalbnf64 F
+GLIBC_2.35 scalbnl F
+GLIBC_2.35 setpayload F
+GLIBC_2.35 setpayloadf F
+GLIBC_2.35 setpayloadf32 F
+GLIBC_2.35 setpayloadf32x F
+GLIBC_2.35 setpayloadf64 F
+GLIBC_2.35 setpayloadl F
+GLIBC_2.35 setpayloadsig F
+GLIBC_2.35 setpayloadsigf F
+GLIBC_2.35 setpayloadsigf32 F
+GLIBC_2.35 setpayloadsigf32x F
+GLIBC_2.35 setpayloadsigf64 F
+GLIBC_2.35 setpayloadsigl F
+GLIBC_2.35 signgam D 0x4
+GLIBC_2.35 significand F
+GLIBC_2.35 significandf F
+GLIBC_2.35 significandl F
+GLIBC_2.35 sin F
+GLIBC_2.35 sincos F
+GLIBC_2.35 sincosf F
+GLIBC_2.35 sincosf32 F
+GLIBC_2.35 sincosf32x F
+GLIBC_2.35 sincosf64 F
+GLIBC_2.35 sincosl F
+GLIBC_2.35 sinf F
+GLIBC_2.35 sinf32 F
+GLIBC_2.35 sinf32x F
+GLIBC_2.35 sinf64 F
+GLIBC_2.35 sinh F
+GLIBC_2.35 sinhf F
+GLIBC_2.35 sinhf32 F
+GLIBC_2.35 sinhf32x F
+GLIBC_2.35 sinhf64 F
+GLIBC_2.35 sinhl F
+GLIBC_2.35 sinl F
+GLIBC_2.35 sqrt F
+GLIBC_2.35 sqrtf F
+GLIBC_2.35 sqrtf32 F
+GLIBC_2.35 sqrtf32x F
+GLIBC_2.35 sqrtf64 F
+GLIBC_2.35 sqrtl F
+GLIBC_2.35 tan F
+GLIBC_2.35 tanf F
+GLIBC_2.35 tanf32 F
+GLIBC_2.35 tanf32x F
+GLIBC_2.35 tanf64 F
+GLIBC_2.35 tanh F
+GLIBC_2.35 tanhf F
+GLIBC_2.35 tanhf32 F
+GLIBC_2.35 tanhf32x F
+GLIBC_2.35 tanhf64 F
+GLIBC_2.35 tanhl F
+GLIBC_2.35 tanl F
+GLIBC_2.35 tgamma F
+GLIBC_2.35 tgammaf F
+GLIBC_2.35 tgammaf32 F
+GLIBC_2.35 tgammaf32x F
+GLIBC_2.35 tgammaf64 F
+GLIBC_2.35 tgammal F
+GLIBC_2.35 totalorder F
+GLIBC_2.35 totalorderf F
+GLIBC_2.35 totalorderf32 F
+GLIBC_2.35 totalorderf32x F
+GLIBC_2.35 totalorderf64 F
+GLIBC_2.35 totalorderl F
+GLIBC_2.35 totalordermag F
+GLIBC_2.35 totalordermagf F
+GLIBC_2.35 totalordermagf32 F
+GLIBC_2.35 totalordermagf32x F
+GLIBC_2.35 totalordermagf64 F
+GLIBC_2.35 totalordermagl F
+GLIBC_2.35 trunc F
+GLIBC_2.35 truncf F
+GLIBC_2.35 truncf32 F
+GLIBC_2.35 truncf32x F
+GLIBC_2.35 truncf64 F
+GLIBC_2.35 truncl F
+GLIBC_2.35 ufromfp F
+GLIBC_2.35 ufromfpf F
+GLIBC_2.35 ufromfpf32 F
+GLIBC_2.35 ufromfpf32x F
+GLIBC_2.35 ufromfpf64 F
+GLIBC_2.35 ufromfpl F
+GLIBC_2.35 ufromfpx F
+GLIBC_2.35 ufromfpxf F
+GLIBC_2.35 ufromfpxf32 F
+GLIBC_2.35 ufromfpxf32x F
+GLIBC_2.35 ufromfpxf64 F
+GLIBC_2.35 ufromfpxl F
+GLIBC_2.35 y0 F
+GLIBC_2.35 y0f F
+GLIBC_2.35 y0f32 F
+GLIBC_2.35 y0f32x F
+GLIBC_2.35 y0f64 F
+GLIBC_2.35 y0l F
+GLIBC_2.35 y1 F
+GLIBC_2.35 y1f F
+GLIBC_2.35 y1f32 F
+GLIBC_2.35 y1f32x F
+GLIBC_2.35 y1f64 F
+GLIBC_2.35 y1l F
+GLIBC_2.35 yn F
+GLIBC_2.35 ynf F
+GLIBC_2.35 ynf32 F
+GLIBC_2.35 ynf32x F
+GLIBC_2.35 ynf64 F
+GLIBC_2.35 ynl F
diff --git a/sysdeps/unix/sysv/linux/or1k/libnsl.abilist b/sysdeps/unix/sysv/linux/or1k/libnsl.abilist
new file mode 100644
index 0000000000..5592653177
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libnsl.abilist
@@ -0,0 +1,121 @@
+GLIBC_2.35 __free_fdresult F
+GLIBC_2.35 __nis_default_access F
+GLIBC_2.35 __nis_default_group F
+GLIBC_2.35 __nis_default_owner F
+GLIBC_2.35 __nis_default_ttl F
+GLIBC_2.35 __nis_finddirectory F
+GLIBC_2.35 __nis_hash F
+GLIBC_2.35 __nisbind_connect F
+GLIBC_2.35 __nisbind_create F
+GLIBC_2.35 __nisbind_destroy F
+GLIBC_2.35 __nisbind_next F
+GLIBC_2.35 __yp_check F
+GLIBC_2.35 nis_add F
+GLIBC_2.35 nis_add_entry F
+GLIBC_2.35 nis_addmember F
+GLIBC_2.35 nis_checkpoint F
+GLIBC_2.35 nis_clone_directory F
+GLIBC_2.35 nis_clone_object F
+GLIBC_2.35 nis_clone_result F
+GLIBC_2.35 nis_creategroup F
+GLIBC_2.35 nis_destroy_object F
+GLIBC_2.35 nis_destroygroup F
+GLIBC_2.35 nis_dir_cmp F
+GLIBC_2.35 nis_domain_of F
+GLIBC_2.35 nis_domain_of_r F
+GLIBC_2.35 nis_first_entry F
+GLIBC_2.35 nis_free_directory F
+GLIBC_2.35 nis_free_object F
+GLIBC_2.35 nis_free_request F
+GLIBC_2.35 nis_freenames F
+GLIBC_2.35 nis_freeresult F
+GLIBC_2.35 nis_freeservlist F
+GLIBC_2.35 nis_freetags F
+GLIBC_2.35 nis_getnames F
+GLIBC_2.35 nis_getservlist F
+GLIBC_2.35 nis_ismember F
+GLIBC_2.35 nis_leaf_of F
+GLIBC_2.35 nis_leaf_of_r F
+GLIBC_2.35 nis_lerror F
+GLIBC_2.35 nis_list F
+GLIBC_2.35 nis_local_directory F
+GLIBC_2.35 nis_local_group F
+GLIBC_2.35 nis_local_host F
+GLIBC_2.35 nis_local_principal F
+GLIBC_2.35 nis_lookup F
+GLIBC_2.35 nis_mkdir F
+GLIBC_2.35 nis_modify F
+GLIBC_2.35 nis_modify_entry F
+GLIBC_2.35 nis_name_of F
+GLIBC_2.35 nis_name_of_r F
+GLIBC_2.35 nis_next_entry F
+GLIBC_2.35 nis_perror F
+GLIBC_2.35 nis_ping F
+GLIBC_2.35 nis_print_directory F
+GLIBC_2.35 nis_print_entry F
+GLIBC_2.35 nis_print_group F
+GLIBC_2.35 nis_print_group_entry F
+GLIBC_2.35 nis_print_link F
+GLIBC_2.35 nis_print_object F
+GLIBC_2.35 nis_print_result F
+GLIBC_2.35 nis_print_rights F
+GLIBC_2.35 nis_print_table F
+GLIBC_2.35 nis_read_obj F
+GLIBC_2.35 nis_remove F
+GLIBC_2.35 nis_remove_entry F
+GLIBC_2.35 nis_removemember F
+GLIBC_2.35 nis_rmdir F
+GLIBC_2.35 nis_servstate F
+GLIBC_2.35 nis_sperrno F
+GLIBC_2.35 nis_sperror F
+GLIBC_2.35 nis_sperror_r F
+GLIBC_2.35 nis_stats F
+GLIBC_2.35 nis_verifygroup F
+GLIBC_2.35 nis_write_obj F
+GLIBC_2.35 readColdStartFile F
+GLIBC_2.35 writeColdStartFile F
+GLIBC_2.35 xdr_cback_data F
+GLIBC_2.35 xdr_domainname F
+GLIBC_2.35 xdr_keydat F
+GLIBC_2.35 xdr_mapname F
+GLIBC_2.35 xdr_obj_p F
+GLIBC_2.35 xdr_peername F
+GLIBC_2.35 xdr_valdat F
+GLIBC_2.35 xdr_yp_buf F
+GLIBC_2.35 xdr_ypall F
+GLIBC_2.35 xdr_ypbind_binding F
+GLIBC_2.35 xdr_ypbind_resp F
+GLIBC_2.35 xdr_ypbind_resptype F
+GLIBC_2.35 xdr_ypbind_setdom F
+GLIBC_2.35 xdr_ypdelete_args F
+GLIBC_2.35 xdr_ypmap_parms F
+GLIBC_2.35 xdr_ypmaplist F
+GLIBC_2.35 xdr_yppush_status F
+GLIBC_2.35 xdr_yppushresp_xfr F
+GLIBC_2.35 xdr_ypreq_key F
+GLIBC_2.35 xdr_ypreq_nokey F
+GLIBC_2.35 xdr_ypreq_xfr F
+GLIBC_2.35 xdr_ypresp_all F
+GLIBC_2.35 xdr_ypresp_key_val F
+GLIBC_2.35 xdr_ypresp_maplist F
+GLIBC_2.35 xdr_ypresp_master F
+GLIBC_2.35 xdr_ypresp_order F
+GLIBC_2.35 xdr_ypresp_val F
+GLIBC_2.35 xdr_ypresp_xfr F
+GLIBC_2.35 xdr_ypstat F
+GLIBC_2.35 xdr_ypupdate_args F
+GLIBC_2.35 xdr_ypxfrstat F
+GLIBC_2.35 yp_all F
+GLIBC_2.35 yp_bind F
+GLIBC_2.35 yp_first F
+GLIBC_2.35 yp_get_default_domain F
+GLIBC_2.35 yp_maplist F
+GLIBC_2.35 yp_master F
+GLIBC_2.35 yp_match F
+GLIBC_2.35 yp_next F
+GLIBC_2.35 yp_order F
+GLIBC_2.35 yp_unbind F
+GLIBC_2.35 yp_update F
+GLIBC_2.35 ypbinderr_string F
+GLIBC_2.35 yperr_string F
+GLIBC_2.35 ypprot_err F
diff --git a/sysdeps/unix/sysv/linux/or1k/libpthread.abilist b/sysdeps/unix/sysv/linux/or1k/libpthread.abilist
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/sysdeps/unix/sysv/linux/or1k/libresolv.abilist b/sysdeps/unix/sysv/linux/or1k/libresolv.abilist
new file mode 100644
index 0000000000..bfeb1f27e0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libresolv.abilist
@@ -0,0 +1,55 @@
+GLIBC_2.35 __b64_ntop F
+GLIBC_2.35 __b64_pton F
+GLIBC_2.35 __dn_count_labels F
+GLIBC_2.35 __fp_nquery F
+GLIBC_2.35 __fp_query F
+GLIBC_2.35 __fp_resstat F
+GLIBC_2.35 __hostalias F
+GLIBC_2.35 __loc_aton F
+GLIBC_2.35 __loc_ntoa F
+GLIBC_2.35 __p_cdname F
+GLIBC_2.35 __p_cdnname F
+GLIBC_2.35 __p_class F
+GLIBC_2.35 __p_class_syms D 0x54
+GLIBC_2.35 __p_fqname F
+GLIBC_2.35 __p_fqnname F
+GLIBC_2.35 __p_option F
+GLIBC_2.35 __p_query F
+GLIBC_2.35 __p_rcode F
+GLIBC_2.35 __p_time F
+GLIBC_2.35 __p_type F
+GLIBC_2.35 __p_type_syms D 0x228
+GLIBC_2.35 __putlong F
+GLIBC_2.35 __putshort F
+GLIBC_2.35 __res_close F
+GLIBC_2.35 __res_hostalias F
+GLIBC_2.35 __res_isourserver F
+GLIBC_2.35 __res_nameinquery F
+GLIBC_2.35 __res_queriesmatch F
+GLIBC_2.35 __sym_ntop F
+GLIBC_2.35 __sym_ntos F
+GLIBC_2.35 __sym_ston F
+GLIBC_2.35 _getlong F
+GLIBC_2.35 _getshort F
+GLIBC_2.35 inet_net_ntop F
+GLIBC_2.35 inet_net_pton F
+GLIBC_2.35 inet_neta F
+GLIBC_2.35 ns_datetosecs F
+GLIBC_2.35 ns_format_ttl F
+GLIBC_2.35 ns_get16 F
+GLIBC_2.35 ns_get32 F
+GLIBC_2.35 ns_initparse F
+GLIBC_2.35 ns_makecanon F
+GLIBC_2.35 ns_msg_getflag F
+GLIBC_2.35 ns_name_ntol F
+GLIBC_2.35 ns_name_rollback F
+GLIBC_2.35 ns_parse_ttl F
+GLIBC_2.35 ns_parserr F
+GLIBC_2.35 ns_put16 F
+GLIBC_2.35 ns_put32 F
+GLIBC_2.35 ns_samedomain F
+GLIBC_2.35 ns_samename F
+GLIBC_2.35 ns_skiprr F
+GLIBC_2.35 ns_sprintrr F
+GLIBC_2.35 ns_sprintrrf F
+GLIBC_2.35 ns_subdomain F
diff --git a/sysdeps/unix/sysv/linux/or1k/librt.abilist b/sysdeps/unix/sysv/linux/or1k/librt.abilist
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/sysdeps/unix/sysv/linux/or1k/libthread_db.abilist b/sysdeps/unix/sysv/linux/or1k/libthread_db.abilist
new file mode 100644
index 0000000000..9607e70c16
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libthread_db.abilist
@@ -0,0 +1,40 @@
+GLIBC_2.35 td_init F
+GLIBC_2.35 td_log F
+GLIBC_2.35 td_symbol_list F
+GLIBC_2.35 td_ta_clear_event F
+GLIBC_2.35 td_ta_delete F
+GLIBC_2.35 td_ta_enable_stats F
+GLIBC_2.35 td_ta_event_addr F
+GLIBC_2.35 td_ta_event_getmsg F
+GLIBC_2.35 td_ta_get_nthreads F
+GLIBC_2.35 td_ta_get_ph F
+GLIBC_2.35 td_ta_get_stats F
+GLIBC_2.35 td_ta_map_id2thr F
+GLIBC_2.35 td_ta_map_lwp2thr F
+GLIBC_2.35 td_ta_new F
+GLIBC_2.35 td_ta_reset_stats F
+GLIBC_2.35 td_ta_set_event F
+GLIBC_2.35 td_ta_setconcurrency F
+GLIBC_2.35 td_ta_thr_iter F
+GLIBC_2.35 td_ta_tsd_iter F
+GLIBC_2.35 td_thr_clear_event F
+GLIBC_2.35 td_thr_dbresume F
+GLIBC_2.35 td_thr_dbsuspend F
+GLIBC_2.35 td_thr_event_enable F
+GLIBC_2.35 td_thr_event_getmsg F
+GLIBC_2.35 td_thr_get_info F
+GLIBC_2.35 td_thr_getfpregs F
+GLIBC_2.35 td_thr_getgregs F
+GLIBC_2.35 td_thr_getxregs F
+GLIBC_2.35 td_thr_getxregsize F
+GLIBC_2.35 td_thr_set_event F
+GLIBC_2.35 td_thr_setfpregs F
+GLIBC_2.35 td_thr_setgregs F
+GLIBC_2.35 td_thr_setprio F
+GLIBC_2.35 td_thr_setsigpending F
+GLIBC_2.35 td_thr_setxregs F
+GLIBC_2.35 td_thr_sigsetmask F
+GLIBC_2.35 td_thr_tls_get_addr F
+GLIBC_2.35 td_thr_tlsbase F
+GLIBC_2.35 td_thr_tsd F
+GLIBC_2.35 td_thr_validate F
diff --git a/sysdeps/unix/sysv/linux/or1k/libutil.abilist b/sysdeps/unix/sysv/linux/or1k/libutil.abilist
new file mode 100644
index 0000000000..f33b84813b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/libutil.abilist
@@ -0,0 +1 @@
+GLIBC_2.35 __libutil_version_placeholder F
diff --git a/sysdeps/unix/sysv/linux/or1k/localplt.data b/sysdeps/unix/sysv/linux/or1k/localplt.data
new file mode 100644
index 0000000000..04eb9fc8dc
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/localplt.data
@@ -0,0 +1,14 @@
+# See scripts/check-localplt.awk for how this file is processed.
+# PLT use is required for the malloc family and for matherr because
+# users can define their own functions and have library internals call them.
+libc.so: calloc
+libc.so: free
+libc.so: malloc
+libc.so: realloc
+# Generated by the compiler because there is no trap insn pattern.
+libc.so: abort ?
+# The TLS-enabled version of these functions is interposed from libc.so.
+ld.so: _dl_signal_error
+ld.so: _dl_catch_error
+ld.so: _dl_signal_exception
+ld.so: _dl_catch_exception
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 11/13] or1k: Build Infrastructure
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (9 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 10/13] or1k: ABI lists Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-22 21:03   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 12/13] build-many-glibcs.py: add OpenRISC support Stafford Horne
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

Here we define the minumum linux kernel version at 5.4.0, as that is the
long term support version where 32-bit architectures start to support
64-bit time API's.  The OpenRISC kernel had some bugs up until version 5.8
which caused issues with glibc fork/clone, they have been backported to
5.4 but not previous versions.
---
 sysdeps/or1k/Implies                        |  3 ++
 sysdeps/or1k/Makefile                       |  7 +++++
 sysdeps/or1k/nofpu/Implies                  |  1 +
 sysdeps/or1k/nptl/Makefile                  | 21 +++++++++++++
 sysdeps/or1k/preconfigure                   | 34 +++++++++++++++++++++
 sysdeps/unix/sysv/linux/or1k/Implies        |  3 ++
 sysdeps/unix/sysv/linux/or1k/Makefile       | 12 ++++++++
 sysdeps/unix/sysv/linux/or1k/configure      |  4 +++
 sysdeps/unix/sysv/linux/or1k/configure.ac   |  4 +++
 sysdeps/unix/sysv/linux/or1k/shlib-versions |  2 ++
 10 files changed, 91 insertions(+)
 create mode 100644 sysdeps/or1k/Implies
 create mode 100644 sysdeps/or1k/Makefile
 create mode 100644 sysdeps/or1k/nofpu/Implies
 create mode 100644 sysdeps/or1k/nptl/Makefile
 create mode 100644 sysdeps/or1k/preconfigure
 create mode 100644 sysdeps/unix/sysv/linux/or1k/Implies
 create mode 100644 sysdeps/unix/sysv/linux/or1k/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/or1k/configure
 create mode 100644 sysdeps/unix/sysv/linux/or1k/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/or1k/shlib-versions

diff --git a/sysdeps/or1k/Implies b/sysdeps/or1k/Implies
new file mode 100644
index 0000000000..387a0ca052
--- /dev/null
+++ b/sysdeps/or1k/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/dbl-64
+ieee754/flt-32
diff --git a/sysdeps/or1k/Makefile b/sysdeps/or1k/Makefile
new file mode 100644
index 0000000000..0241a0587e
--- /dev/null
+++ b/sysdeps/or1k/Makefile
@@ -0,0 +1,7 @@
+ASFLAGS-.os += -fPIC
+
+ifeq ($(subdir),elf)
+# Extra shared linker files to link only into dl-allobjs.so.
+sysdep-rtld-routines += dl-start
+endif
+
diff --git a/sysdeps/or1k/nofpu/Implies b/sysdeps/or1k/nofpu/Implies
new file mode 100644
index 0000000000..abcbadb25f
--- /dev/null
+++ b/sysdeps/or1k/nofpu/Implies
@@ -0,0 +1 @@
+ieee754/soft-fp
diff --git a/sysdeps/or1k/nptl/Makefile b/sysdeps/or1k/nptl/Makefile
new file mode 100644
index 0000000000..0e08821933
--- /dev/null
+++ b/sysdeps/or1k/nptl/Makefile
@@ -0,0 +1,21 @@
+# Copyright (C) 2021 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
+# <https://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/sysdeps/or1k/preconfigure b/sysdeps/or1k/preconfigure
new file mode 100644
index 0000000000..d1b1fb1843
--- /dev/null
+++ b/sysdeps/or1k/preconfigure
@@ -0,0 +1,34 @@
+#
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+
+case "$machine" in
+or1k*)
+  base_machine=or1k
+  machine=or1k
+
+  with_fp_cond="defined __or1k_hard_float__"
+  ;;
+esac
+
diff --git a/sysdeps/unix/sysv/linux/or1k/Implies b/sysdeps/unix/sysv/linux/or1k/Implies
new file mode 100644
index 0000000000..f39f16c04a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/Implies
@@ -0,0 +1,3 @@
+or1k/nptl
+unix/sysv/linux/generic/wordsize-32
+unix/sysv/linux/generic
diff --git a/sysdeps/unix/sysv/linux/or1k/Makefile b/sysdeps/unix/sysv/linux/or1k/Makefile
new file mode 100644
index 0000000000..be20320b2f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/Makefile
@@ -0,0 +1,12 @@
+ifeq ($(subdir),misc)
+  sysdep_routines += prctl or1k_clone
+endif
+
+ifeq ($(subdir),stdlib)
+gen-as-const-headers += ucontext_i.sym
+endif
+
+# pull in __syscall_error routine
+libpthread-routines += sysdep
+librt-routines += sysdep
+
diff --git a/sysdeps/unix/sysv/linux/or1k/configure b/sysdeps/unix/sysv/linux/or1k/configure
new file mode 100644
index 0000000000..5225dfea5b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/configure
@@ -0,0 +1,4 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/or1k.
+
+arch_minimum_kernel=5.4.0
diff --git a/sysdeps/unix/sysv/linux/or1k/configure.ac b/sysdeps/unix/sysv/linux/or1k/configure.ac
new file mode 100644
index 0000000000..6274c4fb02
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/configure.ac
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/or1k.
+
+arch_minimum_kernel=5.4.0
diff --git a/sysdeps/unix/sysv/linux/or1k/shlib-versions b/sysdeps/unix/sysv/linux/or1k/shlib-versions
new file mode 100644
index 0000000000..159653b5c4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/or1k/shlib-versions
@@ -0,0 +1,2 @@
+DEFAULT                 GLIBC_2.35
+ld=ld-linux-or1k.so.1
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 12/13] build-many-glibcs.py: add OpenRISC support
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (10 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 11/13] or1k: Build Infrastructure Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-22 21:04   ` Adhemerval Zanella
  2021-12-10 23:34 ` [PATCH v3 13/13] Documentation for OpenRISC port Stafford Horne
  2021-12-14 20:25 ` [PATCH v3 00/13] Glibc " Adhemerval Zanella
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

---
 scripts/build-many-glibcs.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 6ae2172956..47b2cabc9c 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -334,6 +334,10 @@ class Context(object):
                                  'ccopts': '-mabi=64'}])
         self.add_config(arch='nios2',
                         os_name='linux-gnu')
+        self.add_config(arch='or1k',
+                        os_name='linux-gnu',
+                        variant='soft',
+                        gcc_cfg=['--with-multilib-list=mcmov'])
         self.add_config(arch='powerpc',
                         os_name='linux-gnu',
                         gcc_cfg=['--disable-multilib', '--enable-secureplt'],
@@ -1270,6 +1274,7 @@ def install_linux_headers(policy, cmdlist):
                 'microblaze': 'microblaze',
                 'mips': 'mips',
                 'nios2': 'nios2',
+                'or1k': 'openrisc',
                 'powerpc': 'powerpc',
                 's390': 's390',
                 'riscv32': 'riscv',
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* [PATCH v3 13/13] Documentation for OpenRISC port
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (11 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 12/13] build-many-glibcs.py: add OpenRISC support Stafford Horne
@ 2021-12-10 23:34 ` Stafford Horne
  2021-12-23 12:57   ` Adhemerval Zanella
  2021-12-14 20:25 ` [PATCH v3 00/13] Glibc " Adhemerval Zanella
  13 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-10 23:34 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Openrisc, Stafford Horne

OpenRISC architecture specification:

 https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf

Currently the port as of the 2021-12-07 rebasing has the following test
failures:

 FAIL: timezone/tst-tzset     # Not enough space to create 4GiB file
 FAIL: elf/tst-bz15311        # dynamic ld sort order diff

Writing credits for the port are:

 Stafford Horne  <shorne@gmail.com>
 Christian Svensson  <blue@cmd.nu>
---
 NEWS   | 4 ++++
 README | 1 +
 2 files changed, 5 insertions(+)

diff --git a/NEWS b/NEWS
index 1398cf2e87..f896746574 100644
--- a/NEWS
+++ b/NEWS
@@ -485,6 +485,10 @@ Major new features:
   The latest GCC available at this time (10.2) does not support this level of
   fortification.
 
+* Support for OpenRISC on Linux has been added.
+
+  The OpenRISC pore requires at least Linux 5.4, GCC 11 and binutils 2.35.
+
 Deprecated and removed features, and other changes affecting compatibility:
 
 * The mallinfo function is marked deprecated.  Callers should call
diff --git a/README b/README
index d0f0edb393..3d5a78ccff 100644
--- a/README
+++ b/README
@@ -35,6 +35,7 @@ The GNU C Library supports these configurations for using Linux kernels:
 	microblaze*-*-linux-gnu
 	mips-*-linux-gnu
 	mips64-*-linux-gnu
+	or1k-*-linux-gnu
 	powerpc-*-linux-gnu	Hardware or software floating point, BE only.
 	powerpc64*-*-linux-gnu	Big-endian and little-endian.
 	s390-*-linux-gnu
-- 
2.31.1


^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
                   ` (12 preceding siblings ...)
  2021-12-10 23:34 ` [PATCH v3 13/13] Documentation for OpenRISC port Stafford Horne
@ 2021-12-14 20:25 ` Adhemerval Zanella
  2021-12-15  1:19   ` Adhemerval Zanella
  2021-12-15  5:37   ` Stafford Horne
  13 siblings, 2 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-14 20:25 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> This is the OpenRISC port for glibc that I have been working on.
> 
> Changes since v2:
>  - Fixed suggestions from Joseph Myers:
>    - Fix comment style, and description on top of each file
>    - Make sure macros have parentheses when needed,
>    - Bump required kernel down to 5.4.0 and document
>    - Regenerate arch-syscall.h
>  - Fixed suggestions from Adhemerval:
>    - Remove kernel_stat.h
>    - Just set MMAP2_PAGE_UNIT to 8K
>    - Remove ioctl.c and syscall.c files
>  - Update TCB alignment to 32 bytes
> 
> Changes since v1:
>  - Update api's as suggested by Florian
>  - Remove hard float support
>  - Updates to get all tests passing
>  - Split patch into managable bits similar to recent ARC port
> 
> Documentation:
> 
>   Architecture / ABI docs:
>    https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf
> 
> Test Results:
> 
>   build-many-glibcs.py:
> 
>    PASS with mainline ang gcc-11.
> 
>   Full test suite:
> 
>    The full suite is running using the gcc-11 branch of GCC, mainline shows
>    issues with math soft-fp.
> 
>    Note, there are a few more failures compared to before, this is due to me
>    running with a timeout of 30 vs usual 300.  It allows the tests to complete
>    faster, but I get a few more timeouts.  There were 15 timeouts which I
>    confirm do work if I increase the timeoutfactor. The 2 real failures marked
>    with * below.
> 
>     # test start:    2021-12-08T19:59:00+09:00
> 
>     # failures
>     FAIL:*elf/tst-bz15311

This seems to be a real issue, the output shows the new sorting algorithm seems 
not be enabled (the output shows the destructor order for dynamic_sort=1).  We 
need to figure out what is happening here.

>     FAIL: locale/tst-localedef-path-norm
>     FAIL: malloc/tst-dynarray-fail
>     FAIL: malloc/tst-dynarray-fail-mem
>     FAIL: nptl/tst-mutex10
>     FAIL: nss/tst-nss-files-hosts-getent
>     FAIL: nss/tst-nss-files-hosts-multi
>     FAIL: posix/tst-regcomp-truncated
>     FAIL: stdio-common/tst-vfprintf-width-prec
>     FAIL: stdio-common/tst-vfprintf-width-prec-alloc
>     FAIL: stdio-common/tst-vfprintf-width-prec-mem
>     FAIL: string/test-memcpy
>     FAIL: string/test-memcpy-large
>     FAIL: string/test-mempcpy
>     FAIL: string/tst-cmp
>     FAIL: support/tst-support_blob_repeat
>     FAIL:*timezone/tst-tzset

It seems the testing file system does not support sparse files or at least
has some limits of the file size and support_descriptor_supports_holes is
no deteting it.

I think we should use a large write_offset and block_headroom, maybe
something larger than 32-bit offset to actually check it.  Could you
check if increasing both values does make the test unsupported.

> 
>     # test finish:   2021-12-10T22:04:56+09:00
>     # test duration: 2 days 2 hours 5 minutes and 56 seconds
>     # test for file: tests.sum
>     # test wrapper:  /home/shorne/work/gnu-toolchain/glibc/scripts/cross-test-ssh.sh --timeoutfactor 30 10.0.0.5
> 
>     # summary
> 	 17 FAIL
>        4063 PASS
> 	 28 UNSUPPORTED
> 	 18 XFAIL
> 
>     tst-bz15311.out: https://gist.github.com/5a5dacaeef1eac1f2f5d89701d14c0ad
>     tst-tzset.out: https://gist.github.com/b3a548d82cfc9367905e115821a52754
>     tests.sum:     https://gist.github.com/f85a81012c8329b9a95370a30c7b27fe

Since 8d1927d8dc5aad0f01c929123086be3a5b799d18 it will need an additional
fix to correctly build glibc:

diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
index dc11610920..3fc63eb4e8 100644
--- a/sysdeps/or1k/nptl/tls.h
+++ b/sysdeps/or1k/nptl/tls.h
@@ -150,6 +150,8 @@ register tcbhead_t *__thread_self __asm__("r10");
 # define DB_THREAD_SELF \
   REGISTER (32, 32, 10 * 4, - TLS_INIT_TCB_SIZE - TLS_PRE_TCB_SIZE)
 
+# include <tcb-access.h>
+
 /* Access to data in the thread descriptor is easy.  */
 
 #define THREAD_GETMEM(descr, member) \

With the above fix I can bootstrap a compiler with build-many-glibcs.py.

> 
> Stafford Horne (13):
>   elf: Add reloc for OpenRISC
>   linux/syscalls: Add or1k_atomic syscall for OpenRISC
>   or1k: ABI Implementation
>   or1k: startup and dynamic linking code
>   or1k: Thread Local Storage support
>   or1k: Atomics and Locking primitives
>   or1k: math soft float support
>   or1k: Linux Syscall Interface
>   or1k: Linux ABI
>   or1k: ABI lists
>   or1k: Build Infrastructure
>   build-many-glibcs.py: add OpenRISC support
>   Documentation for OpenRISC port
> 
>  NEWS                                          |    4 +
>  README                                        |    1 +
>  elf/elf.h                                     |   37 +
>  scripts/build-many-glibcs.py                  |    5 +
>  sysdeps/or1k/Implies                          |    3 +
>  sysdeps/or1k/Makefile                         |    7 +
>  sysdeps/or1k/__longjmp.S                      |   55 +
>  sysdeps/or1k/atomic-machine.h                 |   79 +
>  sysdeps/or1k/bits/endianness.h                |   11 +
>  sysdeps/or1k/bits/fenv.h                      |   69 +
>  sysdeps/or1k/bits/link.h                      |   51 +
>  sysdeps/or1k/bits/setjmp.h                    |   32 +
>  sysdeps/or1k/bsd-_setjmp.S                    |    1 +
>  sysdeps/or1k/bsd-setjmp.S                     |    1 +
>  sysdeps/or1k/dl-machine.h                     |  323 +++
>  sysdeps/or1k/dl-start.S                       |   98 +
>  sysdeps/or1k/dl-tls.h                         |   27 +
>  sysdeps/or1k/dl-trampoline.S                  |   79 +
>  sysdeps/or1k/jmpbuf-offsets.h                 |   23 +
>  sysdeps/or1k/jmpbuf-unwind.h                  |   36 +
>  sysdeps/or1k/ldsodefs.h                       |   40 +
>  sysdeps/or1k/libc-tls.c                       |   34 +
>  sysdeps/or1k/libm-test-ulps                   | 1112 +++++++++
>  sysdeps/or1k/libm-test-ulps-name              |    1 +
>  sysdeps/or1k/machine-gmon.h                   |   35 +
>  sysdeps/or1k/memusage.h                       |   21 +
>  sysdeps/or1k/nofpu/Implies                    |    1 +
>  sysdeps/or1k/nofpu/math-tests-exceptions.h    |   29 +
>  sysdeps/or1k/nofpu/math-tests-rounding.h      |   28 +
>  sysdeps/or1k/nptl/Makefile                    |   21 +
>  sysdeps/or1k/nptl/bits/pthreadtypes-arch.h    |   48 +
>  sysdeps/or1k/nptl/pthreaddef.h                |   36 +
>  sysdeps/or1k/nptl/tcb-offsets.sym             |    6 +
>  sysdeps/or1k/nptl/tls.h                       |  189 ++
>  sysdeps/or1k/preconfigure                     |   34 +
>  sysdeps/or1k/setjmp.S                         |   56 +
>  sysdeps/or1k/sfp-machine.h                    |   93 +
>  sysdeps/or1k/sotruss-lib.c                    |   51 +
>  sysdeps/or1k/stackinfo.h                      |   34 +
>  sysdeps/or1k/start.S                          |   99 +
>  sysdeps/or1k/sysdep.h                         |   83 +
>  sysdeps/or1k/tininess.h                       |    1 +
>  sysdeps/or1k/tst-audit.h                      |   24 +
>  sysdeps/unix/sysv/linux/or1k/Implies          |    3 +
>  sysdeps/unix/sysv/linux/or1k/Makefile         |   12 +
>  sysdeps/unix/sysv/linux/or1k/arch-syscall.h   |  325 +++
>  sysdeps/unix/sysv/linux/or1k/bits/procfs.h    |   38 +
>  sysdeps/unix/sysv/linux/or1k/bits/timesize.h  |   19 +
>  sysdeps/unix/sysv/linux/or1k/c++-types.data   |   67 +
>  sysdeps/unix/sysv/linux/or1k/clone.c          |   61 +
>  sysdeps/unix/sysv/linux/or1k/configure        |    4 +
>  sysdeps/unix/sysv/linux/or1k/configure.ac     |    4 +
>  sysdeps/unix/sysv/linux/or1k/getcontext.S     |   72 +
>  sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h |   41 +
>  sysdeps/unix/sysv/linux/or1k/ld.abilist       |    5 +
>  .../sysv/linux/or1k/libBrokenLocale.abilist   |    1 +
>  sysdeps/unix/sysv/linux/or1k/libanl.abilist   |    1 +
>  sysdeps/unix/sysv/linux/or1k/libc.abilist     | 2122 +++++++++++++++++
>  .../sysv/linux/or1k/libc_malloc_debug.abilist |   26 +
>  sysdeps/unix/sysv/linux/or1k/libcrypt.abilist |    2 +
>  sysdeps/unix/sysv/linux/or1k/libdl.abilist    |    0
>  sysdeps/unix/sysv/linux/or1k/libm.abilist     |  759 ++++++
>  sysdeps/unix/sysv/linux/or1k/libnsl.abilist   |  121 +
>  .../unix/sysv/linux/or1k/libpthread.abilist   |    0
>  .../unix/sysv/linux/or1k/libresolv.abilist    |   55 +
>  sysdeps/unix/sysv/linux/or1k/librt.abilist    |    0
>  .../unix/sysv/linux/or1k/libthread_db.abilist |   40 +
>  sysdeps/unix/sysv/linux/or1k/libutil.abilist  |    1 +
>  sysdeps/unix/sysv/linux/or1k/localplt.data    |   14 +
>  sysdeps/unix/sysv/linux/or1k/makecontext.c    |   77 +
>  sysdeps/unix/sysv/linux/or1k/mmap_internal.h  |   28 +
>  sysdeps/unix/sysv/linux/or1k/or1k_clone.S     |   89 +
>  sysdeps/unix/sysv/linux/or1k/setcontext.S     |  108 +
>  sysdeps/unix/sysv/linux/or1k/shlib-versions   |    2 +
>  sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h |   28 +
>  sysdeps/unix/sysv/linux/or1k/swapcontext.S    |  116 +
>  sysdeps/unix/sysv/linux/or1k/sys/ucontext.h   |   53 +
>  sysdeps/unix/sysv/linux/or1k/sys/user.h       |    1 +
>  sysdeps/unix/sysv/linux/or1k/sysdep.c         |   34 +
>  sysdeps/unix/sysv/linux/or1k/sysdep.h         |  201 ++
>  sysdeps/unix/sysv/linux/or1k/ucontext_i.sym   |   26 +
>  sysdeps/unix/sysv/linux/syscall-names.list    |    1 +
>  82 files changed, 7575 insertions(+)
>  create mode 100644 sysdeps/or1k/Implies
>  create mode 100644 sysdeps/or1k/Makefile
>  create mode 100644 sysdeps/or1k/__longjmp.S
>  create mode 100644 sysdeps/or1k/atomic-machine.h
>  create mode 100644 sysdeps/or1k/bits/endianness.h
>  create mode 100644 sysdeps/or1k/bits/fenv.h
>  create mode 100644 sysdeps/or1k/bits/link.h
>  create mode 100644 sysdeps/or1k/bits/setjmp.h
>  create mode 100644 sysdeps/or1k/bsd-_setjmp.S
>  create mode 100644 sysdeps/or1k/bsd-setjmp.S
>  create mode 100644 sysdeps/or1k/dl-machine.h
>  create mode 100644 sysdeps/or1k/dl-start.S
>  create mode 100644 sysdeps/or1k/dl-tls.h
>  create mode 100644 sysdeps/or1k/dl-trampoline.S
>  create mode 100644 sysdeps/or1k/jmpbuf-offsets.h
>  create mode 100644 sysdeps/or1k/jmpbuf-unwind.h
>  create mode 100644 sysdeps/or1k/ldsodefs.h
>  create mode 100644 sysdeps/or1k/libc-tls.c
>  create mode 100644 sysdeps/or1k/libm-test-ulps
>  create mode 100644 sysdeps/or1k/libm-test-ulps-name
>  create mode 100644 sysdeps/or1k/machine-gmon.h
>  create mode 100644 sysdeps/or1k/memusage.h
>  create mode 100644 sysdeps/or1k/nofpu/Implies
>  create mode 100644 sysdeps/or1k/nofpu/math-tests-exceptions.h
>  create mode 100644 sysdeps/or1k/nofpu/math-tests-rounding.h
>  create mode 100644 sysdeps/or1k/nptl/Makefile
>  create mode 100644 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
>  create mode 100644 sysdeps/or1k/nptl/pthreaddef.h
>  create mode 100644 sysdeps/or1k/nptl/tcb-offsets.sym
>  create mode 100644 sysdeps/or1k/nptl/tls.h
>  create mode 100644 sysdeps/or1k/preconfigure
>  create mode 100644 sysdeps/or1k/setjmp.S
>  create mode 100644 sysdeps/or1k/sfp-machine.h
>  create mode 100644 sysdeps/or1k/sotruss-lib.c
>  create mode 100644 sysdeps/or1k/stackinfo.h
>  create mode 100644 sysdeps/or1k/start.S
>  create mode 100644 sysdeps/or1k/sysdep.h
>  create mode 100644 sysdeps/or1k/tininess.h
>  create mode 100644 sysdeps/or1k/tst-audit.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/Implies
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/Makefile
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/arch-syscall.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/procfs.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/timesize.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/c++-types.data
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/clone.c
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure.ac
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/getcontext.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/ld.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libanl.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libc.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libc_malloc_debug.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libcrypt.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libdl.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libm.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libnsl.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libpthread.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libresolv.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/librt.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libthread_db.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libutil.abilist
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/localplt.data
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/makecontext.c
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/mmap_internal.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/or1k_clone.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/setcontext.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/shlib-versions
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/swapcontext.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/user.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.c
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> 

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 01/13] elf: Add reloc for OpenRISC
  2021-12-10 23:34 ` [PATCH v3 01/13] elf: Add reloc for OpenRISC Stafford Horne
@ 2021-12-14 20:28   ` Adhemerval Zanella
  0 siblings, 0 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-14 20:28 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc

The values match binutils ones.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> ---
>  elf/elf.h | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/elf/elf.h b/elf/elf.h
> index baa6c6693e..18458e4d04 100644
> --- a/elf/elf.h
> +++ b/elf/elf.h
> @@ -4125,4 +4125,41 @@ enum
>  #define R_ARC_TLS_LE_S9		0x4a
>  #define R_ARC_TLS_LE_32		0x4b
>  
> +/* OpenRISC 1000 specific relocs.  */
> +#define R_OR1K_NONE		0
> +#define R_OR1K_32		1
> +#define R_OR1K_16		2
> +#define R_OR1K_8		3
> +#define R_OR1K_LO_16_IN_INSN	4
> +#define R_OR1K_HI_16_IN_INSN	5
> +#define R_OR1K_INSN_REL_26	6
> +#define R_OR1K_GNU_VTENTRY	7
> +#define R_OR1K_GNU_VTINHERIT	8
> +#define R_OR1K_32_PCREL		9
> +#define R_OR1K_16_PCREL		10
> +#define R_OR1K_8_PCREL		11
> +#define R_OR1K_GOTPC_HI16	12
> +#define R_OR1K_GOTPC_LO16	13
> +#define R_OR1K_GOT16		14
> +#define R_OR1K_PLT26		15
> +#define R_OR1K_GOTOFF_HI16	16
> +#define R_OR1K_GOTOFF_LO16	17
> +#define R_OR1K_COPY		18
> +#define R_OR1K_GLOB_DAT		19
> +#define R_OR1K_JMP_SLOT		20
> +#define R_OR1K_RELATIVE		21
> +#define R_OR1K_TLS_GD_HI16	22
> +#define R_OR1K_TLS_GD_LO16	23
> +#define R_OR1K_TLS_LDM_HI16	24
> +#define R_OR1K_TLS_LDM_LO16	25
> +#define R_OR1K_TLS_LDO_HI16	26
> +#define R_OR1K_TLS_LDO_LO16	27
> +#define R_OR1K_TLS_IE_HI16	28
> +#define R_OR1K_TLS_IE_LO16	29
> +#define R_OR1K_TLS_LE_HI16	30
> +#define R_OR1K_TLS_LE_LO16	31
> +#define R_OR1K_TLS_TPOFF	32
> +#define R_OR1K_TLS_DTPOFF	33
> +#define R_OR1K_TLS_DTPMOD	34
> +
>  #endif	/* elf.h */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 02/13] linux/syscalls: Add or1k_atomic syscall for OpenRISC
  2021-12-10 23:34 ` [PATCH v3 02/13] linux/syscalls: Add or1k_atomic syscall " Stafford Horne
@ 2021-12-14 20:29   ` Adhemerval Zanella
  0 siblings, 0 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-14 20:29 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc

It matches kernel definition.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> ---
>  sysdeps/unix/sysv/linux/syscall-names.list | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/syscall-names.list b/sysdeps/unix/sysv/linux/syscall-names.list
> index 1a74d090b7..a72dee6275 100644
> --- a/sysdeps/unix/sysv/linux/syscall-names.list
> +++ b/sysdeps/unix/sysv/linux/syscall-names.list
> @@ -304,6 +304,7 @@ open_by_handle_at
>  open_tree
>  openat
>  openat2
> +or1k_atomic
>  osf_adjtime
>  osf_afs_syscall
>  osf_alt_plock

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 03/13] or1k: ABI Implementation
  2021-12-10 23:34 ` [PATCH v3 03/13] or1k: ABI Implementation Stafford Horne
@ 2021-12-14 20:53   ` Adhemerval Zanella
  2021-12-14 22:43     ` Joseph Myers
  2021-12-16 21:28     ` Stafford Horne
  0 siblings, 2 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-14 20:53 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> This code deals with the OpenRISC ABI.

Some comments below.

> ---
>  sysdeps/or1k/__longjmp.S       | 55 ++++++++++++++++++++++
>  sysdeps/or1k/bits/endianness.h | 11 +++++
>  sysdeps/or1k/bits/setjmp.h     | 32 +++++++++++++
>  sysdeps/or1k/bsd-_setjmp.S     |  1 +
>  sysdeps/or1k/bsd-setjmp.S      |  1 +
>  sysdeps/or1k/dl-trampoline.S   | 79 ++++++++++++++++++++++++++++++++
>  sysdeps/or1k/jmpbuf-offsets.h  | 23 ++++++++++
>  sysdeps/or1k/jmpbuf-unwind.h   | 36 +++++++++++++++
>  sysdeps/or1k/machine-gmon.h    | 35 ++++++++++++++
>  sysdeps/or1k/memusage.h        | 21 +++++++++
>  sysdeps/or1k/setjmp.S          | 56 +++++++++++++++++++++++
>  sysdeps/or1k/sysdep.h          | 83 ++++++++++++++++++++++++++++++++++
>  12 files changed, 433 insertions(+)
>  create mode 100644 sysdeps/or1k/__longjmp.S
>  create mode 100644 sysdeps/or1k/bits/endianness.h
>  create mode 100644 sysdeps/or1k/bits/setjmp.h
>  create mode 100644 sysdeps/or1k/bsd-_setjmp.S
>  create mode 100644 sysdeps/or1k/bsd-setjmp.S
>  create mode 100644 sysdeps/or1k/dl-trampoline.S
>  create mode 100644 sysdeps/or1k/jmpbuf-offsets.h
>  create mode 100644 sysdeps/or1k/jmpbuf-unwind.h
>  create mode 100644 sysdeps/or1k/machine-gmon.h
>  create mode 100644 sysdeps/or1k/memusage.h
>  create mode 100644 sysdeps/or1k/setjmp.S
>  create mode 100644 sysdeps/or1k/sysdep.h
> 
> diff --git a/sysdeps/or1k/__longjmp.S b/sysdeps/or1k/__longjmp.S
> new file mode 100644
> index 0000000000..f8aa5dda8f
> --- /dev/null
> +++ b/sysdeps/or1k/__longjmp.S
> @@ -0,0 +1,55 @@
> +/* longjmp, OpenRISC version.
> +   Copyright (C) 2021 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, write to the Free
> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> +   02111-1307 USA.  */
> +
> +#include <features.h>
> +#define _ASM
> +#define _SETJMP_H
> +#include <bits/setjmp.h>
> +
> +	.globl	__longjmp;
> +	.type	__longjmp, @function;
> +	.align	4;
> +
> +__longjmp:

Use ENTRY/END here, as other setjmp functions are doing.

> +	l.lwz	r1, 0(r3)
> +	l.lwz	r2, 4(r3)
> +
> +	/* if r4 is 0, something wrong, so set it to 1 */
> +	l.sfeqi	r4, 0x0
> +	l.bnf	1f		/* r4 != 0, longjmp value sensible */
> +	 l.nop
> +	l.ori	r4, r0, 0x1	/* make nonzero */
> +1:
> +	l.addi	r11, r4, 0
> +	l.lwz	r9, 8(r3)
> +	l.lwz	r10, 12(r3)
> +	l.lwz	r14, 16(r3)
> +	l.lwz	r16, 20(r3)
> +	l.lwz	r18, 24(r3)
> +	l.lwz	r20, 28(r3)
> +	l.lwz	r22, 32(r3)
> +	l.lwz	r24, 36(r3)
> +	l.lwz	r26, 40(r3)
> +	l.lwz	r28, 44(r3)
> +	l.lwz	r30, 48(r3)
> +	l.jr	r9
> +	 l.nop
> +	.size	__longjmp, . - __longjmp
> +
> +libc_hidden_def(__longjmp)
> diff --git a/sysdeps/or1k/bits/endianness.h b/sysdeps/or1k/bits/endianness.h
> new file mode 100644
> index 0000000000..7b61d8adb7
> --- /dev/null
> +++ b/sysdeps/or1k/bits/endianness.h
> @@ -0,0 +1,11 @@
> +#ifndef _BITS_ENDIANNESS_H
> +#define _BITS_ENDIANNESS_H 1
> +
> +#ifndef _BITS_ENDIAN_H
> +# error "Never use <bits/endianness.h> directly; include <endian.h> instead."
> +#endif
> +
> +/* OpenRISC is big-endian.  */
> +#define __BYTE_ORDER __BIG_ENDIAN
> +
> +#endif /* bits/endianness.h */

Ok.

> diff --git a/sysdeps/or1k/bits/setjmp.h b/sysdeps/or1k/bits/setjmp.h
> new file mode 100644
> index 0000000000..dac511c904
> --- /dev/null
> +++ b/sysdeps/or1k/bits/setjmp.h
> @@ -0,0 +1,32 @@
> +/* Define the machine-dependent type `jmp_buf'.  OpenRISC version.
> +   Copyright (C) 2021 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, write to the Free
> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> +   02111-1307 USA.  */
> +
> +
> +#ifndef _OR1K_BITS_SETJMP_H
> +#define _OR1K_BITS_SETJMP_H  1
> +
> +#if !defined _SETJMP_H && !defined _PTHREAD_H
> +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
> +#endif
> +
> +#ifndef _ASM
> +typedef long int __jmp_buf[13];
> +#endif
> +
> +#endif /* _OR1K_BITS_SETJMP_H */

Ok.

> diff --git a/sysdeps/or1k/bsd-_setjmp.S b/sysdeps/or1k/bsd-_setjmp.S
> new file mode 100644
> index 0000000000..4e6a2da560
> --- /dev/null
> +++ b/sysdeps/or1k/bsd-_setjmp.S
> @@ -0,0 +1 @@
> +/* _setjmp is in setjmp.S  */
> diff --git a/sysdeps/or1k/bsd-setjmp.S b/sysdeps/or1k/bsd-setjmp.S
> new file mode 100644
> index 0000000000..1da848d2f1
> --- /dev/null
> +++ b/sysdeps/or1k/bsd-setjmp.S
> @@ -0,0 +1 @@
> +/* setjmp is in setjmp.S  */
> diff --git a/sysdeps/or1k/dl-trampoline.S b/sysdeps/or1k/dl-trampoline.S
> new file mode 100644
> index 0000000000..9ebc68f525
> --- /dev/null
> +++ b/sysdeps/or1k/dl-trampoline.S
> @@ -0,0 +1,79 @@
> +/* Machine-dependent ELF runtime symbol resolution, OpenRISC version.
> +   Copyright (C) 2021 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, write to the Free
> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> +   02111-1307 USA.  */
> +
> +/* This code is used to call _dl_linux_resolver (dl-runtime.c).
> +
> +   We assume that R11 contains the relocation offset and R12 contains
> +   link_map (_DYNAMIC).  This must be consistent with the JUMP_SLOT
> +   layout generated by binutils.  */
> +
> +	.section .text
> +	.align 4
> +
> +	.global	_dl_runtime_resolve
> +	.type	_dl_runtime_resolve, @function
> +
> +_dl_runtime_resolve:
> +	.cfi_startproc
> +	l.sw	-4(r1), r9
> +	l.sw	-8(r1), r1
> +
> +	/* save function arguments.  */
> +	l.sw	-12(r1), r3
> +	l.sw	-16(r1), r4
> +	l.sw	-20(r1), r5
> +	l.sw	-24(r1), r6
> +	l.sw	-28(r1), r7
> +	l.sw	-32(r1), r8
> +
> +	.cfi_offset 9, -4
> +	.cfi_offset 1, -8
> +	.cfi_offset 3, -12
> +	.cfi_offset 4, -16
> +	.cfi_offset 5, -20
> +	.cfi_offset 6, -24
> +	.cfi_offset 7, -28
> +	.cfi_offset 8, -32
> +
> +	l.addi	r1,r1, -32
> +	.cfi_def_cfa_offset 32
> +
> +	l.ori	r3, r12, 0
> +	l.ori	r4, r11, 0
> +
> +	l.jal	_dl_fixup
> +	 l.nop
> +
> +	/* Restore function arguments.  */
> +	l.addi	r1,r1, 32
> +	l.lwz	r8, -32(r1)
> +	l.lwz	r7, -28(r1)
> +	l.lwz	r6, -24(r1)
> +	l.lwz	r5, -20(r1)
> +	l.lwz	r4, -16(r1)
> +	l.lwz	r3, -12(r1)
> +
> +	/* restore return address.  */
> +	l.lwz	r9, -4(r1)
> +
> +	l.jr	r11
> +	 l.nop
> +
> +	.cfi_endproc
> +	.size	_dl_runtime_resolve, . - _dl_runtime_resolve

It seems that _dl_runtime_profile is not implemented and explicit disabled
on sysdeps/or1k/dl-machine.h.  In this case I think it would be better to
explicit disable it on configure:

diff --git a/configure.ac b/configure.ac
index 277d3527d2..6883069b36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,6 +525,9 @@ libc_config_ok=no
 # whether to use such directories.
 with_fp_cond=1
 
+# A preconfigure script may disable profile support
+with_profile=yes
+
 dnl Let sysdeps/*/preconfigure act here.
 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
 
@@ -1891,6 +1894,12 @@ LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
 AC_SUBST(libc_cv_multidir)
 
+if test "x$profile" != xno; then
+  if test "x$with_profile" == xno; then
+    AC_MSG_ERROR([ABI does not support profiling])
+  fi
+fi
+
 AC_SUBST(profile)
 AC_SUBST(static_nss)
 
diff --git a/sysdeps/or1k/preconfigure b/sysdeps/or1k/preconfigure
index d1b1fb1843..b8d4f8c716 100644
--- a/sysdeps/or1k/preconfigure
+++ b/sysdeps/or1k/preconfigure
@@ -32,3 +32,4 @@ or1k*)
   ;;
 esac
 
+with_profile=no


> diff --git a/sysdeps/or1k/jmpbuf-offsets.h b/sysdeps/or1k/jmpbuf-offsets.h
> new file mode 100644
> index 0000000000..e33105cc03
> --- /dev/null
> +++ b/sysdeps/or1k/jmpbuf-offsets.h
> @@ -0,0 +1,23 @@
> +/* Private macros for accessing __jmp_buf contents.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define __JMP_BUF_SP    0
> +
> +/* Helper for generic function ____longjmp_chk.  */
> +#define JB_FRAME_ADDRESS(buf) \
> +    ((void *) (unsigned long) (buf[__JMP_BUF_SP]))
> diff --git a/sysdeps/or1k/jmpbuf-unwind.h b/sysdeps/or1k/jmpbuf-unwind.h
> new file mode 100644
> index 0000000000..6710dea989
> --- /dev/null
> +++ b/sysdeps/or1k/jmpbuf-unwind.h
> @@ -0,0 +1,36 @@
> +/* Macros to help frame unwinding using jmpbuf.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <setjmp.h>
> +#include <jmpbuf-offsets.h>
> +#include <stdint.h>
> +#include <unwind.h>
> +
> +/* Test if longjmp to JMPBUF would unwind the frame
> +   containing a local variable at ADDRESS.  */
> +#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
> +  ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
> +
> +#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
> +  _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
> +
> +#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
> +  ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
> +
> +/* We use the normal longjmp for unwinding.  */
> +#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
> diff --git a/sysdeps/or1k/machine-gmon.h b/sysdeps/or1k/machine-gmon.h
> new file mode 100644
> index 0000000000..7152105eec
> --- /dev/null
> +++ b/sysdeps/or1k/machine-gmon.h
> @@ -0,0 +1,35 @@
> +/* Machine-dependent definitions for profiling support.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +
> +#define _MCOUNT_DECL(frompc, selfpc)					\
> +static void								\
> +__mcount_internal (unsigned long int frompc, unsigned long int selfpc)
> +
> +/* This is very simple as gcc does all the heavy lifting at the _mcount
> +   call site.  GCC passes in the return address of the function calling
> +   _mcount.  */
> +
> +#define MCOUNT								\
> +void									\
> +_mcount (void *frompc)							\
> +{									\
> +  __mcount_internal ((unsigned long int) frompc,			\
> +		     (unsigned long int) __builtin_return_address (0));	\
> +}
> diff --git a/sysdeps/or1k/memusage.h b/sysdeps/or1k/memusage.h
> new file mode 100644
> index 0000000000..a62da17e61
> --- /dev/null
> +++ b/sysdeps/or1k/memusage.h
> @@ -0,0 +1,21 @@
> +/* Definitions for memory usage profiling.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define GETSP() ({ register uintptr_t stack_ptr asm ("r1"); stack_ptr; })
> +
> +#include <sysdeps/generic/memusage.h>
> diff --git a/sysdeps/or1k/setjmp.S b/sysdeps/or1k/setjmp.S
> new file mode 100644
> index 0000000000..660995b493
> --- /dev/null
> +++ b/sysdeps/or1k/setjmp.S
> @@ -0,0 +1,56 @@
> +/* setjmp, OpenRISC version.
> +   Copyright (C) 2021 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, write to the Free
> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> +   02111-1307 USA.  */
> +
> +#include <sysdep.h>
> +#define _ASM
> +#define _SETJMP_H
> +#include <bits/setjmp.h>
> +
> +ENTRY (_setjmp)
> +	l.addi	r4, r0, 0     /* Set second argument to 0.  */
> +	l.j	.Local__sigsetjmp
> +	 l.nop
> +END (_setjmp)
> +libc_hidden_def (_setjmp)
> +
> +ENTRY (setjmp)
> +	l.addi	r4, r0, 1     /* Set second argument to 1.  */
> +	l.j	.Local__sigsetjmp
> +	 l.nop
> +END (setjmp)
> +
> +ENTRY (__sigsetjmp)
> +.Local__sigsetjmp:
> +	l.sw	0(r3), r1
> +	l.sw	4(r3), r2
> +	l.sw	8(r3), r9
> +	l.sw	12(r3), r10
> +	l.sw	16(r3), r14
> +	l.sw	20(r3), r16
> +	l.sw	24(r3), r18
> +	l.sw	28(r3), r20
> +	l.sw	32(r3), r22
> +	l.sw	36(r3), r24
> +	l.sw	40(r3), r26
> +	l.sw	44(r3), r28
> +	l.sw	48(r3), r30
> +	l.j	__sigjmp_save
> +	 l.nop
> +END (__sigsetjmp)
> +hidden_def (__sigsetjmp)
> diff --git a/sysdeps/or1k/sysdep.h b/sysdeps/or1k/sysdep.h
> new file mode 100644
> index 0000000000..61a135afe7
> --- /dev/null
> +++ b/sysdeps/or1k/sysdep.h
> @@ -0,0 +1,83 @@
> +/* Assembler macro definitions.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdeps/generic/sysdep.h>
> +#include <features.h>
> +
> +#if defined __ASSEMBLER__ || defined REQUEST_ASSEMBLER_MACROS
> +
> +/* Make use of .size directive.  */
> +#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
> +
> +/* Define an entry point visible from C.  */
> +#define ENTRY(name)                                                           \
> +  .globl C_SYMBOL_NAME(name);                                                 \
> +  .type C_SYMBOL_NAME(name),@function;                                        \
> +  .align 4;                                                                   \
> +  C_LABEL(name)                                                               \
> +  cfi_startproc;                                                              \
> +  CALL_MCOUNT
> +
> +#undef  END
> +#define END(name)                                                             \
> +  cfi_endproc;                                                                \
> +  ASM_SIZE_DIRECTIVE(name)
> +
> +/* Since C identifiers are not normally prefixed with an underscore
> +   on this system, the asm identifier `syscall_error' intrudes on the
> +   C name space.  Make sure we use an innocuous name.  */
> +#define syscall_error   __syscall_error
> +
> +/* If compiled for profiling, call `mcount' at the start of each function.  */
> +#ifdef  PROF
> +# ifdef __PIC__
> +#  define CALL_MCOUNT						\
> +	l.addi	r1, r1, -8;					\
> +	l.sw	0(r1), r9;					\
> +	l.sw	4(r1), r3;					\
> +	l.ori	r3, r9, 0;					\
> +	l.j	plt(_mcount);					\
> +	 l.nop;							\
> +	l.lwz	r9, 0(r1);					\
> +	l.lwz	r3, 4(r1);					\
> +	l.addi	r1, r1, 8;
> +# else
> +#  define CALL_MCOUNT						\
> +	l.addi	r1, r1, -8;					\
> +	l.sw	0(r1), r9;					\
> +	l.sw	4(r1), r3;					\
> +	l.ori	r3, r9, 0;					\
> +	l.movhi r15, hi(_mcount);				\
> +	l.ori	r15, r15, lo(_mcount);				\
> +	l.jr	r15;						\
> +	 l.nop;							\
> +	l.lwz	r9, 0(r1);					\
> +	l.lwz	r3, 4(r1);					\
> +	l.addi	r1, r1, 8;
> +# endif
> +#else
> +# define CALL_MCOUNT             /* Do nothing.  */
> +#endif
> +
> +/* Local label name for asm code.  */
> +#define L(name)         .L##name
> +
> +/* Specify the size in bytes of a machine register.  */
> +#define REGSIZE         4
> +
> +#endif /* __ASSEMBLER__ */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 03/13] or1k: ABI Implementation
  2021-12-14 20:53   ` Adhemerval Zanella
@ 2021-12-14 22:43     ` Joseph Myers
  2021-12-15  1:15       ` Adhemerval Zanella
  2021-12-16 21:28     ` Stafford Horne
  1 sibling, 1 reply; 61+ messages in thread
From: Joseph Myers @ 2021-12-14 22:43 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Stafford Horne, GLIBC patches, Openrisc

On Tue, 14 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:

> +if test "x$profile" != xno; then
> +  if test "x$with_profile" == xno; then
> +    AC_MSG_ERROR([ABI does not support profiling])

Using == in test is a bashism.

I'd expect such a change to require the build-many-glibcs.py configuration 
for OpenRISC to use --disable-profile.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 03/13] or1k: ABI Implementation
  2021-12-14 22:43     ` Joseph Myers
@ 2021-12-15  1:15       ` Adhemerval Zanella
  2021-12-15 23:33         ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-15  1:15 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Stafford Horne, GLIBC patches, Openrisc



On 14/12/2021 19:43, Joseph Myers wrote:
> On Tue, 14 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:
> 
>> +if test "x$profile" != xno; then
>> +  if test "x$with_profile" == xno; then
>> +    AC_MSG_ERROR([ABI does not support profiling])
> 
> Using == in test is a bashism.
> 
> I'd expect such a change to require the build-many-glibcs.py configuration 
> for OpenRISC to use --disable-profile.
> 

I ended up mixing up things and what or1k does not support is LD_PROFILE
instead of --enable-profile.  In this case I am not sure if it would
be better to just not enable it (by ignoring the LD_PROFILE handling
in rtld.c or dl-support.c) and emitting a warning or by just dumping
and error at process initialization.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-14 20:25 ` [PATCH v3 00/13] Glibc " Adhemerval Zanella
@ 2021-12-15  1:19   ` Adhemerval Zanella
  2021-12-15  5:34     ` Stafford Horne
  2021-12-15  5:37   ` Stafford Horne
  1 sibling, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-15  1:19 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches, Florian Weimer; +Cc: Openrisc



On 14/12/2021 17:25, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
>> This is the OpenRISC port for glibc that I have been working on.
>>
>> Changes since v2:
>>  - Fixed suggestions from Joseph Myers:
>>    - Fix comment style, and description on top of each file
>>    - Make sure macros have parentheses when needed,
>>    - Bump required kernel down to 5.4.0 and document
>>    - Regenerate arch-syscall.h
>>  - Fixed suggestions from Adhemerval:
>>    - Remove kernel_stat.h
>>    - Just set MMAP2_PAGE_UNIT to 8K
>>    - Remove ioctl.c and syscall.c files
>>  - Update TCB alignment to 32 bytes
>>
>> Changes since v1:
>>  - Update api's as suggested by Florian
>>  - Remove hard float support
>>  - Updates to get all tests passing
>>  - Split patch into managable bits similar to recent ARC port
>>
>> Documentation:
>>
>>   Architecture / ABI docs:
>>    https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf
>>
>> Test Results:
>>
>>   build-many-glibcs.py:
>>
>>    PASS with mainline ang gcc-11.
>>
>>   Full test suite:
>>
>>    The full suite is running using the gcc-11 branch of GCC, mainline shows
>>    issues with math soft-fp.
>>
>>    Note, there are a few more failures compared to before, this is due to me
>>    running with a timeout of 30 vs usual 300.  It allows the tests to complete
>>    faster, but I get a few more timeouts.  There were 15 timeouts which I
>>    confirm do work if I increase the timeoutfactor. The 2 real failures marked
>>    with * below.
>>
>>     # test start:    2021-12-08T19:59:00+09:00
>>
>>     # failures
>>     FAIL:*elf/tst-bz15311
> 
> This seems to be a real issue, the output shows the new sorting algorithm seems 
> not be enabled (the output shows the destructor order for dynamic_sort=1).  We 
> need to figure out what is happening here.

It does like the destructor ordering  issue Florian has posted a patch [1].

[1] https://sourceware.org/pipermail/libc-alpha/2021-December/134165.html

> 
>>     FAIL: locale/tst-localedef-path-norm
>>     FAIL: malloc/tst-dynarray-fail
>>     FAIL: malloc/tst-dynarray-fail-mem
>>     FAIL: nptl/tst-mutex10
>>     FAIL: nss/tst-nss-files-hosts-getent
>>     FAIL: nss/tst-nss-files-hosts-multi
>>     FAIL: posix/tst-regcomp-truncated
>>     FAIL: stdio-common/tst-vfprintf-width-prec
>>     FAIL: stdio-common/tst-vfprintf-width-prec-alloc
>>     FAIL: stdio-common/tst-vfprintf-width-prec-mem
>>     FAIL: string/test-memcpy
>>     FAIL: string/test-memcpy-large
>>     FAIL: string/test-mempcpy
>>     FAIL: string/tst-cmp
>>     FAIL: support/tst-support_blob_repeat
>>     FAIL:*timezone/tst-tzset
> 
> It seems the testing file system does not support sparse files or at least
> has some limits of the file size and support_descriptor_supports_holes is
> no deteting it.
> 
> I think we should use a large write_offset and block_headroom, maybe
> something larger than 32-bit offset to actually check it.  Could you
> check if increasing both values does make the test unsupported.
> 
>>
>>     # test finish:   2021-12-10T22:04:56+09:00
>>     # test duration: 2 days 2 hours 5 minutes and 56 seconds
>>     # test for file: tests.sum
>>     # test wrapper:  /home/shorne/work/gnu-toolchain/glibc/scripts/cross-test-ssh.sh --timeoutfactor 30 10.0.0.5
>>
>>     # summary
>> 	 17 FAIL
>>        4063 PASS
>> 	 28 UNSUPPORTED
>> 	 18 XFAIL
>>
>>     tst-bz15311.out: https://gist.github.com/5a5dacaeef1eac1f2f5d89701d14c0ad
>>     tst-tzset.out: https://gist.github.com/b3a548d82cfc9367905e115821a52754
>>     tests.sum:     https://gist.github.com/f85a81012c8329b9a95370a30c7b27fe
> 
> Since 8d1927d8dc5aad0f01c929123086be3a5b799d18 it will need an additional
> fix to correctly build glibc:
> 
> diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
> index dc11610920..3fc63eb4e8 100644
> --- a/sysdeps/or1k/nptl/tls.h
> +++ b/sysdeps/or1k/nptl/tls.h
> @@ -150,6 +150,8 @@ register tcbhead_t *__thread_self __asm__("r10");
>  # define DB_THREAD_SELF \
>    REGISTER (32, 32, 10 * 4, - TLS_INIT_TCB_SIZE - TLS_PRE_TCB_SIZE)
>  
> +# include <tcb-access.h>
> +
>  /* Access to data in the thread descriptor is easy.  */
>  
>  #define THREAD_GETMEM(descr, member) \
> 
> With the above fix I can bootstrap a compiler with build-many-glibcs.py.
> 
>>
>> Stafford Horne (13):
>>   elf: Add reloc for OpenRISC
>>   linux/syscalls: Add or1k_atomic syscall for OpenRISC
>>   or1k: ABI Implementation
>>   or1k: startup and dynamic linking code
>>   or1k: Thread Local Storage support
>>   or1k: Atomics and Locking primitives
>>   or1k: math soft float support
>>   or1k: Linux Syscall Interface
>>   or1k: Linux ABI
>>   or1k: ABI lists
>>   or1k: Build Infrastructure
>>   build-many-glibcs.py: add OpenRISC support
>>   Documentation for OpenRISC port
>>
>>  NEWS                                          |    4 +
>>  README                                        |    1 +
>>  elf/elf.h                                     |   37 +
>>  scripts/build-many-glibcs.py                  |    5 +
>>  sysdeps/or1k/Implies                          |    3 +
>>  sysdeps/or1k/Makefile                         |    7 +
>>  sysdeps/or1k/__longjmp.S                      |   55 +
>>  sysdeps/or1k/atomic-machine.h                 |   79 +
>>  sysdeps/or1k/bits/endianness.h                |   11 +
>>  sysdeps/or1k/bits/fenv.h                      |   69 +
>>  sysdeps/or1k/bits/link.h                      |   51 +
>>  sysdeps/or1k/bits/setjmp.h                    |   32 +
>>  sysdeps/or1k/bsd-_setjmp.S                    |    1 +
>>  sysdeps/or1k/bsd-setjmp.S                     |    1 +
>>  sysdeps/or1k/dl-machine.h                     |  323 +++
>>  sysdeps/or1k/dl-start.S                       |   98 +
>>  sysdeps/or1k/dl-tls.h                         |   27 +
>>  sysdeps/or1k/dl-trampoline.S                  |   79 +
>>  sysdeps/or1k/jmpbuf-offsets.h                 |   23 +
>>  sysdeps/or1k/jmpbuf-unwind.h                  |   36 +
>>  sysdeps/or1k/ldsodefs.h                       |   40 +
>>  sysdeps/or1k/libc-tls.c                       |   34 +
>>  sysdeps/or1k/libm-test-ulps                   | 1112 +++++++++
>>  sysdeps/or1k/libm-test-ulps-name              |    1 +
>>  sysdeps/or1k/machine-gmon.h                   |   35 +
>>  sysdeps/or1k/memusage.h                       |   21 +
>>  sysdeps/or1k/nofpu/Implies                    |    1 +
>>  sysdeps/or1k/nofpu/math-tests-exceptions.h    |   29 +
>>  sysdeps/or1k/nofpu/math-tests-rounding.h      |   28 +
>>  sysdeps/or1k/nptl/Makefile                    |   21 +
>>  sysdeps/or1k/nptl/bits/pthreadtypes-arch.h    |   48 +
>>  sysdeps/or1k/nptl/pthreaddef.h                |   36 +
>>  sysdeps/or1k/nptl/tcb-offsets.sym             |    6 +
>>  sysdeps/or1k/nptl/tls.h                       |  189 ++
>>  sysdeps/or1k/preconfigure                     |   34 +
>>  sysdeps/or1k/setjmp.S                         |   56 +
>>  sysdeps/or1k/sfp-machine.h                    |   93 +
>>  sysdeps/or1k/sotruss-lib.c                    |   51 +
>>  sysdeps/or1k/stackinfo.h                      |   34 +
>>  sysdeps/or1k/start.S                          |   99 +
>>  sysdeps/or1k/sysdep.h                         |   83 +
>>  sysdeps/or1k/tininess.h                       |    1 +
>>  sysdeps/or1k/tst-audit.h                      |   24 +
>>  sysdeps/unix/sysv/linux/or1k/Implies          |    3 +
>>  sysdeps/unix/sysv/linux/or1k/Makefile         |   12 +
>>  sysdeps/unix/sysv/linux/or1k/arch-syscall.h   |  325 +++
>>  sysdeps/unix/sysv/linux/or1k/bits/procfs.h    |   38 +
>>  sysdeps/unix/sysv/linux/or1k/bits/timesize.h  |   19 +
>>  sysdeps/unix/sysv/linux/or1k/c++-types.data   |   67 +
>>  sysdeps/unix/sysv/linux/or1k/clone.c          |   61 +
>>  sysdeps/unix/sysv/linux/or1k/configure        |    4 +
>>  sysdeps/unix/sysv/linux/or1k/configure.ac     |    4 +
>>  sysdeps/unix/sysv/linux/or1k/getcontext.S     |   72 +
>>  sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h |   41 +
>>  sysdeps/unix/sysv/linux/or1k/ld.abilist       |    5 +
>>  .../sysv/linux/or1k/libBrokenLocale.abilist   |    1 +
>>  sysdeps/unix/sysv/linux/or1k/libanl.abilist   |    1 +
>>  sysdeps/unix/sysv/linux/or1k/libc.abilist     | 2122 +++++++++++++++++
>>  .../sysv/linux/or1k/libc_malloc_debug.abilist |   26 +
>>  sysdeps/unix/sysv/linux/or1k/libcrypt.abilist |    2 +
>>  sysdeps/unix/sysv/linux/or1k/libdl.abilist    |    0
>>  sysdeps/unix/sysv/linux/or1k/libm.abilist     |  759 ++++++
>>  sysdeps/unix/sysv/linux/or1k/libnsl.abilist   |  121 +
>>  .../unix/sysv/linux/or1k/libpthread.abilist   |    0
>>  .../unix/sysv/linux/or1k/libresolv.abilist    |   55 +
>>  sysdeps/unix/sysv/linux/or1k/librt.abilist    |    0
>>  .../unix/sysv/linux/or1k/libthread_db.abilist |   40 +
>>  sysdeps/unix/sysv/linux/or1k/libutil.abilist  |    1 +
>>  sysdeps/unix/sysv/linux/or1k/localplt.data    |   14 +
>>  sysdeps/unix/sysv/linux/or1k/makecontext.c    |   77 +
>>  sysdeps/unix/sysv/linux/or1k/mmap_internal.h  |   28 +
>>  sysdeps/unix/sysv/linux/or1k/or1k_clone.S     |   89 +
>>  sysdeps/unix/sysv/linux/or1k/setcontext.S     |  108 +
>>  sysdeps/unix/sysv/linux/or1k/shlib-versions   |    2 +
>>  sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h |   28 +
>>  sysdeps/unix/sysv/linux/or1k/swapcontext.S    |  116 +
>>  sysdeps/unix/sysv/linux/or1k/sys/ucontext.h   |   53 +
>>  sysdeps/unix/sysv/linux/or1k/sys/user.h       |    1 +
>>  sysdeps/unix/sysv/linux/or1k/sysdep.c         |   34 +
>>  sysdeps/unix/sysv/linux/or1k/sysdep.h         |  201 ++
>>  sysdeps/unix/sysv/linux/or1k/ucontext_i.sym   |   26 +
>>  sysdeps/unix/sysv/linux/syscall-names.list    |    1 +
>>  82 files changed, 7575 insertions(+)
>>  create mode 100644 sysdeps/or1k/Implies
>>  create mode 100644 sysdeps/or1k/Makefile
>>  create mode 100644 sysdeps/or1k/__longjmp.S
>>  create mode 100644 sysdeps/or1k/atomic-machine.h
>>  create mode 100644 sysdeps/or1k/bits/endianness.h
>>  create mode 100644 sysdeps/or1k/bits/fenv.h
>>  create mode 100644 sysdeps/or1k/bits/link.h
>>  create mode 100644 sysdeps/or1k/bits/setjmp.h
>>  create mode 100644 sysdeps/or1k/bsd-_setjmp.S
>>  create mode 100644 sysdeps/or1k/bsd-setjmp.S
>>  create mode 100644 sysdeps/or1k/dl-machine.h
>>  create mode 100644 sysdeps/or1k/dl-start.S
>>  create mode 100644 sysdeps/or1k/dl-tls.h
>>  create mode 100644 sysdeps/or1k/dl-trampoline.S
>>  create mode 100644 sysdeps/or1k/jmpbuf-offsets.h
>>  create mode 100644 sysdeps/or1k/jmpbuf-unwind.h
>>  create mode 100644 sysdeps/or1k/ldsodefs.h
>>  create mode 100644 sysdeps/or1k/libc-tls.c
>>  create mode 100644 sysdeps/or1k/libm-test-ulps
>>  create mode 100644 sysdeps/or1k/libm-test-ulps-name
>>  create mode 100644 sysdeps/or1k/machine-gmon.h
>>  create mode 100644 sysdeps/or1k/memusage.h
>>  create mode 100644 sysdeps/or1k/nofpu/Implies
>>  create mode 100644 sysdeps/or1k/nofpu/math-tests-exceptions.h
>>  create mode 100644 sysdeps/or1k/nofpu/math-tests-rounding.h
>>  create mode 100644 sysdeps/or1k/nptl/Makefile
>>  create mode 100644 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
>>  create mode 100644 sysdeps/or1k/nptl/pthreaddef.h
>>  create mode 100644 sysdeps/or1k/nptl/tcb-offsets.sym
>>  create mode 100644 sysdeps/or1k/nptl/tls.h
>>  create mode 100644 sysdeps/or1k/preconfigure
>>  create mode 100644 sysdeps/or1k/setjmp.S
>>  create mode 100644 sysdeps/or1k/sfp-machine.h
>>  create mode 100644 sysdeps/or1k/sotruss-lib.c
>>  create mode 100644 sysdeps/or1k/stackinfo.h
>>  create mode 100644 sysdeps/or1k/start.S
>>  create mode 100644 sysdeps/or1k/sysdep.h
>>  create mode 100644 sysdeps/or1k/tininess.h
>>  create mode 100644 sysdeps/or1k/tst-audit.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/Implies
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/Makefile
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/arch-syscall.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/procfs.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/timesize.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/c++-types.data
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/clone.c
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure.ac
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/getcontext.S
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/ld.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libanl.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libc.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libc_malloc_debug.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libcrypt.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libdl.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libm.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libnsl.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libpthread.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libresolv.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/librt.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libthread_db.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/libutil.abilist
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/localplt.data
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/makecontext.c
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/mmap_internal.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/or1k_clone.S
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/setcontext.S
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/shlib-versions
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/swapcontext.S
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/user.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.c
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.h
>>  create mode 100644 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
>>

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-15  1:19   ` Adhemerval Zanella
@ 2021-12-15  5:34     ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-15  5:34 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Florian Weimer, Openrisc

On Tue, Dec 14, 2021 at 10:19:03PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 14/12/2021 17:25, Adhemerval Zanella wrote:
> > 
> > 
> > On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> >> This is the OpenRISC port for glibc that I have been working on.
> >>
> >> Changes since v2:
> >>  - Fixed suggestions from Joseph Myers:
> >>    - Fix comment style, and description on top of each file
> >>    - Make sure macros have parentheses when needed,
> >>    - Bump required kernel down to 5.4.0 and document
> >>    - Regenerate arch-syscall.h
> >>  - Fixed suggestions from Adhemerval:
> >>    - Remove kernel_stat.h
> >>    - Just set MMAP2_PAGE_UNIT to 8K
> >>    - Remove ioctl.c and syscall.c files
> >>  - Update TCB alignment to 32 bytes
> >>
> >> Changes since v1:
> >>  - Update api's as suggested by Florian
> >>  - Remove hard float support
> >>  - Updates to get all tests passing
> >>  - Split patch into managable bits similar to recent ARC port
> >>
> >> Documentation:
> >>
> >>   Architecture / ABI docs:
> >>    https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf
> >>
> >> Test Results:
> >>
> >>   build-many-glibcs.py:
> >>
> >>    PASS with mainline ang gcc-11.
> >>
> >>   Full test suite:
> >>
> >>    The full suite is running using the gcc-11 branch of GCC, mainline shows
> >>    issues with math soft-fp.
> >>
> >>    Note, there are a few more failures compared to before, this is due to me
> >>    running with a timeout of 30 vs usual 300.  It allows the tests to complete
> >>    faster, but I get a few more timeouts.  There were 15 timeouts which I
> >>    confirm do work if I increase the timeoutfactor. The 2 real failures marked
> >>    with * below.
> >>
> >>     # test start:    2021-12-08T19:59:00+09:00
> >>
> >>     # failures
> >>     FAIL:*elf/tst-bz15311
> > 
> > This seems to be a real issue, the output shows the new sorting algorithm seems 
> > not be enabled (the output shows the destructor order for dynamic_sort=1).  We 
> > need to figure out what is happening here.
> 
> It does like the destructor ordering  issue Florian has posted a patch [1].
> 
> [1] https://sourceware.org/pipermail/libc-alpha/2021-December/134165.html

I confirm applying these 2 patches from Florian does fix elf/tst-bz15311 for me.
Thanks for the heads up.

-Stafford

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-14 20:25 ` [PATCH v3 00/13] Glibc " Adhemerval Zanella
  2021-12-15  1:19   ` Adhemerval Zanella
@ 2021-12-15  5:37   ` Stafford Horne
  2021-12-23 15:46     ` Stafford Horne
  1 sibling, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-15  5:37 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Tue, Dec 14, 2021 at 05:25:09PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > This is the OpenRISC port for glibc that I have been working on.
> > 
> > Changes since v2:
> >  - Fixed suggestions from Joseph Myers:
> >    - Fix comment style, and description on top of each file
> >    - Make sure macros have parentheses when needed,
> >    - Bump required kernel down to 5.4.0 and document
> >    - Regenerate arch-syscall.h
> >  - Fixed suggestions from Adhemerval:
> >    - Remove kernel_stat.h
> >    - Just set MMAP2_PAGE_UNIT to 8K
> >    - Remove ioctl.c and syscall.c files
> >  - Update TCB alignment to 32 bytes
> > 
> > Changes since v1:
> >  - Update api's as suggested by Florian
> >  - Remove hard float support
> >  - Updates to get all tests passing
> >  - Split patch into managable bits similar to recent ARC port
> > 
> > Documentation:
> > 
> >   Architecture / ABI docs:
> >    https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf
> > 
> > Test Results:
> > 
> >   build-many-glibcs.py:
> > 
> >    PASS with mainline ang gcc-11.
> > 
> >   Full test suite:
> > 
> >    The full suite is running using the gcc-11 branch of GCC, mainline shows
> >    issues with math soft-fp.
> > 
> >    Note, there are a few more failures compared to before, this is due to me
> >    running with a timeout of 30 vs usual 300.  It allows the tests to complete
> >    faster, but I get a few more timeouts.  There were 15 timeouts which I
> >    confirm do work if I increase the timeoutfactor. The 2 real failures marked
> >    with * below.
> > 
> >     # test start:    2021-12-08T19:59:00+09:00
> > 
> >     # failures
> >     FAIL:*elf/tst-bz15311
> 
> This seems to be a real issue, the output shows the new sorting algorithm seems 
> not be enabled (the output shows the destructor order for dynamic_sort=1).  We 
> need to figure out what is happening here.
>
> >     FAIL: locale/tst-localedef-path-norm
> >     FAIL: malloc/tst-dynarray-fail
> >     FAIL: malloc/tst-dynarray-fail-mem
> >     FAIL: nptl/tst-mutex10
> >     FAIL: nss/tst-nss-files-hosts-getent
> >     FAIL: nss/tst-nss-files-hosts-multi
> >     FAIL: posix/tst-regcomp-truncated
> >     FAIL: stdio-common/tst-vfprintf-width-prec
> >     FAIL: stdio-common/tst-vfprintf-width-prec-alloc
> >     FAIL: stdio-common/tst-vfprintf-width-prec-mem
> >     FAIL: string/test-memcpy
> >     FAIL: string/test-memcpy-large
> >     FAIL: string/test-mempcpy
> >     FAIL: string/tst-cmp
> >     FAIL: support/tst-support_blob_repeat
> >     FAIL:*timezone/tst-tzset
> 
> It seems the testing file system does not support sparse files or at least
> has some limits of the file size and support_descriptor_supports_holes is
> no deteting it.

Let me see if I can figure out the sparse file support.  If that can work
then it would be good.  The filesystem I am using is:

 tmpfs on /tmp type tmpfs (rw,relatime)

> I think we should use a large write_offset and block_headroom, maybe
> something larger than 32-bit offset to actually check it.  Could you
> check if increasing both values does make the test unsupported.

I will check.

-Stafford

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 03/13] or1k: ABI Implementation
  2021-12-15  1:15       ` Adhemerval Zanella
@ 2021-12-15 23:33         ` Stafford Horne
  2021-12-16 10:30           ` Adhemerval Zanella
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-15 23:33 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Joseph Myers, GLIBC patches, Openrisc

On Wed, Dec 15, 2021, 10:15 AM Adhemerval Zanella <
adhemerval.zanella@linaro.org> wrote:

>
>
> On 14/12/2021 19:43, Joseph Myers wrote:
> > On Tue, 14 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:
> >
> >> +if test "x$profile" != xno; then
> >> +  if test "x$with_profile" == xno; then
> >> +    AC_MSG_ERROR([ABI does not support profiling])
> >
> > Using == in test is a bashism.
> >
> > I'd expect such a change to require the build-many-glibcs.py
> configuration
> > for OpenRISC to use --disable-profile.
> >
>
> I ended up mixing up things and what or1k does not support is LD_PROFILE
> instead of --enable-profile.  In this case I am not sure if it would
> be better to just not enable it (by ignoring the LD_PROFILE handling
> in rtld.c or dl-support.c) and emitting a warning or by just dumping
> and error at process initialization.
>

I checked, new ports like csky and arc also do not seem to support
LD_PROFILE.  They choose not to leave a placeholder block in dl-machine.h
like I did in or1k.

I could remove the comment, or replace it with an abort, but I prefer to
keep it as it makes it clear where to add the dynamic linker profile hook.

-Stafford

>

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 03/13] or1k: ABI Implementation
  2021-12-15 23:33         ` Stafford Horne
@ 2021-12-16 10:30           ` Adhemerval Zanella
  0 siblings, 0 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 10:30 UTC (permalink / raw)
  To: Stafford Horne; +Cc: Joseph Myers, GLIBC patches, Openrisc



On 15/12/2021 20:33, Stafford Horne wrote:
> 
> 
> On Wed, Dec 15, 2021, 10:15 AM Adhemerval Zanella <adhemerval.zanella@linaro.org <mailto:adhemerval.zanella@linaro.org>> wrote:
> 
> 
> 
>     On 14/12/2021 19:43, Joseph Myers wrote:
>     > On Tue, 14 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:
>     >
>     >> +if test "x$profile" != xno; then
>     >> +  if test "x$with_profile" == xno; then
>     >> +    AC_MSG_ERROR([ABI does not support profiling])
>     >
>     > Using == in test is a bashism.
>     >
>     > I'd expect such a change to require the build-many-glibcs.py configuration
>     > for OpenRISC to use --disable-profile.
>     >
> 
>     I ended up mixing up things and what or1k does not support is LD_PROFILE
>     instead of --enable-profile.  In this case I am not sure if it would
>     be better to just not enable it (by ignoring the LD_PROFILE handling
>     in rtld.c or dl-support.c) and emitting a warning or by just dumping
>     and error at process initialization.
> 
> 
> I checked, new ports like csky and arc also do not seem to support LD_PROFILE.  They choose not to leave a placeholder block in dl-machine.h like I did in or1k.
> 
> I could remove the comment, or replace it with an abort, but I prefer to keep it as it makes it clear where to add the dynamic linker profile hook.

I think we should remove the comments, the code might ended up being not updated.

LD_PROFILE seems to be not a really used feature, I will try to clean this up
by adding an internal option that if the port that does not support we,
rtld at least disable all the required code and not start the profile
process (like preparing the file, etc).


^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 04/13] or1k: startup and dynamic linking code
  2021-12-10 23:34 ` [PATCH v3 04/13] or1k: startup and dynamic linking code Stafford Horne
@ 2021-12-16 10:42   ` Adhemerval Zanella
  2021-12-17 23:03     ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 10:42 UTC (permalink / raw)
  To: libc-alpha, Stafford Horne; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> Code for C runtime startup and dynamic loading including PLT layout.

Patch looks ok, although I comment much on ABI and assembly code. Some
comments below.

> ---
>  sysdeps/or1k/bits/link.h   |  51 ++++++
>  sysdeps/or1k/dl-machine.h  | 323 +++++++++++++++++++++++++++++++++++++
>  sysdeps/or1k/dl-start.S    |  98 +++++++++++
>  sysdeps/or1k/ldsodefs.h    |  40 +++++
>  sysdeps/or1k/sotruss-lib.c |  51 ++++++
>  sysdeps/or1k/start.S       |  99 ++++++++++++
>  sysdeps/or1k/tst-audit.h   |  24 +++
>  7 files changed, 686 insertions(+)
>  create mode 100644 sysdeps/or1k/bits/link.h
>  create mode 100644 sysdeps/or1k/dl-machine.h
>  create mode 100644 sysdeps/or1k/dl-start.S
>  create mode 100644 sysdeps/or1k/ldsodefs.h
>  create mode 100644 sysdeps/or1k/sotruss-lib.c
>  create mode 100644 sysdeps/or1k/start.S
>  create mode 100644 sysdeps/or1k/tst-audit.h
> 
> diff --git a/sysdeps/or1k/bits/link.h b/sysdeps/or1k/bits/link.h
> new file mode 100644
> index 0000000000..ad183c9625
> --- /dev/null
> +++ b/sysdeps/or1k/bits/link.h
> @@ -0,0 +1,51 @@
> +/* Declarations for dynamic linker interface. OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _LINK_H
> +# error "Never include <bits/link.h> directly; use <link.h> instead."
> +#endif
> +
> +/* Registers for entry into PLT.  */
> +typedef struct La_or1k_regs
> +{
> +  uint32_t lr_reg[31];
> +} La_or1k_regs;
> +

So is the intent is to provide caller all the register, no only the caller-saved 
registers?

> +/* Return values for calls from PLT.  */
> +typedef struct La_or1k_retval
> +{
> +  uint32_t lrv_r3;
> +} La_or1k_retval;
> +
> +__BEGIN_DECLS
> +
> +extern ElfW(Addr) la_or1k_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
> +					uintptr_t *__refcook,
> +					uintptr_t *__defcook,
> +					La_or1k_regs *__regs,
> +					unsigned int *__flags,
> +					const char *__symname,
> +					long int *__framesizep);
> +extern unsigned int la_or1k_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
> +					 uintptr_t *__refcook,
> +					 uintptr_t *__defcook,
> +					 const La_or1k_regs *__inregs,
> +					 La_or1k_retval *__outregs,
> +					 const char *__symname);
> +
> +__END_DECLS
> diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h
> new file mode 100644
> index 0000000000..d41554769e
> --- /dev/null
> +++ b/sysdeps/or1k/dl-machine.h
> @@ -0,0 +1,323 @@
> +/* Machine-dependent ELF dynamic relocation inline functions.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef dl_machine_h
> +#define dl_machine_h
> +
> +#define ELF_MACHINE_NAME "or1k"
> +
> +#include <sys/cdefs.h>
> +#include <sys/param.h>
> +#include <tls.h>
> +#include <dl-irel.h>
> +#include <dl-static-tls.h>
> +#include <dl-machine-rel.h>
> +
> +/* Return nonzero iff ELF header is compatible with the running host.  */
> +static inline int __attribute__ ((unused))
> +elf_machine_matches_host (const Elf32_Ehdr *ehdr)
> +{
> +  return ehdr->e_machine == EM_OPENRISC;
> +}
> +
> +static inline Elf32_Addr *
> +or1k_get_got (void)
> +{
> +  Elf32_Addr *got;
> +  register long int linkreg asm ("r9");

Is the 'r9' a required register by the ABI to use on this assembly snippet?
I am asking because local name 'registers' are only a hint to gcc, as we
found recently [1], if you really need 'r9' you will probably need to use 
a global name resgister.

> +  asm ("l.jal    0x8\n"
> +       " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
> +       "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
> +       "l.add    %0, %0, %1\n"
> +       : "=r" (got), "=r" (linkreg));
> +
> +  return got;
> +}
> +
> +/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
> +   first element of the GOT.  */
> +static inline Elf32_Addr
> +elf_machine_dynamic (void)
> +{
> +  Elf32_Addr *got = or1k_get_got();

Space before '('.

> +  return *got;
> +}
> +
> +
> +/* Return the run-time load address of the shared object.  */
> +static inline Elf32_Addr
> +elf_machine_load_address (void)
> +{
> +  /* Compute the difference between the runtime address of _DYNAMIC as seen
> +     by a GOTOFF reference, and the link-time address found in the special
> +     unrelocated first GOT entry.  */
> +  Elf32_Addr dyn;
> +  Elf32_Addr *got = or1k_get_got();

Space before '('.

> +
> +  asm ("l.movhi %0, gotoffhi(_DYNAMIC);"
> +       "l.ori   %0, %0, gotofflo(_DYNAMIC);"
> +       "l.add   %0, %0, %1;"
> +       : "=&r"(dyn) : "r"(got));
> +
> +  return dyn - *got;
> +}
> +
> +/* Initial entry point code for the dynamic linker.  The function _dl_start
> +   is the real entry point; it's return value is the user program's entry
> +   point.
> +
> +   Code is really located in dl-start.S, just tell the linker that it
> +   exists.  */
> +#define RTLD_START asm (".globl _dl_start");
> +
> +/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
> +   TLS variable, so undefined references should not be allowed to
> +   define the value.
> +   ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
> +   of the main executable's symbols, as for a COPY reloc.  */
> +
> +#define elf_machine_type_class(type) \
> +  (((type) == R_OR1K_JMP_SLOT \
> +   || (type) == R_OR1K_TLS_DTPMOD \
> +   || (type) == R_OR1K_TLS_DTPOFF \
> +   || (type) == R_OR1K_TLS_TPOFF) * ELF_RTYPE_CLASS_PLT \
> +   | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY)
> +
> +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
> +#define ELF_MACHINE_JMP_SLOT    R_OR1K_JMP_SLOT
> +
> +#define ARCH_LA_PLTENTER or1k_gnu_pltenter
> +#define ARCH_LA_PLTEXIT or1k_gnu_pltexit
> +
> +/* Set up the loaded object described by L so its unrelocated PLT
> +   entries will jump to the on-demand fixup code in dl-runtime.c.  */
> +static inline int __attribute__ ((unused, always_inline))
> +elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
> +			   int lazy, int profile)
> +{
> +  ElfW(Addr) *pltgot;
> +  extern void _dl_runtime_resolve (ElfW(Word));
> +  extern void _dl_runtime_profile (ElfW(Word));
> +
> +  if (l->l_info[DT_JMPREL] && lazy)
> +    {
> +      pltgot = (ElfW(Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
> +
> +      /* Fill in initial entrys of the plt */
> +
> +      /* Register the link_map address in the plt at pltgot[1].
> +	 This will also be used in the resolver for accessing the
> +	 link_map structure.  */
> +      pltgot[1] = (ElfW(Addr)) l;
> +
> +      /* The pltgot[2] entry contains the address of a function which gets
> +	 called to get the address of a so far unresolved function and
> +	 jump to it.  The profiling extension of the dynamic linker allows
> +	 to intercept the calls to collect information.  In this case we
> +	 don't store the address in the GOT so that all future calls also
> +	 end in this function.  */
> +#if 0 /* Profiling not supported in OpenRISC yet (need to implement
> +	 _dl_runtime_profile).  */
> +      if ( profile)
> +	{
> +	   pltgot[2] = (ElfW(Addr)) &_dl_runtime_profile;
> +
> +	  if (GLRO(dl_profile) != NULL
> +	      && _dl_name_match_p (GLRO(dl_profile), l))
> +	    /* Say that we really want profiling and the timers are
> +	       started.  */
> +	    GL(dl_profile_map) = l;
> +	}
> +      else
> +#endif

I think it would be better to remove the commented code and add a comment stating
LD_PROFILE is not currently supported.

> +	{
> +	  /* This function will get called to fix up the GOT entry
> +	     indicated by the offset on the stack, and then jump to
> +	     the resolved address.  */
> +	  pltgot[2] = (ElfW(Addr)) &_dl_runtime_resolve;
> +	}
> +
> +    }
> +
> +  return lazy;
> +}
> +
> +/* Mask identifying addresses reserved for the user program,
> +   where the dynamic linker should not map anything.  */
> +#define ELF_MACHINE_USER_ADDRESS_MASK   0xf8000000UL
> +
> +/* We define an initialization functions.  This is called very early in
> +   _dl_sysdep_start.  */
> +#define DL_PLATFORM_INIT dl_platform_init ()
> +
> +static inline void __attribute__ ((unused))
> +dl_platform_init (void)
> +{
> +  if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
> +    /* Avoid an empty string which would disturb us.  */
> +    GLRO(dl_platform) = NULL;
> +}
> +
> +static inline ElfW(Addr)
> +elf_machine_fixup_plt (struct link_map *map, lookup_t t,
> +		       const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
> +		       const ElfW(Rela) *reloc,
> +		       ElfW(Addr) *reloc_addr, ElfW(Addr) value)
> +{
> +  return *reloc_addr = value;
> +}
> +
> +/* Return the final value of a plt relocation.  */
> +static inline Elf32_Addr
> +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
> +		       Elf32_Addr value)
> +{
> +  return value + reloc->r_addend;
> +}
> +
> +
> +#endif /* !dl_machine_h */
> +
> +#ifdef RESOLVE_MAP
> +
> +/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
> +   MAP is the object containing the reloc.  */
> +
> +static inline void
> +__attribute ((always_inline))
> +elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
> +		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
> +		  const struct r_found_version *version,
> +		  void *const reloc_addr_arg, int skip_ifunc)
> +{
> +  Elf32_Addr *const reloc_addr = reloc_addr_arg;
> +  const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
> +
> +  if (__glibc_unlikely (r_type == R_OR1K_NONE))
> +    return;
> +  else
> +    {
> +# ifndef RESOLVE_CONFLICT_FIND_MAP
> +      const Elf32_Sym *const refsym = sym;
> +# endif
> +      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
> +					      r_type);
> +      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
> +
> +      if (sym != NULL
> +	  && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)
> +	  && __glibc_likely (sym->st_shndx != SHN_UNDEF)
> +	  && __glibc_likely (!skip_ifunc))
> +	value = elf_ifunc_invoke (value);
> +
> +      switch (r_type)
> +	{
> +# ifndef RESOLVE_CONFLICT_FIND_MAP
> +	  case R_OR1K_COPY:
> +	    if (sym == NULL)
> +	      /* This can happen in trace mode if an object could not be
> +		 found.  */
> +	      break;
> +	    if (__glibc_unlikely (sym->st_size > refsym->st_size)
> +		|| (__glibc_unlikely (sym->st_size < refsym->st_size)
> +		  && GLRO(dl_verbose)))
> +	    {
> +	      const char *strtab;
> +
> +	      strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
> +	      _dl_error_printf ("\
> +%s: Symbol `%s' has different size in shared object, consider re-linking\n",
> +		  rtld_progname ?: "<program name unknown>",
> +		  strtab + refsym->st_name);
> +	    }
> +	    memcpy (reloc_addr_arg, (void *) value,
> +		MIN (sym->st_size, refsym->st_size));
> +	    break;
> +# endif /* !RESOLVE_CONFLICT_FIND_MAP */
> +	  case R_OR1K_32:
> +	    /* Support relocations on mis-aligned offsets.  */
> +	    value += reloc->r_addend;
> +	    memcpy (reloc_addr_arg, &value, 4);
> +	    break;
> +	  case R_OR1K_GLOB_DAT:
> +	  case R_OR1K_JMP_SLOT:
> +	    *reloc_addr = value + reloc->r_addend;
> +	    break;
> +	  case R_OR1K_TLS_DTPMOD:
> +# ifdef RTLD_BOOTSTRAP
> +	    /* During startup the dynamic linker is always the module
> +	       with index 1.  */
> +	    *reloc_addr = 1;
> +# else
> +	    if (sym_map != NULL)
> +	      *reloc_addr = sym_map->l_tls_modid;
> +# endif
> +	    break;
> +	  case R_OR1K_TLS_DTPOFF:
> +# ifndef RTLD_BOOTSTRAP
> +	    *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
> +# endif
> +	    break;
> +
> +	  case R_OR1K_TLS_TPOFF:
> +# ifdef RTLD_BOOTSTRAP
> +	    *reloc_addr = sym->st_value + reloc->r_addend +
> +	      map->l_tls_offset - TLS_TCB_SIZE;
> +# else
> +	    if (sym_map != NULL)
> +	      {
> +		CHECK_STATIC_TLS (map, sym_map);
> +		*reloc_addr = sym->st_value + reloc->r_addend +
> +		  sym_map->l_tls_offset - TLS_TCB_SIZE;
> +	      }
> +# endif
> +	    break;
> +	  default:
> +	    _dl_reloc_bad_type (map, r_type, 0);
> +	    break;
> +	}
> +    }
> +}
> +
> +static inline void
> +__attribute__ ((always_inline))
> +elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
> +			   void *const reloc_addr_arg)
> +{
> +  Elf32_Addr *const reloc_addr = reloc_addr_arg;
> +  *reloc_addr = l_addr + reloc->r_addend;
> +}
> +
> +static inline void
> +__attribute__ ((always_inline))
> +elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
> +		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
> +		      int skip_ifunc)
> +{
> +  Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
> +  const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
> +
> +  if (__glibc_likely (r_type == R_OR1K_JMP_SLOT))
> +      *reloc_addr += l_addr;
> +  else if (__glibc_unlikely (r_type == R_OR1K_NONE))
> +    return;
> +  else
> +    _dl_reloc_bad_type (map, r_type, 1);
> +}
> +
> +#endif /* RESOLVE_MAP */
> diff --git a/sysdeps/or1k/dl-start.S b/sysdeps/or1k/dl-start.S
> new file mode 100644
> index 0000000000..ecb1505427
> --- /dev/null
> +++ b/sysdeps/or1k/dl-start.S
> @@ -0,0 +1,98 @@
> +/* Machine-dependent ELF startup code.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +
> +/* Initial entry point code for the dynamic linker.
> +   The function _dl_start is the real entry point;
> +   it's return value is the user program's entry point.  */
> +ENTRY (_start)
> +	/* Count arguments in r11 */
> +	l.ori	r3, r1, 0
> +	l.movhi	r11, 0
> +1:
> +	l.addi	r3, r3, 4
> +	l.lwz	r12, 0(r3)
> +	l.sfnei	r12, 0
> +	l.addi	r11, r11, 1
> +	l.bf	1b
> +	 l.nop
> +	l.addi	r11, r11, -1
> +	/* store argument counter to stack.  */
> +	l.sw	0(r1), r11
> +
> +	/* Load the PIC register.  */
> +	l.jal	0x8
> +	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
> +	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
> +	l.add	r16, r16, r9
> +
> +	l.ori	r3, r1, 0
> +
> +	l.jal	_dl_start
> +	 l.nop
> +	/* Save user entry in a call saved reg.  */
> +	l.ori	r22, r11, 0
> +	/* Fall through to _dl_start_user.  */
> +
> +_dl_start_user:
> +	/* Set up for _dl_init.  */
> +
> +	/* Load _rtld_local (a.k.a _dl_loaded).  */
> +	l.lwz	r12, got(_rtld_local)(r16)
> +	l.lwz	r3, 0(r12)
> +
> +	/* Load argc */
> +	l.lwz	r18, got(_dl_argc)(r16)
> +	l.lwz	r4, 0(r18)
> +
> +	/* Load argv */
> +	l.lwz	r20, got(_dl_argv)(r16)
> +	l.lwz	r5, 0(r20)
> +
> +	/* Load envp = &argv[argc + 1].  */
> +	l.slli	r6, r4, 2
> +	l.addi	r6, r6, 4
> +	l.add	r6, r6, r5
> +
> +	l.jal	plt(_dl_init)
> +	 l.nop
> +
> +	/* Now set up for user entry.
> +	   The already defined ABI loads argc and argv from the stack.
> +
> +	   argc = 0(r1)
> +	   argv = r1 + 4
> +	*/
> +
> +	/* Load SP as argv - 4.  */
> +	l.lwz	r3, 0(r20)
> +	l.addi	r1, r3, -4
> +
> +	/* Save argc.  */
> +	l.lwz	r3, 0(r18)
> +	l.sw	0(r1), r3
> +
> +	/* Pass _dl_fini function address to _start.
> +	   Next start.S will then pass this as rtld_fini to __libc_start_main.  */
> +	l.lwz	r3, got(_dl_fini)(r16)
> +
> +	l.jr	r22
> +	 l.nop
> +
> +END (_start)
> diff --git a/sysdeps/or1k/ldsodefs.h b/sysdeps/or1k/ldsodefs.h
> new file mode 100644
> index 0000000000..89713fcc70
> --- /dev/null
> +++ b/sysdeps/or1k/ldsodefs.h
> @@ -0,0 +1,40 @@
> +/* Run-time dynamic linker data structures for loaded ELF shared objects.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef	_OR1K_LDSODEFS_H
> +#define	_OR1K_LDSODEFS_H	1
> +
> +#include <elf.h>
> +
> +struct La_or1k_regs;
> +struct La_or1k_retval;
> +
> +#define ARCH_PLTENTER_MEMBERS						\
> +    uintptr_t (*or1k_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *, \
> +				  uintptr_t *, struct La_or1k_regs *, \
> +				  unsigned int *, const char *name,	\
> +				  long int *framesizep)
> +
> +#define ARCH_PLTEXIT_MEMBERS						\
> +    unsigned int (*or1k_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *, \
> +				    uintptr_t *, const struct La_or1k_regs *, \
> +				    struct La_or1k_retval *, const char *)
> +
> +#include_next <ldsodefs.h>
> +
> +#endif
> diff --git a/sysdeps/or1k/sotruss-lib.c b/sysdeps/or1k/sotruss-lib.c
> new file mode 100644
> index 0000000000..ee16f84456
> --- /dev/null
> +++ b/sysdeps/or1k/sotruss-lib.c
> @@ -0,0 +1,51 @@
> +/* Override generic sotruss-lib.c to define actual functions for OpenRISC.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define HAVE_ARCH_PLTENTER
> +#define HAVE_ARCH_PLTEXIT
> +
> +#include <elf/sotruss-lib.c>
> +
> +ElfW(Addr)
> +la_or1k_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
> +		       unsigned int ndx __attribute__ ((unused)),
> +		       uintptr_t *refcook, uintptr_t *defcook,
> +		       La_or1k_regs *regs, unsigned int *flags,
> +		       const char *symname, long int *framesizep)
> +{
> +  print_enter (refcook, defcook, symname,
> +	       regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
> +	       *flags);
> +
> +  /* No need to copy anything, we will not need the parameters in any case.  */
> +  *framesizep = 0;
> +
> +  return sym->st_value;
> +}
> +
> +unsigned int
> +la_or1k_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
> +		      uintptr_t *defcook,
> +		      const struct La_or1k_regs *inregs,
> +		      struct La_or1k_retval *outregs,
> +		      const char *symname)
> +{
> +  print_exit (refcook, defcook, symname, outregs->lrv_r3);
> +
> +  return 0;
> +}
> diff --git a/sysdeps/or1k/start.S b/sysdeps/or1k/start.S
> new file mode 100644
> index 0000000000..0424355f36
> --- /dev/null
> +++ b/sysdeps/or1k/start.S
> @@ -0,0 +1,99 @@
> +/* start, OpenRISC version.
> +   Copyright (C) 2021 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, write to the Free
> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> +   02111-1307 USA.  */
> +
> +/* This is the canonical entry point, usually the first thing in the text
> +   segment.
> +
> +   sp   The stack contains the arguments and environment:
> +    0(sp)     argc
> +    4(sp)     argv[0]
> +    ...
> +    (4*argc)(sp)    NULL
> +    (4*(argc+1))(sp)  envp[0]
> +    ...
> +    NULL
> + */
> +
> +#define __ASSEMBLY__
> +#include <sysdep.h>
> +#include <entry.h>
> +
> +ENTRY (ENTRY_POINT)
> +
> +	/* Setup Arguments to the __libc_start_main function.  */
> +
> +	/* Take values for argc and argv off the stack.
> +	   These will be passed as arguments two and three to main
> +	   and thus go in registers r4 and r5, respectively.  */
> +	l.lwz	r4, 0(r1)
> +	l.addi	r5, r1, 4
> +
> +	/* Pass in rtld_fini from dl-start.S.  */
> +	l.or	r8, r3, r3
> +
> +#ifdef PIC
> +	/* Obtain a pointer to .got in r16 */
> +	l.jal	0x8
> +	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
> +	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
> +	l.add	r16, r16, r9
> +
> +	/* Pass in the the main symbol.  */
> +	l.lwz	r3, got(main)(r16)
> +#else
> +	/* Pass in the the main symbol.  */
> +	l.movhi r3, hi(main)
> +	l.ori	r3, r3, lo(main)
> +#endif
> +	/* Used to be init and fini.  */
> +	l.movhi	r6, 0x0
> +	l.movhi	r7, 0x0
> +
> +	/* Push stack limit onto the stack.
> +	   This provides the highest stack address to user code (as stack grows
> +	   downwards.
> +	   This is the seventh argument to __libc_start_main and thus needs to
> +	   be passed on the stack.  */
> +	l.sw	-4(r1), r1
> +
> +	/* Adjust stack to account for a total of 7 args (i.e. the last one is
> +	   on the stack.  */
> +	l.addi	r1, r1, -4
> +
> +	/* Clear the frame pointer and link register since this is the
> +	   outermost frame.  */
> +	l.movhi	r2, 0x0
> +	l.movhi	r9, 0x0
> +
> +	/* Let the libc call main and exit with its return code.  */
> +#ifdef PIC
> +	l.j	plt(__libc_start_main)
> +#else
> +	l.j	__libc_start_main
> +#endif
> +	 l.nop
> +END (ENTRY_POINT)
> +
> +	/* Define a symbol for the first piece of initialized data.  */
> +	.data
> +	.globl __data_start
> +__data_start:
> +	.long 0
> +	.weak data_start
> +	data_start = __data_start
> diff --git a/sysdeps/or1k/tst-audit.h b/sysdeps/or1k/tst-audit.h
> new file mode 100644
> index 0000000000..79ee1b7b02
> --- /dev/null
> +++ b/sysdeps/or1k/tst-audit.h
> @@ -0,0 +1,24 @@
> +/* Definitions for testing PLT entry/exit auditing.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define pltenter la_or1k_gnu_pltenter
> +#define pltexit la_or1k_gnu_pltexit
> +#define La_regs La_or1k_regs
> +#define La_retval La_or1k_retval
> +#define int_retval lrv_r3

[1] https://sourceware.org/pipermail/libc-alpha/2021-December/134176.html

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 05/13] or1k: Thread Local Storage support
  2021-12-10 23:34 ` [PATCH v3 05/13] or1k: Thread Local Storage support Stafford Horne
@ 2021-12-16 11:35   ` Adhemerval Zanella
  2021-12-16 12:37   ` Adhemerval Zanella
  1 sibling, 0 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 11:35 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> OpenRISC includes 3 TLS addressing models.  Local Dynamic optimizations
> are not done in the linker and therefore use the same code sequences as
> Global Dynamic.
> ---
>  sysdeps/or1k/dl-tls.h             |  27 +++++
>  sysdeps/or1k/libc-tls.c           |  34 ++++++
>  sysdeps/or1k/nptl/tcb-offsets.sym |   6 +
>  sysdeps/or1k/nptl/tls.h           | 189 ++++++++++++++++++++++++++++++
>  sysdeps/or1k/stackinfo.h          |  34 ++++++
>  5 files changed, 290 insertions(+)
>  create mode 100644 sysdeps/or1k/dl-tls.h
>  create mode 100644 sysdeps/or1k/libc-tls.c
>  create mode 100644 sysdeps/or1k/nptl/tcb-offsets.sym
>  create mode 100644 sysdeps/or1k/nptl/tls.h
>  create mode 100644 sysdeps/or1k/stackinfo.h
> 
> diff --git a/sysdeps/or1k/dl-tls.h b/sysdeps/or1k/dl-tls.h
> new file mode 100644
> index 0000000000..382588d504
> --- /dev/null
> +++ b/sysdeps/or1k/dl-tls.h
> @@ -0,0 +1,27 @@
> +/* TLS definitions for the ELF dynamic linker.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://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);
> diff --git a/sysdeps/or1k/libc-tls.c b/sysdeps/or1k/libc-tls.c
> new file mode 100644
> index 0000000000..1524855e88
> --- /dev/null
> +++ b/sysdeps/or1k/libc-tls.c
> @@ -0,0 +1,34 @@
> +/* Thread-local storage handling in the ELF dynamic linker.
> +   OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <csu/libc-tls.c>
> +#include <dl-tls.h>
> +
> +/* On OpenRISC, linker optimizations are not required, so __tls_get_addr
> +   can be called even in statically linked binaries.  In this case module
> +   must be always 1 and PT_TLS segment exist in the binary, otherwise it
> +   would not link.  */
> +
> +void *
> +__tls_get_addr (tls_index *ti)
> +{
> +  dtv_t *dtv = THREAD_DTV ();
> +  return (char *) dtv[1].pointer.val + ti->ti_offset;
> +}
> diff --git a/sysdeps/or1k/nptl/tcb-offsets.sym b/sysdeps/or1k/nptl/tcb-offsets.sym
> new file mode 100644
> index 0000000000..86025a402d
> --- /dev/null
> +++ b/sysdeps/or1k/nptl/tcb-offsets.sym
> @@ -0,0 +1,6 @@
> +#include <sysdep.h>
> +#include <tls.h>
> +
> +MULTIPLE_THREADS_OFFSET         offsetof (struct pthread, header.multiple_threads)
> +TID_OFFSET                      offsetof (struct pthread, tid)
> +TP_TO_PTHREAD_OFFSET            -(sizeof (struct pthread) + sizeof (tcbhead_t))

There are not used anywhere, so you can use an empty file for now.  And I
think these definitions are not used in most architectures, if any. 

> diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
> new file mode 100644
> index 0000000000..dc11610920
> --- /dev/null
> +++ b/sysdeps/or1k/nptl/tls.h
> @@ -0,0 +1,189 @@
> +/* Definition for thread-local data handling.  NPTL/OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _TLS_H
> +#define _TLS_H  1
> +
> +#include <dl-sysdep.h>
> +
> +#ifndef __ASSEMBLER__
> +# include <stdbool.h>
> +# include <stddef.h>
> +# include <stdint.h>
> +# include <dl-dtv.h>
> +
> +typedef struct
> +{
> +  dtv_t *dtv;
> +  void *__padding[3]; /* To maintain 16 byte padding, needed by STACK_ALIGN.  */
> +} tcbhead_t;
> +
> +register tcbhead_t *__thread_self __asm__("r10");
> +
> +# define TLS_MULTIPLE_THREADS_IN_TCB 1
> +
> +#else /* __ASSEMBLER__ */
> +# include <tcb-offsets.h>
> +#endif /* __ASSEMBLER__ */
> +
> +#ifndef __ASSEMBLER__
> +
> +/* Get system call information.  */
> +# include <sysdep.h>
> +
> +/* The TP points to the start of the TLS block.
> +   As I understand it, this isn't strictly that "TP points to DTV" - it's
> +   more where to place the TCB in the TLS block.  This will place it in
> +   the beginning.
> +
> +   Layout:
> +    +-----+-----+----------------------+
> +    | PRE | TCB | TLS MEMORY ..        |
> +    +-----+-----+----------------------+
> +		 ^ r10 / TP
> +
> +   PRE is the struct pthread described below
> +   TCB is tcbhead_t
> +   TLS memory is where the TLS program sections are loaded
> +
> +   See _dl_allocate_tls_storage and __libc_setup_tls for more information.  */
> +
> +# define TLS_DTV_AT_TP  1
> +# define TLS_TCB_AT_TP  0
> +
> +/* Get the thread descriptor definition.  */
> +# include <nptl/descr.h>
> +
> +/* Requirements for the TCB.  */
> +# define TLS_INIT_TCB_SIZE    sizeof (tcbhead_t)
> +# define TLS_INIT_TCB_ALIGN   __alignof__ (struct pthread)
> +
> +# define TLS_TCB_SIZE         sizeof (tcbhead_t)
> +# define TLS_TCB_ALIGN        __alignof__ (struct pthread)
> +
> +/* This is the size of the TCB.  */
> +
> +/* This is the size we need before TCB.
> +   To support THREAD_GETMEM with friends we want to have a
> +   struct pthread available.
> +   Yank it in infront of everything, I'm sure nobody will mind.
> +
> +   This memory is really allocated PRE the TLS block, so it's possible
> +   to do ((char*)tlsblock) - TLS_PRE_TCB_SIZE to access it.
> +   This is done for THREAD_SELF.  */
> +
> +# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
> +
> +
> +/* Install the dtv pointer.
> +   When called, dtvp is a pointer not the DTV per say (which should start
> +   with the generation counter) but to the length of the DTV.
> +   We can always index with -1, so we store dtvp[1].  */
> +
> +# define INSTALL_DTV(tcbp, dtvp) \
> +  (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
> +
> +/* Install new dtv for current thread
> +   In a logicial world dtv here would also point to the length of the DTV.
> +   However it does not, this time it points to the generation counter,
> +   so just store it.
> +
> +   Note: -1 is still valid and contains the length.  */
> +
> +# define INSTALL_NEW_DTV(dtv) (THREAD_DTV() = (dtv))
> +
> +/* Return dtv of given thread descriptor.  */
> +# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv)
> +
> +/* Code to initially initialize the thread pointer.
> +
> +   Set TP to the address _after_ tcbhead_t.  This will allow us
> +   to change the size of tcbhead_t without having to re-link everything.
> +
> +   This has to return NULL on success (or a string with the failure text).
> +   It's hard to fail this, so return NULL always.  */
> +
> +# define TLS_INIT_TP(tcbp) \
> +  ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;})
> +
> +/* Value passed to 'clone' for initialization of the thread register.  */
> +# define TLS_DEFINE_INIT_TP(tp, pd) \
> +  void *tp = ((char *) pd + TLS_PRE_TCB_SIZE + TLS_INIT_TCB_SIZE)
> +
> +/* Return the address of the dtv for the current thread.
> +
> +   Dereference TP, offset to dtv - really straightforward.
> +   Remember that we made TP point to after tcb, so we need to reverse that.  */
> +
> +#  define THREAD_DTV() \
> +  ((((tcbhead_t *)__thread_self)-1)->dtv)
> +
> +/* Return the thread descriptor for the current thread.
> +
> +   Return a pointer to the TLS_PRE area where we allocated space for
> +   a struct pthread.  Again, TP points to after tcbhead_t, compensate with
> +   TLS_INIT_TCB_SIZE.
> +
> +   I regard this is a seperate system from the "normal" TLS.  */
> +
> +# define THREAD_SELF \
> +  ((struct pthread *) ((char *) __thread_self - TLS_INIT_TCB_SIZE \
> +    - TLS_PRE_TCB_SIZE))
> +
> +/* Magic for libthread_db to know how to do THREAD_SELF.  */
> +
> +# define DB_THREAD_SELF \
> +  REGISTER (32, 32, 10 * 4, - TLS_INIT_TCB_SIZE - TLS_PRE_TCB_SIZE)
> +
> +/* Access to data in the thread descriptor is easy.  */
> +
> +#define THREAD_GETMEM(descr, member) \
> +  descr->member
> +#define THREAD_GETMEM_NC(descr, member, idx) \
> +  descr->member[idx]
> +#define THREAD_SETMEM(descr, member, value) \
> +  descr->member = (value)
> +#define THREAD_SETMEM_NC(descr, member, idx, value) \
> +  descr->member[idx] = (value)
> +
> +/* Get and set the global scope generation counter in struct pthread.  */
> +
> +#define THREAD_GSCOPE_FLAG_UNUSED 0
> +#define THREAD_GSCOPE_FLAG_USED   1
> +#define THREAD_GSCOPE_FLAG_WAIT   2
> +#define THREAD_GSCOPE_RESET_FLAG()					\
> +  do									\
> +    {									\
> +      int __res = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,\
> +				       THREAD_GSCOPE_FLAG_UNUSED);	\
> +      if (__res == THREAD_GSCOPE_FLAG_WAIT)				\
> +	  lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1,		\
> +			  LLL_PRIVATE);					\
> +    }									\
> +  while (0)
> +#define THREAD_GSCOPE_SET_FLAG()					\
> +  do									\
> +    {									\
> +      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	\
> +      atomic_write_barrier ();						\
> +    }									\
> +  while (0)
> +
> +#endif /* __ASSEMBLER__ */
> +
> +#endif  /* tls.h */
> diff --git a/sysdeps/or1k/stackinfo.h b/sysdeps/or1k/stackinfo.h
> new file mode 100644
> index 0000000000..9273e709bd
> --- /dev/null
> +++ b/sysdeps/or1k/stackinfo.h
> @@ -0,0 +1,34 @@
> +/* Stack definitions for OpenRISC.
> +   Copyright (C) 2021 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
> +   <https://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 or1k the stack grows down.  */
> +#define _STACK_GROWS_DOWN	1
> +
> +/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
> +   present, but it is presumed absent.  */
> +#define DEFAULT_STACK_PERMS (PF_R | PF_W | PF_X)
> +
> +#endif /* stackinfo.h */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 05/13] or1k: Thread Local Storage support
  2021-12-10 23:34 ` [PATCH v3 05/13] or1k: Thread Local Storage support Stafford Horne
  2021-12-16 11:35   ` Adhemerval Zanella
@ 2021-12-16 12:37   ` Adhemerval Zanella
  2021-12-16 19:26     ` Joseph Myers
  2021-12-17 14:23     ` Stafford Horne
  1 sibling, 2 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 12:37 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc

(resending because I hit send button too soon).

On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> OpenRISC includes 3 TLS addressing models.  Local Dynamic optimizations
> are not done in the linker and therefore use the same code sequences as
> Global Dynamic.
> ---
>  sysdeps/or1k/dl-tls.h             |  27 +++++
>  sysdeps/or1k/libc-tls.c           |  34 ++++++
>  sysdeps/or1k/nptl/tcb-offsets.sym |   6 +
>  sysdeps/or1k/nptl/tls.h           | 189 ++++++++++++++++++++++++++++++
>  sysdeps/or1k/stackinfo.h          |  34 ++++++
>  5 files changed, 290 insertions(+)
>  create mode 100644 sysdeps/or1k/dl-tls.h
>  create mode 100644 sysdeps/or1k/libc-tls.c
>  create mode 100644 sysdeps/or1k/nptl/tcb-offsets.sym
>  create mode 100644 sysdeps/or1k/nptl/tls.h
>  create mode 100644 sysdeps/or1k/stackinfo.h
> 
> diff --git a/sysdeps/or1k/dl-tls.h b/sysdeps/or1k/dl-tls.h
> new file mode 100644
> index 0000000000..382588d504
> --- /dev/null
> +++ b/sysdeps/or1k/dl-tls.h
> @@ -0,0 +1,27 @@
> +/* TLS definitions for the ELF dynamic linker.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://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);
> diff --git a/sysdeps/or1k/libc-tls.c b/sysdeps/or1k/libc-tls.c
> new file mode 100644
> index 0000000000..1524855e88
> --- /dev/null
> +++ b/sysdeps/or1k/libc-tls.c
> @@ -0,0 +1,34 @@
> +/* Thread-local storage handling in the ELF dynamic linker.
> +   OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <csu/libc-tls.c>
> +#include <dl-tls.h>
> +
> +/* On OpenRISC, linker optimizations are not required, so __tls_get_addr
> +   can be called even in statically linked binaries.  In this case module
> +   must be always 1 and PT_TLS segment exist in the binary, otherwise it
> +   would not link.  */
> +
> +void *
> +__tls_get_addr (tls_index *ti)
> +{
> +  dtv_t *dtv = THREAD_DTV ();
> +  return (char *) dtv[1].pointer.val + ti->ti_offset;
> +}
> diff --git a/sysdeps/or1k/nptl/tcb-offsets.sym b/sysdeps/or1k/nptl/tcb-offsets.sym
> new file mode 100644
> index 0000000000..86025a402d
> --- /dev/null
> +++ b/sysdeps/or1k/nptl/tcb-offsets.sym
> @@ -0,0 +1,6 @@
> +#include <sysdep.h>
> +#include <tls.h>
> +
> +MULTIPLE_THREADS_OFFSET         offsetof (struct pthread, header.multiple_threads)
> +TID_OFFSET                      offsetof (struct pthread, tid)
> +TP_TO_PTHREAD_OFFSET            -(sizeof (struct pthread) + sizeof (tcbhead_t))

There are not used anywhere, so you can remove the file along with
sysdeps/or1k/nptl/Makefile.

And I think these definitions are not used in most architectures, I will
remove from the architectures that do not use it.

> diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
> new file mode 100644
> index 0000000000..dc11610920
> --- /dev/null
> +++ b/sysdeps/or1k/nptl/tls.h
> @@ -0,0 +1,189 @@
> +/* Definition for thread-local data handling.  NPTL/OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _TLS_H
> +#define _TLS_H  1
> +
> +#include <dl-sysdep.h>
> +
> +#ifndef __ASSEMBLER__
> +# include <stdbool.h>
> +# include <stddef.h>
> +# include <stdint.h>
> +# include <dl-dtv.h>
> +
> +typedef struct
> +{
> +  dtv_t *dtv;
> +  void *__padding[3]; /* To maintain 16 byte padding, needed by STACK_ALIGN.  */
> +} tcbhead_t;
> +
> +register tcbhead_t *__thread_self __asm__("r10");
> +
> +# define TLS_MULTIPLE_THREADS_IN_TCB 1
> +
> +#else /* __ASSEMBLER__ */
> +# include <tcb-offsets.h>

Remove the include, or1k currently does not use it.

> +#endif /* __ASSEMBLER__ */
> +
> +#ifndef __ASSEMBLER__
> +
> +/* Get system call information.  */
> +# include <sysdep.h>
> +
> +/* The TP points to the start of the TLS block.
> +   As I understand it, this isn't strictly that "TP points to DTV" - it's
> +   more where to place the TCB in the TLS block.  This will place it in
> +   the beginning.
> +
> +   Layout:
> +    +-----+-----+----------------------+
> +    | PRE | TCB | TLS MEMORY ..        |
> +    +-----+-----+----------------------+
> +		 ^ r10 / TP
> +
> +   PRE is the struct pthread described below
> +   TCB is tcbhead_t
> +   TLS memory is where the TLS program sections are loaded
> +
> +   See _dl_allocate_tls_storage and __libc_setup_tls for more information.  */
> +
> +# define TLS_DTV_AT_TP  1
> +# define TLS_TCB_AT_TP  0
> +
> +/* Get the thread descriptor definition.  */
> +# include <nptl/descr.h>
> +
> +/* Requirements for the TCB.  */
> +# define TLS_INIT_TCB_SIZE    sizeof (tcbhead_t)
> +# define TLS_INIT_TCB_ALIGN   __alignof__ (struct pthread)
> +
> +# define TLS_TCB_SIZE         sizeof (tcbhead_t)
> +# define TLS_TCB_ALIGN        __alignof__ (struct pthread)
> +
> +/* This is the size of the TCB.  */
> +
> +/* This is the size we need before TCB.
> +   To support THREAD_GETMEM with friends we want to have a
> +   struct pthread available.
> +   Yank it in infront of everything, I'm sure nobody will mind.
> +
> +   This memory is really allocated PRE the TLS block, so it's possible
> +   to do ((char*)tlsblock) - TLS_PRE_TCB_SIZE to access it.
> +   This is done for THREAD_SELF.  */
> +
> +# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
> +
> +
> +/* Install the dtv pointer.
> +   When called, dtvp is a pointer not the DTV per say (which should start
> +   with the generation counter) but to the length of the DTV.
> +   We can always index with -1, so we store dtvp[1].  */
> +
> +# define INSTALL_DTV(tcbp, dtvp) \
> +  (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
> +
> +/* Install new dtv for current thread
> +   In a logicial world dtv here would also point to the length of the DTV.
> +   However it does not, this time it points to the generation counter,
> +   so just store it.
> +
> +   Note: -1 is still valid and contains the length.  */
> +
> +# define INSTALL_NEW_DTV(dtv) (THREAD_DTV() = (dtv))
> +
> +/* Return dtv of given thread descriptor.  */
> +# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv)
> +
> +/* Code to initially initialize the thread pointer.
> +
> +   Set TP to the address _after_ tcbhead_t.  This will allow us
> +   to change the size of tcbhead_t without having to re-link everything.
> +
> +   This has to return NULL on success (or a string with the failure text).
> +   It's hard to fail this, so return NULL always.  */
> +
> +# define TLS_INIT_TP(tcbp) \
> +  ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;})
> +
> +/* Value passed to 'clone' for initialization of the thread register.  */
> +# define TLS_DEFINE_INIT_TP(tp, pd) \
> +  void *tp = ((char *) pd + TLS_PRE_TCB_SIZE + TLS_INIT_TCB_SIZE)
> +
> +/* Return the address of the dtv for the current thread.
> +
> +   Dereference TP, offset to dtv - really straightforward.
> +   Remember that we made TP point to after tcb, so we need to reverse that.  */
> +
> +#  define THREAD_DTV() \
> +  ((((tcbhead_t *)__thread_self)-1)->dtv)
> +
> +/* Return the thread descriptor for the current thread.
> +
> +   Return a pointer to the TLS_PRE area where we allocated space for
> +   a struct pthread.  Again, TP points to after tcbhead_t, compensate with
> +   TLS_INIT_TCB_SIZE.
> +
> +   I regard this is a seperate system from the "normal" TLS.  */
> +
> +# define THREAD_SELF \
> +  ((struct pthread *) ((char *) __thread_self - TLS_INIT_TCB_SIZE \
> +    - TLS_PRE_TCB_SIZE))
> +
> +/* Magic for libthread_db to know how to do THREAD_SELF.  */
> +
> +# define DB_THREAD_SELF \
> +  REGISTER (32, 32, 10 * 4, - TLS_INIT_TCB_SIZE - TLS_PRE_TCB_SIZE)
> +
> +/* Access to data in the thread descriptor is easy.  */
> +
> +#define THREAD_GETMEM(descr, member) \
> +  descr->member
> +#define THREAD_GETMEM_NC(descr, member, idx) \
> +  descr->member[idx]
> +#define THREAD_SETMEM(descr, member, value) \
> +  descr->member = (value)
> +#define THREAD_SETMEM_NC(descr, member, idx, value) \
> +  descr->member[idx] = (value)
> +
> +/* Get and set the global scope generation counter in struct pthread.  */
> +
> +#define THREAD_GSCOPE_FLAG_UNUSED 0
> +#define THREAD_GSCOPE_FLAG_USED   1
> +#define THREAD_GSCOPE_FLAG_WAIT   2
> +#define THREAD_GSCOPE_RESET_FLAG()					\
> +  do									\
> +    {									\
> +      int __res = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,\
> +				       THREAD_GSCOPE_FLAG_UNUSED);	\
> +      if (__res == THREAD_GSCOPE_FLAG_WAIT)				\
> +	  lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1,		\
> +			  LLL_PRIVATE);					\
> +    }									\
> +  while (0)
> +#define THREAD_GSCOPE_SET_FLAG()					\
> +  do									\
> +    {									\
> +      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	\
> +      atomic_write_barrier ();						\
> +    }									\
> +  while (0)
> +
> +#endif /* __ASSEMBLER__ */
> +
> +#endif  /* tls.h */
> diff --git a/sysdeps/or1k/stackinfo.h b/sysdeps/or1k/stackinfo.h
> new file mode 100644
> index 0000000000..9273e709bd
> --- /dev/null
> +++ b/sysdeps/or1k/stackinfo.h
> @@ -0,0 +1,34 @@
> +/* Stack definitions for OpenRISC.
> +   Copyright (C) 2021 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
> +   <https://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 or1k the stack grows down.  */
> +#define _STACK_GROWS_DOWN	1
> +
> +/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
> +   present, but it is presumed absent.  */
> +#define DEFAULT_STACK_PERMS (PF_R | PF_W | PF_X)

Do you really a default stack executable? It is only done for older ABIs and that's
why PT_GNU_STACK was created. Newer ports, like arc and csky assumes otherwise.

> +
> +#endif /* stackinfo.h */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 06/13] or1k: Atomics and Locking primitives
  2021-12-10 23:34 ` [PATCH v3 06/13] or1k: Atomics and Locking primitives Stafford Horne
@ 2021-12-16 12:52   ` Adhemerval Zanella
  2021-12-16 19:43     ` Adhemerval Zanella
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 12:52 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc

LGTM, thanks.

On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> ---
>  sysdeps/or1k/atomic-machine.h | 79 +++++++++++++++++++++++++++++++++++
>  1 file changed, 79 insertions(+)
>  create mode 100644 sysdeps/or1k/atomic-machine.h
> 
> diff --git a/sysdeps/or1k/atomic-machine.h b/sysdeps/or1k/atomic-machine.h
> new file mode 100644
> index 0000000000..1e306ae4ef
> --- /dev/null
> +++ b/sysdeps/or1k/atomic-machine.h
> @@ -0,0 +1,79 @@
> +/* Atomic operations.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef __OR1K_ATOMIC_H_
> +#define __OR1K_ATOMIC_H_
> +
> +#include <stdint.h>
> +
> +typedef int32_t atomic32_t;
> +typedef uint32_t uatomic32_t;
> +
> +typedef intptr_t atomicptr_t;
> +typedef uintptr_t uatomicptr_t;
> +typedef intmax_t atomic_max_t;
> +typedef uintmax_t uatomic_max_t;

Sigh, these definition are used solely in only file, memusage.c.  Another thing
I will cleanup.

> +
> +#define __HAVE_64B_ATOMICS 0
> +#define USE_ATOMIC_COMPILER_BUILTINS 1
> +#define ATOMIC_EXCHANGE_USES_CAS 1
> +
> +#define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \
> +  (abort (), 0)
> +
> +#define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \
> +  (abort (), 0)
> +
> +#define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \
> +  ({                                                                    \
> +    typeof (*mem) __oldval = (oldval);                                  \
> +    !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   \
> +				  model, __ATOMIC_RELAXED);             \
> +  })
> +
> +#define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \
> +  (abort (), 0)
> +
> +#define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \
> +  (abort (), (__typeof (*mem)) 0)
> +
> +#define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \
> +  (abort (), (__typeof (*mem)) 0)
> +
> +#define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \
> +  ({                                                                    \
> +    typeof (*mem) __oldval = (oldval);                                  \
> +    __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,    \
> +				 model, __ATOMIC_RELAXED);              \
> +    __oldval;                                                           \
> +  })
> +
> +#define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \
> +  (abort (), (__typeof (*mem)) 0)
> +
> +#define atomic_compare_and_exchange_bool_acq(mem, new, old)		\
> +  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int,		\
> +			mem, new, old, __ATOMIC_ACQUIRE)
> +
> +#define atomic_compare_and_exchange_val_acq(mem, new, old)		\
> +  __atomic_val_bysize (__arch_compare_and_exchange_val, int,		\
> +		       mem, new, old, __ATOMIC_ACQUIRE)
> +
> +#define atomic_full_barrier() ({ asm volatile ("l.msync" ::: "memory"); })

And I think we can also clean this up as well.

> +
> +#endif /* atomic-machine.h */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 05/13] or1k: Thread Local Storage support
  2021-12-16 12:37   ` Adhemerval Zanella
@ 2021-12-16 19:26     ` Joseph Myers
  2021-12-16 19:33       ` Adhemerval Zanella
  2021-12-17 14:23     ` Stafford Horne
  1 sibling, 1 reply; 61+ messages in thread
From: Joseph Myers @ 2021-12-16 19:26 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Stafford Horne, GLIBC patches, Openrisc

On Thu, 16 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:

> > +/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
> > +   present, but it is presumed absent.  */
> > +#define DEFAULT_STACK_PERMS (PF_R | PF_W | PF_X)
> 
> Do you really a default stack executable? It is only done for older ABIs 
> and that's why PT_GNU_STACK was created. Newer ports, like arc and csky 
> assumes otherwise.

I think this reflects what the kernel does (the relevant definitions being 
elf_read_implies_exec and VM_STACK_DEFAULT_FLAGS / VM_DATA_DEFAULT_FLAGS, 
none of which are overridden for openrisc, so the default 
VM_DATA_DEFAULT_FLAGS definition of VM_DATA_FLAGS_EXEC applies).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 05/13] or1k: Thread Local Storage support
  2021-12-16 19:26     ` Joseph Myers
@ 2021-12-16 19:33       ` Adhemerval Zanella
  0 siblings, 0 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 19:33 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Stafford Horne, GLIBC patches, Openrisc



On 16/12/2021 16:26, Joseph Myers wrote:
> On Thu, 16 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:
> 
>>> +/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
>>> +   present, but it is presumed absent.  */
>>> +#define DEFAULT_STACK_PERMS (PF_R | PF_W | PF_X)
>>
>> Do you really a default stack executable? It is only done for older ABIs 
>> and that's why PT_GNU_STACK was created. Newer ports, like arc and csky 
>> assumes otherwise.
> 
> I think this reflects what the kernel does (the relevant definitions being 
> elf_read_implies_exec and VM_STACK_DEFAULT_FLAGS / VM_DATA_DEFAULT_FLAGS, 
> none of which are overridden for openrisc, so the default 
> VM_DATA_DEFAULT_FLAGS definition of VM_DATA_FLAGS_EXEC applies).
> 

Fair enough, this part is correct then.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 06/13] or1k: Atomics and Locking primitives
  2021-12-16 12:52   ` Adhemerval Zanella
@ 2021-12-16 19:43     ` Adhemerval Zanella
  2021-12-17 15:03       ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 19:43 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 16/12/2021 09:52, Adhemerval Zanella wrote:
> LGTM, thanks.
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
>> ---
>>  sysdeps/or1k/atomic-machine.h | 79 +++++++++++++++++++++++++++++++++++
>>  1 file changed, 79 insertions(+)
>>  create mode 100644 sysdeps/or1k/atomic-machine.h
>>
>> diff --git a/sysdeps/or1k/atomic-machine.h b/sysdeps/or1k/atomic-machine.h
>> new file mode 100644
>> index 0000000000..1e306ae4ef
>> --- /dev/null
>> +++ b/sysdeps/or1k/atomic-machine.h
>> @@ -0,0 +1,79 @@
>> +/* Atomic operations.  OpenRISC version.
>> +   Copyright (C) 2021 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
>> +   <https://www.gnu.org/licenses/>.  */
>> +
>> +#ifndef __OR1K_ATOMIC_H_
>> +#define __OR1K_ATOMIC_H_
>> +
>> +#include <stdint.h>
>> +
>> +typedef int32_t atomic32_t;
>> +typedef uint32_t uatomic32_t;
>> +
>> +typedef intptr_t atomicptr_t;
>> +typedef uintptr_t uatomicptr_t;
>> +typedef intmax_t atomic_max_t;
>> +typedef uintmax_t uatomic_max_t;
> 
> Sigh, these definition are used solely in only file, memusage.c.  Another thing
> I will cleanup.

I just send a patchset that aims to simplify this boilerplate [1].  It should
also simplify other parts of OpenRISC submission.

[1] https://sourceware.org/pipermail/libc-alpha/2021-December/134285.html

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 07/13] or1k: math soft float support
  2021-12-10 23:34 ` [PATCH v3 07/13] or1k: math soft float support Stafford Horne
@ 2021-12-16 19:48   ` Adhemerval Zanella
  2021-12-17 15:02     ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 19:48 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> OpenRISC support hard float but I will like to submit that after glibc
> soft float goes upstream.  The hard float support depends on adding user
> access to the FPCSR, which is not supported by the kernel yet.

The patch looks ok in general, the fenv bits matches the documentation. 

> ---
>  sysdeps/or1k/bits/fenv.h                   |   69 ++
>  sysdeps/or1k/libm-test-ulps                | 1112 ++++++++++++++++++++
>  sysdeps/or1k/libm-test-ulps-name           |    1 +
>  sysdeps/or1k/nofpu/math-tests-exceptions.h |   29 +
>  sysdeps/or1k/nofpu/math-tests-rounding.h   |   28 +
>  sysdeps/or1k/sfp-machine.h                 |   93 ++
>  sysdeps/or1k/tininess.h                    |    1 +
>  7 files changed, 1333 insertions(+)
>  create mode 100644 sysdeps/or1k/bits/fenv.h
>  create mode 100644 sysdeps/or1k/libm-test-ulps
>  create mode 100644 sysdeps/or1k/libm-test-ulps-name
>  create mode 100644 sysdeps/or1k/nofpu/math-tests-exceptions.h
>  create mode 100644 sysdeps/or1k/nofpu/math-tests-rounding.h
>  create mode 100644 sysdeps/or1k/sfp-machine.h
>  create mode 100644 sysdeps/or1k/tininess.h
> 
> diff --git a/sysdeps/or1k/bits/fenv.h b/sysdeps/or1k/bits/fenv.h
> new file mode 100644
> index 0000000000..721136a57d
> --- /dev/null
> +++ b/sysdeps/or1k/bits/fenv.h
> @@ -0,0 +1,69 @@
> +/* Floating point environment, OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _FENV_H
> +# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
> +#endif
> +
> +/* Define bits representing exceptions in the FPCSR status word.  */
> +enum
> +  {
> +    FE_OVERFLOW =
> +#define FE_OVERFLOW	(1 << 3)
> +      FE_OVERFLOW,
> +    FE_UNDERFLOW =
> +#define FE_UNDERFLOW	(1 << 4)
> +      FE_UNDERFLOW,
> +    FE_INEXACT =
> +#define FE_INEXACT	(1 << 8)
> +      FE_INEXACT,
> +    FE_INVALID =
> +#define FE_INVALID	(1 << 9)
> +      FE_INVALID,
> +    FE_DIVBYZERO =
> +#define FE_DIVBYZERO	(1 << 11)
> +      FE_DIVBYZERO,
> +  };
> +

Ok, these match the recv 1.3 documentation.

> +/* All supported exceptions.  */
> +#define FE_ALL_EXCEPT	\
> +	(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
> +
> +/* Define bits representing rounding modes in the FPCSR Rmode field.  */
> +#define FE_TONEAREST  (0x0 << 1)
> +#define FE_TOWARDZERO (0x1 << 1)
> +#define FE_UPWARD     (0x2 << 1)
> +#define FE_DOWNWARD   (0x3 << 1)
> +

Same.

> +/* Type representing exception flags.  */
> +typedef unsigned int fexcept_t;
> +
> +/* Type representing floating-point environment.  */
> +typedef unsigned int fenv_t;
> +
> +/* If the default argument is used we use this value.  */
> +#define FE_DFL_ENV	((const fenv_t *) -1l)
> +
> +#if __GLIBC_USE (IEC_60559_BFP_EXT)
> +/* Type representing floating-point control modes.  */
> +typedef unsigned int femode_t;
> +
> +/* Default floating-point control modes.  */
> +# define FE_DFL_MODE	((const femode_t *) -1L)
> +#endif
> diff --git a/sysdeps/or1k/libm-test-ulps b/sysdeps/or1k/libm-test-ulps
> new file mode 100644
> index 0000000000..94b383669d
> --- /dev/null
> +++ b/sysdeps/or1k/libm-test-ulps
> @@ -0,0 +1,1112 @@
> +# Begin of automatic generation
> +
> +# Maximal error of functions:
> +Function: "acos":
> +double: 1
> +float: 1
> +
> +Function: "acos_downward":
> +double: 1
> +float: 1
> +
> +Function: "acos_towardzero":
> +double: 1
> +float: 1
> +
> +Function: "acos_upward":
> +double: 1
> +float: 1
> +
> +Function: "acosh":
> +double: 2
> +float: 2
> +
> +Function: "acosh_downward":
> +double: 2
> +float: 2
> +
> +Function: "acosh_towardzero":
> +double: 2
> +float: 2
> +
> +Function: "acosh_upward":
> +double: 2
> +float: 2
> +
> +Function: "asin":
> +double: 1
> +float: 1
> +
> +Function: "asin_downward":
> +double: 1
> +float: 1
> +
> +Function: "asin_towardzero":
> +double: 1
> +float: 1
> +
> +Function: "asin_upward":
> +double: 1
> +float: 1
> +
> +Function: "asinh":
> +double: 2
> +float: 2
> +
> +Function: "asinh_downward":
> +double: 3
> +float: 3
> +
> +Function: "asinh_towardzero":
> +double: 2
> +float: 2
> +
> +Function: "asinh_upward":
> +double: 3
> +float: 3
> +
> +Function: "atan":
> +double: 1
> +float: 1
> +
> +Function: "atan2":
> +float: 2
> +
> +Function: "atan2_downward":
> +double: 5
> +float: 2
> +
> +Function: "atan2_towardzero":
> +double: 5
> +float: 2
> +
> +Function: "atan2_upward":
> +double: 8
> +float: 2
> +
> +Function: "atan_downward":
> +double: 1
> +float: 2
> +
> +Function: "atan_towardzero":
> +double: 1
> +float: 1
> +
> +Function: "atan_upward":
> +double: 1
> +float: 2
> +
> +Function: "atanh":
> +double: 2
> +float: 2
> +
> +Function: "atanh_downward":
> +double: 3
> +float: 3
> +
> +Function: "atanh_towardzero":
> +double: 2
> +float: 2
> +
> +Function: "atanh_upward":
> +double: 3
> +float: 3
> +
> +Function: "cabs":
> +double: 1
> +
> +Function: "cabs_downward":
> +double: 1
> +
> +Function: "cabs_towardzero":
> +double: 1
> +
> +Function: "cabs_upward":
> +double: 1
> +
> +Function: Real part of "cacos":
> +double: 1
> +float: 2
> +
> +Function: Imaginary part of "cacos":
> +double: 2
> +float: 2
> +
> +Function: Real part of "cacos_downward":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "cacos_downward":
> +double: 5
> +float: 3
> +
> +Function: Real part of "cacos_towardzero":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "cacos_towardzero":
> +double: 4
> +float: 2
> +
> +Function: Real part of "cacos_upward":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "cacos_upward":
> +double: 5
> +float: 7
> +
> +Function: Real part of "cacosh":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "cacosh":
> +double: 1
> +float: 2
> +
> +Function: Real part of "cacosh_downward":
> +double: 4
> +float: 2
> +
> +Function: Imaginary part of "cacosh_downward":
> +double: 3
> +float: 3
> +
> +Function: Real part of "cacosh_towardzero":
> +double: 4
> +float: 2
> +
> +Function: Imaginary part of "cacosh_towardzero":
> +double: 3
> +float: 2
> +
> +Function: Real part of "cacosh_upward":
> +double: 4
> +float: 3
> +
> +Function: Imaginary part of "cacosh_upward":
> +double: 3
> +float: 2
> +
> +Function: "carg":
> +float: 1
> +
> +Function: "carg_downward":
> +double: 5
> +float: 2
> +
> +Function: "carg_towardzero":
> +double: 5
> +float: 2
> +
> +Function: "carg_upward":
> +double: 8
> +float: 2
> +
> +Function: Real part of "casin":
> +double: 1
> +float: 1
> +
> +Function: Imaginary part of "casin":
> +double: 2
> +float: 2
> +
> +Function: Real part of "casin_downward":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "casin_downward":
> +double: 5
> +float: 3
> +
> +Function: Real part of "casin_towardzero":
> +double: 3
> +float: 1
> +
> +Function: Imaginary part of "casin_towardzero":
> +double: 4
> +float: 2
> +
> +Function: Real part of "casin_upward":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "casin_upward":
> +double: 5
> +float: 7
> +
> +Function: Real part of "casinh":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "casinh":
> +double: 1
> +float: 1
> +
> +Function: Real part of "casinh_downward":
> +double: 5
> +float: 3
> +
> +Function: Imaginary part of "casinh_downward":
> +double: 3
> +float: 2
> +
> +Function: Real part of "casinh_towardzero":
> +double: 4
> +float: 2
> +
> +Function: Imaginary part of "casinh_towardzero":
> +double: 3
> +float: 1
> +
> +Function: Real part of "casinh_upward":
> +double: 5
> +float: 7
> +
> +Function: Imaginary part of "casinh_upward":
> +double: 3
> +float: 2
> +
> +Function: Real part of "catan":
> +double: 1
> +float: 1
> +
> +Function: Imaginary part of "catan":
> +double: 1
> +float: 1
> +
> +Function: Real part of "catan_downward":
> +double: 1
> +float: 2
> +
> +Function: Imaginary part of "catan_downward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "catan_towardzero":
> +double: 1
> +float: 2
> +
> +Function: Imaginary part of "catan_towardzero":
> +double: 2
> +float: 2
> +
> +Function: Real part of "catan_upward":
> +double: 2
> +float: 1
> +
> +Function: Imaginary part of "catan_upward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "catanh":
> +double: 1
> +float: 1
> +
> +Function: Imaginary part of "catanh":
> +double: 1
> +float: 1
> +
> +Function: Real part of "catanh_downward":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "catanh_downward":
> +double: 1
> +float: 2
> +
> +Function: Real part of "catanh_towardzero":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "catanh_towardzero":
> +double: 1
> +float: 2
> +
> +Function: Real part of "catanh_upward":
> +double: 4
> +float: 4
> +
> +Function: Imaginary part of "catanh_upward":
> +double: 2
> +float: 1
> +
> +Function: "cbrt":
> +double: 4
> +float: 1
> +
> +Function: "cbrt_downward":
> +double: 4
> +float: 1
> +
> +Function: "cbrt_towardzero":
> +double: 3
> +float: 1
> +
> +Function: "cbrt_upward":
> +double: 5
> +float: 1
> +
> +Function: Real part of "ccos":
> +double: 1
> +float: 1
> +
> +Function: Imaginary part of "ccos":
> +double: 1
> +float: 1
> +
> +Function: Real part of "ccos_downward":
> +double: 3
> +float: 1
> +
> +Function: Imaginary part of "ccos_downward":
> +double: 3
> +float: 3
> +
> +Function: Real part of "ccos_towardzero":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "ccos_towardzero":
> +double: 3
> +float: 3
> +
> +Function: Real part of "ccos_upward":
> +double: 1
> +float: 2
> +
> +Function: Imaginary part of "ccos_upward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "ccosh":
> +double: 2
> +float: 1
> +
> +Function: Imaginary part of "ccosh":
> +double: 1
> +float: 1
> +
> +Function: Real part of "ccosh_downward":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "ccosh_downward":
> +double: 3
> +float: 3
> +
> +Function: Real part of "ccosh_towardzero":
> +double: 3
> +float: 3
> +
> +Function: Imaginary part of "ccosh_towardzero":
> +double: 3
> +float: 3
> +
> +Function: Real part of "ccosh_upward":
> +double: 1
> +float: 2
> +
> +Function: Imaginary part of "ccosh_upward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "cexp":
> +double: 2
> +float: 1
> +
> +Function: Imaginary part of "cexp":
> +double: 1
> +float: 2
> +
> +Function: Real part of "cexp_downward":
> +double: 4
> +float: 2
> +
> +Function: Imaginary part of "cexp_downward":
> +double: 3
> +float: 3
> +
> +Function: Real part of "cexp_towardzero":
> +double: 4
> +float: 2
> +
> +Function: Imaginary part of "cexp_towardzero":
> +double: 3
> +float: 3
> +
> +Function: Real part of "cexp_upward":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "cexp_upward":
> +double: 3
> +float: 2
> +
> +Function: Real part of "clog":
> +double: 3
> +float: 3
> +
> +Function: Imaginary part of "clog":
> +double: 1
> +float: 1
> +
> +Function: Real part of "clog10":
> +double: 3
> +float: 4
> +
> +Function: Imaginary part of "clog10":
> +double: 2
> +float: 2
> +
> +Function: Real part of "clog10_downward":
> +double: 7
> +float: 5
> +
> +Function: Imaginary part of "clog10_downward":
> +double: 8
> +float: 4
> +
> +Function: Real part of "clog10_towardzero":
> +double: 5
> +float: 5
> +
> +Function: Imaginary part of "clog10_towardzero":
> +double: 8
> +float: 4
> +
> +Function: Real part of "clog10_upward":
> +double: 6
> +float: 5
> +
> +Function: Imaginary part of "clog10_upward":
> +double: 5
> +float: 4
> +
> +Function: Real part of "clog_downward":
> +double: 4
> +float: 3
> +
> +Function: Imaginary part of "clog_downward":
> +double: 5
> +float: 2
> +
> +Function: Real part of "clog_towardzero":
> +double: 8
> +float: 4
> +
> +Function: Imaginary part of "clog_towardzero":
> +double: 5
> +float: 3
> +
> +Function: Real part of "clog_upward":
> +double: 8
> +float: 3
> +
> +Function: Imaginary part of "clog_upward":
> +double: 8
> +float: 2
> +
> +Function: "cos":
> +double: 1
> +float: 1
> +
> +Function: "cos_downward":
> +double: 1
> +float: 1
> +
> +Function: "cos_towardzero":
> +double: 4
> +float: 1
> +
> +Function: "cos_upward":
> +double: 4
> +float: 1
> +
> +Function: "cosh":
> +double: 2
> +float: 2
> +
> +Function: "cosh_downward":
> +double: 2
> +float: 1
> +
> +Function: "cosh_towardzero":
> +double: 2
> +float: 1
> +
> +Function: "cosh_upward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "cpow":
> +double: 2
> +float: 5
> +
> +Function: Imaginary part of "cpow":
> +float: 2
> +
> +Function: Real part of "cpow_downward":
> +double: 5
> +float: 8
> +
> +Function: Imaginary part of "cpow_downward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "cpow_towardzero":
> +double: 5
> +float: 8
> +
> +Function: Imaginary part of "cpow_towardzero":
> +double: 2
> +float: 2
> +
> +Function: Real part of "cpow_upward":
> +double: 4
> +float: 1
> +
> +Function: Imaginary part of "cpow_upward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "csin":
> +double: 1
> +float: 1
> +
> +Function: Real part of "csin_downward":
> +double: 3
> +float: 3
> +
> +Function: Imaginary part of "csin_downward":
> +double: 3
> +float: 1
> +
> +Function: Real part of "csin_towardzero":
> +double: 3
> +float: 3
> +
> +Function: Imaginary part of "csin_towardzero":
> +double: 3
> +float: 1
> +
> +Function: Real part of "csin_upward":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "csin_upward":
> +double: 1
> +float: 2
> +
> +Function: Real part of "csinh":
> +float: 1
> +
> +Function: Imaginary part of "csinh":
> +double: 1
> +float: 1
> +
> +Function: Real part of "csinh_downward":
> +double: 3
> +float: 1
> +
> +Function: Imaginary part of "csinh_downward":
> +double: 3
> +float: 3
> +
> +Function: Real part of "csinh_towardzero":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "csinh_towardzero":
> +double: 3
> +float: 3
> +
> +Function: Real part of "csinh_upward":
> +double: 1
> +float: 2
> +
> +Function: Imaginary part of "csinh_upward":
> +double: 2
> +float: 2
> +
> +Function: Real part of "csqrt":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "csqrt":
> +double: 2
> +float: 2
> +
> +Function: Real part of "csqrt_downward":
> +double: 5
> +float: 4
> +
> +Function: Imaginary part of "csqrt_downward":
> +double: 4
> +float: 3
> +
> +Function: Real part of "csqrt_towardzero":
> +double: 4
> +float: 3
> +
> +Function: Imaginary part of "csqrt_towardzero":
> +double: 4
> +float: 3
> +
> +Function: Real part of "csqrt_upward":
> +double: 5
> +float: 4
> +
> +Function: Imaginary part of "csqrt_upward":
> +double: 3
> +float: 3
> +
> +Function: Real part of "ctan":
> +double: 1
> +float: 1
> +
> +Function: Imaginary part of "ctan":
> +double: 2
> +float: 2
> +
> +Function: Real part of "ctan_downward":
> +double: 6
> +float: 5
> +
> +Function: Imaginary part of "ctan_downward":
> +double: 3
> +float: 2
> +
> +Function: Real part of "ctan_towardzero":
> +double: 5
> +float: 3
> +
> +Function: Imaginary part of "ctan_towardzero":
> +double: 3
> +float: 2
> +
> +Function: Real part of "ctan_upward":
> +double: 2
> +float: 4
> +
> +Function: Imaginary part of "ctan_upward":
> +double: 2
> +float: 1
> +
> +Function: Real part of "ctanh":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "ctanh":
> +double: 2
> +float: 2
> +
> +Function: Real part of "ctanh_downward":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "ctanh_downward":
> +double: 6
> +float: 5
> +
> +Function: Real part of "ctanh_towardzero":
> +double: 3
> +float: 2
> +
> +Function: Imaginary part of "ctanh_towardzero":
> +double: 5
> +float: 3
> +
> +Function: Real part of "ctanh_upward":
> +double: 2
> +float: 2
> +
> +Function: Imaginary part of "ctanh_upward":
> +double: 2
> +float: 3
> +
> +Function: "erf":
> +double: 1
> +float: 1
> +
> +Function: "erf_downward":
> +double: 1
> +float: 1
> +
> +Function: "erf_towardzero":
> +double: 1
> +float: 1
> +
> +Function: "erf_upward":
> +double: 1
> +float: 1
> +
> +Function: "erfc":
> +double: 5
> +float: 3
> +
> +Function: "erfc_downward":
> +double: 5
> +float: 6
> +
> +Function: "erfc_towardzero":
> +double: 3
> +float: 4
> +
> +Function: "erfc_upward":
> +double: 5
> +float: 6
> +
> +Function: "exp":
> +double: 1
> +float: 1
> +
> +Function: "exp10":
> +double: 2
> +float: 1
> +
> +Function: "exp10_downward":
> +double: 3
> +
> +Function: "exp10_towardzero":
> +double: 3
> +
> +Function: "exp10_upward":
> +double: 2
> +float: 1
> +
> +Function: "exp2":
> +double: 1
> +
> +Function: "exp2_downward":
> +double: 1
> +
> +Function: "exp2_towardzero":
> +double: 1
> +
> +Function: "exp2_upward":
> +double: 1
> +float: 1
> +
> +Function: "exp_downward":
> +double: 1
> +float: 1
> +
> +Function: "exp_towardzero":
> +double: 1
> +float: 1
> +
> +Function: "exp_upward":
> +double: 1
> +float: 1
> +
> +Function: "expm1":
> +double: 1
> +float: 1
> +
> +Function: "expm1_downward":
> +double: 1
> +float: 1
> +
> +Function: "expm1_towardzero":
> +double: 1
> +float: 2
> +
> +Function: "expm1_upward":
> +double: 1
> +float: 1
> +
> +Function: "gamma":
> +double: 4
> +float: 7
> +
> +Function: "gamma_downward":
> +double: 7
> +float: 7
> +
> +Function: "gamma_towardzero":
> +double: 7
> +float: 7
> +
> +Function: "gamma_upward":
> +double: 5
> +float: 6
> +
> +Function: "hypot":
> +double: 1
> +
> +Function: "hypot_downward":
> +double: 1
> +
> +Function: "hypot_towardzero":
> +double: 1
> +
> +Function: "hypot_upward":
> +double: 1
> +
> +Function: "j0":
> +double: 2
> +float: 9
> +
> +Function: "j0_downward":
> +double: 2
> +float: 4
> +
> +Function: "j0_towardzero":
> +double: 4
> +float: 5
> +
> +Function: "j0_upward":
> +double: 4
> +float: 5
> +
> +Function: "j1":
> +double: 4
> +float: 9
> +
> +Function: "j1_downward":
> +double: 4
> +float: 5
> +
> +Function: "j1_towardzero":
> +double: 4
> +float: 2
> +
> +Function: "j1_upward":
> +double: 3
> +float: 5
> +
> +Function: "jn":
> +double: 4
> +float: 4
> +
> +Function: "jn_downward":
> +double: 7
> +float: 9
> +
> +Function: "jn_towardzero":
> +double: 7
> +float: 9
> +
> +Function: "jn_upward":
> +double: 7
> +float: 9
> +
> +Function: "lgamma":
> +double: 4
> +float: 7
> +
> +Function: "lgamma_downward":
> +double: 7
> +float: 7
> +
> +Function: "lgamma_towardzero":
> +double: 7
> +float: 7
> +
> +Function: "lgamma_upward":
> +double: 5
> +float: 6
> +
> +Function: "log10":
> +double: 2
> +float: 2
> +
> +Function: "log10_downward":
> +double: 2
> +float: 3
> +
> +Function: "log10_towardzero":
> +double: 2
> +float: 1
> +
> +Function: "log10_upward":
> +double: 2
> +float: 2
> +
> +Function: "log1p":
> +double: 1
> +float: 1
> +
> +Function: "log1p_downward":
> +double: 2
> +float: 2
> +
> +Function: "log1p_towardzero":
> +double: 2
> +float: 2
> +
> +Function: "log1p_upward":
> +double: 2
> +float: 2
> +
> +Function: "log2":
> +float: 1
> +
> +Function: "log2_downward":
> +double: 1
> +
> +Function: "log2_towardzero":
> +double: 1
> +
> +Function: "log2_upward":
> +double: 1
> +
> +Function: "pow":
> +double: 1
> +
> +Function: "pow_downward":
> +double: 1
> +float: 1
> +
> +Function: "pow_towardzero":
> +double: 1
> +float: 1
> +
> +Function: "pow_upward":
> +double: 1
> +float: 1
> +
> +Function: "sin":
> +double: 1
> +float: 1
> +
> +Function: "sin_downward":
> +double: 4
> +float: 1
> +
> +Function: "sin_towardzero":
> +double: 3
> +float: 1
> +
> +Function: "sin_upward":
> +double: 7
> +float: 1
> +
> +Function: "sincos":
> +double: 1
> +
> +Function: "sincos_downward":
> +double: 1
> +float: 1
> +
> +Function: "sincos_towardzero":
> +double: 4
> +float: 1
> +
> +Function: "sincos_upward":
> +double: 1
> +float: 1
> +
> +Function: "sinh":
> +double: 2
> +float: 2
> +
> +Function: "sinh_downward":
> +double: 3
> +float: 3
> +
> +Function: "sinh_towardzero":
> +double: 2
> +float: 2
> +
> +Function: "sinh_upward":
> +double: 3
> +float: 3
> +
> +Function: "tan":
> +float: 1
> +
> +Function: "tan_downward":
> +double: 1
> +float: 2
> +
> +Function: "tan_towardzero":
> +double: 1
> +float: 1
> +
> +Function: "tan_upward":
> +double: 1
> +float: 1
> +
> +Function: "tanh":
> +double: 2
> +float: 2
> +
> +Function: "tanh_downward":
> +double: 3
> +float: 3
> +
> +Function: "tanh_towardzero":
> +double: 2
> +float: 2
> +
> +Function: "tanh_upward":
> +double: 3
> +float: 3
> +
> +Function: "tgamma":
> +double: 9
> +float: 8
> +
> +Function: "tgamma_downward":
> +double: 9
> +float: 9
> +
> +Function: "tgamma_towardzero":
> +double: 9
> +float: 8
> +
> +Function: "tgamma_upward":
> +double: 9
> +float: 8
> +
> +Function: "y0":
> +double: 3
> +float: 9
> +
> +Function: "y0_downward":
> +double: 3
> +float: 6
> +
> +Function: "y0_towardzero":
> +double: 3
> +float: 3
> +
> +Function: "y0_upward":
> +double: 3
> +float: 6
> +
> +Function: "y1":
> +double: 3
> +float: 9
> +
> +Function: "y1_downward":
> +double: 6
> +float: 7
> +
> +Function: "y1_towardzero":
> +double: 3
> +float: 3
> +
> +Function: "y1_upward":
> +double: 7
> +float: 5
> +
> +Function: "yn":
> +double: 3
> +float: 3
> +
> +Function: "yn_downward":
> +double: 6
> +float: 8
> +
> +Function: "yn_towardzero":
> +double: 8
> +float: 8
> +
> +Function: "yn_upward":
> +double: 8
> +float: 8
> +
> +# end of automatic generation
> diff --git a/sysdeps/or1k/libm-test-ulps-name b/sysdeps/or1k/libm-test-ulps-name
> new file mode 100644
> index 0000000000..0af6591fd9
> --- /dev/null
> +++ b/sysdeps/or1k/libm-test-ulps-name
> @@ -0,0 +1 @@
> +OpenRISC
> diff --git a/sysdeps/or1k/nofpu/math-tests-exceptions.h b/sysdeps/or1k/nofpu/math-tests-exceptions.h
> new file mode 100644
> index 0000000000..cf4ed98279
> --- /dev/null
> +++ b/sysdeps/or1k/nofpu/math-tests-exceptions.h
> @@ -0,0 +1,29 @@
> +/* Configuration for math tests: support for exceptions.  OpenRISC no-FPU
> +   version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef OR1K_NOFPU_MATH_TESTS_EXCEPTIONS_H
> +#define OR1K_NOFPU_MATH_TESTS_EXCEPTIONS_H 1
> +
> +/* We support setting floating-point exception flags on hard-float
> +   targets.  These are not supported on soft-float targets.  */
> +#define EXCEPTION_TESTS_float 0
> +#define EXCEPTION_TESTS_double        0
> +#define EXCEPTION_TESTS_long_double   0
> +
> +#endif /* math-tests-exceptions.h.  */
> diff --git a/sysdeps/or1k/nofpu/math-tests-rounding.h b/sysdeps/or1k/nofpu/math-tests-rounding.h
> new file mode 100644
> index 0000000000..2b69a541a3
> --- /dev/null
> +++ b/sysdeps/or1k/nofpu/math-tests-rounding.h
> @@ -0,0 +1,28 @@
> +/* Configuration for math tests: rounding mode support.  OpenRISC no-FPU
> +   version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef OR1K_NOFPU_MATH_TESTS_ROUNDING_H
> +#define OR1K_NOFPU_MATH_TESTS_ROUNDING_H 1
> +
> +/* On soft-float targets we only support the "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 /* math-tests-rounding.h.  */
> diff --git a/sysdeps/or1k/sfp-machine.h b/sysdeps/or1k/sfp-machine.h
> new file mode 100644
> index 0000000000..18f2676510
> --- /dev/null
> +++ b/sysdeps/or1k/sfp-machine.h
> @@ -0,0 +1,93 @@
> +/* OpenRISC softfloat definitions.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define _FP_W_TYPE_SIZE		32
> +#define _FP_W_TYPE		unsigned long
> +#define _FP_WS_TYPE		signed long
> +#define _FP_I_TYPE		long
> +
> +#define _FP_MUL_MEAT_S(R,X,Y)				\
> +  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
> +#define _FP_MUL_MEAT_D(R,X,Y)				\
> +  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
> +#define _FP_MUL_MEAT_Q(R,X,Y)				\
> +  _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
> +
> +#define _FP_MUL_MEAT_DW_S(R,X,Y)				\
> +  _FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
> +#define _FP_MUL_MEAT_DW_D(R,X,Y)				\
> +  _FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
> +#define _FP_MUL_MEAT_DW_Q(R,X,Y)				\
> +  _FP_MUL_MEAT_DW_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
> +
> +
> +#define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_loop(S,R,X,Y)
> +#define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
> +#define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
> +
> +#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
> +#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
> +#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
> +#define _FP_NANSIGN_S		0
> +#define _FP_NANSIGN_D		0
> +#define _FP_NANSIGN_Q		0
> +
> +#define _FP_KEEPNANFRACP 1
> +#define _FP_QNANNEGATEDP 0
> +
> +/* Someone please check this.  */
> +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
> +  do {								\
> +    if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)		\
> +	&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))	\
> +      {								\
> +	R##_s = Y##_s;						\
> +	_FP_FRAC_COPY_##wc(R,Y);				\
> +      }								\
> +    else							\
> +      {								\
> +	R##_s = X##_s;						\
> +	_FP_FRAC_COPY_##wc(R,X);				\
> +      }								\
> +    R##_c = FP_CLS_NAN;						\
> +  } while (0)
> +
> +/* Handle getting and setting rounding mode for soft fp operations.  */
> +
> +#define FP_RND_NEAREST		(0x0 << 1)
> +#define FP_RND_ZERO		(0x1 << 1)
> +#define FP_RND_PINF		(0x2 << 1)
> +#define FP_RND_MINF		(0x3 << 1)
> +#define FP_RND_MASK		(0x3 << 1)
> +
> +#define FP_EX_OVERFLOW		(1 << 3)
> +#define FP_EX_UNDERFLOW		(1 << 4)
> +#define FP_EX_INEXACT		(1 << 8)
> +#define FP_EX_INVALID		(1 << 9)
> +#define FP_EX_DIVZERO		(1 << 11)
> +#define FP_EX_ALL \
> +	(FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \
> +	 | FP_EX_INEXACT)
> +
> +#define _FP_DECL_EX \
> +  unsigned int _fpcsr __attribute__ ((unused)) = FP_RND_NEAREST
> +
> +#define FP_ROUNDMODE (_fpcsr & FP_RND_MASK)
> +
> +#define _FP_TININESS_AFTER_ROUNDING 0
> diff --git a/sysdeps/or1k/tininess.h b/sysdeps/or1k/tininess.h
> new file mode 100644
> index 0000000000..dafbc6cad5
> --- /dev/null
> +++ b/sysdeps/or1k/tininess.h
> @@ -0,0 +1 @@
> +#define TININESS_AFTER_ROUNDING	0

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 08/13] or1k: Linux Syscall Interface
  2021-12-10 23:34 ` [PATCH v3 08/13] or1k: Linux Syscall Interface Stafford Horne
@ 2021-12-16 21:17   ` Adhemerval Zanella
  2021-12-17 15:01     ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-16 21:17 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc

Some comments below.

On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> ---
>  sysdeps/unix/sysv/linux/or1k/arch-syscall.h   | 325 ++++++++++++++++++
>  sysdeps/unix/sysv/linux/or1k/bits/timesize.h  |  19 +
>  sysdeps/unix/sysv/linux/or1k/clone.c          |  61 ++++
>  sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h |  41 +++
>  sysdeps/unix/sysv/linux/or1k/mmap_internal.h  |  28 ++
>  sysdeps/unix/sysv/linux/or1k/or1k_clone.S     |  89 +++++
>  sysdeps/unix/sysv/linux/or1k/sysdep.c         |  34 ++
>  sysdeps/unix/sysv/linux/or1k/sysdep.h         | 201 +++++++++++
>  8 files changed, 798 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/arch-syscall.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/timesize.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/clone.c
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/mmap_internal.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/or1k_clone.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.c
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.h
> 
> diff --git a/sysdeps/unix/sysv/linux/or1k/arch-syscall.h b/sysdeps/unix/sysv/linux/or1k/arch-syscall.h
> new file mode 100644
> index 0000000000..c6c3556137
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/arch-syscall.h
> @@ -0,0 +1,325 @@
> +/* AUTOGENERATED by update-syscall-lists.py.  */
> +#define __NR_accept 202
> +#define __NR_accept4 242
> +#define __NR_acct 89
> +#define __NR_add_key 217
> +#define __NR_adjtimex 171
> +#define __NR_bind 200
> +#define __NR_bpf 280
> +#define __NR_brk 214
> +#define __NR_capget 90
> +#define __NR_capset 91
> +#define __NR_chdir 49
> +#define __NR_chroot 51
> +#define __NR_clock_adjtime 266
> +#define __NR_clock_adjtime64 405
> +#define __NR_clock_getres 114
> +#define __NR_clock_getres_time64 406
> +#define __NR_clock_gettime 113
> +#define __NR_clock_gettime64 403
> +#define __NR_clock_nanosleep 115
> +#define __NR_clock_nanosleep_time64 407
> +#define __NR_clock_settime 112
> +#define __NR_clock_settime64 404
> +#define __NR_clone 220
> +#define __NR_clone3 435
> +#define __NR_close 57
> +#define __NR_close_range 436
> +#define __NR_connect 203
> +#define __NR_copy_file_range 285
> +#define __NR_delete_module 106
> +#define __NR_dup 23
> +#define __NR_dup3 24
> +#define __NR_epoll_create1 20
> +#define __NR_epoll_ctl 21
> +#define __NR_epoll_pwait 22
> +#define __NR_epoll_pwait2 441
> +#define __NR_eventfd2 19
> +#define __NR_execve 221
> +#define __NR_execveat 281
> +#define __NR_exit 93
> +#define __NR_exit_group 94
> +#define __NR_faccessat 48
> +#define __NR_faccessat2 439
> +#define __NR_fadvise64_64 223
> +#define __NR_fallocate 47
> +#define __NR_fanotify_init 262
> +#define __NR_fanotify_mark 263
> +#define __NR_fchdir 50
> +#define __NR_fchmod 52
> +#define __NR_fchmodat 53
> +#define __NR_fchown 55
> +#define __NR_fchownat 54
> +#define __NR_fcntl64 25
> +#define __NR_fdatasync 83
> +#define __NR_fgetxattr 10
> +#define __NR_finit_module 273
> +#define __NR_flistxattr 13
> +#define __NR_flock 32
> +#define __NR_fremovexattr 16
> +#define __NR_fsconfig 431
> +#define __NR_fsetxattr 7
> +#define __NR_fsmount 432
> +#define __NR_fsopen 430
> +#define __NR_fspick 433
> +#define __NR_fstat64 80
> +#define __NR_fstatat64 79
> +#define __NR_fstatfs64 44
> +#define __NR_fsync 82
> +#define __NR_ftruncate64 46
> +#define __NR_futex 98
> +#define __NR_futex_time64 422
> +#define __NR_get_mempolicy 236
> +#define __NR_get_robust_list 100
> +#define __NR_getcpu 168
> +#define __NR_getcwd 17
> +#define __NR_getdents64 61
> +#define __NR_getegid 177
> +#define __NR_geteuid 175
> +#define __NR_getgid 176
> +#define __NR_getgroups 158
> +#define __NR_getitimer 102
> +#define __NR_getpeername 205
> +#define __NR_getpgid 155
> +#define __NR_getpid 172
> +#define __NR_getppid 173
> +#define __NR_getpriority 141
> +#define __NR_getrandom 278
> +#define __NR_getresgid 150
> +#define __NR_getresuid 148
> +#define __NR_getrlimit 163
> +#define __NR_getrusage 165
> +#define __NR_getsid 156
> +#define __NR_getsockname 204
> +#define __NR_getsockopt 209
> +#define __NR_gettid 178
> +#define __NR_gettimeofday 169
> +#define __NR_getuid 174
> +#define __NR_getxattr 8
> +#define __NR_init_module 105
> +#define __NR_inotify_add_watch 27
> +#define __NR_inotify_init1 26
> +#define __NR_inotify_rm_watch 28
> +#define __NR_io_cancel 3
> +#define __NR_io_destroy 1
> +#define __NR_io_getevents 4
> +#define __NR_io_pgetevents 292
> +#define __NR_io_pgetevents_time64 416
> +#define __NR_io_setup 0
> +#define __NR_io_submit 2
> +#define __NR_io_uring_enter 426
> +#define __NR_io_uring_register 427
> +#define __NR_io_uring_setup 425
> +#define __NR_ioctl 29
> +#define __NR_ioprio_get 31
> +#define __NR_ioprio_set 30
> +#define __NR_kcmp 272
> +#define __NR_kexec_file_load 294
> +#define __NR_kexec_load 104
> +#define __NR_keyctl 219
> +#define __NR_kill 129
> +#define __NR_landlock_add_rule 445
> +#define __NR_landlock_create_ruleset 444
> +#define __NR_landlock_restrict_self 446
> +#define __NR_lgetxattr 9
> +#define __NR_linkat 37
> +#define __NR_listen 201
> +#define __NR_listxattr 11
> +#define __NR_llistxattr 12
> +#define __NR_llseek 62
> +#define __NR_lookup_dcookie 18
> +#define __NR_lremovexattr 15
> +#define __NR_lsetxattr 6
> +#define __NR_madvise 233
> +#define __NR_mbind 235
> +#define __NR_membarrier 283
> +#define __NR_memfd_create 279
> +#define __NR_migrate_pages 238
> +#define __NR_mincore 232
> +#define __NR_mkdirat 34
> +#define __NR_mknodat 33
> +#define __NR_mlock 228
> +#define __NR_mlock2 284
> +#define __NR_mlockall 230
> +#define __NR_mmap2 222
> +#define __NR_mount 40
> +#define __NR_mount_setattr 442
> +#define __NR_move_mount 429
> +#define __NR_move_pages 239
> +#define __NR_mprotect 226
> +#define __NR_mq_getsetattr 185
> +#define __NR_mq_notify 184
> +#define __NR_mq_open 180
> +#define __NR_mq_timedreceive 183
> +#define __NR_mq_timedreceive_time64 419
> +#define __NR_mq_timedsend 182
> +#define __NR_mq_timedsend_time64 418
> +#define __NR_mq_unlink 181
> +#define __NR_mremap 216
> +#define __NR_msgctl 187
> +#define __NR_msgget 186
> +#define __NR_msgrcv 188
> +#define __NR_msgsnd 189
> +#define __NR_msync 227
> +#define __NR_munlock 229
> +#define __NR_munlockall 231
> +#define __NR_munmap 215
> +#define __NR_name_to_handle_at 264
> +#define __NR_nanosleep 101
> +#define __NR_nfsservctl 42
> +#define __NR_open_by_handle_at 265
> +#define __NR_open_tree 428
> +#define __NR_openat 56
> +#define __NR_openat2 437
> +#define __NR_or1k_atomic 244
> +#define __NR_perf_event_open 241
> +#define __NR_personality 92
> +#define __NR_pidfd_getfd 438
> +#define __NR_pidfd_open 434
> +#define __NR_pidfd_send_signal 424
> +#define __NR_pipe2 59
> +#define __NR_pivot_root 41
> +#define __NR_pkey_alloc 289
> +#define __NR_pkey_free 290
> +#define __NR_pkey_mprotect 288
> +#define __NR_ppoll 73
> +#define __NR_ppoll_time64 414
> +#define __NR_prctl 167
> +#define __NR_pread64 67
> +#define __NR_preadv 69
> +#define __NR_preadv2 286
> +#define __NR_prlimit64 261
> +#define __NR_process_madvise 440
> +#define __NR_process_mrelease 448
> +#define __NR_process_vm_readv 270
> +#define __NR_process_vm_writev 271
> +#define __NR_pselect6 72
> +#define __NR_pselect6_time64 413
> +#define __NR_ptrace 117
> +#define __NR_pwrite64 68
> +#define __NR_pwritev 70
> +#define __NR_pwritev2 287
> +#define __NR_quotactl 60
> +#define __NR_quotactl_fd 443
> +#define __NR_read 63
> +#define __NR_readahead 213
> +#define __NR_readlinkat 78
> +#define __NR_readv 65
> +#define __NR_reboot 142
> +#define __NR_recvfrom 207
> +#define __NR_recvmmsg 243
> +#define __NR_recvmmsg_time64 417
> +#define __NR_recvmsg 212
> +#define __NR_remap_file_pages 234
> +#define __NR_removexattr 14
> +#define __NR_renameat 38
> +#define __NR_renameat2 276
> +#define __NR_request_key 218
> +#define __NR_restart_syscall 128
> +#define __NR_rseq 293
> +#define __NR_rt_sigaction 134
> +#define __NR_rt_sigpending 136
> +#define __NR_rt_sigprocmask 135
> +#define __NR_rt_sigqueueinfo 138
> +#define __NR_rt_sigreturn 139
> +#define __NR_rt_sigsuspend 133
> +#define __NR_rt_sigtimedwait 137
> +#define __NR_rt_sigtimedwait_time64 421
> +#define __NR_rt_tgsigqueueinfo 240
> +#define __NR_sched_get_priority_max 125
> +#define __NR_sched_get_priority_min 126
> +#define __NR_sched_getaffinity 123
> +#define __NR_sched_getattr 275
> +#define __NR_sched_getparam 121
> +#define __NR_sched_getscheduler 120
> +#define __NR_sched_rr_get_interval 127
> +#define __NR_sched_rr_get_interval_time64 423
> +#define __NR_sched_setaffinity 122
> +#define __NR_sched_setattr 274
> +#define __NR_sched_setparam 118
> +#define __NR_sched_setscheduler 119
> +#define __NR_sched_yield 124
> +#define __NR_seccomp 277
> +#define __NR_semctl 191
> +#define __NR_semget 190
> +#define __NR_semop 193
> +#define __NR_semtimedop 192
> +#define __NR_semtimedop_time64 420
> +#define __NR_sendfile64 71
> +#define __NR_sendmmsg 269
> +#define __NR_sendmsg 211
> +#define __NR_sendto 206
> +#define __NR_set_mempolicy 237
> +#define __NR_set_robust_list 99
> +#define __NR_set_tid_address 96
> +#define __NR_setdomainname 162
> +#define __NR_setfsgid 152
> +#define __NR_setfsuid 151
> +#define __NR_setgid 144
> +#define __NR_setgroups 159
> +#define __NR_sethostname 161
> +#define __NR_setitimer 103
> +#define __NR_setns 268
> +#define __NR_setpgid 154
> +#define __NR_setpriority 140
> +#define __NR_setregid 143
> +#define __NR_setresgid 149
> +#define __NR_setresuid 147
> +#define __NR_setreuid 145
> +#define __NR_setrlimit 164
> +#define __NR_setsid 157
> +#define __NR_setsockopt 208
> +#define __NR_settimeofday 170
> +#define __NR_setuid 146
> +#define __NR_setxattr 5
> +#define __NR_shmat 196
> +#define __NR_shmctl 195
> +#define __NR_shmdt 197
> +#define __NR_shmget 194
> +#define __NR_shutdown 210
> +#define __NR_sigaltstack 132
> +#define __NR_signalfd4 74
> +#define __NR_socket 198
> +#define __NR_socketpair 199
> +#define __NR_splice 76
> +#define __NR_statfs64 43
> +#define __NR_statx 291
> +#define __NR_swapoff 225
> +#define __NR_swapon 224
> +#define __NR_symlinkat 36
> +#define __NR_sync 81
> +#define __NR_sync_file_range 84
> +#define __NR_syncfs 267
> +#define __NR_sysinfo 179
> +#define __NR_syslog 116
> +#define __NR_tee 77
> +#define __NR_tgkill 131
> +#define __NR_timer_create 107
> +#define __NR_timer_delete 111
> +#define __NR_timer_getoverrun 109
> +#define __NR_timer_gettime 108
> +#define __NR_timer_gettime64 408
> +#define __NR_timer_settime 110
> +#define __NR_timer_settime64 409
> +#define __NR_timerfd_create 85
> +#define __NR_timerfd_gettime 87
> +#define __NR_timerfd_gettime64 410
> +#define __NR_timerfd_settime 86
> +#define __NR_timerfd_settime64 411
> +#define __NR_times 153
> +#define __NR_tkill 130
> +#define __NR_truncate64 45
> +#define __NR_umask 166
> +#define __NR_umount2 39
> +#define __NR_uname 160
> +#define __NR_unlinkat 35
> +#define __NR_unshare 97
> +#define __NR_userfaultfd 282
> +#define __NR_utimensat 88
> +#define __NR_utimensat_time64 412
> +#define __NR_vhangup 58
> +#define __NR_vmsplice 75
> +#define __NR_wait4 260
> +#define __NR_waitid 95
> +#define __NR_write 64
> +#define __NR_writev 66
> diff --git a/sysdeps/unix/sysv/linux/or1k/bits/timesize.h b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
> new file mode 100644
> index 0000000000..3ab388da7f
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
> @@ -0,0 +1,19 @@
> +/* Bit size of the time_t type at glibc build time, OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define __TIMESIZE	64

Ok, although I think we should flip the default to 64 bits make
old ports to override to 32.

> diff --git a/sysdeps/unix/sysv/linux/or1k/clone.c b/sysdeps/unix/sysv/linux/or1k/clone.c
> new file mode 100644
> index 0000000000..531fd17e29
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/clone.c
> @@ -0,0 +1,61 @@
> +/* OpenRISC helper for the clone syscall.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <stdarg.h>
> +#include <sysdep.h>
> +
> +extern int __or1k_clone (int (*fn)(void *), void *child_stack,
> +			 int flags, void *arg, pid_t *ptid,
> +			 void *tls, pid_t *ctid);
> +
> +
> +/* The OpenRISC ABI uses the stack for varargs like those using in clone
> +   but the linux syscall ABI uses registers.
> +   This function moves from varargs to regs.  */
> +int
> +__clone (int (*fn)(void *), void *child_stack,
> +	 int flags, void *arg, ...
> +	 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ )
> +{
> +  void *ptid;
> +  void *tls;
> +  void *ctid;
> +  va_list ap;
> +  int err;
> +
> +  va_start (ap, arg);
> +  ptid = va_arg (ap, void *);
> +  tls = va_arg (ap, void *);
> +  ctid = va_arg (ap, void *);
> +  va_end (ap);
> +
> +  /* Sanity check the arguments */
> +  err = -EINVAL;
> +  if (!fn)
> +    goto syscall_error;
> +  if (!child_stack)
> +    goto syscall_error;
> +
> +  return __or1k_clone (fn, child_stack, flags, arg, ptid, tls, ctid);
> +
> +syscall_error:
> +  __set_errno (-err);
> +  return -1;
> +}
> +libc_hidden_def (__clone)
> +weak_alias (__clone, clone)

Ok, I take that implementing it solely on __or1k_clone is more complex than
using a C wrapper.

> diff --git a/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
> new file mode 100644
> index 0000000000..3c5c1826ab
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
> @@ -0,0 +1,41 @@
> +/* jump buffer constants, OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +/* Produced by this program:
> +
> +   #include <stdio.h>
> +   #include <unistd.h>
> +   #include <setjmp.h>
> +   #include <stddef.h>
> +
> +   int main (int argc, char **argv)
> +   {
> +       printf ("#define JMP_BUF_SIZE %d\n", sizeof (jmp_buf));
> +       printf ("#define JMP_BUF_ALIGN %d\n", __alignof__ (jmp_buf));
> +       printf ("#define SIGJMP_BUF_SIZE %d\n", sizeof (sigjmp_buf));
> +       printf ("#define SIGJMP_BUF_ALIGN %d\n", __alignof__ (sigjmp_buf));
> +       printf ("#define MASK_WAS_SAVED_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __mask_was_saved));
> +       printf ("#define SAVED_MASK_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __saved_mask));
> +   } */
> +
> +#define JMP_BUF_SIZE 184
> +#define JMP_BUF_ALIGN 4
> +#define SIGJMP_BUF_SIZE 184
> +#define SIGJMP_BUF_ALIGN 4
> +#define MASK_WAS_SAVED_OFFSET 52
> +#define SAVED_MASK_OFFSET 56

You don't need this file since bc801b3a40f3a9bc8f24f1d0fdc39413874c3172.

> diff --git a/sysdeps/unix/sysv/linux/or1k/mmap_internal.h b/sysdeps/unix/sysv/linux/or1k/mmap_internal.h
> new file mode 100644
> index 0000000000..817b841e5b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/mmap_internal.h
> @@ -0,0 +1,28 @@
> +/* Common mmap definition for Linux implementation.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef MMAP_OR1K_INTERNAL_LINUX_H
> +#define MMAP_OR1K_INTERNAL_LINUX_H
> +
> +/* OpenRISC Linux sets the page shift to 13 and mmap2 expects
> +   offsets to be provided in 8K pages.  */
> +#define MMAP2_PAGE_UNIT 8192ULL
> +
> +#include_next <mmap_internal.h>
> +
> +#endif

Ok.

> diff --git a/sysdeps/unix/sysv/linux/or1k/or1k_clone.S b/sysdeps/unix/sysv/linux/or1k/or1k_clone.S
> new file mode 100644
> index 0000000000..337eb17d06
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/or1k_clone.S
> @@ -0,0 +1,89 @@
> +/* clone helper __or1k_clone for OpenRISC.
> +   Copyright (C) 2021 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, write to the Free
> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> +   02111-1307 USA.  */
> +
> +#include <sysdep.h>
> +#include <tls.h>
> +#define __ASSEMBLY__
> +#include <linux/sched.h>
> +
> +	.text
> +ENTRY(__or1k_clone)
> +
> +	/* To handle GCC varargs we need to use our __clone wrapper to pop
> +	   everything from the stack for us.
> +	   Now everything is placed in the registers which saves us a lot
> +	   of trouble.
> +
> +	   The userland implementation is:
> +
> +	     int clone (int (*fn)(void *), void *child_stack,
> +			int flags, void *arg, pid_t *ptid,
> +			struct user_desc *tls, pid_t *ctid);
> +	   The kernel entry is:
> +
> +	     int clone (long flags, void *child_stack, int *parent_tid,
> +			int *child_tid, struct void *tls)
> +
> +	     NB: tls isn't really an argument, it is read from r7 directly.  */
> +
> +	/* First, align the stack to 4 bytes.  */
> +	l.xori	r11, r0, -4
> +	l.and	r4, r4, r11
> +
> +	/* Put 'fn', 'arg' and 'flags' on the child stack.  */
> +	l.addi	r4, r4, -12
> +	l.sw	8(r4), r3
> +	l.sw	4(r4), r6
> +	l.sw	0(r4), r5
> +
> +	l.ori	r3, r5, 0
> +	/* The child_stack is already in r4.  */
> +	l.ori	r5, r7, 0
> +	l.lwz	r6, 0(r1)
> +	l.ori	r7, r8, 0
> +
> +	DO_CALL (clone)
> +
> +	l.sfgeui r11, 0xf001
> +	l.bf	L(error)
> +	 l.nop
> +
> +	/* If we are not the child, return the pid.  */
> +	l.sfeqi	r11, 0
> +	l.bf	L(thread_start)
> +	 l.nop
> +
> +	l.jr	r9
> +	 l.nop
> +
> +L(thread_start):
> +	/* Load function from stack.  */
> +	l.lwz	r11, 8(r1)
> +	l.jalr	r11
> +	 l.lwz	r3, 4(r1)
> +
> +	/* Exit the child thread.  */
> +	l.ori	r3, r11, 0
> +	DO_CALL (exit)
> +
> +L(error):
> +	l.j	SYSCALL_ERROR_NAME
> +	 l.ori	r3, r11, 0
> +
> +PSEUDO_END (__or1k_clone)
> diff --git a/sysdeps/unix/sysv/linux/or1k/sysdep.c b/sysdeps/unix/sysv/linux/or1k/sysdep.c
> new file mode 100644
> index 0000000000..1130cba687
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/sysdep.c
> @@ -0,0 +1,34 @@
> +/* OpenRISC wrapper for setting errno.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +#include <errno.h>
> +
> +long int __syscall_error (long int err);
> +hidden_proto (__syscall_error)
> +
> +/* This routine is jumped to by all the syscall handlers, to stash
> +   an error number into errno.  */
> +long int
> +__syscall_error (long int err)
> +{
> +  __set_errno (- err);
> +  return -1;
> +}
> +hidden_def (__syscall_error)
> diff --git a/sysdeps/unix/sysv/linux/or1k/sysdep.h b/sysdeps/unix/sysv/linux/or1k/sysdep.h
> new file mode 100644
> index 0000000000..5dd6da48a1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/sysdep.h
> @@ -0,0 +1,201 @@
> +/* Assembler and syscall macros.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _LINUX_OR1K_SYSDEP_H
> +#define _LINUX_OR1K_SYSDEP_H 1
> +
> +#include <sysdeps/or1k/sysdep.h>
> +#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
> +#include <tls.h>
> +
> +/* "workarounds" for generic code needing to handle 64-bit time_t.  */
> +
> +#undef __NR_clock_getres
> +#undef __NR_futex
> +#undef __NR_ppoll
> +#undef __NR_pselect6
> +#undef __NR_recvmmsg
> +#undef __NR_rt_sigtimedwait
> +#undef __NR_semtimedop
> +#undef __NR_utimensat
> +
> +/* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c.  */
> +#define __NR_clock_getres	__NR_clock_getres_time64
> +/* Fix sysdeps/nptl/lowlevellock-futex.h.  */
> +#define __NR_futex		__NR_futex_time64
> +/* Fix sysdeps/unix/sysv/linux/pause.c.  */
> +#define __NR_ppoll		__NR_ppoll_time64
> +/* Fix sysdeps/unix/sysv/linux/select.c.  */
> +#define __NR_pselect6		__NR_pselect6_time64
> +/* Fix sysdeps/unix/sysv/linux/recvmmsg.c.  */
> +#define __NR_recvmmsg		__NR_recvmmsg_time64
> +/* Fix sysdeps/unix/sysv/linux/sigtimedwait.c.  */
> +#define __NR_rt_sigtimedwait	__NR_rt_sigtimedwait_time64
> +/* Fix sysdeps/unix/sysv/linux/semtimedop.c.  */
> +#define __NR_semtimedop		__NR_semtimedop_time64
> +/* Hack sysdeps/unix/sysv/linux/generic/utimes.c.  */
> +#define __NR_utimensat		__NR_utimensat_time64
> +
> +#undef SYS_ify
> +#define SYS_ify(syscall_name)   (__NR_##syscall_name)
> +
> +/* Linux uses a negative return value to indicate syscall errors,
> +   unlike most Unices, which use the condition codes' carry flag.
> +
> +   Since version 2.1 the return value of a system call might be
> +   negative even if the call succeeded.  E.g., the lseek system call
> +   might return a large offset.  Therefore we must not anymore test
> +   for < 0, but test for a real error by making sure the value in R0
> +   is a real error number.  Linus said he will make sure the no syscall
> +   returns a value in -1 .. -4095 as a valid result so we can safely
> +   test with -4095.  */
> +
> +#ifdef __ASSEMBLER__
> +
> +/* Macros used in syscall-template.S */
> +#define ret          l.jr r9; l.nop
> +#define ret_NOERRNO  l.jr r9; l.nop
> +
> +#undef	DO_CALL
> +#define DO_CALL(syscall_name) \
> +  l.addi r11, r0, SYS_ify (syscall_name); \
> +  l.sys 1; \
> +   l.nop
> +
> +#undef	PSEUDO
> +#define PSEUDO(name, syscall_name, args) \
> +  ENTRY (name); \
> +  DO_CALL(syscall_name); \
> +  /* if -4096 < ret < 0 holds, it's an error */ \
> +  l.sfgeui r11, 0xf001; \
> +  l.bf L(pseudo_end); \
> +   l.nop
> +
> +#undef	PSEUDO_NOERRNO
> +#define PSEUDO_NOERRNO(name, syscall_name, args)  \
> +  ENTRY (name);           \
> +  DO_CALL(syscall_name)
> +
> +#undef	PSEUDO_END
> +#define PSEUDO_END(name) \
> +L(pseudo_end): \
> +  l.j SYSCALL_ERROR_NAME; \
> +  l.ori r3,r11,0; \
> +  END (name)
> +
> +#undef	PSEUDO_END_NOERRNO
> +#define PSEUDO_END_NOERRNO(name) \
> +  END (name)
> +
> +#ifndef PIC
> +/* For static code, on error jump to __syscall_error directly.  */
> +# define SYSCALL_ERROR_NAME __syscall_error
> +#elif !IS_IN (libc)
> +/* Use the internal name for libc shared objects.  */
> +# define SYSCALL_ERROR_NAME __GI___syscall_error
> +#else
> +/* Otherwise, on error do a full PLT jump.  */
> +# define SYSCALL_ERROR_NAME plt(__syscall_error)
> +#endif
> +
> +#else /* not __ASSEMBLER__ */
> +
> +#include <errno.h>
> +
> +extern long int __syscall_error (long int neg_errno);
> +
> +/* Pointer mangling is not yet supported for or1k.  */
> +#define PTR_MANGLE(var) (void) (var)
> +#define PTR_DEMANGLE(var) (void) (var)
> +
> +#undef INTERNAL_SYSCALL
> +#define INTERNAL_SYSCALL(name, nr, args...) \
> +	INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
> +
> +/* The _NCS variant allows non-constant syscall numbers.  */
> +#undef INTERNAL_SYSCALL_NCS
> +#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
> +        ({ unsigned long int __sys_result;                                     \
> +          {                                                                    \
> +            long int _sc_ret = (long int) number;                              \
> +            LOAD_ARGS_##nr (args)                                              \
> +            register long int __sc_ret __asm__ ("r11") = _sc_ret;              \
> +            __asm__ __volatile__ ("l.sys 1\n\t"                                \
> +				  " l.nop\n\t"                                 \
> +                                  : "+r" (__sc_ret)                            \
> +                                  : ASM_ARGS_##nr                              \
> +                                  : ASM_CLOBBERS_##nr                          \
> +                                    "r12", "r13", "r15", "r17", "r19",         \
> +                                    "r21", "r23", "r25", "r27", "r29",         \
> +                                    "r31", "memory");                          \
> +            __sys_result = __sc_ret;                                           \
> +          }                                                                    \
> +          (long int) __sys_result; })
> +
> +/* From here on we have nested macros that generate code for
> +   setting up syscall arguments.  */
> +
> +#define LOAD_ARGS_0()
> +
> +#define ASM_ARGS_0
> +#define ASM_CLOBBERS_0  "r3", ASM_CLOBBERS_1
> +
> +#define LOAD_ARGS_1(a) \
> +  long int _a = (long int)(a);                             \
> +  register long int __a __asm__ ("r3") = _a;
> +#define ASM_ARGS_1 "r" (__a)
> +#define ASM_CLOBBERS_1  "r4", ASM_CLOBBERS_2
> +
> +#define LOAD_ARGS_2(a, b) \
> +  long int _b = (long int)(b);                             \
> +  LOAD_ARGS_1 (a)                                          \
> +  register long int __b __asm__ ("r4") = _b;
> +#define ASM_ARGS_2 ASM_ARGS_1, "r" (__b)
> +#define ASM_CLOBBERS_2  "r5", ASM_CLOBBERS_3
> +
> +#define LOAD_ARGS_3(a, b, c) \
> +  long int _c = (long int)(c);                             \
> +  LOAD_ARGS_2 (a, b)                                       \
> +  register long int __c __asm__ ("r5") = _c;
> +#define ASM_ARGS_3 ASM_ARGS_2, "r" (__c)
> +#define ASM_CLOBBERS_3  "r6", ASM_CLOBBERS_4
> +
> +#define LOAD_ARGS_4(a, b, c, d) \
> +    LOAD_ARGS_3 (a, b, c)                                  \
> +  long int _d = (long int)(d);                             \
> +  register long int __d __asm__ ("r6") = _d;
> +#define ASM_ARGS_4 ASM_ARGS_3, "r" (__d)
> +#define ASM_CLOBBERS_4  "r7", ASM_CLOBBERS_5
> +
> +#define LOAD_ARGS_5(a, b, c, d, e) \
> +  long int _e = (long int)(e);                             \
> +  LOAD_ARGS_4 (a, b, c, d)                                 \
> +  register long int __e __asm__ ("r7") = _e;
> +#define ASM_ARGS_5 ASM_ARGS_4, "r" (__e)
> +#define ASM_CLOBBERS_5  "r8", ASM_CLOBBERS_6
> +
> +#define LOAD_ARGS_6(a, b, c, d, e, f) \
> +  long int _f = (long int)(f);                             \
> +  LOAD_ARGS_5 (a, b, c, d, e)                              \
> +  register long int __f __asm__ ("r8") = _f;
> +#define ASM_ARGS_6 ASM_ARGS_5, "r" (__f)
> +#define ASM_CLOBBERS_6
> +
> +#endif /* not __ASSEMBLER__ */
> +
> +#endif /* linux/or1k/sysdep.h */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 03/13] or1k: ABI Implementation
  2021-12-14 20:53   ` Adhemerval Zanella
  2021-12-14 22:43     ` Joseph Myers
@ 2021-12-16 21:28     ` Stafford Horne
  1 sibling, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-16 21:28 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Tue, Dec 14, 2021 at 05:53:20PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > This code deals with the OpenRISC ABI.
> 
> Some comments below.
> 
> > ---
> >  sysdeps/or1k/__longjmp.S       | 55 ++++++++++++++++++++++
> >  sysdeps/or1k/bits/endianness.h | 11 +++++
> >  sysdeps/or1k/bits/setjmp.h     | 32 +++++++++++++
> >  sysdeps/or1k/bsd-_setjmp.S     |  1 +
> >  sysdeps/or1k/bsd-setjmp.S      |  1 +
> >  sysdeps/or1k/dl-trampoline.S   | 79 ++++++++++++++++++++++++++++++++
> >  sysdeps/or1k/jmpbuf-offsets.h  | 23 ++++++++++
> >  sysdeps/or1k/jmpbuf-unwind.h   | 36 +++++++++++++++
> >  sysdeps/or1k/machine-gmon.h    | 35 ++++++++++++++
> >  sysdeps/or1k/memusage.h        | 21 +++++++++
> >  sysdeps/or1k/setjmp.S          | 56 +++++++++++++++++++++++
> >  sysdeps/or1k/sysdep.h          | 83 ++++++++++++++++++++++++++++++++++
> >  12 files changed, 433 insertions(+)
> >  create mode 100644 sysdeps/or1k/__longjmp.S
> >  create mode 100644 sysdeps/or1k/bits/endianness.h
> >  create mode 100644 sysdeps/or1k/bits/setjmp.h
> >  create mode 100644 sysdeps/or1k/bsd-_setjmp.S
> >  create mode 100644 sysdeps/or1k/bsd-setjmp.S
> >  create mode 100644 sysdeps/or1k/dl-trampoline.S
> >  create mode 100644 sysdeps/or1k/jmpbuf-offsets.h
> >  create mode 100644 sysdeps/or1k/jmpbuf-unwind.h
> >  create mode 100644 sysdeps/or1k/machine-gmon.h
> >  create mode 100644 sysdeps/or1k/memusage.h
> >  create mode 100644 sysdeps/or1k/setjmp.S
> >  create mode 100644 sysdeps/or1k/sysdep.h
> > 
> > diff --git a/sysdeps/or1k/__longjmp.S b/sysdeps/or1k/__longjmp.S
> > new file mode 100644
> > index 0000000000..f8aa5dda8f
> > --- /dev/null
> > +++ b/sysdeps/or1k/__longjmp.S
> > @@ -0,0 +1,55 @@
> > +/* longjmp, OpenRISC version.
> > +   Copyright (C) 2021 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, write to the Free
> > +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > +   02111-1307 USA.  */
> > +
> > +#include <features.h>
> > +#define _ASM
> > +#define _SETJMP_H
> > +#include <bits/setjmp.h>
> > +
> > +	.globl	__longjmp;
> > +	.type	__longjmp, @function;
> > +	.align	4;
> > +
> > +__longjmp:
> 
> Use ENTRY/END here, as other setjmp functions are doing.

OK.

> > +	l.lwz	r1, 0(r3)
> > +	l.lwz	r2, 4(r3)
> > +
> > +	/* if r4 is 0, something wrong, so set it to 1 */
> > +	l.sfeqi	r4, 0x0
> > +	l.bnf	1f		/* r4 != 0, longjmp value sensible */
> > +	 l.nop
> > +	l.ori	r4, r0, 0x1	/* make nonzero */
> > +1:
> > +	l.addi	r11, r4, 0
> > +	l.lwz	r9, 8(r3)
> > +	l.lwz	r10, 12(r3)
> > +	l.lwz	r14, 16(r3)
> > +	l.lwz	r16, 20(r3)
> > +	l.lwz	r18, 24(r3)
> > +	l.lwz	r20, 28(r3)
> > +	l.lwz	r22, 32(r3)
> > +	l.lwz	r24, 36(r3)
> > +	l.lwz	r26, 40(r3)
> > +	l.lwz	r28, 44(r3)
> > +	l.lwz	r30, 48(r3)
> > +	l.jr	r9
> > +	 l.nop
> > +	.size	__longjmp, . - __longjmp
> > +
> > +libc_hidden_def(__longjmp)
> > diff --git a/sysdeps/or1k/bits/endianness.h b/sysdeps/or1k/bits/endianness.h
> > new file mode 100644
> > index 0000000000..7b61d8adb7
> > --- /dev/null
> > +++ b/sysdeps/or1k/bits/endianness.h
> > @@ -0,0 +1,11 @@
> > +#ifndef _BITS_ENDIANNESS_H
> > +#define _BITS_ENDIANNESS_H 1
> > +
> > +#ifndef _BITS_ENDIAN_H
> > +# error "Never use <bits/endianness.h> directly; include <endian.h> instead."
> > +#endif
> > +
> > +/* OpenRISC is big-endian.  */
> > +#define __BYTE_ORDER __BIG_ENDIAN
> > +
> > +#endif /* bits/endianness.h */
> 
> Ok.
> 
> > diff --git a/sysdeps/or1k/bits/setjmp.h b/sysdeps/or1k/bits/setjmp.h
> > new file mode 100644
> > index 0000000000..dac511c904
> > --- /dev/null
> > +++ b/sysdeps/or1k/bits/setjmp.h
> > @@ -0,0 +1,32 @@
> > +/* Define the machine-dependent type `jmp_buf'.  OpenRISC version.
> > +   Copyright (C) 2021 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, write to the Free
> > +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > +   02111-1307 USA.  */
> > +
> > +
> > +#ifndef _OR1K_BITS_SETJMP_H
> > +#define _OR1K_BITS_SETJMP_H  1
> > +
> > +#if !defined _SETJMP_H && !defined _PTHREAD_H
> > +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
> > +#endif
> > +
> > +#ifndef _ASM
> > +typedef long int __jmp_buf[13];
> > +#endif
> > +
> > +#endif /* _OR1K_BITS_SETJMP_H */
> 
> Ok.
> 
> > diff --git a/sysdeps/or1k/bsd-_setjmp.S b/sysdeps/or1k/bsd-_setjmp.S
> > new file mode 100644
> > index 0000000000..4e6a2da560
> > --- /dev/null
> > +++ b/sysdeps/or1k/bsd-_setjmp.S
> > @@ -0,0 +1 @@
> > +/* _setjmp is in setjmp.S  */
> > diff --git a/sysdeps/or1k/bsd-setjmp.S b/sysdeps/or1k/bsd-setjmp.S
> > new file mode 100644
> > index 0000000000..1da848d2f1
> > --- /dev/null
> > +++ b/sysdeps/or1k/bsd-setjmp.S
> > @@ -0,0 +1 @@
> > +/* setjmp is in setjmp.S  */
> > diff --git a/sysdeps/or1k/dl-trampoline.S b/sysdeps/or1k/dl-trampoline.S
> > new file mode 100644
> > index 0000000000..9ebc68f525
> > --- /dev/null
> > +++ b/sysdeps/or1k/dl-trampoline.S
> > @@ -0,0 +1,79 @@
> > +/* Machine-dependent ELF runtime symbol resolution, OpenRISC version.
> > +   Copyright (C) 2021 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, write to the Free
> > +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > +   02111-1307 USA.  */
> > +
> > +/* This code is used to call _dl_linux_resolver (dl-runtime.c).
> > +
> > +   We assume that R11 contains the relocation offset and R12 contains
> > +   link_map (_DYNAMIC).  This must be consistent with the JUMP_SLOT
> > +   layout generated by binutils.  */
> > +
> > +	.section .text
> > +	.align 4
> > +
> > +	.global	_dl_runtime_resolve
> > +	.type	_dl_runtime_resolve, @function
> > +
> > +_dl_runtime_resolve:
> > +	.cfi_startproc
> > +	l.sw	-4(r1), r9
> > +	l.sw	-8(r1), r1
> > +
> > +	/* save function arguments.  */
> > +	l.sw	-12(r1), r3
> > +	l.sw	-16(r1), r4
> > +	l.sw	-20(r1), r5
> > +	l.sw	-24(r1), r6
> > +	l.sw	-28(r1), r7
> > +	l.sw	-32(r1), r8
> > +
> > +	.cfi_offset 9, -4
> > +	.cfi_offset 1, -8
> > +	.cfi_offset 3, -12
> > +	.cfi_offset 4, -16
> > +	.cfi_offset 5, -20
> > +	.cfi_offset 6, -24
> > +	.cfi_offset 7, -28
> > +	.cfi_offset 8, -32
> > +
> > +	l.addi	r1,r1, -32
> > +	.cfi_def_cfa_offset 32
> > +
> > +	l.ori	r3, r12, 0
> > +	l.ori	r4, r11, 0
> > +
> > +	l.jal	_dl_fixup
> > +	 l.nop
> > +
> > +	/* Restore function arguments.  */
> > +	l.addi	r1,r1, 32
> > +	l.lwz	r8, -32(r1)
> > +	l.lwz	r7, -28(r1)
> > +	l.lwz	r6, -24(r1)
> > +	l.lwz	r5, -20(r1)
> > +	l.lwz	r4, -16(r1)
> > +	l.lwz	r3, -12(r1)
> > +
> > +	/* restore return address.  */
> > +	l.lwz	r9, -4(r1)
> > +
> > +	l.jr	r11
> > +	 l.nop
> > +
> > +	.cfi_endproc
> > +	.size	_dl_runtime_resolve, . - _dl_runtime_resolve

Fixed ENTRY/END here too.

> It seems that _dl_runtime_profile is not implemented and explicit disabled
> on sysdeps/or1k/dl-machine.h.  In this case I think it would be better to
> explicit disable it on configure... [snip]

As discussed further on, I will remove the commented code.

> > diff --git a/sysdeps/or1k/jmpbuf-offsets.h b/sysdeps/or1k/jmpbuf-offsets.h
> > new file mode 100644
> > index 0000000000..e33105cc03
> > --- /dev/null
> > +++ b/sysdeps/or1k/jmpbuf-offsets.h
> > @@ -0,0 +1,23 @@
> > +/* Private macros for accessing __jmp_buf contents.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#define __JMP_BUF_SP    0
> > +
> > +/* Helper for generic function ____longjmp_chk.  */
> > +#define JB_FRAME_ADDRESS(buf) \
> > +    ((void *) (unsigned long) (buf[__JMP_BUF_SP]))
> > diff --git a/sysdeps/or1k/jmpbuf-unwind.h b/sysdeps/or1k/jmpbuf-unwind.h
> > new file mode 100644
> > index 0000000000..6710dea989
> > --- /dev/null
> > +++ b/sysdeps/or1k/jmpbuf-unwind.h
> > @@ -0,0 +1,36 @@
> > +/* Macros to help frame unwinding using jmpbuf.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <setjmp.h>
> > +#include <jmpbuf-offsets.h>
> > +#include <stdint.h>
> > +#include <unwind.h>
> > +
> > +/* Test if longjmp to JMPBUF would unwind the frame
> > +   containing a local variable at ADDRESS.  */
> > +#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
> > +  ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
> > +
> > +#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
> > +  _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
> > +
> > +#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
> > +  ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
> > +
> > +/* We use the normal longjmp for unwinding.  */
> > +#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
> > diff --git a/sysdeps/or1k/machine-gmon.h b/sysdeps/or1k/machine-gmon.h
> > new file mode 100644
> > index 0000000000..7152105eec
> > --- /dev/null
> > +++ b/sysdeps/or1k/machine-gmon.h
> > @@ -0,0 +1,35 @@
> > +/* Machine-dependent definitions for profiling support.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +
> > +#define _MCOUNT_DECL(frompc, selfpc)					\
> > +static void								\
> > +__mcount_internal (unsigned long int frompc, unsigned long int selfpc)
> > +
> > +/* This is very simple as gcc does all the heavy lifting at the _mcount
> > +   call site.  GCC passes in the return address of the function calling
> > +   _mcount.  */
> > +
> > +#define MCOUNT								\
> > +void									\
> > +_mcount (void *frompc)							\
> > +{									\
> > +  __mcount_internal ((unsigned long int) frompc,			\
> > +		     (unsigned long int) __builtin_return_address (0));	\
> > +}
> > diff --git a/sysdeps/or1k/memusage.h b/sysdeps/or1k/memusage.h
> > new file mode 100644
> > index 0000000000..a62da17e61
> > --- /dev/null
> > +++ b/sysdeps/or1k/memusage.h
> > @@ -0,0 +1,21 @@
> > +/* Definitions for memory usage profiling.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#define GETSP() ({ register uintptr_t stack_ptr asm ("r1"); stack_ptr; })
> > +
> > +#include <sysdeps/generic/memusage.h>
> > diff --git a/sysdeps/or1k/setjmp.S b/sysdeps/or1k/setjmp.S
> > new file mode 100644
> > index 0000000000..660995b493
> > --- /dev/null
> > +++ b/sysdeps/or1k/setjmp.S
> > @@ -0,0 +1,56 @@
> > +/* setjmp, OpenRISC version.
> > +   Copyright (C) 2021 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, write to the Free
> > +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > +   02111-1307 USA.  */
> > +
> > +#include <sysdep.h>
> > +#define _ASM
> > +#define _SETJMP_H
> > +#include <bits/setjmp.h>
> > +
> > +ENTRY (_setjmp)
> > +	l.addi	r4, r0, 0     /* Set second argument to 0.  */
> > +	l.j	.Local__sigsetjmp
> > +	 l.nop
> > +END (_setjmp)
> > +libc_hidden_def (_setjmp)
> > +
> > +ENTRY (setjmp)
> > +	l.addi	r4, r0, 1     /* Set second argument to 1.  */
> > +	l.j	.Local__sigsetjmp
> > +	 l.nop
> > +END (setjmp)
> > +
> > +ENTRY (__sigsetjmp)
> > +.Local__sigsetjmp:
> > +	l.sw	0(r3), r1
> > +	l.sw	4(r3), r2
> > +	l.sw	8(r3), r9
> > +	l.sw	12(r3), r10
> > +	l.sw	16(r3), r14
> > +	l.sw	20(r3), r16
> > +	l.sw	24(r3), r18
> > +	l.sw	28(r3), r20
> > +	l.sw	32(r3), r22
> > +	l.sw	36(r3), r24
> > +	l.sw	40(r3), r26
> > +	l.sw	44(r3), r28
> > +	l.sw	48(r3), r30
> > +	l.j	__sigjmp_save
> > +	 l.nop
> > +END (__sigsetjmp)
> > +hidden_def (__sigsetjmp)
> > diff --git a/sysdeps/or1k/sysdep.h b/sysdeps/or1k/sysdep.h
> > new file mode 100644
> > index 0000000000..61a135afe7
> > --- /dev/null
> > +++ b/sysdeps/or1k/sysdep.h
> > @@ -0,0 +1,83 @@
> > +/* Assembler macro definitions.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdeps/generic/sysdep.h>
> > +#include <features.h>
> > +
> > +#if defined __ASSEMBLER__ || defined REQUEST_ASSEMBLER_MACROS
> > +
> > +/* Make use of .size directive.  */
> > +#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
> > +
> > +/* Define an entry point visible from C.  */
> > +#define ENTRY(name)                                                           \
> > +  .globl C_SYMBOL_NAME(name);                                                 \
> > +  .type C_SYMBOL_NAME(name),@function;                                        \
> > +  .align 4;                                                                   \
> > +  C_LABEL(name)                                                               \
> > +  cfi_startproc;                                                              \
> > +  CALL_MCOUNT
> > +
> > +#undef  END
> > +#define END(name)                                                             \
> > +  cfi_endproc;                                                                \
> > +  ASM_SIZE_DIRECTIVE(name)
> > +
> > +/* Since C identifiers are not normally prefixed with an underscore
> > +   on this system, the asm identifier `syscall_error' intrudes on the
> > +   C name space.  Make sure we use an innocuous name.  */
> > +#define syscall_error   __syscall_error
> > +
> > +/* If compiled for profiling, call `mcount' at the start of each function.  */
> > +#ifdef  PROF
> > +# ifdef __PIC__
> > +#  define CALL_MCOUNT						\
> > +	l.addi	r1, r1, -8;					\
> > +	l.sw	0(r1), r9;					\
> > +	l.sw	4(r1), r3;					\
> > +	l.ori	r3, r9, 0;					\
> > +	l.j	plt(_mcount);					\
> > +	 l.nop;							\
> > +	l.lwz	r9, 0(r1);					\
> > +	l.lwz	r3, 4(r1);					\
> > +	l.addi	r1, r1, 8;
> > +# else
> > +#  define CALL_MCOUNT						\
> > +	l.addi	r1, r1, -8;					\
> > +	l.sw	0(r1), r9;					\
> > +	l.sw	4(r1), r3;					\
> > +	l.ori	r3, r9, 0;					\
> > +	l.movhi r15, hi(_mcount);				\
> > +	l.ori	r15, r15, lo(_mcount);				\
> > +	l.jr	r15;						\
> > +	 l.nop;							\
> > +	l.lwz	r9, 0(r1);					\
> > +	l.lwz	r3, 4(r1);					\
> > +	l.addi	r1, r1, 8;
> > +# endif
> > +#else
> > +# define CALL_MCOUNT             /* Do nothing.  */
> > +#endif
> > +
> > +/* Local label name for asm code.  */
> > +#define L(name)         .L##name
> > +
> > +/* Specify the size in bytes of a machine register.  */
> > +#define REGSIZE         4
> > +
> > +#endif /* __ASSEMBLER__ */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 05/13] or1k: Thread Local Storage support
  2021-12-16 12:37   ` Adhemerval Zanella
  2021-12-16 19:26     ` Joseph Myers
@ 2021-12-17 14:23     ` Stafford Horne
  1 sibling, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-17 14:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Thu, Dec 16, 2021 at 09:37:26AM -0300, Adhemerval Zanella wrote:
> (resending because I hit send button too soon).
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > OpenRISC includes 3 TLS addressing models.  Local Dynamic optimizations
> > are not done in the linker and therefore use the same code sequences as
> > Global Dynamic.
> > ---
> >  sysdeps/or1k/dl-tls.h             |  27 +++++
> >  sysdeps/or1k/libc-tls.c           |  34 ++++++
> >  sysdeps/or1k/nptl/tcb-offsets.sym |   6 +
> >  sysdeps/or1k/nptl/tls.h           | 189 ++++++++++++++++++++++++++++++
> >  sysdeps/or1k/stackinfo.h          |  34 ++++++
> >  5 files changed, 290 insertions(+)
> >  create mode 100644 sysdeps/or1k/dl-tls.h
> >  create mode 100644 sysdeps/or1k/libc-tls.c
> >  create mode 100644 sysdeps/or1k/nptl/tcb-offsets.sym
> >  create mode 100644 sysdeps/or1k/nptl/tls.h
> >  create mode 100644 sysdeps/or1k/stackinfo.h
> > 
> > diff --git a/sysdeps/or1k/dl-tls.h b/sysdeps/or1k/dl-tls.h
> > new file mode 100644
> > index 0000000000..382588d504
> > --- /dev/null
> > +++ b/sysdeps/or1k/dl-tls.h
> > @@ -0,0 +1,27 @@
> > +/* TLS definitions for the ELF dynamic linker.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://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);
> > diff --git a/sysdeps/or1k/libc-tls.c b/sysdeps/or1k/libc-tls.c
> > new file mode 100644
> > index 0000000000..1524855e88
> > --- /dev/null
> > +++ b/sysdeps/or1k/libc-tls.c
> > @@ -0,0 +1,34 @@
> > +/* Thread-local storage handling in the ELF dynamic linker.
> > +   OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <csu/libc-tls.c>
> > +#include <dl-tls.h>
> > +
> > +/* On OpenRISC, linker optimizations are not required, so __tls_get_addr
> > +   can be called even in statically linked binaries.  In this case module
> > +   must be always 1 and PT_TLS segment exist in the binary, otherwise it
> > +   would not link.  */
> > +
> > +void *
> > +__tls_get_addr (tls_index *ti)
> > +{
> > +  dtv_t *dtv = THREAD_DTV ();
> > +  return (char *) dtv[1].pointer.val + ti->ti_offset;
> > +}
> > diff --git a/sysdeps/or1k/nptl/tcb-offsets.sym b/sysdeps/or1k/nptl/tcb-offsets.sym
> > new file mode 100644
> > index 0000000000..86025a402d
> > --- /dev/null
> > +++ b/sysdeps/or1k/nptl/tcb-offsets.sym
> > @@ -0,0 +1,6 @@
> > +#include <sysdep.h>
> > +#include <tls.h>
> > +
> > +MULTIPLE_THREADS_OFFSET         offsetof (struct pthread, header.multiple_threads)
> > +TID_OFFSET                      offsetof (struct pthread, tid)
> > +TP_TO_PTHREAD_OFFSET            -(sizeof (struct pthread) + sizeof (tcbhead_t))
> 
> There are not used anywhere, so you can remove the file along with
> sysdeps/or1k/nptl/Makefile.

OK.

> And I think these definitions are not used in most architectures, I will
> remove from the architectures that do not use it.

Yes, nice cleanup.

> > diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
> > new file mode 100644
> > index 0000000000..dc11610920
> > --- /dev/null
> > +++ b/sysdeps/or1k/nptl/tls.h
> > @@ -0,0 +1,189 @@
> > +/* Definition for thread-local data handling.  NPTL/OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef _TLS_H
> > +#define _TLS_H  1
> > +
> > +#include <dl-sysdep.h>
> > +
> > +#ifndef __ASSEMBLER__
> > +# include <stdbool.h>
> > +# include <stddef.h>
> > +# include <stdint.h>
> > +# include <dl-dtv.h>
> > +
> > +typedef struct
> > +{
> > +  dtv_t *dtv;
> > +  void *__padding[3]; /* To maintain 16 byte padding, needed by STACK_ALIGN.  */
> > +} tcbhead_t;
> > +
> > +register tcbhead_t *__thread_self __asm__("r10");
> > +
> > +# define TLS_MULTIPLE_THREADS_IN_TCB 1
> > +
> > +#else /* __ASSEMBLER__ */
> > +# include <tcb-offsets.h>
> 
> Remove the include, or1k currently does not use it.

OK.

> > +#endif /* __ASSEMBLER__ */
> > +
> > +#ifndef __ASSEMBLER__
> > +
> > +/* Get system call information.  */
> > +# include <sysdep.h>
> > +
> > +/* The TP points to the start of the TLS block.
> > +   As I understand it, this isn't strictly that "TP points to DTV" - it's
> > +   more where to place the TCB in the TLS block.  This will place it in
> > +   the beginning.
> > +
> > +   Layout:
> > +    +-----+-----+----------------------+
> > +    | PRE | TCB | TLS MEMORY ..        |
> > +    +-----+-----+----------------------+
> > +		 ^ r10 / TP
> > +
> > +   PRE is the struct pthread described below
> > +   TCB is tcbhead_t
> > +   TLS memory is where the TLS program sections are loaded
> > +
> > +   See _dl_allocate_tls_storage and __libc_setup_tls for more information.  */
> > +
> > +# define TLS_DTV_AT_TP  1
> > +# define TLS_TCB_AT_TP  0
> > +
> > +/* Get the thread descriptor definition.  */
> > +# include <nptl/descr.h>
> > +
> > +/* Requirements for the TCB.  */
> > +# define TLS_INIT_TCB_SIZE    sizeof (tcbhead_t)
> > +# define TLS_INIT_TCB_ALIGN   __alignof__ (struct pthread)
> > +
> > +# define TLS_TCB_SIZE         sizeof (tcbhead_t)
> > +# define TLS_TCB_ALIGN        __alignof__ (struct pthread)
> > +
> > +/* This is the size of the TCB.  */
> > +
> > +/* This is the size we need before TCB.
> > +   To support THREAD_GETMEM with friends we want to have a
> > +   struct pthread available.
> > +   Yank it in infront of everything, I'm sure nobody will mind.
> > +
> > +   This memory is really allocated PRE the TLS block, so it's possible
> > +   to do ((char*)tlsblock) - TLS_PRE_TCB_SIZE to access it.
> > +   This is done for THREAD_SELF.  */
> > +
> > +# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
> > +
> > +
> > +/* Install the dtv pointer.
> > +   When called, dtvp is a pointer not the DTV per say (which should start
> > +   with the generation counter) but to the length of the DTV.
> > +   We can always index with -1, so we store dtvp[1].  */
> > +
> > +# define INSTALL_DTV(tcbp, dtvp) \
> > +  (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
> > +
> > +/* Install new dtv for current thread
> > +   In a logicial world dtv here would also point to the length of the DTV.
> > +   However it does not, this time it points to the generation counter,
> > +   so just store it.
> > +
> > +   Note: -1 is still valid and contains the length.  */
> > +
> > +# define INSTALL_NEW_DTV(dtv) (THREAD_DTV() = (dtv))
> > +
> > +/* Return dtv of given thread descriptor.  */
> > +# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv)
> > +
> > +/* Code to initially initialize the thread pointer.
> > +
> > +   Set TP to the address _after_ tcbhead_t.  This will allow us
> > +   to change the size of tcbhead_t without having to re-link everything.
> > +
> > +   This has to return NULL on success (or a string with the failure text).
> > +   It's hard to fail this, so return NULL always.  */
> > +
> > +# define TLS_INIT_TP(tcbp) \
> > +  ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;})
> > +
> > +/* Value passed to 'clone' for initialization of the thread register.  */
> > +# define TLS_DEFINE_INIT_TP(tp, pd) \
> > +  void *tp = ((char *) pd + TLS_PRE_TCB_SIZE + TLS_INIT_TCB_SIZE)
> > +
> > +/* Return the address of the dtv for the current thread.
> > +
> > +   Dereference TP, offset to dtv - really straightforward.
> > +   Remember that we made TP point to after tcb, so we need to reverse that.  */
> > +
> > +#  define THREAD_DTV() \
> > +  ((((tcbhead_t *)__thread_self)-1)->dtv)
> > +
> > +/* Return the thread descriptor for the current thread.
> > +
> > +   Return a pointer to the TLS_PRE area where we allocated space for
> > +   a struct pthread.  Again, TP points to after tcbhead_t, compensate with
> > +   TLS_INIT_TCB_SIZE.
> > +
> > +   I regard this is a seperate system from the "normal" TLS.  */
> > +
> > +# define THREAD_SELF \
> > +  ((struct pthread *) ((char *) __thread_self - TLS_INIT_TCB_SIZE \
> > +    - TLS_PRE_TCB_SIZE))
> > +
> > +/* Magic for libthread_db to know how to do THREAD_SELF.  */
> > +
> > +# define DB_THREAD_SELF \
> > +  REGISTER (32, 32, 10 * 4, - TLS_INIT_TCB_SIZE - TLS_PRE_TCB_SIZE)
> > +
> > +/* Access to data in the thread descriptor is easy.  */
> > +
> > +#define THREAD_GETMEM(descr, member) \
> > +  descr->member
> > +#define THREAD_GETMEM_NC(descr, member, idx) \
> > +  descr->member[idx]
> > +#define THREAD_SETMEM(descr, member, value) \
> > +  descr->member = (value)
> > +#define THREAD_SETMEM_NC(descr, member, idx, value) \
> > +  descr->member[idx] = (value)
> > +
> > +/* Get and set the global scope generation counter in struct pthread.  */
> > +
> > +#define THREAD_GSCOPE_FLAG_UNUSED 0
> > +#define THREAD_GSCOPE_FLAG_USED   1
> > +#define THREAD_GSCOPE_FLAG_WAIT   2
> > +#define THREAD_GSCOPE_RESET_FLAG()					\
> > +  do									\
> > +    {									\
> > +      int __res = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,\
> > +				       THREAD_GSCOPE_FLAG_UNUSED);	\
> > +      if (__res == THREAD_GSCOPE_FLAG_WAIT)				\
> > +	  lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1,		\
> > +			  LLL_PRIVATE);					\
> > +    }									\
> > +  while (0)
> > +#define THREAD_GSCOPE_SET_FLAG()					\
> > +  do									\
> > +    {									\
> > +      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	\
> > +      atomic_write_barrier ();						\
> > +    }									\
> > +  while (0)
> > +
> > +#endif /* __ASSEMBLER__ */
> > +
> > +#endif  /* tls.h */
> > diff --git a/sysdeps/or1k/stackinfo.h b/sysdeps/or1k/stackinfo.h
> > new file mode 100644
> > index 0000000000..9273e709bd
> > --- /dev/null
> > +++ b/sysdeps/or1k/stackinfo.h
> > @@ -0,0 +1,34 @@
> > +/* Stack definitions for OpenRISC.
> > +   Copyright (C) 2021 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
> > +   <https://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 or1k the stack grows down.  */
> > +#define _STACK_GROWS_DOWN	1
> > +
> > +/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
> > +   present, but it is presumed absent.  */
> > +#define DEFAULT_STACK_PERMS (PF_R | PF_W | PF_X)
> 
> Do you really a default stack executable? It is only done for older ABIs and that's
> why PT_GNU_STACK was created. Newer ports, like arc and csky assumes otherwise.
> 
> > +
> > +#endif /* stackinfo.h */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 08/13] or1k: Linux Syscall Interface
  2021-12-16 21:17   ` Adhemerval Zanella
@ 2021-12-17 15:01     ` Stafford Horne
  2021-12-17 17:41       ` Adhemerval Zanella
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-17 15:01 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Thu, Dec 16, 2021 at 06:17:45PM -0300, Adhemerval Zanella wrote:
> Some comments below.
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > ---
> >  sysdeps/unix/sysv/linux/or1k/arch-syscall.h   | 325 ++++++++++++++++++
> >  sysdeps/unix/sysv/linux/or1k/bits/timesize.h  |  19 +
> >  sysdeps/unix/sysv/linux/or1k/clone.c          |  61 ++++
> >  sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h |  41 +++
> >  sysdeps/unix/sysv/linux/or1k/mmap_internal.h  |  28 ++
> >  sysdeps/unix/sysv/linux/or1k/or1k_clone.S     |  89 +++++
> >  sysdeps/unix/sysv/linux/or1k/sysdep.c         |  34 ++
> >  sysdeps/unix/sysv/linux/or1k/sysdep.h         | 201 +++++++++++
> >  8 files changed, 798 insertions(+)
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/arch-syscall.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/timesize.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/clone.c
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/mmap_internal.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/or1k_clone.S
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.c
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sysdep.h
> > 
> > diff --git a/sysdeps/unix/sysv/linux/or1k/arch-syscall.h b/sysdeps/unix/sysv/linux/or1k/arch-syscall.h
> > new file mode 100644
> > index 0000000000..c6c3556137
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/arch-syscall.h
> > @@ -0,0 +1,325 @@
> > +/* AUTOGENERATED by update-syscall-lists.py.  */
> > +#define __NR_accept 202
> > +#define __NR_accept4 242
> > +#define __NR_acct 89
> > +#define __NR_add_key 217
> > +#define __NR_adjtimex 171
> > +#define __NR_bind 200
> > +#define __NR_bpf 280
> > +#define __NR_brk 214
> > +#define __NR_capget 90
> > +#define __NR_capset 91
> > +#define __NR_chdir 49
> > +#define __NR_chroot 51
> > +#define __NR_clock_adjtime 266
> > +#define __NR_clock_adjtime64 405
> > +#define __NR_clock_getres 114
> > +#define __NR_clock_getres_time64 406
> > +#define __NR_clock_gettime 113
> > +#define __NR_clock_gettime64 403
> > +#define __NR_clock_nanosleep 115
> > +#define __NR_clock_nanosleep_time64 407
> > +#define __NR_clock_settime 112
> > +#define __NR_clock_settime64 404
> > +#define __NR_clone 220
> > +#define __NR_clone3 435
> > +#define __NR_close 57
> > +#define __NR_close_range 436
> > +#define __NR_connect 203
> > +#define __NR_copy_file_range 285
> > +#define __NR_delete_module 106
> > +#define __NR_dup 23
> > +#define __NR_dup3 24
> > +#define __NR_epoll_create1 20
> > +#define __NR_epoll_ctl 21
> > +#define __NR_epoll_pwait 22
> > +#define __NR_epoll_pwait2 441
> > +#define __NR_eventfd2 19
> > +#define __NR_execve 221
> > +#define __NR_execveat 281
> > +#define __NR_exit 93
> > +#define __NR_exit_group 94
> > +#define __NR_faccessat 48
> > +#define __NR_faccessat2 439
> > +#define __NR_fadvise64_64 223
> > +#define __NR_fallocate 47
> > +#define __NR_fanotify_init 262
> > +#define __NR_fanotify_mark 263
> > +#define __NR_fchdir 50
> > +#define __NR_fchmod 52
> > +#define __NR_fchmodat 53
> > +#define __NR_fchown 55
> > +#define __NR_fchownat 54
> > +#define __NR_fcntl64 25
> > +#define __NR_fdatasync 83
> > +#define __NR_fgetxattr 10
> > +#define __NR_finit_module 273
> > +#define __NR_flistxattr 13
> > +#define __NR_flock 32
> > +#define __NR_fremovexattr 16
> > +#define __NR_fsconfig 431
> > +#define __NR_fsetxattr 7
> > +#define __NR_fsmount 432
> > +#define __NR_fsopen 430
> > +#define __NR_fspick 433
> > +#define __NR_fstat64 80
> > +#define __NR_fstatat64 79
> > +#define __NR_fstatfs64 44
> > +#define __NR_fsync 82
> > +#define __NR_ftruncate64 46
> > +#define __NR_futex 98
> > +#define __NR_futex_time64 422
> > +#define __NR_get_mempolicy 236
> > +#define __NR_get_robust_list 100
> > +#define __NR_getcpu 168
> > +#define __NR_getcwd 17
> > +#define __NR_getdents64 61
> > +#define __NR_getegid 177
> > +#define __NR_geteuid 175
> > +#define __NR_getgid 176
> > +#define __NR_getgroups 158
> > +#define __NR_getitimer 102
> > +#define __NR_getpeername 205
> > +#define __NR_getpgid 155
> > +#define __NR_getpid 172
> > +#define __NR_getppid 173
> > +#define __NR_getpriority 141
> > +#define __NR_getrandom 278
> > +#define __NR_getresgid 150
> > +#define __NR_getresuid 148
> > +#define __NR_getrlimit 163
> > +#define __NR_getrusage 165
> > +#define __NR_getsid 156
> > +#define __NR_getsockname 204
> > +#define __NR_getsockopt 209
> > +#define __NR_gettid 178
> > +#define __NR_gettimeofday 169
> > +#define __NR_getuid 174
> > +#define __NR_getxattr 8
> > +#define __NR_init_module 105
> > +#define __NR_inotify_add_watch 27
> > +#define __NR_inotify_init1 26
> > +#define __NR_inotify_rm_watch 28
> > +#define __NR_io_cancel 3
> > +#define __NR_io_destroy 1
> > +#define __NR_io_getevents 4
> > +#define __NR_io_pgetevents 292
> > +#define __NR_io_pgetevents_time64 416
> > +#define __NR_io_setup 0
> > +#define __NR_io_submit 2
> > +#define __NR_io_uring_enter 426
> > +#define __NR_io_uring_register 427
> > +#define __NR_io_uring_setup 425
> > +#define __NR_ioctl 29
> > +#define __NR_ioprio_get 31
> > +#define __NR_ioprio_set 30
> > +#define __NR_kcmp 272
> > +#define __NR_kexec_file_load 294
> > +#define __NR_kexec_load 104
> > +#define __NR_keyctl 219
> > +#define __NR_kill 129
> > +#define __NR_landlock_add_rule 445
> > +#define __NR_landlock_create_ruleset 444
> > +#define __NR_landlock_restrict_self 446
> > +#define __NR_lgetxattr 9
> > +#define __NR_linkat 37
> > +#define __NR_listen 201
> > +#define __NR_listxattr 11
> > +#define __NR_llistxattr 12
> > +#define __NR_llseek 62
> > +#define __NR_lookup_dcookie 18
> > +#define __NR_lremovexattr 15
> > +#define __NR_lsetxattr 6
> > +#define __NR_madvise 233
> > +#define __NR_mbind 235
> > +#define __NR_membarrier 283
> > +#define __NR_memfd_create 279
> > +#define __NR_migrate_pages 238
> > +#define __NR_mincore 232
> > +#define __NR_mkdirat 34
> > +#define __NR_mknodat 33
> > +#define __NR_mlock 228
> > +#define __NR_mlock2 284
> > +#define __NR_mlockall 230
> > +#define __NR_mmap2 222
> > +#define __NR_mount 40
> > +#define __NR_mount_setattr 442
> > +#define __NR_move_mount 429
> > +#define __NR_move_pages 239
> > +#define __NR_mprotect 226
> > +#define __NR_mq_getsetattr 185
> > +#define __NR_mq_notify 184
> > +#define __NR_mq_open 180
> > +#define __NR_mq_timedreceive 183
> > +#define __NR_mq_timedreceive_time64 419
> > +#define __NR_mq_timedsend 182
> > +#define __NR_mq_timedsend_time64 418
> > +#define __NR_mq_unlink 181
> > +#define __NR_mremap 216
> > +#define __NR_msgctl 187
> > +#define __NR_msgget 186
> > +#define __NR_msgrcv 188
> > +#define __NR_msgsnd 189
> > +#define __NR_msync 227
> > +#define __NR_munlock 229
> > +#define __NR_munlockall 231
> > +#define __NR_munmap 215
> > +#define __NR_name_to_handle_at 264
> > +#define __NR_nanosleep 101
> > +#define __NR_nfsservctl 42
> > +#define __NR_open_by_handle_at 265
> > +#define __NR_open_tree 428
> > +#define __NR_openat 56
> > +#define __NR_openat2 437
> > +#define __NR_or1k_atomic 244
> > +#define __NR_perf_event_open 241
> > +#define __NR_personality 92
> > +#define __NR_pidfd_getfd 438
> > +#define __NR_pidfd_open 434
> > +#define __NR_pidfd_send_signal 424
> > +#define __NR_pipe2 59
> > +#define __NR_pivot_root 41
> > +#define __NR_pkey_alloc 289
> > +#define __NR_pkey_free 290
> > +#define __NR_pkey_mprotect 288
> > +#define __NR_ppoll 73
> > +#define __NR_ppoll_time64 414
> > +#define __NR_prctl 167
> > +#define __NR_pread64 67
> > +#define __NR_preadv 69
> > +#define __NR_preadv2 286
> > +#define __NR_prlimit64 261
> > +#define __NR_process_madvise 440
> > +#define __NR_process_mrelease 448
> > +#define __NR_process_vm_readv 270
> > +#define __NR_process_vm_writev 271
> > +#define __NR_pselect6 72
> > +#define __NR_pselect6_time64 413
> > +#define __NR_ptrace 117
> > +#define __NR_pwrite64 68
> > +#define __NR_pwritev 70
> > +#define __NR_pwritev2 287
> > +#define __NR_quotactl 60
> > +#define __NR_quotactl_fd 443
> > +#define __NR_read 63
> > +#define __NR_readahead 213
> > +#define __NR_readlinkat 78
> > +#define __NR_readv 65
> > +#define __NR_reboot 142
> > +#define __NR_recvfrom 207
> > +#define __NR_recvmmsg 243
> > +#define __NR_recvmmsg_time64 417
> > +#define __NR_recvmsg 212
> > +#define __NR_remap_file_pages 234
> > +#define __NR_removexattr 14
> > +#define __NR_renameat 38
> > +#define __NR_renameat2 276
> > +#define __NR_request_key 218
> > +#define __NR_restart_syscall 128
> > +#define __NR_rseq 293
> > +#define __NR_rt_sigaction 134
> > +#define __NR_rt_sigpending 136
> > +#define __NR_rt_sigprocmask 135
> > +#define __NR_rt_sigqueueinfo 138
> > +#define __NR_rt_sigreturn 139
> > +#define __NR_rt_sigsuspend 133
> > +#define __NR_rt_sigtimedwait 137
> > +#define __NR_rt_sigtimedwait_time64 421
> > +#define __NR_rt_tgsigqueueinfo 240
> > +#define __NR_sched_get_priority_max 125
> > +#define __NR_sched_get_priority_min 126
> > +#define __NR_sched_getaffinity 123
> > +#define __NR_sched_getattr 275
> > +#define __NR_sched_getparam 121
> > +#define __NR_sched_getscheduler 120
> > +#define __NR_sched_rr_get_interval 127
> > +#define __NR_sched_rr_get_interval_time64 423
> > +#define __NR_sched_setaffinity 122
> > +#define __NR_sched_setattr 274
> > +#define __NR_sched_setparam 118
> > +#define __NR_sched_setscheduler 119
> > +#define __NR_sched_yield 124
> > +#define __NR_seccomp 277
> > +#define __NR_semctl 191
> > +#define __NR_semget 190
> > +#define __NR_semop 193
> > +#define __NR_semtimedop 192
> > +#define __NR_semtimedop_time64 420
> > +#define __NR_sendfile64 71
> > +#define __NR_sendmmsg 269
> > +#define __NR_sendmsg 211
> > +#define __NR_sendto 206
> > +#define __NR_set_mempolicy 237
> > +#define __NR_set_robust_list 99
> > +#define __NR_set_tid_address 96
> > +#define __NR_setdomainname 162
> > +#define __NR_setfsgid 152
> > +#define __NR_setfsuid 151
> > +#define __NR_setgid 144
> > +#define __NR_setgroups 159
> > +#define __NR_sethostname 161
> > +#define __NR_setitimer 103
> > +#define __NR_setns 268
> > +#define __NR_setpgid 154
> > +#define __NR_setpriority 140
> > +#define __NR_setregid 143
> > +#define __NR_setresgid 149
> > +#define __NR_setresuid 147
> > +#define __NR_setreuid 145
> > +#define __NR_setrlimit 164
> > +#define __NR_setsid 157
> > +#define __NR_setsockopt 208
> > +#define __NR_settimeofday 170
> > +#define __NR_setuid 146
> > +#define __NR_setxattr 5
> > +#define __NR_shmat 196
> > +#define __NR_shmctl 195
> > +#define __NR_shmdt 197
> > +#define __NR_shmget 194
> > +#define __NR_shutdown 210
> > +#define __NR_sigaltstack 132
> > +#define __NR_signalfd4 74
> > +#define __NR_socket 198
> > +#define __NR_socketpair 199
> > +#define __NR_splice 76
> > +#define __NR_statfs64 43
> > +#define __NR_statx 291
> > +#define __NR_swapoff 225
> > +#define __NR_swapon 224
> > +#define __NR_symlinkat 36
> > +#define __NR_sync 81
> > +#define __NR_sync_file_range 84
> > +#define __NR_syncfs 267
> > +#define __NR_sysinfo 179
> > +#define __NR_syslog 116
> > +#define __NR_tee 77
> > +#define __NR_tgkill 131
> > +#define __NR_timer_create 107
> > +#define __NR_timer_delete 111
> > +#define __NR_timer_getoverrun 109
> > +#define __NR_timer_gettime 108
> > +#define __NR_timer_gettime64 408
> > +#define __NR_timer_settime 110
> > +#define __NR_timer_settime64 409
> > +#define __NR_timerfd_create 85
> > +#define __NR_timerfd_gettime 87
> > +#define __NR_timerfd_gettime64 410
> > +#define __NR_timerfd_settime 86
> > +#define __NR_timerfd_settime64 411
> > +#define __NR_times 153
> > +#define __NR_tkill 130
> > +#define __NR_truncate64 45
> > +#define __NR_umask 166
> > +#define __NR_umount2 39
> > +#define __NR_uname 160
> > +#define __NR_unlinkat 35
> > +#define __NR_unshare 97
> > +#define __NR_userfaultfd 282
> > +#define __NR_utimensat 88
> > +#define __NR_utimensat_time64 412
> > +#define __NR_vhangup 58
> > +#define __NR_vmsplice 75
> > +#define __NR_wait4 260
> > +#define __NR_waitid 95
> > +#define __NR_write 64
> > +#define __NR_writev 66
> > diff --git a/sysdeps/unix/sysv/linux/or1k/bits/timesize.h b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
> > new file mode 100644
> > index 0000000000..3ab388da7f
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
> > @@ -0,0 +1,19 @@
> > +/* Bit size of the time_t type at glibc build time, OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#define __TIMESIZE	64
> 
> Ok, although I think we should flip the default to 64 bits make
> old ports to override to 32.

It makes sense.  It might be a bit tricky as currently __TIMESIZE default is
__WORDSIZE.  I see a few old ports which have __WORDSIZE 32 and 64 like sparc.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/clone.c b/sysdeps/unix/sysv/linux/or1k/clone.c
> > new file mode 100644
> > index 0000000000..531fd17e29
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/clone.c
> > @@ -0,0 +1,61 @@
> > +/* OpenRISC helper for the clone syscall.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <stdarg.h>
> > +#include <sysdep.h>
> > +
> > +extern int __or1k_clone (int (*fn)(void *), void *child_stack,
> > +			 int flags, void *arg, pid_t *ptid,
> > +			 void *tls, pid_t *ctid);
> > +
> > +
> > +/* The OpenRISC ABI uses the stack for varargs like those using in clone
> > +   but the linux syscall ABI uses registers.
> > +   This function moves from varargs to regs.  */
> > +int
> > +__clone (int (*fn)(void *), void *child_stack,
> > +	 int flags, void *arg, ...
> > +	 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ )
> > +{
> > +  void *ptid;
> > +  void *tls;
> > +  void *ctid;
> > +  va_list ap;
> > +  int err;
> > +
> > +  va_start (ap, arg);
> > +  ptid = va_arg (ap, void *);
> > +  tls = va_arg (ap, void *);
> > +  ctid = va_arg (ap, void *);
> > +  va_end (ap);
> > +
> > +  /* Sanity check the arguments */
> > +  err = -EINVAL;
> > +  if (!fn)
> > +    goto syscall_error;
> > +  if (!child_stack)
> > +    goto syscall_error;
> > +
> > +  return __or1k_clone (fn, child_stack, flags, arg, ptid, tls, ctid);
> > +
> > +syscall_error:
> > +  __set_errno (-err);
> > +  return -1;
> > +}
> > +libc_hidden_def (__clone)
> > +weak_alias (__clone, clone)
> 
> Ok, I take that implementing it solely on __or1k_clone is more complex than
> using a C wrapper.

I am not to clear what you mean here, I take you are asking why we keep
__or1k_clone in assembly rather than implement __or1k_clone in C too.

There are some stack setup bits in __or1k_clone which require assembly.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
> > new file mode 100644
> > index 0000000000..3c5c1826ab
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/jmp_buf-macros.h
> > @@ -0,0 +1,41 @@
> > +/* jump buffer constants, OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +/* Produced by this program:
> > +
> > +   #include <stdio.h>
> > +   #include <unistd.h>
> > +   #include <setjmp.h>
> > +   #include <stddef.h>
> > +
> > +   int main (int argc, char **argv)
> > +   {
> > +       printf ("#define JMP_BUF_SIZE %d\n", sizeof (jmp_buf));
> > +       printf ("#define JMP_BUF_ALIGN %d\n", __alignof__ (jmp_buf));
> > +       printf ("#define SIGJMP_BUF_SIZE %d\n", sizeof (sigjmp_buf));
> > +       printf ("#define SIGJMP_BUF_ALIGN %d\n", __alignof__ (sigjmp_buf));
> > +       printf ("#define MASK_WAS_SAVED_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __mask_was_saved));
> > +       printf ("#define SAVED_MASK_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __saved_mask));
> > +   } */
> > +
> > +#define JMP_BUF_SIZE 184
> > +#define JMP_BUF_ALIGN 4
> > +#define SIGJMP_BUF_SIZE 184
> > +#define SIGJMP_BUF_ALIGN 4
> > +#define MASK_WAS_SAVED_OFFSET 52
> > +#define SAVED_MASK_OFFSET 56
> 
> You don't need this file since bc801b3a40f3a9bc8f24f1d0fdc39413874c3172.

OK. I think I forgot to remove them.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/mmap_internal.h b/sysdeps/unix/sysv/linux/or1k/mmap_internal.h
> > new file mode 100644
> > index 0000000000..817b841e5b
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/mmap_internal.h
> > @@ -0,0 +1,28 @@
> > +/* Common mmap definition for Linux implementation.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef MMAP_OR1K_INTERNAL_LINUX_H
> > +#define MMAP_OR1K_INTERNAL_LINUX_H
> > +
> > +/* OpenRISC Linux sets the page shift to 13 and mmap2 expects
> > +   offsets to be provided in 8K pages.  */
> > +#define MMAP2_PAGE_UNIT 8192ULL
> > +
> > +#include_next <mmap_internal.h>
> > +
> > +#endif
> 
> Ok.
> 
> > diff --git a/sysdeps/unix/sysv/linux/or1k/or1k_clone.S b/sysdeps/unix/sysv/linux/or1k/or1k_clone.S
> > new file mode 100644
> > index 0000000000..337eb17d06
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/or1k_clone.S
> > @@ -0,0 +1,89 @@
> > +/* clone helper __or1k_clone for OpenRISC.
> > +   Copyright (C) 2021 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, write to the Free
> > +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > +   02111-1307 USA.  */
> > +
> > +#include <sysdep.h>
> > +#include <tls.h>
> > +#define __ASSEMBLY__
> > +#include <linux/sched.h>
> > +
> > +	.text
> > +ENTRY(__or1k_clone)
> > +
> > +	/* To handle GCC varargs we need to use our __clone wrapper to pop
> > +	   everything from the stack for us.
> > +	   Now everything is placed in the registers which saves us a lot
> > +	   of trouble.
> > +
> > +	   The userland implementation is:
> > +
> > +	     int clone (int (*fn)(void *), void *child_stack,
> > +			int flags, void *arg, pid_t *ptid,
> > +			struct user_desc *tls, pid_t *ctid);
> > +	   The kernel entry is:
> > +
> > +	     int clone (long flags, void *child_stack, int *parent_tid,
> > +			int *child_tid, struct void *tls)
> > +
> > +	     NB: tls isn't really an argument, it is read from r7 directly.  */
> > +
> > +	/* First, align the stack to 4 bytes.  */
> > +	l.xori	r11, r0, -4
> > +	l.and	r4, r4, r11
> > +
> > +	/* Put 'fn', 'arg' and 'flags' on the child stack.  */
> > +	l.addi	r4, r4, -12
> > +	l.sw	8(r4), r3
> > +	l.sw	4(r4), r6
> > +	l.sw	0(r4), r5
> > +
> > +	l.ori	r3, r5, 0
> > +	/* The child_stack is already in r4.  */
> > +	l.ori	r5, r7, 0
> > +	l.lwz	r6, 0(r1)
> > +	l.ori	r7, r8, 0
> > +
> > +	DO_CALL (clone)
> > +
> > +	l.sfgeui r11, 0xf001
> > +	l.bf	L(error)
> > +	 l.nop
> > +
> > +	/* If we are not the child, return the pid.  */
> > +	l.sfeqi	r11, 0
> > +	l.bf	L(thread_start)
> > +	 l.nop
> > +
> > +	l.jr	r9
> > +	 l.nop
> > +
> > +L(thread_start):
> > +	/* Load function from stack.  */
> > +	l.lwz	r11, 8(r1)
> > +	l.jalr	r11
> > +	 l.lwz	r3, 4(r1)
> > +
> > +	/* Exit the child thread.  */
> > +	l.ori	r3, r11, 0
> > +	DO_CALL (exit)
> > +
> > +L(error):
> > +	l.j	SYSCALL_ERROR_NAME
> > +	 l.ori	r3, r11, 0
> > +
> > +PSEUDO_END (__or1k_clone)

Using PSEUDO_END is wrong here, I switched to END.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/sysdep.c b/sysdeps/unix/sysv/linux/or1k/sysdep.c
> > new file mode 100644
> > index 0000000000..1130cba687
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/sysdep.c
> > @@ -0,0 +1,34 @@
> > +/* OpenRISC wrapper for setting errno.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +#include <errno.h>
> > +
> > +long int __syscall_error (long int err);
> > +hidden_proto (__syscall_error)
> > +
> > +/* This routine is jumped to by all the syscall handlers, to stash
> > +   an error number into errno.  */
> > +long int
> > +__syscall_error (long int err)
> > +{
> > +  __set_errno (- err);
> > +  return -1;
> > +}
> > +hidden_def (__syscall_error)
> > diff --git a/sysdeps/unix/sysv/linux/or1k/sysdep.h b/sysdeps/unix/sysv/linux/or1k/sysdep.h
> > new file mode 100644
> > index 0000000000..5dd6da48a1
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/sysdep.h
> > @@ -0,0 +1,201 @@
> > +/* Assembler and syscall macros.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef _LINUX_OR1K_SYSDEP_H
> > +#define _LINUX_OR1K_SYSDEP_H 1
> > +
> > +#include <sysdeps/or1k/sysdep.h>
> > +#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
> > +#include <tls.h>
> > +
> > +/* "workarounds" for generic code needing to handle 64-bit time_t.  */
> > +
> > +#undef __NR_clock_getres
> > +#undef __NR_futex
> > +#undef __NR_ppoll
> > +#undef __NR_pselect6
> > +#undef __NR_recvmmsg
> > +#undef __NR_rt_sigtimedwait
> > +#undef __NR_semtimedop
> > +#undef __NR_utimensat
> > +
> > +/* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c.  */
> > +#define __NR_clock_getres	__NR_clock_getres_time64
> > +/* Fix sysdeps/nptl/lowlevellock-futex.h.  */
> > +#define __NR_futex		__NR_futex_time64
> > +/* Fix sysdeps/unix/sysv/linux/pause.c.  */
> > +#define __NR_ppoll		__NR_ppoll_time64
> > +/* Fix sysdeps/unix/sysv/linux/select.c.  */
> > +#define __NR_pselect6		__NR_pselect6_time64
> > +/* Fix sysdeps/unix/sysv/linux/recvmmsg.c.  */
> > +#define __NR_recvmmsg		__NR_recvmmsg_time64
> > +/* Fix sysdeps/unix/sysv/linux/sigtimedwait.c.  */
> > +#define __NR_rt_sigtimedwait	__NR_rt_sigtimedwait_time64
> > +/* Fix sysdeps/unix/sysv/linux/semtimedop.c.  */
> > +#define __NR_semtimedop		__NR_semtimedop_time64
> > +/* Hack sysdeps/unix/sysv/linux/generic/utimes.c.  */
> > +#define __NR_utimensat		__NR_utimensat_time64
> > +
> > +#undef SYS_ify
> > +#define SYS_ify(syscall_name)   (__NR_##syscall_name)
> > +
> > +/* Linux uses a negative return value to indicate syscall errors,
> > +   unlike most Unices, which use the condition codes' carry flag.
> > +
> > +   Since version 2.1 the return value of a system call might be
> > +   negative even if the call succeeded.  E.g., the lseek system call
> > +   might return a large offset.  Therefore we must not anymore test
> > +   for < 0, but test for a real error by making sure the value in R0
> > +   is a real error number.  Linus said he will make sure the no syscall
> > +   returns a value in -1 .. -4095 as a valid result so we can safely
> > +   test with -4095.  */
> > +
> > +#ifdef __ASSEMBLER__
> > +
> > +/* Macros used in syscall-template.S */
> > +#define ret          l.jr r9; l.nop
> > +#define ret_NOERRNO  l.jr r9; l.nop
> > +
> > +#undef	DO_CALL
> > +#define DO_CALL(syscall_name) \
> > +  l.addi r11, r0, SYS_ify (syscall_name); \
> > +  l.sys 1; \
> > +   l.nop
> > +
> > +#undef	PSEUDO
> > +#define PSEUDO(name, syscall_name, args) \
> > +  ENTRY (name); \
> > +  DO_CALL(syscall_name); \
> > +  /* if -4096 < ret < 0 holds, it's an error */ \
> > +  l.sfgeui r11, 0xf001; \
> > +  l.bf L(pseudo_end); \
> > +   l.nop
> > +
> > +#undef	PSEUDO_NOERRNO
> > +#define PSEUDO_NOERRNO(name, syscall_name, args)  \
> > +  ENTRY (name);           \
> > +  DO_CALL(syscall_name)
> > +
> > +#undef	PSEUDO_END
> > +#define PSEUDO_END(name) \
> > +L(pseudo_end): \
> > +  l.j SYSCALL_ERROR_NAME; \
> > +  l.ori r3,r11,0; \
> > +  END (name)
> > +
> > +#undef	PSEUDO_END_NOERRNO
> > +#define PSEUDO_END_NOERRNO(name) \
> > +  END (name)
> > +
> > +#ifndef PIC
> > +/* For static code, on error jump to __syscall_error directly.  */
> > +# define SYSCALL_ERROR_NAME __syscall_error
> > +#elif !IS_IN (libc)
> > +/* Use the internal name for libc shared objects.  */
> > +# define SYSCALL_ERROR_NAME __GI___syscall_error
> > +#else
> > +/* Otherwise, on error do a full PLT jump.  */
> > +# define SYSCALL_ERROR_NAME plt(__syscall_error)
> > +#endif
> > +
> > +#else /* not __ASSEMBLER__ */
> > +
> > +#include <errno.h>
> > +
> > +extern long int __syscall_error (long int neg_errno);
> > +
> > +/* Pointer mangling is not yet supported for or1k.  */
> > +#define PTR_MANGLE(var) (void) (var)
> > +#define PTR_DEMANGLE(var) (void) (var)
> > +
> > +#undef INTERNAL_SYSCALL
> > +#define INTERNAL_SYSCALL(name, nr, args...) \
> > +	INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
> > +
> > +/* The _NCS variant allows non-constant syscall numbers.  */
> > +#undef INTERNAL_SYSCALL_NCS
> > +#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
> > +        ({ unsigned long int __sys_result;                                     \
> > +          {                                                                    \
> > +            long int _sc_ret = (long int) number;                              \
> > +            LOAD_ARGS_##nr (args)                                              \
> > +            register long int __sc_ret __asm__ ("r11") = _sc_ret;              \
> > +            __asm__ __volatile__ ("l.sys 1\n\t"                                \
> > +				  " l.nop\n\t"                                 \
> > +                                  : "+r" (__sc_ret)                            \
> > +                                  : ASM_ARGS_##nr                              \
> > +                                  : ASM_CLOBBERS_##nr                          \
> > +                                    "r12", "r13", "r15", "r17", "r19",         \
> > +                                    "r21", "r23", "r25", "r27", "r29",         \
> > +                                    "r31", "memory");                          \
> > +            __sys_result = __sc_ret;                                           \
> > +          }                                                                    \
> > +          (long int) __sys_result; })
> > +
> > +/* From here on we have nested macros that generate code for
> > +   setting up syscall arguments.  */
> > +
> > +#define LOAD_ARGS_0()
> > +
> > +#define ASM_ARGS_0
> > +#define ASM_CLOBBERS_0  "r3", ASM_CLOBBERS_1
> > +
> > +#define LOAD_ARGS_1(a) \
> > +  long int _a = (long int)(a);                             \
> > +  register long int __a __asm__ ("r3") = _a;
> > +#define ASM_ARGS_1 "r" (__a)
> > +#define ASM_CLOBBERS_1  "r4", ASM_CLOBBERS_2
> > +
> > +#define LOAD_ARGS_2(a, b) \
> > +  long int _b = (long int)(b);                             \
> > +  LOAD_ARGS_1 (a)                                          \
> > +  register long int __b __asm__ ("r4") = _b;
> > +#define ASM_ARGS_2 ASM_ARGS_1, "r" (__b)
> > +#define ASM_CLOBBERS_2  "r5", ASM_CLOBBERS_3
> > +
> > +#define LOAD_ARGS_3(a, b, c) \
> > +  long int _c = (long int)(c);                             \
> > +  LOAD_ARGS_2 (a, b)                                       \
> > +  register long int __c __asm__ ("r5") = _c;
> > +#define ASM_ARGS_3 ASM_ARGS_2, "r" (__c)
> > +#define ASM_CLOBBERS_3  "r6", ASM_CLOBBERS_4
> > +
> > +#define LOAD_ARGS_4(a, b, c, d) \
> > +    LOAD_ARGS_3 (a, b, c)                                  \
> > +  long int _d = (long int)(d);                             \
> > +  register long int __d __asm__ ("r6") = _d;
> > +#define ASM_ARGS_4 ASM_ARGS_3, "r" (__d)
> > +#define ASM_CLOBBERS_4  "r7", ASM_CLOBBERS_5
> > +
> > +#define LOAD_ARGS_5(a, b, c, d, e) \
> > +  long int _e = (long int)(e);                             \
> > +  LOAD_ARGS_4 (a, b, c, d)                                 \
> > +  register long int __e __asm__ ("r7") = _e;
> > +#define ASM_ARGS_5 ASM_ARGS_4, "r" (__e)
> > +#define ASM_CLOBBERS_5  "r8", ASM_CLOBBERS_6
> > +
> > +#define LOAD_ARGS_6(a, b, c, d, e, f) \
> > +  long int _f = (long int)(f);                             \
> > +  LOAD_ARGS_5 (a, b, c, d, e)                              \
> > +  register long int __f __asm__ ("r8") = _f;
> > +#define ASM_ARGS_6 ASM_ARGS_5, "r" (__f)
> > +#define ASM_CLOBBERS_6
> > +
> > +#endif /* not __ASSEMBLER__ */
> > +
> > +#endif /* linux/or1k/sysdep.h */

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 07/13] or1k: math soft float support
  2021-12-16 19:48   ` Adhemerval Zanella
@ 2021-12-17 15:02     ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-17 15:02 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Thu, Dec 16, 2021 at 04:48:06PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > OpenRISC support hard float but I will like to submit that after glibc
> > soft float goes upstream.  The hard float support depends on adding user
> > access to the FPCSR, which is not supported by the kernel yet.
> 
> The patch looks ok in general, the fenv bits matches the documentation. 

Thank you.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 06/13] or1k: Atomics and Locking primitives
  2021-12-16 19:43     ` Adhemerval Zanella
@ 2021-12-17 15:03       ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-17 15:03 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Thu, Dec 16, 2021 at 04:43:52PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 16/12/2021 09:52, Adhemerval Zanella wrote:
> > LGTM, thanks.
> > 
> > On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> >> ---
> >>  sysdeps/or1k/atomic-machine.h | 79 +++++++++++++++++++++++++++++++++++
> >>  1 file changed, 79 insertions(+)
> >>  create mode 100644 sysdeps/or1k/atomic-machine.h
> >>
> >> diff --git a/sysdeps/or1k/atomic-machine.h b/sysdeps/or1k/atomic-machine.h
> >> new file mode 100644
> >> index 0000000000..1e306ae4ef
> >> --- /dev/null
> >> +++ b/sysdeps/or1k/atomic-machine.h
> >> @@ -0,0 +1,79 @@
> >> +/* Atomic operations.  OpenRISC version.
> >> +   Copyright (C) 2021 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
> >> +   <https://www.gnu.org/licenses/>.  */
> >> +
> >> +#ifndef __OR1K_ATOMIC_H_
> >> +#define __OR1K_ATOMIC_H_
> >> +
> >> +#include <stdint.h>
> >> +
> >> +typedef int32_t atomic32_t;
> >> +typedef uint32_t uatomic32_t;
> >> +
> >> +typedef intptr_t atomicptr_t;
> >> +typedef uintptr_t uatomicptr_t;
> >> +typedef intmax_t atomic_max_t;
> >> +typedef uintmax_t uatomic_max_t;
> > 
> > Sigh, these definition are used solely in only file, memusage.c.  Another thing
> > I will cleanup.
> 
> I just send a patchset that aims to simplify this boilerplate [1].  It should
> also simplify other parts of OpenRISC submission.
> 
> [1] https://sourceware.org/pipermail/libc-alpha/2021-December/134285.html

Thanks, I have seen it.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 08/13] or1k: Linux Syscall Interface
  2021-12-17 15:01     ` Stafford Horne
@ 2021-12-17 17:41       ` Adhemerval Zanella
  2021-12-20 11:53         ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-17 17:41 UTC (permalink / raw)
  To: Stafford Horne; +Cc: GLIBC patches, Openrisc



On 17/12/2021 12:01, Stafford Horne wrote:
> On Thu, Dec 16, 2021 at 06:17:45PM -0300, Adhemerval Zanella wrote:
>>> diff --git a/sysdeps/unix/sysv/linux/or1k/bits/timesize.h b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
>>> new file mode 100644
>>> index 0000000000..3ab388da7f
>>> --- /dev/null
>>> +++ b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
>>> @@ -0,0 +1,19 @@
>>> +/* Bit size of the time_t type at glibc build time, OpenRISC version.
>>> +   Copyright (C) 2021 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
>>> +   <https://www.gnu.org/licenses/>.  */
>>> +
>>> +#define __TIMESIZE	64
>>
>> Ok, although I think we should flip the default to 64 bits make
>> old ports to override to 32.
> 
> It makes sense.  It might be a bit tricky as currently __TIMESIZE default is
> __WORDSIZE.  I see a few old ports which have __WORDSIZE 32 and 64 like sparc.

I will fix this upstream, it is just a matter to override to 32 for older ports.

>>
>> Ok, I take that implementing it solely on __or1k_clone is more complex than
>> using a C wrapper.
> 
> I am not to clear what you mean here, I take you are asking why we keep
> __or1k_clone in assembly rather than implement __or1k_clone in C too.
> 
> There are some stack setup bits in __or1k_clone which require assembly.
> 

I meant otherwise in fact, why not implement clone for or1k purely in assembly.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 04/13] or1k: startup and dynamic linking code
  2021-12-16 10:42   ` Adhemerval Zanella
@ 2021-12-17 23:03     ` Stafford Horne
  2021-12-20 19:45       ` Adhemerval Zanella
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-17 23:03 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Openrisc

On Thu, Dec 16, 2021 at 07:42:46AM -0300, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > Code for C runtime startup and dynamic loading including PLT layout.
> 
> Patch looks ok, although I comment much on ABI and assembly code. Some
> comments below.
> 
> > ---
> >  sysdeps/or1k/bits/link.h   |  51 ++++++
> >  sysdeps/or1k/dl-machine.h  | 323 +++++++++++++++++++++++++++++++++++++
> >  sysdeps/or1k/dl-start.S    |  98 +++++++++++
> >  sysdeps/or1k/ldsodefs.h    |  40 +++++
> >  sysdeps/or1k/sotruss-lib.c |  51 ++++++
> >  sysdeps/or1k/start.S       |  99 ++++++++++++
> >  sysdeps/or1k/tst-audit.h   |  24 +++
> >  7 files changed, 686 insertions(+)
> >  create mode 100644 sysdeps/or1k/bits/link.h
> >  create mode 100644 sysdeps/or1k/dl-machine.h
> >  create mode 100644 sysdeps/or1k/dl-start.S
> >  create mode 100644 sysdeps/or1k/ldsodefs.h
> >  create mode 100644 sysdeps/or1k/sotruss-lib.c
> >  create mode 100644 sysdeps/or1k/start.S
> >  create mode 100644 sysdeps/or1k/tst-audit.h
> > 
> > diff --git a/sysdeps/or1k/bits/link.h b/sysdeps/or1k/bits/link.h
> > new file mode 100644
> > index 0000000000..ad183c9625
> > --- /dev/null
> > +++ b/sysdeps/or1k/bits/link.h
> > @@ -0,0 +1,51 @@
> > +/* Declarations for dynamic linker interface. OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef _LINK_H
> > +# error "Never include <bits/link.h> directly; use <link.h> instead."
> > +#endif
> > +
> > +/* Registers for entry into PLT.  */
> > +typedef struct La_or1k_regs
> > +{
> > +  uint32_t lr_reg[31];
> > +} La_or1k_regs;
> > +
> 
> So is the intent is to provide caller all the register, no only the caller-saved 
> registers?

As I see it...

Shouldn't these usually be the argument registers used in la_pltenter to print
our the function call? i.e.

  print_enter (refcook, defcook, symname,
               regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
               *flags);

These registers get setup in sysdeps/{arch}/dl-trampoline.S by
_dl_runtime_profile, which then pass them to _dl_profile_fixup.

The problem is openrisc doesn't implement _dl_runtime_profile so we haven't
defined what the registers are.

I noticed the same for arc, csky, riscv.

These are needed to be defined for sotruss, but I dont seem them being used.

Is that correct?

> > +/* Return values for calls from PLT.  */
> > +typedef struct La_or1k_retval
> > +{
> > +  uint32_t lrv_r3;
> > +} La_or1k_retval;
> > +
> > +__BEGIN_DECLS
> > +
> > +extern ElfW(Addr) la_or1k_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
> > +					uintptr_t *__refcook,
> > +					uintptr_t *__defcook,
> > +					La_or1k_regs *__regs,
> > +					unsigned int *__flags,
> > +					const char *__symname,
> > +					long int *__framesizep);
> > +extern unsigned int la_or1k_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
> > +					 uintptr_t *__refcook,
> > +					 uintptr_t *__defcook,
> > +					 const La_or1k_regs *__inregs,
> > +					 La_or1k_retval *__outregs,
> > +					 const char *__symname);
> > +
> > +__END_DECLS
> > diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h
> > new file mode 100644
> > index 0000000000..d41554769e
> > --- /dev/null
> > +++ b/sysdeps/or1k/dl-machine.h
> > @@ -0,0 +1,323 @@
> > +/* Machine-dependent ELF dynamic relocation inline functions.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef dl_machine_h
> > +#define dl_machine_h
> > +
> > +#define ELF_MACHINE_NAME "or1k"
> > +
> > +#include <sys/cdefs.h>
> > +#include <sys/param.h>
> > +#include <tls.h>
> > +#include <dl-irel.h>
> > +#include <dl-static-tls.h>
> > +#include <dl-machine-rel.h>
> > +
> > +/* Return nonzero iff ELF header is compatible with the running host.  */
> > +static inline int __attribute__ ((unused))
> > +elf_machine_matches_host (const Elf32_Ehdr *ehdr)
> > +{
> > +  return ehdr->e_machine == EM_OPENRISC;
> > +}
> > +
> > +static inline Elf32_Addr *
> > +or1k_get_got (void)
> > +{
> > +  Elf32_Addr *got;
> > +  register long int linkreg asm ("r9");
> 
> Is the 'r9' a required register by the ABI to use on this assembly snippet?
> I am asking because local name 'registers' are only a hint to gcc, as we
> found recently [1], if you really need 'r9' you will probably need to use 
> a global name resgister.

The r9 is to avoid the snippet from clobbering r9.  The result of l.jal will
update r9 (link register) we want to make sure that is what we used for %1.

I think there were issues with other ways I tried.

Let me look into it more.

> > +  asm ("l.jal    0x8\n"
> > +       " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
> > +       "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
> > +       "l.add    %0, %0, %1\n"
> > +       : "=r" (got), "=r" (linkreg));
> > +
> > +  return got;
> > +}
> > +
> > +/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
> > +   first element of the GOT.  */
> > +static inline Elf32_Addr
> > +elf_machine_dynamic (void)
> > +{
> > +  Elf32_Addr *got = or1k_get_got();
> 
> Space before '('.

OK.

> > +  return *got;
> > +}
> > +
> > +
> > +/* Return the run-time load address of the shared object.  */
> > +static inline Elf32_Addr
> > +elf_machine_load_address (void)
> > +{
> > +  /* Compute the difference between the runtime address of _DYNAMIC as seen
> > +     by a GOTOFF reference, and the link-time address found in the special
> > +     unrelocated first GOT entry.  */
> > +  Elf32_Addr dyn;
> > +  Elf32_Addr *got = or1k_get_got();
> 
> Space before '('.

OK.

> > +
> > +  asm ("l.movhi %0, gotoffhi(_DYNAMIC);"
> > +       "l.ori   %0, %0, gotofflo(_DYNAMIC);"
> > +       "l.add   %0, %0, %1;"
> > +       : "=&r"(dyn) : "r"(got));
> > +
> > +  return dyn - *got;
> > +}
> > +
> > +/* Initial entry point code for the dynamic linker.  The function _dl_start
> > +   is the real entry point; it's return value is the user program's entry
> > +   point.
> > +
> > +   Code is really located in dl-start.S, just tell the linker that it
> > +   exists.  */
> > +#define RTLD_START asm (".globl _dl_start");
> > +
> > +/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
> > +   TLS variable, so undefined references should not be allowed to
> > +   define the value.
> > +   ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
> > +   of the main executable's symbols, as for a COPY reloc.  */
> > +
> > +#define elf_machine_type_class(type) \
> > +  (((type) == R_OR1K_JMP_SLOT \
> > +   || (type) == R_OR1K_TLS_DTPMOD \
> > +   || (type) == R_OR1K_TLS_DTPOFF \
> > +   || (type) == R_OR1K_TLS_TPOFF) * ELF_RTYPE_CLASS_PLT \
> > +   | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY)
> > +
> > +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
> > +#define ELF_MACHINE_JMP_SLOT    R_OR1K_JMP_SLOT
> > +
> > +#define ARCH_LA_PLTENTER or1k_gnu_pltenter
> > +#define ARCH_LA_PLTEXIT or1k_gnu_pltexit
> > +
> > +/* Set up the loaded object described by L so its unrelocated PLT
> > +   entries will jump to the on-demand fixup code in dl-runtime.c.  */
> > +static inline int __attribute__ ((unused, always_inline))
> > +elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
> > +			   int lazy, int profile)
> > +{
> > +  ElfW(Addr) *pltgot;
> > +  extern void _dl_runtime_resolve (ElfW(Word));
> > +  extern void _dl_runtime_profile (ElfW(Word));
> > +
> > +  if (l->l_info[DT_JMPREL] && lazy)
> > +    {
> > +      pltgot = (ElfW(Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
> > +
> > +      /* Fill in initial entrys of the plt */
> > +
> > +      /* Register the link_map address in the plt at pltgot[1].
> > +	 This will also be used in the resolver for accessing the
> > +	 link_map structure.  */
> > +      pltgot[1] = (ElfW(Addr)) l;
> > +
> > +      /* The pltgot[2] entry contains the address of a function which gets
> > +	 called to get the address of a so far unresolved function and
> > +	 jump to it.  The profiling extension of the dynamic linker allows
> > +	 to intercept the calls to collect information.  In this case we
> > +	 don't store the address in the GOT so that all future calls also
> > +	 end in this function.  */
> > +#if 0 /* Profiling not supported in OpenRISC yet (need to implement
> > +	 _dl_runtime_profile).  */
> > +      if ( profile)
> > +	{
> > +	   pltgot[2] = (ElfW(Addr)) &_dl_runtime_profile;
> > +
> > +	  if (GLRO(dl_profile) != NULL
> > +	      && _dl_name_match_p (GLRO(dl_profile), l))
> > +	    /* Say that we really want profiling and the timers are
> > +	       started.  */
> > +	    GL(dl_profile_map) = l;
> > +	}
> > +      else
> > +#endif
> 
> I think it would be better to remove the commented code and add a comment stating
> LD_PROFILE is not currently supported.

OK.

> > +	{
> > +	  /* This function will get called to fix up the GOT entry
> > +	     indicated by the offset on the stack, and then jump to
> > +	     the resolved address.  */
> > +	  pltgot[2] = (ElfW(Addr)) &_dl_runtime_resolve;
> > +	}
> > +
> > +    }
> > +
> > +  return lazy;
> > +}
> > +
> > +/* Mask identifying addresses reserved for the user program,
> > +   where the dynamic linker should not map anything.  */
> > +#define ELF_MACHINE_USER_ADDRESS_MASK   0xf8000000UL
> > +
> > +/* We define an initialization functions.  This is called very early in
> > +   _dl_sysdep_start.  */
> > +#define DL_PLATFORM_INIT dl_platform_init ()
> > +
> > +static inline void __attribute__ ((unused))
> > +dl_platform_init (void)
> > +{
> > +  if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
> > +    /* Avoid an empty string which would disturb us.  */
> > +    GLRO(dl_platform) = NULL;
> > +}
> > +
> > +static inline ElfW(Addr)
> > +elf_machine_fixup_plt (struct link_map *map, lookup_t t,
> > +		       const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
> > +		       const ElfW(Rela) *reloc,
> > +		       ElfW(Addr) *reloc_addr, ElfW(Addr) value)
> > +{
> > +  return *reloc_addr = value;
> > +}
> > +
> > +/* Return the final value of a plt relocation.  */
> > +static inline Elf32_Addr
> > +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
> > +		       Elf32_Addr value)
> > +{
> > +  return value + reloc->r_addend;
> > +}
> > +
> > +
> > +#endif /* !dl_machine_h */
> > +
> > +#ifdef RESOLVE_MAP
> > +
> > +/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
> > +   MAP is the object containing the reloc.  */
> > +
> > +static inline void
> > +__attribute ((always_inline))
> > +elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
> > +		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
> > +		  const struct r_found_version *version,
> > +		  void *const reloc_addr_arg, int skip_ifunc)
> > +{
> > +  Elf32_Addr *const reloc_addr = reloc_addr_arg;
> > +  const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
> > +
> > +  if (__glibc_unlikely (r_type == R_OR1K_NONE))
> > +    return;
> > +  else
> > +    {
> > +# ifndef RESOLVE_CONFLICT_FIND_MAP
> > +      const Elf32_Sym *const refsym = sym;
> > +# endif
> > +      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
> > +					      r_type);
> > +      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
> > +
> > +      if (sym != NULL
> > +	  && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)
> > +	  && __glibc_likely (sym->st_shndx != SHN_UNDEF)
> > +	  && __glibc_likely (!skip_ifunc))
> > +	value = elf_ifunc_invoke (value);
> > +
> > +      switch (r_type)
> > +	{
> > +# ifndef RESOLVE_CONFLICT_FIND_MAP
> > +	  case R_OR1K_COPY:
> > +	    if (sym == NULL)
> > +	      /* This can happen in trace mode if an object could not be
> > +		 found.  */
> > +	      break;
> > +	    if (__glibc_unlikely (sym->st_size > refsym->st_size)
> > +		|| (__glibc_unlikely (sym->st_size < refsym->st_size)
> > +		  && GLRO(dl_verbose)))
> > +	    {
> > +	      const char *strtab;
> > +
> > +	      strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
> > +	      _dl_error_printf ("\
> > +%s: Symbol `%s' has different size in shared object, consider re-linking\n",
> > +		  rtld_progname ?: "<program name unknown>",
> > +		  strtab + refsym->st_name);
> > +	    }
> > +	    memcpy (reloc_addr_arg, (void *) value,
> > +		MIN (sym->st_size, refsym->st_size));
> > +	    break;
> > +# endif /* !RESOLVE_CONFLICT_FIND_MAP */
> > +	  case R_OR1K_32:
> > +	    /* Support relocations on mis-aligned offsets.  */
> > +	    value += reloc->r_addend;
> > +	    memcpy (reloc_addr_arg, &value, 4);
> > +	    break;
> > +	  case R_OR1K_GLOB_DAT:
> > +	  case R_OR1K_JMP_SLOT:
> > +	    *reloc_addr = value + reloc->r_addend;
> > +	    break;
> > +	  case R_OR1K_TLS_DTPMOD:
> > +# ifdef RTLD_BOOTSTRAP
> > +	    /* During startup the dynamic linker is always the module
> > +	       with index 1.  */
> > +	    *reloc_addr = 1;
> > +# else
> > +	    if (sym_map != NULL)
> > +	      *reloc_addr = sym_map->l_tls_modid;
> > +# endif
> > +	    break;
> > +	  case R_OR1K_TLS_DTPOFF:
> > +# ifndef RTLD_BOOTSTRAP
> > +	    *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
> > +# endif
> > +	    break;
> > +
> > +	  case R_OR1K_TLS_TPOFF:
> > +# ifdef RTLD_BOOTSTRAP
> > +	    *reloc_addr = sym->st_value + reloc->r_addend +
> > +	      map->l_tls_offset - TLS_TCB_SIZE;
> > +# else
> > +	    if (sym_map != NULL)
> > +	      {
> > +		CHECK_STATIC_TLS (map, sym_map);
> > +		*reloc_addr = sym->st_value + reloc->r_addend +
> > +		  sym_map->l_tls_offset - TLS_TCB_SIZE;
> > +	      }
> > +# endif
> > +	    break;
> > +	  default:
> > +	    _dl_reloc_bad_type (map, r_type, 0);
> > +	    break;
> > +	}
> > +    }
> > +}
> > +
> > +static inline void
> > +__attribute__ ((always_inline))
> > +elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
> > +			   void *const reloc_addr_arg)
> > +{
> > +  Elf32_Addr *const reloc_addr = reloc_addr_arg;
> > +  *reloc_addr = l_addr + reloc->r_addend;
> > +}
> > +
> > +static inline void
> > +__attribute__ ((always_inline))
> > +elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
> > +		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
> > +		      int skip_ifunc)
> > +{
> > +  Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
> > +  const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
> > +
> > +  if (__glibc_likely (r_type == R_OR1K_JMP_SLOT))
> > +      *reloc_addr += l_addr;
> > +  else if (__glibc_unlikely (r_type == R_OR1K_NONE))
> > +    return;
> > +  else
> > +    _dl_reloc_bad_type (map, r_type, 1);
> > +}
> > +
> > +#endif /* RESOLVE_MAP */
> > diff --git a/sysdeps/or1k/dl-start.S b/sysdeps/or1k/dl-start.S
> > new file mode 100644
> > index 0000000000..ecb1505427
> > --- /dev/null
> > +++ b/sysdeps/or1k/dl-start.S
> > @@ -0,0 +1,98 @@
> > +/* Machine-dependent ELF startup code.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +
> > +/* Initial entry point code for the dynamic linker.
> > +   The function _dl_start is the real entry point;
> > +   it's return value is the user program's entry point.  */
> > +ENTRY (_start)
> > +	/* Count arguments in r11 */
> > +	l.ori	r3, r1, 0
> > +	l.movhi	r11, 0
> > +1:
> > +	l.addi	r3, r3, 4
> > +	l.lwz	r12, 0(r3)
> > +	l.sfnei	r12, 0
> > +	l.addi	r11, r11, 1
> > +	l.bf	1b
> > +	 l.nop
> > +	l.addi	r11, r11, -1
> > +	/* store argument counter to stack.  */
> > +	l.sw	0(r1), r11
> > +
> > +	/* Load the PIC register.  */
> > +	l.jal	0x8
> > +	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
> > +	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
> > +	l.add	r16, r16, r9
> > +
> > +	l.ori	r3, r1, 0
> > +
> > +	l.jal	_dl_start
> > +	 l.nop
> > +	/* Save user entry in a call saved reg.  */
> > +	l.ori	r22, r11, 0
> > +	/* Fall through to _dl_start_user.  */
> > +
> > +_dl_start_user:
> > +	/* Set up for _dl_init.  */
> > +
> > +	/* Load _rtld_local (a.k.a _dl_loaded).  */
> > +	l.lwz	r12, got(_rtld_local)(r16)
> > +	l.lwz	r3, 0(r12)
> > +
> > +	/* Load argc */
> > +	l.lwz	r18, got(_dl_argc)(r16)
> > +	l.lwz	r4, 0(r18)
> > +
> > +	/* Load argv */
> > +	l.lwz	r20, got(_dl_argv)(r16)
> > +	l.lwz	r5, 0(r20)
> > +
> > +	/* Load envp = &argv[argc + 1].  */
> > +	l.slli	r6, r4, 2
> > +	l.addi	r6, r6, 4
> > +	l.add	r6, r6, r5
> > +
> > +	l.jal	plt(_dl_init)
> > +	 l.nop
> > +
> > +	/* Now set up for user entry.
> > +	   The already defined ABI loads argc and argv from the stack.
> > +
> > +	   argc = 0(r1)
> > +	   argv = r1 + 4
> > +	*/
> > +
> > +	/* Load SP as argv - 4.  */
> > +	l.lwz	r3, 0(r20)
> > +	l.addi	r1, r3, -4
> > +
> > +	/* Save argc.  */
> > +	l.lwz	r3, 0(r18)
> > +	l.sw	0(r1), r3
> > +
> > +	/* Pass _dl_fini function address to _start.
> > +	   Next start.S will then pass this as rtld_fini to __libc_start_main.  */
> > +	l.lwz	r3, got(_dl_fini)(r16)
> > +
> > +	l.jr	r22
> > +	 l.nop
> > +
> > +END (_start)
> > diff --git a/sysdeps/or1k/ldsodefs.h b/sysdeps/or1k/ldsodefs.h
> > new file mode 100644
> > index 0000000000..89713fcc70
> > --- /dev/null
> > +++ b/sysdeps/or1k/ldsodefs.h
> > @@ -0,0 +1,40 @@
> > +/* Run-time dynamic linker data structures for loaded ELF shared objects.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef	_OR1K_LDSODEFS_H
> > +#define	_OR1K_LDSODEFS_H	1
> > +
> > +#include <elf.h>
> > +
> > +struct La_or1k_regs;
> > +struct La_or1k_retval;
> > +
> > +#define ARCH_PLTENTER_MEMBERS						\
> > +    uintptr_t (*or1k_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *, \
> > +				  uintptr_t *, struct La_or1k_regs *, \
> > +				  unsigned int *, const char *name,	\
> > +				  long int *framesizep)
> > +
> > +#define ARCH_PLTEXIT_MEMBERS						\
> > +    unsigned int (*or1k_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *, \
> > +				    uintptr_t *, const struct La_or1k_regs *, \
> > +				    struct La_or1k_retval *, const char *)
> > +
> > +#include_next <ldsodefs.h>
> > +
> > +#endif
> > diff --git a/sysdeps/or1k/sotruss-lib.c b/sysdeps/or1k/sotruss-lib.c
> > new file mode 100644
> > index 0000000000..ee16f84456
> > --- /dev/null
> > +++ b/sysdeps/or1k/sotruss-lib.c
> > @@ -0,0 +1,51 @@
> > +/* Override generic sotruss-lib.c to define actual functions for OpenRISC.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#define HAVE_ARCH_PLTENTER
> > +#define HAVE_ARCH_PLTEXIT
> > +
> > +#include <elf/sotruss-lib.c>
> > +
> > +ElfW(Addr)
> > +la_or1k_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
> > +		       unsigned int ndx __attribute__ ((unused)),
> > +		       uintptr_t *refcook, uintptr_t *defcook,
> > +		       La_or1k_regs *regs, unsigned int *flags,
> > +		       const char *symname, long int *framesizep)
> > +{
> > +  print_enter (refcook, defcook, symname,
> > +	       regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
> > +	       *flags);
> > +
> > +  /* No need to copy anything, we will not need the parameters in any case.  */
> > +  *framesizep = 0;
> > +
> > +  return sym->st_value;
> > +}
> > +
> > +unsigned int
> > +la_or1k_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
> > +		      uintptr_t *defcook,
> > +		      const struct La_or1k_regs *inregs,
> > +		      struct La_or1k_retval *outregs,
> > +		      const char *symname)
> > +{
> > +  print_exit (refcook, defcook, symname, outregs->lrv_r3);
> > +
> > +  return 0;
> > +}
> > diff --git a/sysdeps/or1k/start.S b/sysdeps/or1k/start.S
> > new file mode 100644
> > index 0000000000..0424355f36
> > --- /dev/null
> > +++ b/sysdeps/or1k/start.S
> > @@ -0,0 +1,99 @@
> > +/* start, OpenRISC version.
> > +   Copyright (C) 2021 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, write to the Free
> > +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > +   02111-1307 USA.  */
> > +
> > +/* This is the canonical entry point, usually the first thing in the text
> > +   segment.
> > +
> > +   sp   The stack contains the arguments and environment:
> > +    0(sp)     argc
> > +    4(sp)     argv[0]
> > +    ...
> > +    (4*argc)(sp)    NULL
> > +    (4*(argc+1))(sp)  envp[0]
> > +    ...
> > +    NULL
> > + */
> > +
> > +#define __ASSEMBLY__
> > +#include <sysdep.h>
> > +#include <entry.h>
> > +
> > +ENTRY (ENTRY_POINT)
> > +
> > +	/* Setup Arguments to the __libc_start_main function.  */
> > +
> > +	/* Take values for argc and argv off the stack.
> > +	   These will be passed as arguments two and three to main
> > +	   and thus go in registers r4 and r5, respectively.  */
> > +	l.lwz	r4, 0(r1)
> > +	l.addi	r5, r1, 4
> > +
> > +	/* Pass in rtld_fini from dl-start.S.  */
> > +	l.or	r8, r3, r3
> > +
> > +#ifdef PIC
> > +	/* Obtain a pointer to .got in r16 */
> > +	l.jal	0x8
> > +	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
> > +	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
> > +	l.add	r16, r16, r9
> > +
> > +	/* Pass in the the main symbol.  */
> > +	l.lwz	r3, got(main)(r16)
> > +#else
> > +	/* Pass in the the main symbol.  */
> > +	l.movhi r3, hi(main)
> > +	l.ori	r3, r3, lo(main)
> > +#endif
> > +	/* Used to be init and fini.  */
> > +	l.movhi	r6, 0x0
> > +	l.movhi	r7, 0x0
> > +
> > +	/* Push stack limit onto the stack.
> > +	   This provides the highest stack address to user code (as stack grows
> > +	   downwards.
> > +	   This is the seventh argument to __libc_start_main and thus needs to
> > +	   be passed on the stack.  */
> > +	l.sw	-4(r1), r1
> > +
> > +	/* Adjust stack to account for a total of 7 args (i.e. the last one is
> > +	   on the stack.  */
> > +	l.addi	r1, r1, -4
> > +
> > +	/* Clear the frame pointer and link register since this is the
> > +	   outermost frame.  */
> > +	l.movhi	r2, 0x0
> > +	l.movhi	r9, 0x0
> > +
> > +	/* Let the libc call main and exit with its return code.  */
> > +#ifdef PIC
> > +	l.j	plt(__libc_start_main)
> > +#else
> > +	l.j	__libc_start_main
> > +#endif
> > +	 l.nop
> > +END (ENTRY_POINT)
> > +
> > +	/* Define a symbol for the first piece of initialized data.  */
> > +	.data
> > +	.globl __data_start
> > +__data_start:
> > +	.long 0
> > +	.weak data_start
> > +	data_start = __data_start
> > diff --git a/sysdeps/or1k/tst-audit.h b/sysdeps/or1k/tst-audit.h
> > new file mode 100644
> > index 0000000000..79ee1b7b02
> > --- /dev/null
> > +++ b/sysdeps/or1k/tst-audit.h
> > @@ -0,0 +1,24 @@
> > +/* Definitions for testing PLT entry/exit auditing.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#define pltenter la_or1k_gnu_pltenter
> > +#define pltexit la_or1k_gnu_pltexit
> > +#define La_regs La_or1k_regs
> > +#define La_retval La_or1k_retval
> > +#define int_retval lrv_r3
> 
> [1] https://sourceware.org/pipermail/libc-alpha/2021-December/134176.html

Ill try to change it and test.

Thanks for the comments.

-Stafford

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 08/13] or1k: Linux Syscall Interface
  2021-12-17 17:41       ` Adhemerval Zanella
@ 2021-12-20 11:53         ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-20 11:53 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Fri, Dec 17, 2021 at 02:41:20PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 17/12/2021 12:01, Stafford Horne wrote:
> > On Thu, Dec 16, 2021 at 06:17:45PM -0300, Adhemerval Zanella wrote:
> >>> diff --git a/sysdeps/unix/sysv/linux/or1k/bits/timesize.h b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
> >>> new file mode 100644
> >>> index 0000000000..3ab388da7f
> >>> --- /dev/null
> >>> +++ b/sysdeps/unix/sysv/linux/or1k/bits/timesize.h
> >>> @@ -0,0 +1,19 @@
> >>> +/* Bit size of the time_t type at glibc build time, OpenRISC version.
> >>> +   Copyright (C) 2021 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
> >>> +   <https://www.gnu.org/licenses/>.  */
> >>> +
> >>> +#define __TIMESIZE	64
> >>
> >> Ok, although I think we should flip the default to 64 bits make
> >> old ports to override to 32.
> > 
> > It makes sense.  It might be a bit tricky as currently __TIMESIZE default is
> > __WORDSIZE.  I see a few old ports which have __WORDSIZE 32 and 64 like sparc.
> 
> I will fix this upstream, it is just a matter to override to 32 for older ports.
> 
> >>
> >> Ok, I take that implementing it solely on __or1k_clone is more complex than
> >> using a C wrapper.
> > 
> > I am not to clear what you mean here, I take you are asking why we keep
> > __or1k_clone in assembly rather than implement __or1k_clone in C too.
> > 
> > There are some stack setup bits in __or1k_clone which require assembly.
> > 
> 
> I meant otherwise in fact, why not implement clone for or1k purely in assembly.

I see, it could be done but I think it's easier to maintain with the va_arg
parsing and generic set_errno handling being in C.

-Staffford

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 04/13] or1k: startup and dynamic linking code
  2021-12-17 23:03     ` Stafford Horne
@ 2021-12-20 19:45       ` Adhemerval Zanella
  2021-12-20 21:40         ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-20 19:45 UTC (permalink / raw)
  To: Stafford Horne; +Cc: libc-alpha, Openrisc



On 17/12/2021 20:03, Stafford Horne wrote:
> On Thu, Dec 16, 2021 at 07:42:46AM -0300, Adhemerval Zanella wrote:
>>
>>
>> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
>>> Code for C runtime startup and dynamic loading including PLT layout.
>>
>> Patch looks ok, although I comment much on ABI and assembly code. Some
>> comments below.
>>
>>> ---
>>>  sysdeps/or1k/bits/link.h   |  51 ++++++
>>>  sysdeps/or1k/dl-machine.h  | 323 +++++++++++++++++++++++++++++++++++++
>>>  sysdeps/or1k/dl-start.S    |  98 +++++++++++
>>>  sysdeps/or1k/ldsodefs.h    |  40 +++++
>>>  sysdeps/or1k/sotruss-lib.c |  51 ++++++
>>>  sysdeps/or1k/start.S       |  99 ++++++++++++
>>>  sysdeps/or1k/tst-audit.h   |  24 +++
>>>  7 files changed, 686 insertions(+)
>>>  create mode 100644 sysdeps/or1k/bits/link.h
>>>  create mode 100644 sysdeps/or1k/dl-machine.h
>>>  create mode 100644 sysdeps/or1k/dl-start.S
>>>  create mode 100644 sysdeps/or1k/ldsodefs.h
>>>  create mode 100644 sysdeps/or1k/sotruss-lib.c
>>>  create mode 100644 sysdeps/or1k/start.S
>>>  create mode 100644 sysdeps/or1k/tst-audit.h
>>>
>>> diff --git a/sysdeps/or1k/bits/link.h b/sysdeps/or1k/bits/link.h
>>> new file mode 100644
>>> index 0000000000..ad183c9625
>>> --- /dev/null
>>> +++ b/sysdeps/or1k/bits/link.h
>>> @@ -0,0 +1,51 @@
>>> +/* Declarations for dynamic linker interface. OpenRISC version.
>>> +   Copyright (C) 2021 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
>>> +   <https://www.gnu.org/licenses/>.  */
>>> +
>>> +#ifndef _LINK_H
>>> +# error "Never include <bits/link.h> directly; use <link.h> instead."
>>> +#endif
>>> +
>>> +/* Registers for entry into PLT.  */
>>> +typedef struct La_or1k_regs
>>> +{
>>> +  uint32_t lr_reg[31];
>>> +} La_or1k_regs;
>>> +
>>
>> So is the intent is to provide caller all the register, no only the caller-saved 
>> registers?
> 
> As I see it...
> 
> Shouldn't these usually be the argument registers used in la_pltenter to print
> our the function call? i.e.
> 
>   print_enter (refcook, defcook, symname,
>                regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
>                *flags);
> 
> These registers get setup in sysdeps/{arch}/dl-trampoline.S by
> _dl_runtime_profile, which then pass them to _dl_profile_fixup.
> 
> The problem is openrisc doesn't implement _dl_runtime_profile so we haven't
> defined what the registers are.
> 
> I noticed the same for arc, csky, riscv.
> 
> These are needed to be defined for sotruss, but I dont seem them being used.
> 
> Is that correct?

The register are really dependend of the function calling ABI of the architecture,
if you check other architecture like x86 and powerpc you will see that La_i86_regs
and La_ppc64_regs only saves the caller-saved ones.  It is mainly because for
PLT tracking, as done by audit modules, other register are not really useful 
(since they are just internal ones to the caller function).

> 
>>> +/* Return values for calls from PLT.  */
>>> +typedef struct La_or1k_retval
>>> +{
>>> +  uint32_t lrv_r3;
>>> +} La_or1k_retval;
>>> +
>>> +__BEGIN_DECLS
>>> +
>>> +extern ElfW(Addr) la_or1k_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
>>> +					uintptr_t *__refcook,
>>> +					uintptr_t *__defcook,
>>> +					La_or1k_regs *__regs,
>>> +					unsigned int *__flags,
>>> +					const char *__symname,
>>> +					long int *__framesizep);
>>> +extern unsigned int la_or1k_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
>>> +					 uintptr_t *__refcook,
>>> +					 uintptr_t *__defcook,
>>> +					 const La_or1k_regs *__inregs,
>>> +					 La_or1k_retval *__outregs,
>>> +					 const char *__symname);
>>> +
>>> +__END_DECLS
>>> diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h
>>> new file mode 100644
>>> index 0000000000..d41554769e
>>> --- /dev/null
>>> +++ b/sysdeps/or1k/dl-machine.h
>>> @@ -0,0 +1,323 @@
>>> +/* Machine-dependent ELF dynamic relocation inline functions.  OpenRISC version.
>>> +   Copyright (C) 2021 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
>>> +   <https://www.gnu.org/licenses/>.  */
>>> +
>>> +#ifndef dl_machine_h
>>> +#define dl_machine_h
>>> +
>>> +#define ELF_MACHINE_NAME "or1k"
>>> +
>>> +#include <sys/cdefs.h>
>>> +#include <sys/param.h>
>>> +#include <tls.h>
>>> +#include <dl-irel.h>
>>> +#include <dl-static-tls.h>
>>> +#include <dl-machine-rel.h>
>>> +
>>> +/* Return nonzero iff ELF header is compatible with the running host.  */
>>> +static inline int __attribute__ ((unused))
>>> +elf_machine_matches_host (const Elf32_Ehdr *ehdr)
>>> +{
>>> +  return ehdr->e_machine == EM_OPENRISC;
>>> +}
>>> +
>>> +static inline Elf32_Addr *
>>> +or1k_get_got (void)
>>> +{
>>> +  Elf32_Addr *got;
>>> +  register long int linkreg asm ("r9");
>>
>> Is the 'r9' a required register by the ABI to use on this assembly snippet?
>> I am asking because local name 'registers' are only a hint to gcc, as we
>> found recently [1], if you really need 'r9' you will probably need to use 
>> a global name resgister.
> 
> The r9 is to avoid the snippet from clobbering r9.  The result of l.jal will
> update r9 (link register) we want to make sure that is what we used for %1.
> 
> I think there were issues with other ways I tried.

Should you add it the clobbered list instead?

> 
> Let me look into it more.
> 
>>> +  asm ("l.jal    0x8\n"
>>> +       " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
>>> +       "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
>>> +       "l.add    %0, %0, %1\n"
>>> +       : "=r" (got), "=r" (linkreg));

With something like (unstested):


  static inline Elf32_Addr *
  or1k_get_got (void)
  {
    Elf32_Addr *got;
    asm ("l.jal    0x8\n"
         " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
         "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
         "l.add    %0, %0, %1\n"
         : "=r" (got)
         :
         : "r9");
  }

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 04/13] or1k: startup and dynamic linking code
  2021-12-20 19:45       ` Adhemerval Zanella
@ 2021-12-20 21:40         ` Stafford Horne
  2021-12-21 11:09           ` Adhemerval Zanella
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-20 21:40 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Openrisc

On Mon, Dec 20, 2021 at 04:45:21PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 17/12/2021 20:03, Stafford Horne wrote:
> > On Thu, Dec 16, 2021 at 07:42:46AM -0300, Adhemerval Zanella wrote:
> >>
> >>
> >> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> >>> Code for C runtime startup and dynamic loading including PLT layout.
> >>
> >> Patch looks ok, although I comment much on ABI and assembly code. Some
> >> comments below.
> >>
> >>> ---
> >>>  sysdeps/or1k/bits/link.h   |  51 ++++++
> >>>  sysdeps/or1k/dl-machine.h  | 323 +++++++++++++++++++++++++++++++++++++
> >>>  sysdeps/or1k/dl-start.S    |  98 +++++++++++
> >>>  sysdeps/or1k/ldsodefs.h    |  40 +++++
> >>>  sysdeps/or1k/sotruss-lib.c |  51 ++++++
> >>>  sysdeps/or1k/start.S       |  99 ++++++++++++
> >>>  sysdeps/or1k/tst-audit.h   |  24 +++
> >>>  7 files changed, 686 insertions(+)
> >>>  create mode 100644 sysdeps/or1k/bits/link.h
> >>>  create mode 100644 sysdeps/or1k/dl-machine.h
> >>>  create mode 100644 sysdeps/or1k/dl-start.S
> >>>  create mode 100644 sysdeps/or1k/ldsodefs.h
> >>>  create mode 100644 sysdeps/or1k/sotruss-lib.c
> >>>  create mode 100644 sysdeps/or1k/start.S
> >>>  create mode 100644 sysdeps/or1k/tst-audit.h
> >>>
> >>> diff --git a/sysdeps/or1k/bits/link.h b/sysdeps/or1k/bits/link.h
> >>> new file mode 100644
> >>> index 0000000000..ad183c9625
> >>> --- /dev/null
> >>> +++ b/sysdeps/or1k/bits/link.h
> >>> @@ -0,0 +1,51 @@
> >>> +/* Declarations for dynamic linker interface. OpenRISC version.
> >>> +   Copyright (C) 2021 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
> >>> +   <https://www.gnu.org/licenses/>.  */
> >>> +
> >>> +#ifndef _LINK_H
> >>> +# error "Never include <bits/link.h> directly; use <link.h> instead."
> >>> +#endif
> >>> +
> >>> +/* Registers for entry into PLT.  */
> >>> +typedef struct La_or1k_regs
> >>> +{
> >>> +  uint32_t lr_reg[31];
> >>> +} La_or1k_regs;
> >>> +
> >>
> >> So is the intent is to provide caller all the register, no only the caller-saved 
> >> registers?
> > 
> > As I see it...
> > 
> > Shouldn't these usually be the argument registers used in la_pltenter to print
> > our the function call? i.e.
> > 
> >   print_enter (refcook, defcook, symname,
> >                regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
> >                *flags);
> > 
> > These registers get setup in sysdeps/{arch}/dl-trampoline.S by
> > _dl_runtime_profile, which then pass them to _dl_profile_fixup.
> > 
> > The problem is openrisc doesn't implement _dl_runtime_profile so we haven't
> > defined what the registers are.
> > 
> > I noticed the same for arc, csky, riscv.
> > 
> > These are needed to be defined for sotruss, but I dont seem them being used.
> > 
> > Is that correct?
> 
> The register are really dependend of the function calling ABI of the architecture,
> if you check other architecture like x86 and powerpc you will see that La_i86_regs
> and La_ppc64_regs only saves the caller-saved ones.  It is mainly because for
> PLT tracking, as done by audit modules, other register are not really useful 
> (since they are just internal ones to the caller function).

I see, but isn't this register saving done in _dl_profile_resolve?

OpenRISC doesn't define _dl_profile_resolve.

I can change the definition  of La_or1k_regs, but as I see it it is currently
not used other than building sotruss-lib and audit modules.  But I don't see
how pltenter will be called without implementing _dl_profile_resolve.

> > 
> >>> +/* Return values for calls from PLT.  */
> >>> +typedef struct La_or1k_retval
> >>> +{
> >>> +  uint32_t lrv_r3;
> >>> +} La_or1k_retval;
> >>> +
> >>> +__BEGIN_DECLS
> >>> +
> >>> +extern ElfW(Addr) la_or1k_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
> >>> +					uintptr_t *__refcook,
> >>> +					uintptr_t *__defcook,
> >>> +					La_or1k_regs *__regs,
> >>> +					unsigned int *__flags,
> >>> +					const char *__symname,
> >>> +					long int *__framesizep);
> >>> +extern unsigned int la_or1k_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
> >>> +					 uintptr_t *__refcook,
> >>> +					 uintptr_t *__defcook,
> >>> +					 const La_or1k_regs *__inregs,
> >>> +					 La_or1k_retval *__outregs,
> >>> +					 const char *__symname);
> >>> +
> >>> +__END_DECLS
> >>> diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h
> >>> new file mode 100644
> >>> index 0000000000..d41554769e
> >>> --- /dev/null
> >>> +++ b/sysdeps/or1k/dl-machine.h
> >>> @@ -0,0 +1,323 @@
> >>> +/* Machine-dependent ELF dynamic relocation inline functions.  OpenRISC version.
> >>> +   Copyright (C) 2021 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
> >>> +   <https://www.gnu.org/licenses/>.  */
> >>> +
> >>> +#ifndef dl_machine_h
> >>> +#define dl_machine_h
> >>> +
> >>> +#define ELF_MACHINE_NAME "or1k"
> >>> +
> >>> +#include <sys/cdefs.h>
> >>> +#include <sys/param.h>
> >>> +#include <tls.h>
> >>> +#include <dl-irel.h>
> >>> +#include <dl-static-tls.h>
> >>> +#include <dl-machine-rel.h>
> >>> +
> >>> +/* Return nonzero iff ELF header is compatible with the running host.  */
> >>> +static inline int __attribute__ ((unused))
> >>> +elf_machine_matches_host (const Elf32_Ehdr *ehdr)
> >>> +{
> >>> +  return ehdr->e_machine == EM_OPENRISC;
> >>> +}
> >>> +
> >>> +static inline Elf32_Addr *
> >>> +or1k_get_got (void)
> >>> +{
> >>> +  Elf32_Addr *got;
> >>> +  register long int linkreg asm ("r9");
> >>
> >> Is the 'r9' a required register by the ABI to use on this assembly snippet?
> >> I am asking because local name 'registers' are only a hint to gcc, as we
> >> found recently [1], if you really need 'r9' you will probably need to use 
> >> a global name resgister.
> > 
> > The r9 is to avoid the snippet from clobbering r9.  The result of l.jal will
> > update r9 (link register) we want to make sure that is what we used for %1.
> > 
> > I think there were issues with other ways I tried.
> 
> Should you add it the clobbered list instead?
> 
> > 
> > Let me look into it more.
> > 
> >>> +  asm ("l.jal    0x8\n"
> >>> +       " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
> >>> +       "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
> >>> +       "l.add    %0, %0, %1\n"
> >>> +       : "=r" (got), "=r" (linkreg));
> 
> With something like (unstested):
> 
> 
>   static inline Elf32_Addr *
>   or1k_get_got (void)
>   {
>     Elf32_Addr *got;
>     asm ("l.jal    0x8\n"
>          " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
>          "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
>          "l.add    %0, %0, %1\n"
>          : "=r" (got)
>          :
>          : "r9");
>   }

Yes, this is what I ended up changing it to.

Is the indentation important here? I had it as:

    static inline Elf32_Addr *
    or1k_get_got (void)
    {
      Elf32_Addr *got;

      asm ("l.jal    0x8\n"
	   " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
	   "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
	   "l.add    %0, %0, r9\n"
	   : "=r" (got) : : "r9");

      return got;
    }

-Stafford

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 04/13] or1k: startup and dynamic linking code
  2021-12-20 21:40         ` Stafford Horne
@ 2021-12-21 11:09           ` Adhemerval Zanella
  2021-12-21 11:46             ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-21 11:09 UTC (permalink / raw)
  To: Stafford Horne; +Cc: libc-alpha, Openrisc



On 20/12/2021 18:40, Stafford Horne wrote:
> On Mon, Dec 20, 2021 at 04:45:21PM -0300, Adhemerval Zanella wrote:
>>
>>
>> On 17/12/2021 20:03, Stafford Horne wrote:
>>> On Thu, Dec 16, 2021 at 07:42:46AM -0300, Adhemerval Zanella wrote:
>>>>
>>>>
>>>> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
>>>>> Code for C runtime startup and dynamic loading including PLT layout.
>>>>
>>>> Patch looks ok, although I comment much on ABI and assembly code. Some
>>>> comments below.
>>>>
>>>>> ---
>>>>>  sysdeps/or1k/bits/link.h   |  51 ++++++
>>>>>  sysdeps/or1k/dl-machine.h  | 323 +++++++++++++++++++++++++++++++++++++
>>>>>  sysdeps/or1k/dl-start.S    |  98 +++++++++++
>>>>>  sysdeps/or1k/ldsodefs.h    |  40 +++++
>>>>>  sysdeps/or1k/sotruss-lib.c |  51 ++++++
>>>>>  sysdeps/or1k/start.S       |  99 ++++++++++++
>>>>>  sysdeps/or1k/tst-audit.h   |  24 +++
>>>>>  7 files changed, 686 insertions(+)
>>>>>  create mode 100644 sysdeps/or1k/bits/link.h
>>>>>  create mode 100644 sysdeps/or1k/dl-machine.h
>>>>>  create mode 100644 sysdeps/or1k/dl-start.S
>>>>>  create mode 100644 sysdeps/or1k/ldsodefs.h
>>>>>  create mode 100644 sysdeps/or1k/sotruss-lib.c
>>>>>  create mode 100644 sysdeps/or1k/start.S
>>>>>  create mode 100644 sysdeps/or1k/tst-audit.h
>>>>>
>>>>> diff --git a/sysdeps/or1k/bits/link.h b/sysdeps/or1k/bits/link.h
>>>>> new file mode 100644
>>>>> index 0000000000..ad183c9625
>>>>> --- /dev/null
>>>>> +++ b/sysdeps/or1k/bits/link.h
>>>>> @@ -0,0 +1,51 @@
>>>>> +/* Declarations for dynamic linker interface. OpenRISC version.
>>>>> +   Copyright (C) 2021 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
>>>>> +   <https://www.gnu.org/licenses/>.  */
>>>>> +
>>>>> +#ifndef _LINK_H
>>>>> +# error "Never include <bits/link.h> directly; use <link.h> instead."
>>>>> +#endif
>>>>> +
>>>>> +/* Registers for entry into PLT.  */
>>>>> +typedef struct La_or1k_regs
>>>>> +{
>>>>> +  uint32_t lr_reg[31];
>>>>> +} La_or1k_regs;
>>>>> +
>>>>
>>>> So is the intent is to provide caller all the register, no only the caller-saved 
>>>> registers?
>>>
>>> As I see it...
>>>
>>> Shouldn't these usually be the argument registers used in la_pltenter to print
>>> our the function call? i.e.
>>>
>>>   print_enter (refcook, defcook, symname,
>>>                regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
>>>                *flags);
>>>
>>> These registers get setup in sysdeps/{arch}/dl-trampoline.S by
>>> _dl_runtime_profile, which then pass them to _dl_profile_fixup.
>>>
>>> The problem is openrisc doesn't implement _dl_runtime_profile so we haven't
>>> defined what the registers are.
>>>
>>> I noticed the same for arc, csky, riscv.
>>>
>>> These are needed to be defined for sotruss, but I dont seem them being used.
>>>
>>> Is that correct?
>>
>> The register are really dependend of the function calling ABI of the architecture,
>> if you check other architecture like x86 and powerpc you will see that La_i86_regs
>> and La_ppc64_regs only saves the caller-saved ones.  It is mainly because for
>> PLT tracking, as done by audit modules, other register are not really useful 
>> (since they are just internal ones to the caller function).
> 
> I see, but isn't this register saving done in _dl_profile_resolve?
> 
> OpenRISC doesn't define _dl_profile_resolve.
> 
> I can change the definition  of La_or1k_regs, but as I see it it is currently
> not used other than building sotruss-lib and audit modules.  But I don't see
> how pltenter will be called without implementing _dl_profile_resolve.

The issue is the definition you set now will define the current audit ABI
(LAV_CURRENT), which means if you eventually implement _dl_profile_resolve
support for or1k you will need to either save/restore all registers or
zero the non calles-saved ones.  

That's why modeling the audit PLT register structure over the ABI calling
functions makes more sense.

> 
>>>
>>>>> +/* Return values for calls from PLT.  */
>>>>> +typedef struct La_or1k_retval
>>>>> +{
>>>>> +  uint32_t lrv_r3;
>>>>> +} La_or1k_retval;
>>>>> +
>>>>> +__BEGIN_DECLS
>>>>> +
>>>>> +extern ElfW(Addr) la_or1k_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
>>>>> +					uintptr_t *__refcook,
>>>>> +					uintptr_t *__defcook,
>>>>> +					La_or1k_regs *__regs,
>>>>> +					unsigned int *__flags,
>>>>> +					const char *__symname,
>>>>> +					long int *__framesizep);
>>>>> +extern unsigned int la_or1k_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
>>>>> +					 uintptr_t *__refcook,
>>>>> +					 uintptr_t *__defcook,
>>>>> +					 const La_or1k_regs *__inregs,
>>>>> +					 La_or1k_retval *__outregs,
>>>>> +					 const char *__symname);
>>>>> +
>>>>> +__END_DECLS
>>>>> diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h
>>>>> new file mode 100644
>>>>> index 0000000000..d41554769e
>>>>> --- /dev/null
>>>>> +++ b/sysdeps/or1k/dl-machine.h
>>>>> @@ -0,0 +1,323 @@
>>>>> +/* Machine-dependent ELF dynamic relocation inline functions.  OpenRISC version.
>>>>> +   Copyright (C) 2021 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
>>>>> +   <https://www.gnu.org/licenses/>.  */
>>>>> +
>>>>> +#ifndef dl_machine_h
>>>>> +#define dl_machine_h
>>>>> +
>>>>> +#define ELF_MACHINE_NAME "or1k"
>>>>> +
>>>>> +#include <sys/cdefs.h>
>>>>> +#include <sys/param.h>
>>>>> +#include <tls.h>
>>>>> +#include <dl-irel.h>
>>>>> +#include <dl-static-tls.h>
>>>>> +#include <dl-machine-rel.h>
>>>>> +
>>>>> +/* Return nonzero iff ELF header is compatible with the running host.  */
>>>>> +static inline int __attribute__ ((unused))
>>>>> +elf_machine_matches_host (const Elf32_Ehdr *ehdr)
>>>>> +{
>>>>> +  return ehdr->e_machine == EM_OPENRISC;
>>>>> +}
>>>>> +
>>>>> +static inline Elf32_Addr *
>>>>> +or1k_get_got (void)
>>>>> +{
>>>>> +  Elf32_Addr *got;
>>>>> +  register long int linkreg asm ("r9");
>>>>
>>>> Is the 'r9' a required register by the ABI to use on this assembly snippet?
>>>> I am asking because local name 'registers' are only a hint to gcc, as we
>>>> found recently [1], if you really need 'r9' you will probably need to use 
>>>> a global name resgister.
>>>
>>> The r9 is to avoid the snippet from clobbering r9.  The result of l.jal will
>>> update r9 (link register) we want to make sure that is what we used for %1.
>>>
>>> I think there were issues with other ways I tried.
>>
>> Should you add it the clobbered list instead?
>>
>>>
>>> Let me look into it more.
>>>
>>>>> +  asm ("l.jal    0x8\n"
>>>>> +       " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
>>>>> +       "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
>>>>> +       "l.add    %0, %0, %1\n"
>>>>> +       : "=r" (got), "=r" (linkreg));
>>
>> With something like (unstested):
>>
>>
>>   static inline Elf32_Addr *
>>   or1k_get_got (void)
>>   {
>>     Elf32_Addr *got;
>>     asm ("l.jal    0x8\n"
>>          " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
>>          "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
>>          "l.add    %0, %0, %1\n"
>>          : "=r" (got)
>>          :
>>          : "r9");
>>   }
> 
> Yes, this is what I ended up changing it to.
> 
> Is the indentation important here? I had it as:

I think either one is fine.

> 
>     static inline Elf32_Addr *
>     or1k_get_got (void)
>     {
>       Elf32_Addr *got;
> 
>       asm ("l.jal    0x8\n"
> 	   " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n"
> 	   "l.ori    %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n"
> 	   "l.add    %0, %0, r9\n"
> 	   : "=r" (got) : : "r9");
> 
>       return got;
>     }
> 
> -Stafford

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 04/13] or1k: startup and dynamic linking code
  2021-12-21 11:09           ` Adhemerval Zanella
@ 2021-12-21 11:46             ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-21 11:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Openrisc

On Tue, Dec 21, 2021 at 08:09:11AM -0300, Adhemerval Zanella wrote:
> 
> 
> On 20/12/2021 18:40, Stafford Horne wrote:
> > On Mon, Dec 20, 2021 at 04:45:21PM -0300, Adhemerval Zanella wrote:
> >>
> >>
> >> On 17/12/2021 20:03, Stafford Horne wrote:
> >>> On Thu, Dec 16, 2021 at 07:42:46AM -0300, Adhemerval Zanella wrote:
> >>>>
> >>>>
> >>>> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> >>>>> Code for C runtime startup and dynamic loading including PLT layout.
> >>>>
> >>>> Patch looks ok, although I comment much on ABI and assembly code. Some
> >>>> comments below.
> >>>>
> >>>>> ---
> >>>>>  sysdeps/or1k/bits/link.h   |  51 ++++++
> >>>>>  sysdeps/or1k/dl-machine.h  | 323 +++++++++++++++++++++++++++++++++++++
> >>>>>  sysdeps/or1k/dl-start.S    |  98 +++++++++++
> >>>>>  sysdeps/or1k/ldsodefs.h    |  40 +++++
> >>>>>  sysdeps/or1k/sotruss-lib.c |  51 ++++++
> >>>>>  sysdeps/or1k/start.S       |  99 ++++++++++++
> >>>>>  sysdeps/or1k/tst-audit.h   |  24 +++
> >>>>>  7 files changed, 686 insertions(+)
> >>>>>  create mode 100644 sysdeps/or1k/bits/link.h
> >>>>>  create mode 100644 sysdeps/or1k/dl-machine.h
> >>>>>  create mode 100644 sysdeps/or1k/dl-start.S
> >>>>>  create mode 100644 sysdeps/or1k/ldsodefs.h
> >>>>>  create mode 100644 sysdeps/or1k/sotruss-lib.c
> >>>>>  create mode 100644 sysdeps/or1k/start.S
> >>>>>  create mode 100644 sysdeps/or1k/tst-audit.h
> >>>>>
> >>>>> diff --git a/sysdeps/or1k/bits/link.h b/sysdeps/or1k/bits/link.h
> >>>>> new file mode 100644
> >>>>> index 0000000000..ad183c9625
> >>>>> --- /dev/null
> >>>>> +++ b/sysdeps/or1k/bits/link.h
> >>>>> @@ -0,0 +1,51 @@
> >>>>> +/* Declarations for dynamic linker interface. OpenRISC version.
> >>>>> +   Copyright (C) 2021 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
> >>>>> +   <https://www.gnu.org/licenses/>.  */
> >>>>> +
> >>>>> +#ifndef _LINK_H
> >>>>> +# error "Never include <bits/link.h> directly; use <link.h> instead."
> >>>>> +#endif
> >>>>> +
> >>>>> +/* Registers for entry into PLT.  */
> >>>>> +typedef struct La_or1k_regs
> >>>>> +{
> >>>>> +  uint32_t lr_reg[31];
> >>>>> +} La_or1k_regs;
> >>>>> +
> >>>>
> >>>> So is the intent is to provide caller all the register, no only the caller-saved 
> >>>> registers?
> >>>
> >>> As I see it...
> >>>
> >>> Shouldn't these usually be the argument registers used in la_pltenter to print
> >>> our the function call? i.e.
> >>>
> >>>   print_enter (refcook, defcook, symname,
> >>>                regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
> >>>                *flags);
> >>>
> >>> These registers get setup in sysdeps/{arch}/dl-trampoline.S by
> >>> _dl_runtime_profile, which then pass them to _dl_profile_fixup.
> >>>
> >>> The problem is openrisc doesn't implement _dl_runtime_profile so we haven't
> >>> defined what the registers are.
> >>>
> >>> I noticed the same for arc, csky, riscv.
> >>>
> >>> These are needed to be defined for sotruss, but I dont seem them being used.
> >>>
> >>> Is that correct?
> >>
> >> The register are really dependend of the function calling ABI of the architecture,
> >> if you check other architecture like x86 and powerpc you will see that La_i86_regs
> >> and La_ppc64_regs only saves the caller-saved ones.  It is mainly because for
> >> PLT tracking, as done by audit modules, other register are not really useful 
> >> (since they are just internal ones to the caller function).
> > 
> > I see, but isn't this register saving done in _dl_profile_resolve?
> > 
> > OpenRISC doesn't define _dl_profile_resolve.
> > 
> > I can change the definition  of La_or1k_regs, but as I see it it is currently
> > not used other than building sotruss-lib and audit modules.  But I don't see
> > how pltenter will be called without implementing _dl_profile_resolve.
> 
> The issue is the definition you set now will define the current audit ABI
> (LAV_CURRENT), which means if you eventually implement _dl_profile_resolve
> support for or1k you will need to either save/restore all registers or
> zero the non calles-saved ones.  
> 
> That's why modeling the audit PLT register structure over the ABI calling
> functions makes more sense.

Understood, that makes it clear.  I will make updates.

-Stafford


^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 09/13] or1k: Linux ABI
  2021-12-10 23:34 ` [PATCH v3 09/13] or1k: Linux ABI Stafford Horne
@ 2021-12-21 13:41   ` Adhemerval Zanella
  2021-12-21 14:54     ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-21 13:41 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc

Some comments below.

On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> ---
>  sysdeps/or1k/nptl/bits/pthreadtypes-arch.h    |  48 ++++++++
>  sysdeps/or1k/nptl/pthreaddef.h                |  36 ++++++
>  sysdeps/unix/sysv/linux/or1k/bits/procfs.h    |  38 ++++++
>  sysdeps/unix/sysv/linux/or1k/getcontext.S     |  72 +++++++++++
>  sysdeps/unix/sysv/linux/or1k/makecontext.c    |  77 ++++++++++++
>  sysdeps/unix/sysv/linux/or1k/setcontext.S     | 108 ++++++++++++++++
>  sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h |  28 +++++
>  sysdeps/unix/sysv/linux/or1k/swapcontext.S    | 116 ++++++++++++++++++
>  sysdeps/unix/sysv/linux/or1k/sys/ucontext.h   |  53 ++++++++
>  sysdeps/unix/sysv/linux/or1k/sys/user.h       |   1 +
>  sysdeps/unix/sysv/linux/or1k/ucontext_i.sym   |  26 ++++
>  11 files changed, 603 insertions(+)
>  create mode 100644 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
>  create mode 100644 sysdeps/or1k/nptl/pthreaddef.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/procfs.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/getcontext.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/makecontext.c
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/setcontext.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/swapcontext.S
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/user.h
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> 
> diff --git a/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> new file mode 100644
> index 0000000000..56a62a7161
> --- /dev/null
> +++ b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> @@ -0,0 +1,48 @@
> +/* Machine-specific pthread type layouts.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _BITS_PTHREADTYPES_H
> +#define _BITS_PTHREADTYPES_H	1
> +
> +#include <bits/wordsize.h>
> +
> +/* Opaque union sizes for:
> +     pthread_attr_t - internally pthread_attr
> +     pthread_mutex_t - internally __pthread_mutex_s
> +     pthread_mutexattr_t - internally pthread_mutexattr
> +     pthread_cond_t - internally __pthread_cond_s
> +     pthread_condattr_t - internally pthread_condattr
> +     pthread_rwlock_t - internally __pthread_rwlock_arch_t
> +     pthread_rwlockattr_t - internally pthread_rwlockattr
> +     pthread_barrier_t - internally pthread_barrier
> +     pthread_barrierattr_t - internally pthread_barrierattr  */
> +
> +#define __SIZEOF_PTHREAD_ATTR_T 32
> +#define __SIZEOF_PTHREAD_MUTEX_T 32
> +#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
> +#define __SIZEOF_PTHREAD_COND_T 48
> +#define __SIZEOF_PTHREAD_CONDATTR_T 4
> +#define __SIZEOF_PTHREAD_RWLOCK_T 44
> +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
> +#define __SIZEOF_PTHREAD_BARRIER_T 20
> +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
> +
> +#define __LOCK_ALIGNMENT
> +#define __ONCE_ALIGNMENT
> +
> +#endif	/* bits/pthreadtypes.h */

Why can't use the default values on sysdeps/nptl/bits/pthreadtypes-arch.h ?

> diff --git a/sysdeps/or1k/nptl/pthreaddef.h b/sysdeps/or1k/nptl/pthreaddef.h
> new file mode 100644
> index 0000000000..d17918ea11
> --- /dev/null
> +++ b/sysdeps/or1k/nptl/pthreaddef.h
> @@ -0,0 +1,36 @@
> +/* pthread machine parameter definitions.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +/* Default stack size.  */
> +#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
> +
> +/* Minimum guard size.  */
> +#define ARCH_MIN_GUARD_SIZE 0
> +
> +/* Required stack pointer alignment at beginning.  */
> +#define STACK_ALIGN 16
> +
> +/* Minimal stack size after allocating thread descriptor and guard size.  */
> +#define MINIMAL_REST_STACK 2048
> +
> +/* Alignment requirement for TCB.  Needs to be >= to STACK_ALIGN.  */
> +#define TCB_ALIGNMENT 32
> +
> +/* Location of current stack frame.  */
> +#define CURRENT_STACK_FRAME __builtin_frame_address (0)

Ok.  As a side note, maybe we could provide a default header with this exact
definitions. 

> diff --git a/sysdeps/unix/sysv/linux/or1k/bits/procfs.h b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> new file mode 100644
> index 0000000000..b50c92efb1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> @@ -0,0 +1,38 @@
> +/* Types for registers for sys/procfs.h.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://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>
> +
> +#define ELF_NGREG __NGREG
> +
> +/* Type for a general-purpose register.  */
> +typedef unsigned long int elf_greg_t;
> +
> +/* And the array of general-purpose registers.  We could have used `struct
> +   user_regs' directly, but tradition says that the register set is an array,
> +   which does have some peculiar semantics, so leave it that way.
> +   GDB uses this for prtrace GETREGSET, on OpenRISC the regset contains 32
> +   gprs the PC and the SR, 34 longs.  */
> +typedef elf_greg_t elf_gregset_t[34];
> +
> +/* Register set for the floating-point registers.  */
> +typedef elf_greg_t elf_fpregset_t[32];

It indicates that that or1k would only support float32, is that correct?

> diff --git a/sysdeps/unix/sysv/linux/or1k/getcontext.S b/sysdeps/unix/sysv/linux/or1k/getcontext.S
> new file mode 100644
> index 0000000000..4c2e64db7a
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/getcontext.S
> @@ -0,0 +1,72 @@
> +/* Save current context.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +#include "ucontext_i.h"
> +
> +/* int getcontext (ucontext_t *ucp)
> +
> +   Returns 0 on success -1 and errno on failure.
> + */
> +	.text
> +ENTRY(__getcontext)
> +	/* Store r1, the stack pointer.  */
> +	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
> +	/* Store r2, the frame pointer.  */
> +	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
> +	/* Store r9, the link register.  */
> +	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
> +	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
> +	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
> +	/* Store r10, the TLS register.  */
> +	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
> +	/* Store r14-r30 even, callee saved registers.  */
> +	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
> +	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
> +	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
> +	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
> +	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
> +	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
> +	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
> +	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
> +	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
> +
> +	/* Get signal mask.  */
> +	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
> +	l.ori	r6, r0, _NSIG8
> +	l.addi	r5, r3, UCONTEXT_SIGMASK
> +	l.ori	r4, r0, 0
> +	l.ori	r3, r0, SIG_BLOCK
> +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> +	/* Do the syscall.  */
> +	l.sys	1
> +	 l.nop
> +
> +	/* if -4096 < ret < 0 holds, it's an error */
> +	l.sfgeui r11, 0xf001
> +	l.bf	1f
> +	 l.nop
> +
> +	l.jr	r9
> +	 l.ori r11, r0, 0
> +
> +1:	l.j	__syscall_error
> +	 l.ori	r3, r11, 0
> +
> +END(__getcontext)
> +weak_alias(__getcontext, getcontext)
> diff --git a/sysdeps/unix/sysv/linux/or1k/makecontext.c b/sysdeps/unix/sysv/linux/or1k/makecontext.c
> new file mode 100644
> index 0000000000..3dd4134a6b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/makecontext.c
> @@ -0,0 +1,77 @@
> +/* Create new context.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +#include <stdarg.h>
> +#include <stdint.h>
> +#include <ucontext.h>
> +
> +/* makecontext sets up a stack and the registers for the
> +   user context.  The stack looks like this:
> +
> +		+-----------------------+
> +		| padding as required   |
> +		+-----------------------+
> +    sp ->       | parameters 7 to n     |
> +		+-----------------------+
> +
> +   The registers are set up like this:
> +     r3-r8  : parameters 1 to 6
> +     r14    : uc_link
> +     r1     : stack pointer
> +     r2     : frame pointer, set to NULL
> +*/
> +void
> +__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
> +{
> +  extern void __startcontext (void);
> +  unsigned long int *sp;
> +  va_list ap;
> +  int i;
> +
> +  sp = (unsigned long int *)
> +    ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
> +
> +  /* Allocate stack arguments.  */
> +  sp -= argc < 6 ? 0 : argc - 6;
> +
> +  /* Keep the stack aligned.  */
> +  sp = (unsigned long int *) (((uintptr_t) sp) & -4L);

Is stack required to be 4 or 16 (STACK_ALIGN from pthreaddef.h)?

> +
> +  /* Keep uc_link in r14.  */
> +  ucp->uc_mcontext.__gprs[14] = (uintptr_t) ucp->uc_link;
> +  /* Return address points to function __startcontext.  */
> +  ucp->uc_mcontext.__gprs[9] = (uintptr_t) &__startcontext;
> +  /* Frame pointer is null.  */
> +  ucp->uc_mcontext.__gprs[2] = (uintptr_t) 0;
> +  /* Restart in user-space starting at 'func'.  */
> +  ucp->uc_mcontext.__gprs[11] = (uintptr_t) func;
> +  /* Set stack pointer.  */
> +  ucp->uc_mcontext.__gprs[1] = (uintptr_t) sp;
> +
> +  va_start (ap, argc);
> +  for (i = 0; i < argc; ++i)
> +    if (i < 6)
> +      ucp->uc_mcontext.__gprs[i + 3] = va_arg (ap, unsigned long int);
> +    else
> +      sp[i - 6] = va_arg (ap, unsigned long int);
> +
> +  va_end (ap);
> +}
> +
> +weak_alias (__makecontext, makecontext)
> diff --git a/sysdeps/unix/sysv/linux/or1k/setcontext.S b/sysdeps/unix/sysv/linux/or1k/setcontext.S
> new file mode 100644
> index 0000000000..b4808d5422
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/setcontext.S
> @@ -0,0 +1,108 @@
> +/* Set current context.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +#include "ucontext_i.h"
> +
> +/* int setcontext (const ucontext_t *ucp) */
> +	.text
> +ENTRY(__setcontext)
> +	l.ori	r30, r3, 0
> +
> +	/* Restore signal mask.  */
> +	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
> +	l.ori	r6, r0, _NSIG8
> +	l.ori	r5, r0, 0
> +	l.addi	r4, r3, UCONTEXT_SIGMASK
> +	l.ori	r3, r0, SIG_SETMASK
> +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> +	/* Do the syscall.  */
> +	l.sys 1
> +	 l.nop
> +
> +	/* if -4096 < ret < 0 holds, it's an error */
> +	l.sfgeui r11, 0xf001
> +	l.bf	1f
> +	 l.nop
> +
> +	/* Restore argument registers, for the makecontext case.  */
> +	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
> +	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
> +	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
> +	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
> +	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
> +	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
> +
> +	/* Restore registers stored in getcontext.  */
> +	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
> +	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
> +	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
> +	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
> +	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
> +	/* Restore r14-r30 even, callee saved registers.  */
> +	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
> +	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
> +	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
> +	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
> +	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
> +	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
> +	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
> +	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
> +	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
> +
> +	l.jr	r11
> +	 l.ori	r11, r0, 0
> +
> +1:	l.j	__syscall_error
> +	 l.ori	r3, r11, 0
> +
> +END (__setcontext)
> +weak_alias (__setcontext, setcontext)
> +
> +	/* We add a NOP here because when the unwinder is looking for the
> +	   enclosing function of the link register (r9) address FDE lookup will
> +	   use '$r9 - 1' finding setcontext which is wrong.  This is because in
> +	   makecontext we have set r9 to the start of &__startcontext.
> +
> +	   If this NOP did not exist the unwinder would repeatedly find
> +	   __setcontext's FDE in an infinite loop.  Modifiying/deleting the below
> +	   __startcontext's FDE has no help on this.  */
> +	l.nop
> +
> +ENTRY(__startcontext)
> +
> +	l.ori	r3, r14, 0
> +	l.sfeq	r3, r0
> +	/* If uc_link is not 0 resume there, otherwise exit.  */
> +	l.bnf	__setcontext
> +	 l.nop
> +
> +#ifdef SHARED
> +	/* Obtain a pointer to .got in r16 */
> +	l.jal	0x8
> +	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
> +	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
> +	l.add	r16, r16, r9
> +	l.lwz	r16, got(exit)(r16)
> +	l.jr	r16
> +#else
> +	l.j	exit
> +#endif
> +	 l.nop
> +
> +END(__startcontext)
> diff --git a/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> new file mode 100644
> index 0000000000..de94b59578
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> @@ -0,0 +1,28 @@
> +/* Profile counter helper to get PC from sigcontext.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SIGCONTEXTINFO_H
> +#define _SIGCONTEXTINFO_H
> +
> +static inline uintptr_t
> +sigcontext_get_pc (const ucontext_t *ctx)
> +{
> +  return ctx->uc_mcontext.__pc;
> +}
> +
> +#endif /* _SIGCONTEXTINFO_H */
> diff --git a/sysdeps/unix/sysv/linux/or1k/swapcontext.S b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
> new file mode 100644
> index 0000000000..2acdc6d9bd
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
> @@ -0,0 +1,116 @@
> +/* Swap two contexts.  OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sysdep.h>
> +#include "ucontext_i.h"
> +
> +/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
> +	.text
> +ENTRY(__swapcontext)
> +
> +	/* Same as getcontext.  */
> +	/* Store r1, the stack pointer.  */
> +	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
> +	/* Store r2, the frame pointer.  */
> +	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
> +	/* Store r9, the link register.  */
> +	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
> +	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
> +	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
> +	/* Store r10, the TLS register.  */
> +	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
> +	/* Store r14-r30 even, callee saved registers.  */
> +	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
> +	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
> +	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
> +	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
> +	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
> +	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
> +	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
> +	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
> +	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
> +
> +	/* Store ucp to non-argument syscall preserved register.  */
> +	l.ori	r30, r4, 0
> +
> +	/* Get signal mask.  */
> +	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
> +	l.ori	r6, r0, _NSIG8
> +	l.addi	r5, r3, UCONTEXT_SIGMASK
> +	l.ori	r4, r0, 0
> +	l.ori	r3, r0, SIG_BLOCK
> +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> +	/* Do the syscall.  */
> +	l.sys	1
> +	 l.nop
> +
> +	/* if -4096 < ret < 0 holds, it's an error */
> +	l.sfgeui r11, 0xf001
> +	l.bf	1f
> +	 l.nop
> +
> +	/* Same as setcontext.  */
> +
> +	/* Restore signal mask.  */
> +	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
> +	l.ori	r6, r0, _NSIG8
> +	l.ori	r5, r0, 0
> +	l.addi	r4, r30, UCONTEXT_SIGMASK
> +	l.ori	r3, r0, SIG_SETMASK
> +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> +	/* Do the syscall.  */
> +	l.sys 1
> +	 l.nop
> +
> +	/* if -4096 < ret < 0 holds, it's an error */
> +	l.sfgeui r11, 0xf001
> +	l.bf	1f
> +	 l.nop
> +
> +	/* Restore argument registers, for the makecontext case.  */
> +	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
> +	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
> +	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
> +	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
> +	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
> +	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
> +
> +	/* Restore registers stored in getcontext.  */
> +	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
> +	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
> +	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
> +	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
> +	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
> +	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
> +	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
> +	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
> +	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
> +	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
> +	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
> +	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
> +	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
> +	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
> +
> +	l.jr	r11
> +	 l.ori	r11, r0, 0
> +
> +1:	l.j	__syscall_error
> +	 l.ori	r3, r11, 0
> +
> +END (__swapcontext)
> +weak_alias (__swapcontext, swapcontext)
> diff --git a/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> new file mode 100644
> index 0000000000..c4aead8f93
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> @@ -0,0 +1,53 @@
> +/* ucontext_t definition, OpenRISC version.
> +   Copyright (C) 2021 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
> +   <https://www.gnu.org/licenses/>.  */
> +
> +/* System V/OpenRISC compliant context switching support.  */
> +
> +#ifndef _SYS_UCONTEXT_H
> +#define _SYS_UCONTEXT_H	1
> +
> +#include <features.h>
> +
> +#include <bits/types/sigset_t.h>
> +#include <bits/types/stack_t.h>
> +
> +/* Number of general registers.  */
> +#define __NGREG	32
> +#ifdef __USE_MISC
> +# define NGREG	__NGREG
> +#endif
> +
> +/* Context to describe whole processor state.  */
> +typedef struct
> +  {
> +    unsigned long int __gprs[__NGREG];
> +    unsigned long int __pc;
> +    unsigned long int __sr;
> +  } mcontext_t;
> +
> +/* Userlevel context.  */
> +typedef struct ucontext_t
> +  {
> +    unsigned long int __uc_flags;
> +    struct ucontext_t *uc_link;
> +    stack_t uc_stack;
> +    mcontext_t uc_mcontext;
> +    sigset_t uc_sigmask;
> +  } ucontext_t;
> +
> +#endif /* sys/ucontext.h */
> diff --git a/sysdeps/unix/sysv/linux/or1k/sys/user.h b/sysdeps/unix/sysv/linux/or1k/sys/user.h
> new file mode 100644
> index 0000000000..c871f1a03d
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/sys/user.h
> @@ -0,0 +1 @@
> +/* This file is not needed, but in practice gdb might try to include it.  */
> diff --git a/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> new file mode 100644
> index 0000000000..a8d4db080f
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> @@ -0,0 +1,26 @@
> +#include <inttypes.h>
> +#include <signal.h>
> +#include <stddef.h>
> +#include <sys/ucontext.h>
> +
> +-- Constants used by the rt_sigprocmask call.
> +
> +SIG_BLOCK
> +SIG_SETMASK
> +
> +_NSIG8				(_NSIG / 8)
> +
> +-- Offsets of the fields in the ucontext_t structure.
> +#define ucontext(member)	offsetof (ucontext_t, member)
> +#define stack(member)		ucontext (uc_stack.member)
> +
> +UCONTEXT_LINK			ucontext (uc_link)
> +UCONTEXT_STACK			ucontext (uc_stack)
> +UCONTEXT_MCONTEXT		ucontext (uc_mcontext)
> +UCONTEXT_SIGMASK		ucontext (uc_sigmask)
> +
> +STACK_SP			stack (ss_sp)
> +STACK_SIZE			stack (ss_size)
> +STACK_FLAGS			stack (ss_flags)
> +
> +UCONTEXT_SIZE			sizeof (ucontext_t)

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 09/13] or1k: Linux ABI
  2021-12-21 13:41   ` Adhemerval Zanella
@ 2021-12-21 14:54     ` Stafford Horne
  2021-12-22 10:54       ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-21 14:54 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Tue, Dec 21, 2021 at 10:41:17AM -0300, Adhemerval Zanella wrote:
> Some comments below.
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > ---
> >  sysdeps/or1k/nptl/bits/pthreadtypes-arch.h    |  48 ++++++++
> >  sysdeps/or1k/nptl/pthreaddef.h                |  36 ++++++
> >  sysdeps/unix/sysv/linux/or1k/bits/procfs.h    |  38 ++++++
> >  sysdeps/unix/sysv/linux/or1k/getcontext.S     |  72 +++++++++++
> >  sysdeps/unix/sysv/linux/or1k/makecontext.c    |  77 ++++++++++++
> >  sysdeps/unix/sysv/linux/or1k/setcontext.S     | 108 ++++++++++++++++
> >  sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h |  28 +++++
> >  sysdeps/unix/sysv/linux/or1k/swapcontext.S    | 116 ++++++++++++++++++
> >  sysdeps/unix/sysv/linux/or1k/sys/ucontext.h   |  53 ++++++++
> >  sysdeps/unix/sysv/linux/or1k/sys/user.h       |   1 +
> >  sysdeps/unix/sysv/linux/or1k/ucontext_i.sym   |  26 ++++
> >  11 files changed, 603 insertions(+)
> >  create mode 100644 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> >  create mode 100644 sysdeps/or1k/nptl/pthreaddef.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/getcontext.S
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/makecontext.c
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/setcontext.S
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/swapcontext.S
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/user.h
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> > 
> > diff --git a/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> > new file mode 100644
> > index 0000000000..56a62a7161
> > --- /dev/null
> > +++ b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> > @@ -0,0 +1,48 @@
> > +/* Machine-specific pthread type layouts.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef _BITS_PTHREADTYPES_H
> > +#define _BITS_PTHREADTYPES_H	1
> > +
> > +#include <bits/wordsize.h>
> > +
> > +/* Opaque union sizes for:
> > +     pthread_attr_t - internally pthread_attr
> > +     pthread_mutex_t - internally __pthread_mutex_s
> > +     pthread_mutexattr_t - internally pthread_mutexattr
> > +     pthread_cond_t - internally __pthread_cond_s
> > +     pthread_condattr_t - internally pthread_condattr
> > +     pthread_rwlock_t - internally __pthread_rwlock_arch_t
> > +     pthread_rwlockattr_t - internally pthread_rwlockattr
> > +     pthread_barrier_t - internally pthread_barrier
> > +     pthread_barrierattr_t - internally pthread_barrierattr  */
> > +
> > +#define __SIZEOF_PTHREAD_ATTR_T 32
> > +#define __SIZEOF_PTHREAD_MUTEX_T 32
> > +#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
> > +#define __SIZEOF_PTHREAD_COND_T 48
> > +#define __SIZEOF_PTHREAD_CONDATTR_T 4
> > +#define __SIZEOF_PTHREAD_RWLOCK_T 44
> > +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
> > +#define __SIZEOF_PTHREAD_BARRIER_T 20
> > +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
> > +
> > +#define __LOCK_ALIGNMENT
> > +#define __ONCE_ALIGNMENT
> > +
> > +#endif	/* bits/pthreadtypes.h */
> 
> Why can't use the default values on sysdeps/nptl/bits/pthreadtypes-arch.h ?

I think it can, let me test.

> > diff --git a/sysdeps/or1k/nptl/pthreaddef.h b/sysdeps/or1k/nptl/pthreaddef.h
> > new file mode 100644
> > index 0000000000..d17918ea11
> > --- /dev/null
> > +++ b/sysdeps/or1k/nptl/pthreaddef.h
> > @@ -0,0 +1,36 @@
> > +/* pthread machine parameter definitions.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +/* Default stack size.  */
> > +#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
> > +
> > +/* Minimum guard size.  */
> > +#define ARCH_MIN_GUARD_SIZE 0
> > +
> > +/* Required stack pointer alignment at beginning.  */
> > +#define STACK_ALIGN 16
> > +
> > +/* Minimal stack size after allocating thread descriptor and guard size.  */
> > +#define MINIMAL_REST_STACK 2048
> > +
> > +/* Alignment requirement for TCB.  Needs to be >= to STACK_ALIGN.  */
> > +#define TCB_ALIGNMENT 32
> > +
> > +/* Location of current stack frame.  */
> > +#define CURRENT_STACK_FRAME __builtin_frame_address (0)
> 
> Ok.  As a side note, maybe we could provide a default header with this exact
> definitions. 
> 
> > diff --git a/sysdeps/unix/sysv/linux/or1k/bits/procfs.h b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> > new file mode 100644
> > index 0000000000..b50c92efb1
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> > @@ -0,0 +1,38 @@
> > +/* Types for registers for sys/procfs.h.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://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>
> > +
> > +#define ELF_NGREG __NGREG
> > +
> > +/* Type for a general-purpose register.  */
> > +typedef unsigned long int elf_greg_t;
> > +
> > +/* And the array of general-purpose registers.  We could have used `struct
> > +   user_regs' directly, but tradition says that the register set is an array,
> > +   which does have some peculiar semantics, so leave it that way.
> > +   GDB uses this for prtrace GETREGSET, on OpenRISC the regset contains 32
> > +   gprs the PC and the SR, 34 longs.  */
> > +typedef elf_greg_t elf_gregset_t[34];
> > +
> > +/* Register set for the floating-point registers.  */
> > +typedef elf_greg_t elf_fpregset_t[32];
> 
> It indicates that that or1k would only support float32, is that correct?

OpenRISC support 64-bit double's by using register pairs. i.e. r16,r17 +
r18,r19.  The floating point and genral purpose registers actually are the
same 32 registers.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/getcontext.S b/sysdeps/unix/sysv/linux/or1k/getcontext.S
> > new file mode 100644
> > index 0000000000..4c2e64db7a
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/getcontext.S
> > @@ -0,0 +1,72 @@
> > +/* Save current context.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +#include "ucontext_i.h"
> > +
> > +/* int getcontext (ucontext_t *ucp)
> > +
> > +   Returns 0 on success -1 and errno on failure.
> > + */
> > +	.text
> > +ENTRY(__getcontext)
> > +	/* Store r1, the stack pointer.  */
> > +	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
> > +	/* Store r2, the frame pointer.  */
> > +	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
> > +	/* Store r9, the link register.  */
> > +	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
> > +	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
> > +	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
> > +	/* Store r10, the TLS register.  */
> > +	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
> > +	/* Store r14-r30 even, callee saved registers.  */
> > +	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
> > +	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
> > +	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
> > +	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
> > +	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
> > +	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
> > +	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
> > +	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
> > +	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
> > +
> > +	/* Get signal mask.  */
> > +	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
> > +	l.ori	r6, r0, _NSIG8
> > +	l.addi	r5, r3, UCONTEXT_SIGMASK
> > +	l.ori	r4, r0, 0
> > +	l.ori	r3, r0, SIG_BLOCK
> > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > +	/* Do the syscall.  */
> > +	l.sys	1
> > +	 l.nop
> > +
> > +	/* if -4096 < ret < 0 holds, it's an error */
> > +	l.sfgeui r11, 0xf001
> > +	l.bf	1f
> > +	 l.nop
> > +
> > +	l.jr	r9
> > +	 l.ori r11, r0, 0
> > +
> > +1:	l.j	__syscall_error
> > +	 l.ori	r3, r11, 0
> > +
> > +END(__getcontext)
> > +weak_alias(__getcontext, getcontext)
> > diff --git a/sysdeps/unix/sysv/linux/or1k/makecontext.c b/sysdeps/unix/sysv/linux/or1k/makecontext.c
> > new file mode 100644
> > index 0000000000..3dd4134a6b
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/makecontext.c
> > @@ -0,0 +1,77 @@
> > +/* Create new context.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +#include <stdarg.h>
> > +#include <stdint.h>
> > +#include <ucontext.h>
> > +
> > +/* makecontext sets up a stack and the registers for the
> > +   user context.  The stack looks like this:
> > +
> > +		+-----------------------+
> > +		| padding as required   |
> > +		+-----------------------+
> > +    sp ->       | parameters 7 to n     |
> > +		+-----------------------+
> > +
> > +   The registers are set up like this:
> > +     r3-r8  : parameters 1 to 6
> > +     r14    : uc_link
> > +     r1     : stack pointer
> > +     r2     : frame pointer, set to NULL
> > +*/
> > +void
> > +__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
> > +{
> > +  extern void __startcontext (void);
> > +  unsigned long int *sp;
> > +  va_list ap;
> > +  int i;
> > +
> > +  sp = (unsigned long int *)
> > +    ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
> > +
> > +  /* Allocate stack arguments.  */
> > +  sp -= argc < 6 ? 0 : argc - 6;
> > +
> > +  /* Keep the stack aligned.  */
> > +  sp = (unsigned long int *) (((uintptr_t) sp) & -4L);
> 
> Is stack required to be 4 or 16 (STACK_ALIGN from pthreaddef.h)?

Is STACK_ALIGN used for anything other than asserts now?

I cannot recall why the alignment was set to 16 bytes, it may be copy and paste
or it may be due to our cache lines being either 16bytes or 32bytes (usually
32).

Do you see any issue changing STACK_ALIGN to 4 bytes?

-Stafford

> > +
> > +  /* Keep uc_link in r14.  */
> > +  ucp->uc_mcontext.__gprs[14] = (uintptr_t) ucp->uc_link;
> > +  /* Return address points to function __startcontext.  */
> > +  ucp->uc_mcontext.__gprs[9] = (uintptr_t) &__startcontext;
> > +  /* Frame pointer is null.  */
> > +  ucp->uc_mcontext.__gprs[2] = (uintptr_t) 0;
> > +  /* Restart in user-space starting at 'func'.  */
> > +  ucp->uc_mcontext.__gprs[11] = (uintptr_t) func;
> > +  /* Set stack pointer.  */
> > +  ucp->uc_mcontext.__gprs[1] = (uintptr_t) sp;
> > +
> > +  va_start (ap, argc);
> > +  for (i = 0; i < argc; ++i)
> > +    if (i < 6)
> > +      ucp->uc_mcontext.__gprs[i + 3] = va_arg (ap, unsigned long int);
> > +    else
> > +      sp[i - 6] = va_arg (ap, unsigned long int);
> > +
> > +  va_end (ap);
> > +}
> > +
> > +weak_alias (__makecontext, makecontext)
> > diff --git a/sysdeps/unix/sysv/linux/or1k/setcontext.S b/sysdeps/unix/sysv/linux/or1k/setcontext.S
> > new file mode 100644
> > index 0000000000..b4808d5422
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/setcontext.S
> > @@ -0,0 +1,108 @@
> > +/* Set current context.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +#include "ucontext_i.h"
> > +
> > +/* int setcontext (const ucontext_t *ucp) */
> > +	.text
> > +ENTRY(__setcontext)
> > +	l.ori	r30, r3, 0
> > +
> > +	/* Restore signal mask.  */
> > +	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
> > +	l.ori	r6, r0, _NSIG8
> > +	l.ori	r5, r0, 0
> > +	l.addi	r4, r3, UCONTEXT_SIGMASK
> > +	l.ori	r3, r0, SIG_SETMASK
> > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > +	/* Do the syscall.  */
> > +	l.sys 1
> > +	 l.nop
> > +
> > +	/* if -4096 < ret < 0 holds, it's an error */
> > +	l.sfgeui r11, 0xf001
> > +	l.bf	1f
> > +	 l.nop
> > +
> > +	/* Restore argument registers, for the makecontext case.  */
> > +	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
> > +	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
> > +	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
> > +	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
> > +	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
> > +	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
> > +
> > +	/* Restore registers stored in getcontext.  */
> > +	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
> > +	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
> > +	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
> > +	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
> > +	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
> > +	/* Restore r14-r30 even, callee saved registers.  */
> > +	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
> > +	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
> > +	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
> > +	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
> > +	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
> > +	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
> > +	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
> > +	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
> > +	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
> > +
> > +	l.jr	r11
> > +	 l.ori	r11, r0, 0
> > +
> > +1:	l.j	__syscall_error
> > +	 l.ori	r3, r11, 0
> > +
> > +END (__setcontext)
> > +weak_alias (__setcontext, setcontext)
> > +
> > +	/* We add a NOP here because when the unwinder is looking for the
> > +	   enclosing function of the link register (r9) address FDE lookup will
> > +	   use '$r9 - 1' finding setcontext which is wrong.  This is because in
> > +	   makecontext we have set r9 to the start of &__startcontext.
> > +
> > +	   If this NOP did not exist the unwinder would repeatedly find
> > +	   __setcontext's FDE in an infinite loop.  Modifiying/deleting the below
> > +	   __startcontext's FDE has no help on this.  */
> > +	l.nop
> > +
> > +ENTRY(__startcontext)
> > +
> > +	l.ori	r3, r14, 0
> > +	l.sfeq	r3, r0
> > +	/* If uc_link is not 0 resume there, otherwise exit.  */
> > +	l.bnf	__setcontext
> > +	 l.nop
> > +
> > +#ifdef SHARED
> > +	/* Obtain a pointer to .got in r16 */
> > +	l.jal	0x8
> > +	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
> > +	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
> > +	l.add	r16, r16, r9
> > +	l.lwz	r16, got(exit)(r16)
> > +	l.jr	r16
> > +#else
> > +	l.j	exit
> > +#endif
> > +	 l.nop
> > +
> > +END(__startcontext)
> > diff --git a/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> > new file mode 100644
> > index 0000000000..de94b59578
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> > @@ -0,0 +1,28 @@
> > +/* Profile counter helper to get PC from sigcontext.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#ifndef _SIGCONTEXTINFO_H
> > +#define _SIGCONTEXTINFO_H
> > +
> > +static inline uintptr_t
> > +sigcontext_get_pc (const ucontext_t *ctx)
> > +{
> > +  return ctx->uc_mcontext.__pc;
> > +}
> > +
> > +#endif /* _SIGCONTEXTINFO_H */
> > diff --git a/sysdeps/unix/sysv/linux/or1k/swapcontext.S b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
> > new file mode 100644
> > index 0000000000..2acdc6d9bd
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
> > @@ -0,0 +1,116 @@
> > +/* Swap two contexts.  OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <sysdep.h>
> > +#include "ucontext_i.h"
> > +
> > +/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
> > +	.text
> > +ENTRY(__swapcontext)
> > +
> > +	/* Same as getcontext.  */
> > +	/* Store r1, the stack pointer.  */
> > +	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
> > +	/* Store r2, the frame pointer.  */
> > +	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
> > +	/* Store r9, the link register.  */
> > +	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
> > +	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
> > +	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
> > +	/* Store r10, the TLS register.  */
> > +	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
> > +	/* Store r14-r30 even, callee saved registers.  */
> > +	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
> > +	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
> > +	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
> > +	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
> > +	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
> > +	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
> > +	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
> > +	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
> > +	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
> > +
> > +	/* Store ucp to non-argument syscall preserved register.  */
> > +	l.ori	r30, r4, 0
> > +
> > +	/* Get signal mask.  */
> > +	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
> > +	l.ori	r6, r0, _NSIG8
> > +	l.addi	r5, r3, UCONTEXT_SIGMASK
> > +	l.ori	r4, r0, 0
> > +	l.ori	r3, r0, SIG_BLOCK
> > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > +	/* Do the syscall.  */
> > +	l.sys	1
> > +	 l.nop
> > +
> > +	/* if -4096 < ret < 0 holds, it's an error */
> > +	l.sfgeui r11, 0xf001
> > +	l.bf	1f
> > +	 l.nop
> > +
> > +	/* Same as setcontext.  */
> > +
> > +	/* Restore signal mask.  */
> > +	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
> > +	l.ori	r6, r0, _NSIG8
> > +	l.ori	r5, r0, 0
> > +	l.addi	r4, r30, UCONTEXT_SIGMASK
> > +	l.ori	r3, r0, SIG_SETMASK
> > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > +	/* Do the syscall.  */
> > +	l.sys 1
> > +	 l.nop
> > +
> > +	/* if -4096 < ret < 0 holds, it's an error */
> > +	l.sfgeui r11, 0xf001
> > +	l.bf	1f
> > +	 l.nop
> > +
> > +	/* Restore argument registers, for the makecontext case.  */
> > +	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
> > +	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
> > +	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
> > +	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
> > +	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
> > +	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
> > +
> > +	/* Restore registers stored in getcontext.  */
> > +	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
> > +	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
> > +	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
> > +	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
> > +	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
> > +	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
> > +	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
> > +	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
> > +	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
> > +	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
> > +	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
> > +	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
> > +	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
> > +	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
> > +
> > +	l.jr	r11
> > +	 l.ori	r11, r0, 0
> > +
> > +1:	l.j	__syscall_error
> > +	 l.ori	r3, r11, 0
> > +
> > +END (__swapcontext)
> > +weak_alias (__swapcontext, swapcontext)
> > diff --git a/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> > new file mode 100644
> > index 0000000000..c4aead8f93
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> > @@ -0,0 +1,53 @@
> > +/* ucontext_t definition, OpenRISC version.
> > +   Copyright (C) 2021 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
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +/* System V/OpenRISC compliant context switching support.  */
> > +
> > +#ifndef _SYS_UCONTEXT_H
> > +#define _SYS_UCONTEXT_H	1
> > +
> > +#include <features.h>
> > +
> > +#include <bits/types/sigset_t.h>
> > +#include <bits/types/stack_t.h>
> > +
> > +/* Number of general registers.  */
> > +#define __NGREG	32
> > +#ifdef __USE_MISC
> > +# define NGREG	__NGREG
> > +#endif
> > +
> > +/* Context to describe whole processor state.  */
> > +typedef struct
> > +  {
> > +    unsigned long int __gprs[__NGREG];
> > +    unsigned long int __pc;
> > +    unsigned long int __sr;
> > +  } mcontext_t;
> > +
> > +/* Userlevel context.  */
> > +typedef struct ucontext_t
> > +  {
> > +    unsigned long int __uc_flags;
> > +    struct ucontext_t *uc_link;
> > +    stack_t uc_stack;
> > +    mcontext_t uc_mcontext;
> > +    sigset_t uc_sigmask;
> > +  } ucontext_t;
> > +
> > +#endif /* sys/ucontext.h */
> > diff --git a/sysdeps/unix/sysv/linux/or1k/sys/user.h b/sysdeps/unix/sysv/linux/or1k/sys/user.h
> > new file mode 100644
> > index 0000000000..c871f1a03d
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/sys/user.h
> > @@ -0,0 +1 @@
> > +/* This file is not needed, but in practice gdb might try to include it.  */
> > diff --git a/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> > new file mode 100644
> > index 0000000000..a8d4db080f
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> > @@ -0,0 +1,26 @@
> > +#include <inttypes.h>
> > +#include <signal.h>
> > +#include <stddef.h>
> > +#include <sys/ucontext.h>
> > +
> > +-- Constants used by the rt_sigprocmask call.
> > +
> > +SIG_BLOCK
> > +SIG_SETMASK
> > +
> > +_NSIG8				(_NSIG / 8)
> > +
> > +-- Offsets of the fields in the ucontext_t structure.
> > +#define ucontext(member)	offsetof (ucontext_t, member)
> > +#define stack(member)		ucontext (uc_stack.member)
> > +
> > +UCONTEXT_LINK			ucontext (uc_link)
> > +UCONTEXT_STACK			ucontext (uc_stack)
> > +UCONTEXT_MCONTEXT		ucontext (uc_mcontext)
> > +UCONTEXT_SIGMASK		ucontext (uc_sigmask)
> > +
> > +STACK_SP			stack (ss_sp)
> > +STACK_SIZE			stack (ss_size)
> > +STACK_FLAGS			stack (ss_flags)
> > +
> > +UCONTEXT_SIZE			sizeof (ucontext_t)

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 09/13] or1k: Linux ABI
  2021-12-21 14:54     ` Stafford Horne
@ 2021-12-22 10:54       ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-22 10:54 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Tue, Dec 21, 2021 at 11:54:46PM +0900, Stafford Horne wrote:
> On Tue, Dec 21, 2021 at 10:41:17AM -0300, Adhemerval Zanella wrote:
> > Some comments below.
> > 
> > On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > > ---
> > >  sysdeps/or1k/nptl/bits/pthreadtypes-arch.h    |  48 ++++++++
> > >  sysdeps/or1k/nptl/pthreaddef.h                |  36 ++++++
> > >  sysdeps/unix/sysv/linux/or1k/bits/procfs.h    |  38 ++++++
> > >  sysdeps/unix/sysv/linux/or1k/getcontext.S     |  72 +++++++++++
> > >  sysdeps/unix/sysv/linux/or1k/makecontext.c    |  77 ++++++++++++
> > >  sysdeps/unix/sysv/linux/or1k/setcontext.S     | 108 ++++++++++++++++
> > >  sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h |  28 +++++
> > >  sysdeps/unix/sysv/linux/or1k/swapcontext.S    | 116 ++++++++++++++++++
> > >  sysdeps/unix/sysv/linux/or1k/sys/ucontext.h   |  53 ++++++++
> > >  sysdeps/unix/sysv/linux/or1k/sys/user.h       |   1 +
> > >  sysdeps/unix/sysv/linux/or1k/ucontext_i.sym   |  26 ++++
> > >  11 files changed, 603 insertions(+)
> > >  create mode 100644 sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> > >  create mode 100644 sysdeps/or1k/nptl/pthreaddef.h
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/getcontext.S
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/makecontext.c
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/setcontext.S
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/swapcontext.S
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/sys/user.h
> > >  create mode 100644 sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> > > 
> > > diff --git a/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> > > new file mode 100644
> > > index 0000000000..56a62a7161
> > > --- /dev/null
> > > +++ b/sysdeps/or1k/nptl/bits/pthreadtypes-arch.h
> > > @@ -0,0 +1,48 @@
> > > +/* Machine-specific pthread type layouts.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +#ifndef _BITS_PTHREADTYPES_H
> > > +#define _BITS_PTHREADTYPES_H	1
> > > +
> > > +#include <bits/wordsize.h>
> > > +
> > > +/* Opaque union sizes for:
> > > +     pthread_attr_t - internally pthread_attr
> > > +     pthread_mutex_t - internally __pthread_mutex_s
> > > +     pthread_mutexattr_t - internally pthread_mutexattr
> > > +     pthread_cond_t - internally __pthread_cond_s
> > > +     pthread_condattr_t - internally pthread_condattr
> > > +     pthread_rwlock_t - internally __pthread_rwlock_arch_t
> > > +     pthread_rwlockattr_t - internally pthread_rwlockattr
> > > +     pthread_barrier_t - internally pthread_barrier
> > > +     pthread_barrierattr_t - internally pthread_barrierattr  */
> > > +
> > > +#define __SIZEOF_PTHREAD_ATTR_T 32
> > > +#define __SIZEOF_PTHREAD_MUTEX_T 32
> > > +#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
> > > +#define __SIZEOF_PTHREAD_COND_T 48
> > > +#define __SIZEOF_PTHREAD_CONDATTR_T 4
> > > +#define __SIZEOF_PTHREAD_RWLOCK_T 44
> > > +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
> > > +#define __SIZEOF_PTHREAD_BARRIER_T 20
> > > +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
> > > +
> > > +#define __LOCK_ALIGNMENT
> > > +#define __ONCE_ALIGNMENT
> > > +
> > > +#endif	/* bits/pthreadtypes.h */
> > 
> > Why can't use the default values on sysdeps/nptl/bits/pthreadtypes-arch.h ?
> 
> I think it can, let me test.
> 
> > > diff --git a/sysdeps/or1k/nptl/pthreaddef.h b/sysdeps/or1k/nptl/pthreaddef.h
> > > new file mode 100644
> > > index 0000000000..d17918ea11
> > > --- /dev/null
> > > +++ b/sysdeps/or1k/nptl/pthreaddef.h
> > > @@ -0,0 +1,36 @@
> > > +/* pthread machine parameter definitions.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +/* Default stack size.  */
> > > +#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
> > > +
> > > +/* Minimum guard size.  */
> > > +#define ARCH_MIN_GUARD_SIZE 0
> > > +
> > > +/* Required stack pointer alignment at beginning.  */
> > > +#define STACK_ALIGN 16
> > > +
> > > +/* Minimal stack size after allocating thread descriptor and guard size.  */
> > > +#define MINIMAL_REST_STACK 2048
> > > +
> > > +/* Alignment requirement for TCB.  Needs to be >= to STACK_ALIGN.  */
> > > +#define TCB_ALIGNMENT 32
> > > +
> > > +/* Location of current stack frame.  */
> > > +#define CURRENT_STACK_FRAME __builtin_frame_address (0)
> > 
> > Ok.  As a side note, maybe we could provide a default header with this exact
> > definitions. 
> > 
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/bits/procfs.h b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> > > new file mode 100644
> > > index 0000000000..b50c92efb1
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/bits/procfs.h
> > > @@ -0,0 +1,38 @@
> > > +/* Types for registers for sys/procfs.h.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://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>
> > > +
> > > +#define ELF_NGREG __NGREG
> > > +
> > > +/* Type for a general-purpose register.  */
> > > +typedef unsigned long int elf_greg_t;
> > > +
> > > +/* And the array of general-purpose registers.  We could have used `struct
> > > +   user_regs' directly, but tradition says that the register set is an array,
> > > +   which does have some peculiar semantics, so leave it that way.
> > > +   GDB uses this for prtrace GETREGSET, on OpenRISC the regset contains 32
> > > +   gprs the PC and the SR, 34 longs.  */
> > > +typedef elf_greg_t elf_gregset_t[34];
> > > +
> > > +/* Register set for the floating-point registers.  */
> > > +typedef elf_greg_t elf_fpregset_t[32];
> > 
> > It indicates that that or1k would only support float32, is that correct?
> 
> OpenRISC support 64-bit double's by using register pairs. i.e. r16,r17 +
> r18,r19.  The floating point and genral purpose registers actually are the
> same 32 registers.
> 
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/getcontext.S b/sysdeps/unix/sysv/linux/or1k/getcontext.S
> > > new file mode 100644
> > > index 0000000000..4c2e64db7a
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/getcontext.S
> > > @@ -0,0 +1,72 @@
> > > +/* Save current context.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +#include <sysdep.h>
> > > +#include "ucontext_i.h"
> > > +
> > > +/* int getcontext (ucontext_t *ucp)
> > > +
> > > +   Returns 0 on success -1 and errno on failure.
> > > + */
> > > +	.text
> > > +ENTRY(__getcontext)
> > > +	/* Store r1, the stack pointer.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
> > > +	/* Store r2, the frame pointer.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
> > > +	/* Store r9, the link register.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
> > > +	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
> > > +	/* Store r10, the TLS register.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
> > > +	/* Store r14-r30 even, callee saved registers.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
> > > +	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
> > > +	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
> > > +	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
> > > +	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
> > > +	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
> > > +	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
> > > +	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
> > > +	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
> > > +
> > > +	/* Get signal mask.  */
> > > +	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
> > > +	l.ori	r6, r0, _NSIG8
> > > +	l.addi	r5, r3, UCONTEXT_SIGMASK
> > > +	l.ori	r4, r0, 0
> > > +	l.ori	r3, r0, SIG_BLOCK
> > > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > > +	/* Do the syscall.  */
> > > +	l.sys	1
> > > +	 l.nop
> > > +
> > > +	/* if -4096 < ret < 0 holds, it's an error */
> > > +	l.sfgeui r11, 0xf001
> > > +	l.bf	1f
> > > +	 l.nop
> > > +
> > > +	l.jr	r9
> > > +	 l.ori r11, r0, 0
> > > +
> > > +1:	l.j	__syscall_error
> > > +	 l.ori	r3, r11, 0
> > > +
> > > +END(__getcontext)
> > > +weak_alias(__getcontext, getcontext)
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/makecontext.c b/sysdeps/unix/sysv/linux/or1k/makecontext.c
> > > new file mode 100644
> > > index 0000000000..3dd4134a6b
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/makecontext.c
> > > @@ -0,0 +1,77 @@
> > > +/* Create new context.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +#include <sysdep.h>
> > > +#include <stdarg.h>
> > > +#include <stdint.h>
> > > +#include <ucontext.h>
> > > +
> > > +/* makecontext sets up a stack and the registers for the
> > > +   user context.  The stack looks like this:
> > > +
> > > +		+-----------------------+
> > > +		| padding as required   |
> > > +		+-----------------------+
> > > +    sp ->       | parameters 7 to n     |
> > > +		+-----------------------+
> > > +
> > > +   The registers are set up like this:
> > > +     r3-r8  : parameters 1 to 6
> > > +     r14    : uc_link
> > > +     r1     : stack pointer
> > > +     r2     : frame pointer, set to NULL
> > > +*/
> > > +void
> > > +__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
> > > +{
> > > +  extern void __startcontext (void);
> > > +  unsigned long int *sp;
> > > +  va_list ap;
> > > +  int i;
> > > +
> > > +  sp = (unsigned long int *)
> > > +    ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
> > > +
> > > +  /* Allocate stack arguments.  */
> > > +  sp -= argc < 6 ? 0 : argc - 6;
> > > +
> > > +  /* Keep the stack aligned.  */
> > > +  sp = (unsigned long int *) (((uintptr_t) sp) & -4L);
> > 
> > Is stack required to be 4 or 16 (STACK_ALIGN from pthreaddef.h)?
> 
> Is STACK_ALIGN used for anything other than asserts now?
> 
> I cannot recall why the alignment was set to 16 bytes, it may be copy and paste
> or it may be due to our cache lines being either 16bytes or 32bytes (usually
> 32).
> 
> Do you see any issue changing STACK_ALIGN to 4 bytes?

Nevermind, this should be in the OpenRISC spec.  And it is, it specifies 4 byte
alignment.

Also, GCC and GDB define it as 4.

-Stafford

> -Stafford
> 
> > > +
> > > +  /* Keep uc_link in r14.  */
> > > +  ucp->uc_mcontext.__gprs[14] = (uintptr_t) ucp->uc_link;
> > > +  /* Return address points to function __startcontext.  */
> > > +  ucp->uc_mcontext.__gprs[9] = (uintptr_t) &__startcontext;
> > > +  /* Frame pointer is null.  */
> > > +  ucp->uc_mcontext.__gprs[2] = (uintptr_t) 0;
> > > +  /* Restart in user-space starting at 'func'.  */
> > > +  ucp->uc_mcontext.__gprs[11] = (uintptr_t) func;
> > > +  /* Set stack pointer.  */
> > > +  ucp->uc_mcontext.__gprs[1] = (uintptr_t) sp;
> > > +
> > > +  va_start (ap, argc);
> > > +  for (i = 0; i < argc; ++i)
> > > +    if (i < 6)
> > > +      ucp->uc_mcontext.__gprs[i + 3] = va_arg (ap, unsigned long int);
> > > +    else
> > > +      sp[i - 6] = va_arg (ap, unsigned long int);
> > > +
> > > +  va_end (ap);
> > > +}
> > > +
> > > +weak_alias (__makecontext, makecontext)
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/setcontext.S b/sysdeps/unix/sysv/linux/or1k/setcontext.S
> > > new file mode 100644
> > > index 0000000000..b4808d5422
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/setcontext.S
> > > @@ -0,0 +1,108 @@
> > > +/* Set current context.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +#include <sysdep.h>
> > > +#include "ucontext_i.h"
> > > +
> > > +/* int setcontext (const ucontext_t *ucp) */
> > > +	.text
> > > +ENTRY(__setcontext)
> > > +	l.ori	r30, r3, 0
> > > +
> > > +	/* Restore signal mask.  */
> > > +	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
> > > +	l.ori	r6, r0, _NSIG8
> > > +	l.ori	r5, r0, 0
> > > +	l.addi	r4, r3, UCONTEXT_SIGMASK
> > > +	l.ori	r3, r0, SIG_SETMASK
> > > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > > +	/* Do the syscall.  */
> > > +	l.sys 1
> > > +	 l.nop
> > > +
> > > +	/* if -4096 < ret < 0 holds, it's an error */
> > > +	l.sfgeui r11, 0xf001
> > > +	l.bf	1f
> > > +	 l.nop
> > > +
> > > +	/* Restore argument registers, for the makecontext case.  */
> > > +	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
> > > +	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
> > > +	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
> > > +	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
> > > +	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
> > > +	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
> > > +
> > > +	/* Restore registers stored in getcontext.  */
> > > +	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
> > > +	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
> > > +	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
> > > +	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
> > > +	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
> > > +	/* Restore r14-r30 even, callee saved registers.  */
> > > +	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
> > > +	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
> > > +	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
> > > +	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
> > > +	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
> > > +	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
> > > +	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
> > > +	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
> > > +	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
> > > +
> > > +	l.jr	r11
> > > +	 l.ori	r11, r0, 0
> > > +
> > > +1:	l.j	__syscall_error
> > > +	 l.ori	r3, r11, 0
> > > +
> > > +END (__setcontext)
> > > +weak_alias (__setcontext, setcontext)
> > > +
> > > +	/* We add a NOP here because when the unwinder is looking for the
> > > +	   enclosing function of the link register (r9) address FDE lookup will
> > > +	   use '$r9 - 1' finding setcontext which is wrong.  This is because in
> > > +	   makecontext we have set r9 to the start of &__startcontext.
> > > +
> > > +	   If this NOP did not exist the unwinder would repeatedly find
> > > +	   __setcontext's FDE in an infinite loop.  Modifiying/deleting the below
> > > +	   __startcontext's FDE has no help on this.  */
> > > +	l.nop
> > > +
> > > +ENTRY(__startcontext)
> > > +
> > > +	l.ori	r3, r14, 0
> > > +	l.sfeq	r3, r0
> > > +	/* If uc_link is not 0 resume there, otherwise exit.  */
> > > +	l.bnf	__setcontext
> > > +	 l.nop
> > > +
> > > +#ifdef SHARED
> > > +	/* Obtain a pointer to .got in r16 */
> > > +	l.jal	0x8
> > > +	 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
> > > +	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
> > > +	l.add	r16, r16, r9
> > > +	l.lwz	r16, got(exit)(r16)
> > > +	l.jr	r16
> > > +#else
> > > +	l.j	exit
> > > +#endif
> > > +	 l.nop
> > > +
> > > +END(__startcontext)
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> > > new file mode 100644
> > > index 0000000000..de94b59578
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/sigcontextinfo.h
> > > @@ -0,0 +1,28 @@
> > > +/* Profile counter helper to get PC from sigcontext.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +#ifndef _SIGCONTEXTINFO_H
> > > +#define _SIGCONTEXTINFO_H
> > > +
> > > +static inline uintptr_t
> > > +sigcontext_get_pc (const ucontext_t *ctx)
> > > +{
> > > +  return ctx->uc_mcontext.__pc;
> > > +}
> > > +
> > > +#endif /* _SIGCONTEXTINFO_H */
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/swapcontext.S b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
> > > new file mode 100644
> > > index 0000000000..2acdc6d9bd
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/swapcontext.S
> > > @@ -0,0 +1,116 @@
> > > +/* Swap two contexts.  OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +#include <sysdep.h>
> > > +#include "ucontext_i.h"
> > > +
> > > +/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
> > > +	.text
> > > +ENTRY(__swapcontext)
> > > +
> > > +	/* Same as getcontext.  */
> > > +	/* Store r1, the stack pointer.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT +  1*4)(r3), r1
> > > +	/* Store r2, the frame pointer.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT +  2*4)(r3), r2
> > > +	/* Store r9, the link register.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT +  9*4)(r3), r9
> > > +	/* Store r9 to reg[11] too, as we need two links for makecontext.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT + 11*4)(r3), r9
> > > +	/* Store r10, the TLS register.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT + 10*4)(r3), r10
> > > +	/* Store r14-r30 even, callee saved registers.  */
> > > +	l.sw	(UCONTEXT_MCONTEXT + 14*4)(r3), r14
> > > +	l.sw	(UCONTEXT_MCONTEXT + 16*4)(r3), r16
> > > +	l.sw	(UCONTEXT_MCONTEXT + 18*4)(r3), r18
> > > +	l.sw	(UCONTEXT_MCONTEXT + 20*4)(r3), r20
> > > +	l.sw	(UCONTEXT_MCONTEXT + 22*4)(r3), r22
> > > +	l.sw	(UCONTEXT_MCONTEXT + 24*4)(r3), r24
> > > +	l.sw	(UCONTEXT_MCONTEXT + 26*4)(r3), r26
> > > +	l.sw	(UCONTEXT_MCONTEXT + 28*4)(r3), r28
> > > +	l.sw	(UCONTEXT_MCONTEXT + 30*4)(r3), r30
> > > +
> > > +	/* Store ucp to non-argument syscall preserved register.  */
> > > +	l.ori	r30, r4, 0
> > > +
> > > +	/* Get signal mask.  */
> > > +	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
> > > +	l.ori	r6, r0, _NSIG8
> > > +	l.addi	r5, r3, UCONTEXT_SIGMASK
> > > +	l.ori	r4, r0, 0
> > > +	l.ori	r3, r0, SIG_BLOCK
> > > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > > +	/* Do the syscall.  */
> > > +	l.sys	1
> > > +	 l.nop
> > > +
> > > +	/* if -4096 < ret < 0 holds, it's an error */
> > > +	l.sfgeui r11, 0xf001
> > > +	l.bf	1f
> > > +	 l.nop
> > > +
> > > +	/* Same as setcontext.  */
> > > +
> > > +	/* Restore signal mask.  */
> > > +	/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
> > > +	l.ori	r6, r0, _NSIG8
> > > +	l.ori	r5, r0, 0
> > > +	l.addi	r4, r30, UCONTEXT_SIGMASK
> > > +	l.ori	r3, r0, SIG_SETMASK
> > > +	l.ori	r11, r0, SYS_ify (rt_sigprocmask)
> > > +	/* Do the syscall.  */
> > > +	l.sys 1
> > > +	 l.nop
> > > +
> > > +	/* if -4096 < ret < 0 holds, it's an error */
> > > +	l.sfgeui r11, 0xf001
> > > +	l.bf	1f
> > > +	 l.nop
> > > +
> > > +	/* Restore argument registers, for the makecontext case.  */
> > > +	l.lwz	r3, (UCONTEXT_MCONTEXT +  3*4)(r30)
> > > +	l.lwz	r4, (UCONTEXT_MCONTEXT +  4*4)(r30)
> > > +	l.lwz	r5, (UCONTEXT_MCONTEXT +  5*4)(r30)
> > > +	l.lwz	r6, (UCONTEXT_MCONTEXT +  6*4)(r30)
> > > +	l.lwz	r7, (UCONTEXT_MCONTEXT +  7*4)(r30)
> > > +	l.lwz	r8, (UCONTEXT_MCONTEXT +  8*4)(r30)
> > > +
> > > +	/* Restore registers stored in getcontext.  */
> > > +	l.lwz	r1,  (UCONTEXT_MCONTEXT +  1*4)(r30)
> > > +	l.lwz	r2,  (UCONTEXT_MCONTEXT +  2*4)(r30)
> > > +	l.lwz	r9,  (UCONTEXT_MCONTEXT +  9*4)(r30)
> > > +	l.lwz	r10, (UCONTEXT_MCONTEXT + 10*4)(r30)
> > > +	l.lwz	r11, (UCONTEXT_MCONTEXT + 11*4)(r30)
> > > +	l.lwz	r14, (UCONTEXT_MCONTEXT + 14*4)(r30)
> > > +	l.lwz	r16, (UCONTEXT_MCONTEXT + 16*4)(r30)
> > > +	l.lwz	r18, (UCONTEXT_MCONTEXT + 18*4)(r30)
> > > +	l.lwz	r20, (UCONTEXT_MCONTEXT + 20*4)(r30)
> > > +	l.lwz	r22, (UCONTEXT_MCONTEXT + 22*4)(r30)
> > > +	l.lwz	r24, (UCONTEXT_MCONTEXT + 24*4)(r30)
> > > +	l.lwz	r26, (UCONTEXT_MCONTEXT + 26*4)(r30)
> > > +	l.lwz	r28, (UCONTEXT_MCONTEXT + 28*4)(r30)
> > > +	l.lwz	r30, (UCONTEXT_MCONTEXT + 30*4)(r30)
> > > +
> > > +	l.jr	r11
> > > +	 l.ori	r11, r0, 0
> > > +
> > > +1:	l.j	__syscall_error
> > > +	 l.ori	r3, r11, 0
> > > +
> > > +END (__swapcontext)
> > > +weak_alias (__swapcontext, swapcontext)
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> > > new file mode 100644
> > > index 0000000000..c4aead8f93
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h
> > > @@ -0,0 +1,53 @@
> > > +/* ucontext_t definition, OpenRISC version.
> > > +   Copyright (C) 2021 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
> > > +   <https://www.gnu.org/licenses/>.  */
> > > +
> > > +/* System V/OpenRISC compliant context switching support.  */
> > > +
> > > +#ifndef _SYS_UCONTEXT_H
> > > +#define _SYS_UCONTEXT_H	1
> > > +
> > > +#include <features.h>
> > > +
> > > +#include <bits/types/sigset_t.h>
> > > +#include <bits/types/stack_t.h>
> > > +
> > > +/* Number of general registers.  */
> > > +#define __NGREG	32
> > > +#ifdef __USE_MISC
> > > +# define NGREG	__NGREG
> > > +#endif
> > > +
> > > +/* Context to describe whole processor state.  */
> > > +typedef struct
> > > +  {
> > > +    unsigned long int __gprs[__NGREG];
> > > +    unsigned long int __pc;
> > > +    unsigned long int __sr;
> > > +  } mcontext_t;
> > > +
> > > +/* Userlevel context.  */
> > > +typedef struct ucontext_t
> > > +  {
> > > +    unsigned long int __uc_flags;
> > > +    struct ucontext_t *uc_link;
> > > +    stack_t uc_stack;
> > > +    mcontext_t uc_mcontext;
> > > +    sigset_t uc_sigmask;
> > > +  } ucontext_t;
> > > +
> > > +#endif /* sys/ucontext.h */
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/sys/user.h b/sysdeps/unix/sysv/linux/or1k/sys/user.h
> > > new file mode 100644
> > > index 0000000000..c871f1a03d
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/sys/user.h
> > > @@ -0,0 +1 @@
> > > +/* This file is not needed, but in practice gdb might try to include it.  */
> > > diff --git a/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> > > new file mode 100644
> > > index 0000000000..a8d4db080f
> > > --- /dev/null
> > > +++ b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym
> > > @@ -0,0 +1,26 @@
> > > +#include <inttypes.h>
> > > +#include <signal.h>
> > > +#include <stddef.h>
> > > +#include <sys/ucontext.h>
> > > +
> > > +-- Constants used by the rt_sigprocmask call.
> > > +
> > > +SIG_BLOCK
> > > +SIG_SETMASK
> > > +
> > > +_NSIG8				(_NSIG / 8)
> > > +
> > > +-- Offsets of the fields in the ucontext_t structure.
> > > +#define ucontext(member)	offsetof (ucontext_t, member)
> > > +#define stack(member)		ucontext (uc_stack.member)
> > > +
> > > +UCONTEXT_LINK			ucontext (uc_link)
> > > +UCONTEXT_STACK			ucontext (uc_stack)
> > > +UCONTEXT_MCONTEXT		ucontext (uc_mcontext)
> > > +UCONTEXT_SIGMASK		ucontext (uc_sigmask)
> > > +
> > > +STACK_SP			stack (ss_sp)
> > > +STACK_SIZE			stack (ss_size)
> > > +STACK_FLAGS			stack (ss_flags)
> > > +
> > > +UCONTEXT_SIZE			sizeof (ucontext_t)

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 10/13] or1k: ABI lists
  2021-12-10 23:34 ` [PATCH v3 10/13] or1k: ABI lists Stafford Horne
@ 2021-12-22 20:20   ` Adhemerval Zanella
  2021-12-23  8:36     ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-22 20:20 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches, Florian Weimer; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:

> diff --git a/sysdeps/unix/sysv/linux/or1k/ld.abilist b/sysdeps/unix/sysv/linux/or1k/ld.abilist
> new file mode 100644
> index 0000000000..c4b85c8a33
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/ld.abilist
> @@ -0,0 +1,5 @@
> +GLIBC_2.35 __libc_stack_end D 0x4
> +GLIBC_2.35 __stack_chk_guard D 0x4
> +GLIBC_2.35 __tls_get_addr F
> +GLIBC_2.35 _dl_mcount F
> +GLIBC_2.35 _r_debug D 0x14

You will need to regenerate it to include the rseq symbols:

GLIBC_2.35 __rseq_flags D 0x4
GLIBC_2.35 __rseq_offset D 0x4
GLIBC_2.35 __rseq_size D 0x4


> diff --git a/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist b/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
> new file mode 100644
> index 0000000000..366c393274
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
> @@ -0,0 +1 @@
> +GLIBC_2.35 __ctype_get_mb_cur_max F
> diff --git a/sysdeps/unix/sysv/linux/or1k/libanl.abilist b/sysdeps/unix/sysv/linux/or1k/libanl.abilist
> new file mode 100644
> index 0000000000..c6437809db
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/libanl.abilist
> @@ -0,0 +1 @@
> +GLIBC_2.35 __libanl_version_placeholder F

This does seems right, or1k should not require the placeholder.  I think
we are missing a SHLIB_COMPAT on resolv/libanl-compat.c:

diff --git a/resolv/libanl-compat.c b/resolv/libanl-compat.c
index 29df76f278..02c18bde90 100644
--- a/resolv/libanl-compat.c
+++ b/resolv/libanl-compat.c
@@ -30,6 +30,8 @@ __libanl_version_placeholder_1 (void)
 {
 }
 
+# if SHLIB_COMPAT (libanl, GLIBC_2_2_3, GLIBC_2_34)
 compat_symbol (libanl, __libanl_version_placeholder_1,
                __libanl_version_placeholder, GLIBC_2_2_3);
+# endif
 #endif

> diff --git a/sysdeps/unix/sysv/linux/or1k/libutil.abilist b/sysdeps/unix/sysv/linux/or1k/libutil.abilist
> new file mode 100644
> index 0000000000..f33b84813b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/libutil.abilist
> @@ -0,0 +1 @@
> +GLIBC_2.35 __libutil_version_placeholder F

This also does not seems right, libutil-compat will only built for
have-GLIBC_2.33, which is not the case.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 11/13] or1k: Build Infrastructure
  2021-12-10 23:34 ` [PATCH v3 11/13] or1k: Build Infrastructure Stafford Horne
@ 2021-12-22 21:03   ` Adhemerval Zanella
  2021-12-23  7:32     ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-22 21:03 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> Here we define the minumum linux kernel version at 5.4.0, as that is the
> long term support version where 32-bit architectures start to support
> 64-bit time API's.  The OpenRISC kernel had some bugs up until version 5.8
> which caused issues with glibc fork/clone, they have been backported to
> 5.4 but not previous versions.

Some comments below, the rest looks ok.

> ---
>  sysdeps/or1k/Implies                        |  3 ++
>  sysdeps/or1k/Makefile                       |  7 +++++
>  sysdeps/or1k/nofpu/Implies                  |  1 +
>  sysdeps/or1k/nptl/Makefile                  | 21 +++++++++++++
>  sysdeps/or1k/preconfigure                   | 34 +++++++++++++++++++++
>  sysdeps/unix/sysv/linux/or1k/Implies        |  3 ++
>  sysdeps/unix/sysv/linux/or1k/Makefile       | 12 ++++++++
>  sysdeps/unix/sysv/linux/or1k/configure      |  4 +++
>  sysdeps/unix/sysv/linux/or1k/configure.ac   |  4 +++
>  sysdeps/unix/sysv/linux/or1k/shlib-versions |  2 ++
>  10 files changed, 91 insertions(+)
>  create mode 100644 sysdeps/or1k/Implies
>  create mode 100644 sysdeps/or1k/Makefile
>  create mode 100644 sysdeps/or1k/nofpu/Implies
>  create mode 100644 sysdeps/or1k/nptl/Makefile
>  create mode 100644 sysdeps/or1k/preconfigure
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/Implies
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/Makefile
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure.ac
>  create mode 100644 sysdeps/unix/sysv/linux/or1k/shlib-versions
> 
> diff --git a/sysdeps/or1k/Implies b/sysdeps/or1k/Implies
> new file mode 100644
> index 0000000000..387a0ca052
> --- /dev/null
> +++ b/sysdeps/or1k/Implies
> @@ -0,0 +1,3 @@
> +wordsize-32
> +ieee754/dbl-64
> +ieee754/flt-32
> diff --git a/sysdeps/or1k/Makefile b/sysdeps/or1k/Makefile
> new file mode 100644
> index 0000000000..0241a0587e
> --- /dev/null
> +++ b/sysdeps/or1k/Makefile
> @@ -0,0 +1,7 @@
> +ASFLAGS-.os += -fPIC
> +
> +ifeq ($(subdir),elf)
> +# Extra shared linker files to link only into dl-allobjs.so.
> +sysdep-rtld-routines += dl-start
> +endif
> +
> diff --git a/sysdeps/or1k/nofpu/Implies b/sysdeps/or1k/nofpu/Implies
> new file mode 100644
> index 0000000000..abcbadb25f
> --- /dev/null
> +++ b/sysdeps/or1k/nofpu/Implies
> @@ -0,0 +1 @@
> +ieee754/soft-fp
> diff --git a/sysdeps/or1k/nptl/Makefile b/sysdeps/or1k/nptl/Makefile
> new file mode 100644
> index 0000000000..0e08821933
> --- /dev/null
> +++ b/sysdeps/or1k/nptl/Makefile
> @@ -0,0 +1,21 @@
> +# Copyright (C) 2021 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
> +# <https://www.gnu.org/licenses/>.
> +
> +ifeq ($(subdir),csu)
> +gen-as-const-headers += tcb-offsets.sym
> +endif

I think you do not need this anymore since 691d9ae9e6f3bcb.

> diff --git a/sysdeps/or1k/preconfigure b/sysdeps/or1k/preconfigure
> new file mode 100644
> index 0000000000..d1b1fb1843
> --- /dev/null
> +++ b/sysdeps/or1k/preconfigure
> @@ -0,0 +1,34 @@
> +#
> +# This is free and unencumbered software released into the public domain.
> +#
> +# Anyone is free to copy, modify, publish, use, compile, sell, or
> +# distribute this software, either in source code form or as a compiled
> +# binary, for any purpose, commercial or non-commercial, and by any
> +# means.
> +#
> +# In jurisdictions that recognize copyright laws, the author or authors
> +# of this software dedicate any and all copyright interest in the
> +# software to the public domain. We make this dedication for the benefit
> +# of the public at large and to the detriment of our heirs and
> +# successors. We intend this dedication to be an overt act of
> +# relinquishment in perpetuity of all present and future rights to this
> +# software under copyright law.
> +#
> +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> +# OTHER DEALINGS IN THE SOFTWARE.
> +#
> +
> +case "$machine" in
> +or1k*)
> +  base_machine=or1k
> +  machine=or1k
> +
> +  with_fp_cond="defined __or1k_hard_float__"
> +  ;;
> +esac
> +
> diff --git a/sysdeps/unix/sysv/linux/or1k/Implies b/sysdeps/unix/sysv/linux/or1k/Implies
> new file mode 100644
> index 0000000000..f39f16c04a
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/Implies
> @@ -0,0 +1,3 @@
> +or1k/nptl
> +unix/sysv/linux/generic/wordsize-32
> +unix/sysv/linux/generic
> diff --git a/sysdeps/unix/sysv/linux/or1k/Makefile b/sysdeps/unix/sysv/linux/or1k/Makefile
> new file mode 100644
> index 0000000000..be20320b2f
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/Makefile
> @@ -0,0 +1,12 @@
> +ifeq ($(subdir),misc)
> +  sysdep_routines += prctl or1k_clone

The indentations seems off here and I think there is no need of prctl.

> +endif
> +
> +ifeq ($(subdir),stdlib)
> +gen-as-const-headers += ucontext_i.sym
> +endif
> +
> +# pull in __syscall_error routine
> +libpthread-routines += sysdep
> +librt-routines += sysdep
> +
> diff --git a/sysdeps/unix/sysv/linux/or1k/configure b/sysdeps/unix/sysv/linux/or1k/configure
> new file mode 100644
> index 0000000000..5225dfea5b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/configure
> @@ -0,0 +1,4 @@
> +# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
> + # Local configure fragment for sysdeps/unix/sysv/linux/or1k.
> +
> +arch_minimum_kernel=5.4.0
> diff --git a/sysdeps/unix/sysv/linux/or1k/configure.ac b/sysdeps/unix/sysv/linux/or1k/configure.ac
> new file mode 100644
> index 0000000000..6274c4fb02
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/configure.ac
> @@ -0,0 +1,4 @@
> +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> +# Local configure fragment for sysdeps/unix/sysv/linux/or1k.
> +
> +arch_minimum_kernel=5.4.0
> diff --git a/sysdeps/unix/sysv/linux/or1k/shlib-versions b/sysdeps/unix/sysv/linux/or1k/shlib-versions
> new file mode 100644
> index 0000000000..159653b5c4
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/or1k/shlib-versions
> @@ -0,0 +1,2 @@
> +DEFAULT                 GLIBC_2.35
> +ld=ld-linux-or1k.so.1

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 12/13] build-many-glibcs.py: add OpenRISC support
  2021-12-10 23:34 ` [PATCH v3 12/13] build-many-glibcs.py: add OpenRISC support Stafford Horne
@ 2021-12-22 21:04   ` Adhemerval Zanella
  2021-12-23  7:15     ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-22 21:04 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> ---
>  scripts/build-many-glibcs.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index 6ae2172956..47b2cabc9c 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -334,6 +334,10 @@ class Context(object):
>                                   'ccopts': '-mabi=64'}])
>          self.add_config(arch='nios2',
>                          os_name='linux-gnu')
> +        self.add_config(arch='or1k',
> +                        os_name='linux-gnu',
> +                        variant='soft',
> +                        gcc_cfg=['--with-multilib-list=mcmov'])

Why is this option required?

>          self.add_config(arch='powerpc',
>                          os_name='linux-gnu',
>                          gcc_cfg=['--disable-multilib', '--enable-secureplt'],
> @@ -1270,6 +1274,7 @@ def install_linux_headers(policy, cmdlist):
>                  'microblaze': 'microblaze',
>                  'mips': 'mips',
>                  'nios2': 'nios2',
> +                'or1k': 'openrisc',
>                  'powerpc': 'powerpc',
>                  's390': 's390',
>                  'riscv32': 'riscv',

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 12/13] build-many-glibcs.py: add OpenRISC support
  2021-12-22 21:04   ` Adhemerval Zanella
@ 2021-12-23  7:15     ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-23  7:15 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Wed, Dec 22, 2021 at 06:04:07PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > ---
> >  scripts/build-many-glibcs.py | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> > index 6ae2172956..47b2cabc9c 100755
> > --- a/scripts/build-many-glibcs.py
> > +++ b/scripts/build-many-glibcs.py
> > @@ -334,6 +334,10 @@ class Context(object):
> >                                   'ccopts': '-mabi=64'}])
> >          self.add_config(arch='nios2',
> >                          os_name='linux-gnu')
> > +        self.add_config(arch='or1k',
> > +                        os_name='linux-gnu',
> > +                        variant='soft',
> > +                        gcc_cfg=['--with-multilib-list=mcmov'])
> 
> Why is this option required?

The default is to build with multilib-list mcmov,msoft-mul,msoft-div.  Which
would generate 3 toolchains.
To make the build faster I reduced it to the mcmov (support conditional move
instructions).

I could change to run with --disable-multilib, but enabling cmov is usually
always wanted.

> >          self.add_config(arch='powerpc',
> >                          os_name='linux-gnu',
> >                          gcc_cfg=['--disable-multilib', '--enable-secureplt'],
> > @@ -1270,6 +1274,7 @@ def install_linux_headers(policy, cmdlist):
> >                  'microblaze': 'microblaze',
> >                  'mips': 'mips',
> >                  'nios2': 'nios2',
> > +                'or1k': 'openrisc',
> >                  'powerpc': 'powerpc',
> >                  's390': 's390',
> >                  'riscv32': 'riscv',

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 11/13] or1k: Build Infrastructure
  2021-12-22 21:03   ` Adhemerval Zanella
@ 2021-12-23  7:32     ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-23  7:32 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Wed, Dec 22, 2021 at 06:03:27PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > Here we define the minumum linux kernel version at 5.4.0, as that is the
> > long term support version where 32-bit architectures start to support
> > 64-bit time API's.  The OpenRISC kernel had some bugs up until version 5.8
> > which caused issues with glibc fork/clone, they have been backported to
> > 5.4 but not previous versions.
> 
> Some comments below, the rest looks ok.
> 
> > ---
> >  sysdeps/or1k/Implies                        |  3 ++
> >  sysdeps/or1k/Makefile                       |  7 +++++
> >  sysdeps/or1k/nofpu/Implies                  |  1 +
> >  sysdeps/or1k/nptl/Makefile                  | 21 +++++++++++++
> >  sysdeps/or1k/preconfigure                   | 34 +++++++++++++++++++++
> >  sysdeps/unix/sysv/linux/or1k/Implies        |  3 ++
> >  sysdeps/unix/sysv/linux/or1k/Makefile       | 12 ++++++++
> >  sysdeps/unix/sysv/linux/or1k/configure      |  4 +++
> >  sysdeps/unix/sysv/linux/or1k/configure.ac   |  4 +++
> >  sysdeps/unix/sysv/linux/or1k/shlib-versions |  2 ++
> >  10 files changed, 91 insertions(+)
> >  create mode 100644 sysdeps/or1k/Implies
> >  create mode 100644 sysdeps/or1k/Makefile
> >  create mode 100644 sysdeps/or1k/nofpu/Implies
> >  create mode 100644 sysdeps/or1k/nptl/Makefile
> >  create mode 100644 sysdeps/or1k/preconfigure
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/Implies
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/Makefile
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/configure.ac
> >  create mode 100644 sysdeps/unix/sysv/linux/or1k/shlib-versions
> > 
> > diff --git a/sysdeps/or1k/Implies b/sysdeps/or1k/Implies
> > new file mode 100644
> > index 0000000000..387a0ca052
> > --- /dev/null
> > +++ b/sysdeps/or1k/Implies
> > @@ -0,0 +1,3 @@
> > +wordsize-32
> > +ieee754/dbl-64
> > +ieee754/flt-32
> > diff --git a/sysdeps/or1k/Makefile b/sysdeps/or1k/Makefile
> > new file mode 100644
> > index 0000000000..0241a0587e
> > --- /dev/null
> > +++ b/sysdeps/or1k/Makefile
> > @@ -0,0 +1,7 @@
> > +ASFLAGS-.os += -fPIC
> > +
> > +ifeq ($(subdir),elf)
> > +# Extra shared linker files to link only into dl-allobjs.so.
> > +sysdep-rtld-routines += dl-start
> > +endif
> > +
> > diff --git a/sysdeps/or1k/nofpu/Implies b/sysdeps/or1k/nofpu/Implies
> > new file mode 100644
> > index 0000000000..abcbadb25f
> > --- /dev/null
> > +++ b/sysdeps/or1k/nofpu/Implies
> > @@ -0,0 +1 @@
> > +ieee754/soft-fp
> > diff --git a/sysdeps/or1k/nptl/Makefile b/sysdeps/or1k/nptl/Makefile
> > new file mode 100644
> > index 0000000000..0e08821933
> > --- /dev/null
> > +++ b/sysdeps/or1k/nptl/Makefile
> > @@ -0,0 +1,21 @@
> > +# Copyright (C) 2021 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
> > +# <https://www.gnu.org/licenses/>.
> > +
> > +ifeq ($(subdir),csu)
> > +gen-as-const-headers += tcb-offsets.sym
> > +endif
> 
> I think you do not need this anymore since 691d9ae9e6f3bcb.

Yes, I have removed it locally already.

> > diff --git a/sysdeps/or1k/preconfigure b/sysdeps/or1k/preconfigure
> > new file mode 100644
> > index 0000000000..d1b1fb1843
> > --- /dev/null
> > +++ b/sysdeps/or1k/preconfigure
> > @@ -0,0 +1,34 @@
> > +#
> > +# This is free and unencumbered software released into the public domain.
> > +#
> > +# Anyone is free to copy, modify, publish, use, compile, sell, or
> > +# distribute this software, either in source code form or as a compiled
> > +# binary, for any purpose, commercial or non-commercial, and by any
> > +# means.
> > +#
> > +# In jurisdictions that recognize copyright laws, the author or authors
> > +# of this software dedicate any and all copyright interest in the
> > +# software to the public domain. We make this dedication for the benefit
> > +# of the public at large and to the detriment of our heirs and
> > +# successors. We intend this dedication to be an overt act of
> > +# relinquishment in perpetuity of all present and future rights to this
> > +# software under copyright law.
> > +#
> > +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> > +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> > +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> > +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> > +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> > +# OTHER DEALINGS IN THE SOFTWARE.
> > +#
> > +
> > +case "$machine" in
> > +or1k*)
> > +  base_machine=or1k
> > +  machine=or1k
> > +
> > +  with_fp_cond="defined __or1k_hard_float__"
> > +  ;;
> > +esac
> > +
> > diff --git a/sysdeps/unix/sysv/linux/or1k/Implies b/sysdeps/unix/sysv/linux/or1k/Implies
> > new file mode 100644
> > index 0000000000..f39f16c04a
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/Implies
> > @@ -0,0 +1,3 @@
> > +or1k/nptl
> > +unix/sysv/linux/generic/wordsize-32
> > +unix/sysv/linux/generic
> > diff --git a/sysdeps/unix/sysv/linux/or1k/Makefile b/sysdeps/unix/sysv/linux/or1k/Makefile
> > new file mode 100644
> > index 0000000000..be20320b2f
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/Makefile
> > @@ -0,0 +1,12 @@
> > +ifeq ($(subdir),misc)
> > +  sysdep_routines += prctl or1k_clone
> 
> The indentations seems off here and I think there is no need of prctl.

OK.

> > +endif
> > +
> > +ifeq ($(subdir),stdlib)
> > +gen-as-const-headers += ucontext_i.sym
> > +endif
> > +
> > +# pull in __syscall_error routine
> > +libpthread-routines += sysdep
> > +librt-routines += sysdep

Also, I don't think these are needed.  I don't see them on new ports.

I think its after moving libpthread and librt into libc.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/configure b/sysdeps/unix/sysv/linux/or1k/configure
> > new file mode 100644
> > index 0000000000..5225dfea5b
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/configure
> > @@ -0,0 +1,4 @@
> > +# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
> > + # Local configure fragment for sysdeps/unix/sysv/linux/or1k.
> > +
> > +arch_minimum_kernel=5.4.0
> > diff --git a/sysdeps/unix/sysv/linux/or1k/configure.ac b/sysdeps/unix/sysv/linux/or1k/configure.ac
> > new file mode 100644
> > index 0000000000..6274c4fb02
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/configure.ac
> > @@ -0,0 +1,4 @@
> > +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> > +# Local configure fragment for sysdeps/unix/sysv/linux/or1k.
> > +
> > +arch_minimum_kernel=5.4.0
> > diff --git a/sysdeps/unix/sysv/linux/or1k/shlib-versions b/sysdeps/unix/sysv/linux/or1k/shlib-versions
> > new file mode 100644
> > index 0000000000..159653b5c4
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/shlib-versions
> > @@ -0,0 +1,2 @@
> > +DEFAULT                 GLIBC_2.35
> > +ld=ld-linux-or1k.so.1

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 10/13] or1k: ABI lists
  2021-12-22 20:20   ` Adhemerval Zanella
@ 2021-12-23  8:36     ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-23  8:36 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Florian Weimer, Openrisc

On Wed, Dec 22, 2021 at 05:20:10PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> 
> > diff --git a/sysdeps/unix/sysv/linux/or1k/ld.abilist b/sysdeps/unix/sysv/linux/or1k/ld.abilist
> > new file mode 100644
> > index 0000000000..c4b85c8a33
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/ld.abilist
> > @@ -0,0 +1,5 @@
> > +GLIBC_2.35 __libc_stack_end D 0x4
> > +GLIBC_2.35 __stack_chk_guard D 0x4
> > +GLIBC_2.35 __tls_get_addr F
> > +GLIBC_2.35 _dl_mcount F
> > +GLIBC_2.35 _r_debug D 0x14
> 
> You will need to regenerate it to include the rseq symbols:
> 
> GLIBC_2.35 __rseq_flags D 0x4
> GLIBC_2.35 __rseq_offset D 0x4
> GLIBC_2.35 __rseq_size D 0x4

OK, I will regenerate, this patch series was generated from before
these symbols were introduced.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist b/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
> > new file mode 100644
> > index 0000000000..366c393274
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/libBrokenLocale.abilist
> > @@ -0,0 +1 @@
> > +GLIBC_2.35 __ctype_get_mb_cur_max F
> > diff --git a/sysdeps/unix/sysv/linux/or1k/libanl.abilist b/sysdeps/unix/sysv/linux/or1k/libanl.abilist
> > new file mode 100644
> > index 0000000000..c6437809db
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/libanl.abilist
> > @@ -0,0 +1 @@
> > +GLIBC_2.35 __libanl_version_placeholder F
> 
> This does seems right, or1k should not require the placeholder.  I think
> we are missing a SHLIB_COMPAT on resolv/libanl-compat.c:
> 
> diff --git a/resolv/libanl-compat.c b/resolv/libanl-compat.c
> index 29df76f278..02c18bde90 100644
> --- a/resolv/libanl-compat.c
> +++ b/resolv/libanl-compat.c
> @@ -30,6 +30,8 @@ __libanl_version_placeholder_1 (void)
>  {
>  }
>  
> +# if SHLIB_COMPAT (libanl, GLIBC_2_2_3, GLIBC_2_34)
>  compat_symbol (libanl, __libanl_version_placeholder_1,
>                 __libanl_version_placeholder, GLIBC_2_2_3);
> +# endif
>  #endif

I confirm this fixes the issue.

> > diff --git a/sysdeps/unix/sysv/linux/or1k/libutil.abilist b/sysdeps/unix/sysv/linux/or1k/libutil.abilist
> > new file mode 100644
> > index 0000000000..f33b84813b
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/or1k/libutil.abilist
> > @@ -0,0 +1 @@
> > +GLIBC_2.35 __libutil_version_placeholder F
> 
> This also does not seems right, libutil-compat will only built for
> have-GLIBC_2.33, which is not the case.

I think this file is leftover now that libutil is just an libutil.a
update-abi generates nothing.

I have just deleted the file.  check-abi seems to work ok.

Note, I aldo delete the other blank abilist files. So:

        deleted:    sysdeps/unix/sysv/linux/or1k/libanl.abilist
        deleted:    sysdeps/unix/sysv/linux/or1k/libdl.abilist
        deleted:    sysdeps/unix/sysv/linux/or1k/libpthread.abilist
        deleted:    sysdeps/unix/sysv/linux/or1k/librt.abilist
        deleted:    sysdeps/unix/sysv/linux/or1k/libutil.abilist

-Stafford

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 13/13] Documentation for OpenRISC port
  2021-12-10 23:34 ` [PATCH v3 13/13] Documentation for OpenRISC port Stafford Horne
@ 2021-12-23 12:57   ` Adhemerval Zanella
  0 siblings, 0 replies; 61+ messages in thread
From: Adhemerval Zanella @ 2021-12-23 12:57 UTC (permalink / raw)
  To: Stafford Horne, GLIBC patches; +Cc: Openrisc



On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> OpenRISC architecture specification:
> 
>  https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf
> 
> Currently the port as of the 2021-12-07 rebasing has the following test
> failures:
> 
>  FAIL: timezone/tst-tzset     # Not enough space to create 4GiB file
>  FAIL: elf/tst-bz15311        # dynamic ld sort order diff
> 
> Writing credits for the port are:
> 
>  Stafford Horne  <shorne@gmail.com>
>  Christian Svensson  <blue@cmd.nu>> ---
>  NEWS   | 4 ++++
>  README | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/NEWS b/NEWS
> index 1398cf2e87..f896746574 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -485,6 +485,10 @@ Major new features:
>    The latest GCC available at this time (10.2) does not support this level of
>    fortification.
>  
> +* Support for OpenRISC on Linux has been added.

I think it would be useful to add only soft-float is currently supported.

> +
> +  The OpenRISC pore requires at least Linux 5.4, GCC 11 and binutils 2.35.
> +>  Deprecated and removed features, and other changes affecting compatibility:
>  
>  * The mallinfo function is marked deprecated.  Callers should call
> diff --git a/README b/README
> index d0f0edb393..3d5a78ccff 100644
> --- a/README
> +++ b/README
> @@ -35,6 +35,7 @@ The GNU C Library supports these configurations for using Linux kernels:
>  	microblaze*-*-linux-gnu
>  	mips-*-linux-gnu
>  	mips64-*-linux-gnu
> +	or1k-*-linux-gnu
>  	powerpc-*-linux-gnu	Hardware or software floating point, BE only.
>  	powerpc64*-*-linux-gnu	Big-endian and little-endian.
>  	s390-*-linux-gnu

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-15  5:37   ` Stafford Horne
@ 2021-12-23 15:46     ` Stafford Horne
  2021-12-23 15:57       ` Andreas Schwab
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-23 15:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches, Openrisc

On Wed, Dec 15, 2021 at 02:37:23PM +0900, Stafford Horne wrote:
> On Tue, Dec 14, 2021 at 05:25:09PM -0300, Adhemerval Zanella wrote:
> > 
> > 
> > On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote:
> > > This is the OpenRISC port for glibc that I have been working on.
> > > 
> > > Changes since v2:
> > >  - Fixed suggestions from Joseph Myers:
> > >    - Fix comment style, and description on top of each file
> > >    - Make sure macros have parentheses when needed,
> > >    - Bump required kernel down to 5.4.0 and document
> > >    - Regenerate arch-syscall.h
> > >  - Fixed suggestions from Adhemerval:
> > >    - Remove kernel_stat.h
> > >    - Just set MMAP2_PAGE_UNIT to 8K
> > >    - Remove ioctl.c and syscall.c files
> > >  - Update TCB alignment to 32 bytes
> > > 
> > > Changes since v1:
> > >  - Update api's as suggested by Florian
> > >  - Remove hard float support
> > >  - Updates to get all tests passing
> > >  - Split patch into managable bits similar to recent ARC port
> > > 
> > > Documentation:
> > > 
> > >   Architecture / ABI docs:
> > >    https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf
> > > 
> > > Test Results:
> > > 
> > >   build-many-glibcs.py:
> > > 
> > >    PASS with mainline ang gcc-11.
> > > 
> > >   Full test suite:
> > > 
> > >    The full suite is running using the gcc-11 branch of GCC, mainline shows
> > >    issues with math soft-fp.
> > > 
> > >    Note, there are a few more failures compared to before, this is due to me
> > >    running with a timeout of 30 vs usual 300.  It allows the tests to complete
> > >    faster, but I get a few more timeouts.  There were 15 timeouts which I
> > >    confirm do work if I increase the timeoutfactor. The 2 real failures marked
> > >    with * below.
> > > 
> > >     # test start:    2021-12-08T19:59:00+09:00
> > > 
> > >     # failures
> > >     FAIL:*elf/tst-bz15311
> > 
> > This seems to be a real issue, the output shows the new sorting algorithm seems 
> > not be enabled (the output shows the destructor order for dynamic_sort=1).  We 
> > need to figure out what is happening here.
> >
> > >     FAIL: locale/tst-localedef-path-norm
> > >     FAIL: malloc/tst-dynarray-fail
> > >     FAIL: malloc/tst-dynarray-fail-mem
> > >     FAIL: nptl/tst-mutex10
> > >     FAIL: nss/tst-nss-files-hosts-getent
> > >     FAIL: nss/tst-nss-files-hosts-multi
> > >     FAIL: posix/tst-regcomp-truncated
> > >     FAIL: stdio-common/tst-vfprintf-width-prec
> > >     FAIL: stdio-common/tst-vfprintf-width-prec-alloc
> > >     FAIL: stdio-common/tst-vfprintf-width-prec-mem
> > >     FAIL: string/test-memcpy
> > >     FAIL: string/test-memcpy-large
> > >     FAIL: string/test-mempcpy
> > >     FAIL: string/tst-cmp
> > >     FAIL: support/tst-support_blob_repeat
> > >     FAIL:*timezone/tst-tzset
> > 
> > It seems the testing file system does not support sparse files or at least
> > has some limits of the file size and support_descriptor_supports_holes is
> > no deteting it.
> 
> Let me see if I can figure out the sparse file support.  If that can work
> then it would be good.  The filesystem I am using is:
> 
>  tmpfs on /tmp type tmpfs (rw,relatime)
> 
> > I think we should use a large write_offset and block_headroom, maybe
> > something larger than 32-bit offset to actually check it.  Could you
> > check if increasing both values does make the test unsupported.
> 
> I will check.

I looked into this, the following patch seems to help.  Below are some notes I was
keeping as I debugged it.

It seems the write to the tmp file was failing due the re-open not passing
O_LARGEFILE.  I am running with this patch now, and instead of failing it is
working on creating the file, but taking a long time.  I will let it run, but
need to step away now.

diff --git a/timezone/tst-tzset.c b/timezone/tst-tzset.c
index 3dad42e041..65633c4a25 100644
--- a/timezone/tst-tzset.c
+++ b/timezone/tst-tzset.c
@@ -44,7 +44,7 @@ create_tz_file (off64_t size)
 
   // Reopen for large-file support.
   close (fd);
-  fd = open64 (path, O_WRONLY);
+  fd = open64 (path, O_WRONLY|O_LARGEFILE);
   if (fd < 0)
     {
       printf ("open64 (%s) failed: %m\n", path);




Debugging

The patch below and notes are how I got to the conclusion.

  - tmsfs does support sparse files, but I am not able to write files larger
    than 4GiB.  But also as per below 2GiB seems to be a boundary.
  - We get an write error 'File too large'
  - Looking at ther kernel code I see two paths that generate this error
    but it doesn't look like I should be hitting them.
    * write size exceeds RLIMIT - though I have it set to unlimited
    * write size exceeds fs_maxbytes - on tmpfs sb->s_maxbytes = MAX_LFS_FILESIZE
                                       on 32-bit MAX_LFS_FILESIZE ((loff_t)ULONG_MAX << PAGE_SHIFT)
  - support_descriptor_supports_holes will not fail unless we run it on files
    re-opened with open64.
  - This is where I noticed that open64 was missing O_LARGEFILE.

Output with write_offset = 2LL * 1024 * 1024 * 1024 - 2;
    File size : 16 limit 160
    1x: File size : 32/2147483646 limit 160
    2x: File size : 32/4294967292 limit 160
    File size : 16 limit 160
    1x: File size : 32/2147483646 limit 160
    2x: File size : 32/4294967292 limit 160
    Single-byte write failed
    creating timezone file of size: 4095MiB failed.

Output with write_offset = 2LL * 1024 * 1024 * 1024 - 1;
    File size : 16 limit 160
    error: xwrite.c:32: write of 1 bytes failed after 0: File too large
    error: 1 test failures

Strace of running the patch, we see no O_LARGEFILE after re-open.

[pid 11318] openat(AT_FDCWD, "/tmp/tst-tzset-v0uEVn", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600) = 3
[pid 11318] getpid()                    = 11318
[pid 11318] close(3)                    = 0
[pid 11318] openat(AT_FDCWD, "/tmp/tst-tzset-v0uEVn", O_WRONLY) = 3
[pid 11318] statx(3, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
[pid 11318] _llseek(3, 0, [0], SEEK_SET) = 0
[pid 11318] write(3, "@", 1)            = 1
[pid 11318] fsync(3)                    = 0
[pid 11318] statx(3, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=1, ...}) = 0
[pid 11318] write(1, "File size : 16 limit 160\n", 25File size : 16 limit 160
) = 25
[pid 11318] _llseek(3, 2147483647, [2147483647], SEEK_SET) = 0
[pid 11318] write(3, "@", 1)            = -1 EFBIG (File too large)

diff --git a/support/support_descriptor_supports_holes.c b/support/support_descriptor_supports_holes.c
index 83bdcc71dc..46fdb6174a 100644
--- a/support/support_descriptor_supports_holes.c
+++ b/support/support_descriptor_supports_holes.c
@@ -31,15 +31,17 @@ support_descriptor_supports_holes (int fd)
          and hopefully large enough to trigger the creation of holes.
          We cannot use the file system block size as a reference here
          because it is incorrect for network file systems.  */
-      write_offset = 16 * 1024 * 1024,
+  //    write_offset = 125 * 1024 * 1024,
 
       /* Our write may add this number of additional blocks (see
          block_limit below): writing at offset 16M can require two data block
          indirections, each of which can be as large as 8KB on ext2, thus 32
          512B sectors.  */
-      block_headroom = 32,
+      block_headroom = 128,
     };
 
+  unsigned long long int write_offset = 2LL * 1024 * 1024 * 1024 - 1;
+
   struct stat64 st;
   xfstat (fd, &st);
   if (!S_ISREG (st.st_mode))
@@ -66,6 +68,7 @@ support_descriptor_supports_holes (int fd)
      the write offset.  */
   unsigned long long int block_limit = 2 * st.st_blocks + block_headroom;
 
+printf ("File size : %lld limit %lld\n", (long long int) st.st_blocks, block_limit);
   /* Write a single byte at 16 megabytes.  */
   xlseek (fd, write_offset, SEEK_SET);
   xwrite (fd, &b, 1);
@@ -74,6 +77,8 @@ support_descriptor_supports_holes (int fd)
   xfstat (fd, &st);
   bool supports_holes = st.st_blocks <= block_limit;
 
+printf ("1x: File size : %lld/%lld limit %lld\n", (long long int) st.st_blocks, write_offset, block_limit);
+
   /* Also check that extending the file does not fill up holes.  */
   xftruncate (fd, 2 * write_offset);
   /* Attempt to bypass delayed allocation.  */
@@ -81,6 +86,8 @@ support_descriptor_supports_holes (int fd)
   xfstat (fd, &st);
   supports_holes = supports_holes && st.st_blocks <= block_limit;
 
+printf ("2x: File size : %lld/%lld limit %lld\n", (long long int) st.st_blocks, 2 * write_offset, block_limit);
+
   /* Return to a zero-length file.  */
   xftruncate (fd, 0);
   xlseek (fd, 0, SEEK_SET);
diff --git a/timezone/tst-tzset.c b/timezone/tst-tzset.c
index 3dad42e041..0fa06f7206 100644
--- a/timezone/tst-tzset.c
+++ b/timezone/tst-tzset.c
@@ -39,8 +39,6 @@ create_tz_file (off64_t size)
   int fd = create_temp_file ("tst-tzset-", &path);
   if (fd < 0)
     exit (1);
-  if (!support_descriptor_supports_holes (fd))
-    FAIL_UNSUPPORTED ("File %s does not support holes", path);
 
   // Reopen for large-file support.
   close (fd);
@@ -51,6 +49,9 @@ create_tz_file (off64_t size)
       exit (1);
     }
 
+  if (!support_descriptor_supports_holes (fd))
+    FAIL_UNSUPPORTED ("File %s does not support holes", path);
+
   static const char data[] = {
     0x54, 0x5a, 0x69, 0x66, 0x32, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-23 15:46     ` Stafford Horne
@ 2021-12-23 15:57       ` Andreas Schwab
  2021-12-23 21:26         ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Andreas Schwab @ 2021-12-23 15:57 UTC (permalink / raw)
  To: Stafford Horne via Libc-alpha
  Cc: Adhemerval Zanella, Stafford Horne, Openrisc

On Dez 24 2021, Stafford Horne via Libc-alpha wrote:

> It seems the write to the tmp file was failing due the re-open not passing
> O_LARGEFILE.

open64 implies O_LARGEFILE, so if that is making a difference, then your
open64 is broken.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-23 15:57       ` Andreas Schwab
@ 2021-12-23 21:26         ` Stafford Horne
  2021-12-25  7:24           ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-23 21:26 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Stafford Horne via Libc-alpha, Adhemerval Zanella, Openrisc

On Thu, Dec 23, 2021 at 04:57:56PM +0100, Andreas Schwab wrote:
> On Dez 24 2021, Stafford Horne via Libc-alpha wrote:
> 
> > It seems the write to the tmp file was failing due the re-open not passing
> > O_LARGEFILE.
> 
> open64 implies O_LARGEFILE, so if that is making a difference, then your
> open64 is broken.

Right, that is what the docs say.  This architecuture is 32-bits.

And the open64 path is generic.

Possibly this bit removing O_LARGEFILE is wrong?

In sysdeps/unix/sysv/linux/open64.c:

  27 #ifdef __OFF_T_MATCHES_OFF64_T
  28 # define EXTRA_OPEN_FLAGS 0
  29 #else
  30 # define EXTRA_OPEN_FLAGS O_LARGEFILE
  31 #endif

Otherwise there is something is wrong on linux.  It is explicitly checking
for the precense of O_LARGEFILE.

in fs/read_write.c in generic_write_check_limits:

        if (!(file->f_flags & O_LARGEFILE))
                max_size = MAX_NON_LFS;

> -- 
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-23 21:26         ` Stafford Horne
@ 2021-12-25  7:24           ` Stafford Horne
  2021-12-25 22:44             ` Stafford Horne
  0 siblings, 1 reply; 61+ messages in thread
From: Stafford Horne @ 2021-12-25  7:24 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Stafford Horne via Libc-alpha, Adhemerval Zanella, Openrisc

On Fri, Dec 24, 2021, 6:26 AM Stafford Horne <shorne@gmail.com> wrote:

> On Thu, Dec 23, 2021 at 04:57:56PM +0100, Andreas Schwab wrote:
> > On Dez 24 2021, Stafford Horne via Libc-alpha wrote:
> >
> > > It seems the write to the tmp file was failing due the re-open not
> passing
> > > O_LARGEFILE.
> >
> > open64 implies O_LARGEFILE, so if that is making a difference, then your
> > open64 is broken.
>
> Right, that is what the docs say.  This architecuture is 32-bits.
>
> And the open64 path is generic.
>
> Possibly this bit removing O_LARGEFILE is wrong?
>
> In sysdeps/unix/sysv/linux/open64.c:
>
>   27 #ifdef __OFF_T_MATCHES_OFF64_T
>   28 # define EXTRA_OPEN_FLAGS 0
>   29 #else
>   30 # define EXTRA_OPEN_FLAGS O_LARGEFILE
>   31 #endif
>
> Otherwise there is something is wrong on linux.  It is explicitly checking
> for the precense of O_LARGEFILE.
>
> in fs/read_write.c in generic_write_check_limits:
>
>         if (!(file->f_flags & O_LARGEFILE))
>                 max_size = MAX_NON_LFS;
>

There's something wrong with __OFF_T_MATCHES_OFF64_T in this port.  We have
32-bit off_t in Linux.  So __OFF_T_MATCHES_OFF64_T should be undefined I
think.  I'll look into.

-Stafford

>

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PATCH v3 00/13] Glibc OpenRISC port
  2021-12-25  7:24           ` Stafford Horne
@ 2021-12-25 22:44             ` Stafford Horne
  0 siblings, 0 replies; 61+ messages in thread
From: Stafford Horne @ 2021-12-25 22:44 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Stafford Horne via Libc-alpha, Adhemerval Zanella, Openrisc

On Sat, Dec 25, 2021 at 04:24:35PM +0900, Stafford Horne wrote:
> On Fri, Dec 24, 2021, 6:26 AM Stafford Horne <shorne@gmail.com> wrote:
> 
> > On Thu, Dec 23, 2021 at 04:57:56PM +0100, Andreas Schwab wrote:
> > > On Dez 24 2021, Stafford Horne via Libc-alpha wrote:
> > >
> > > > It seems the write to the tmp file was failing due the re-open not
> > passing
> > > > O_LARGEFILE.
> > >
> > > open64 implies O_LARGEFILE, so if that is making a difference, then your
> > > open64 is broken.
> >
> > Right, that is what the docs say.  This architecuture is 32-bits.
> >
> > And the open64 path is generic.
> >
> > Possibly this bit removing O_LARGEFILE is wrong?
> >
> > In sysdeps/unix/sysv/linux/open64.c:
> >
> >   27 #ifdef __OFF_T_MATCHES_OFF64_T
> >   28 # define EXTRA_OPEN_FLAGS 0
> >   29 #else
> >   30 # define EXTRA_OPEN_FLAGS O_LARGEFILE
> >   31 #endif
> >
> > Otherwise there is something is wrong on linux.  It is explicitly checking
> > for the precense of O_LARGEFILE.
> >
> > in fs/read_write.c in generic_write_check_limits:
> >
> >         if (!(file->f_flags & O_LARGEFILE))
> >                 max_size = MAX_NON_LFS;
> >
> 
> There's something wrong with __OFF_T_MATCHES_OFF64_T in this port.  We have
> 32-bit off_t in Linux.  So __OFF_T_MATCHES_OFF64_T should be undefined I
> think.  I'll look into.

So, __OFF_T_MATCHES_OFF64_T if defined if TIMESIZE==64 && WORDSIZE==32, and it's
correct from glibc's perspective as off_t is 64-bits in the user API.  However,
it is not correct for use for setting O_LARGEFILE.

In linux the O_LARGEFILE flag is forced based on architecture configuration
ARCH_32BIT_OFF_T.

    #define force_o_largefile() (!IS_ENABLED(CONFIG_ARCH_32BIT_OFF_T))

Then it is used in syscalls:

    SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
		    umode_t, mode)
    {
	    if (force_o_largefile())
		    flags |= O_LARGEFILE;
	    return do_sys_open(dfd, filename, flags, mode);
    }

On most 32-bit architectures ARCH_32BIT_OFF_T is configured.  SO I think there
is something wrong with how we are setting up EXTRA_OPEN_FLAGS based on
__OFF_T_MATCHES_OFF64_T only.  Maybe it should be changed to WORDSIZE==32 or a
combination.  I will send a separate patch to discuss.

-Stafford

^ permalink raw reply	[flat|nested] 61+ messages in thread

end of thread, other threads:[~2021-12-25 22:44 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 23:34 [PATCH v3 00/13] Glibc OpenRISC port Stafford Horne
2021-12-10 23:34 ` [PATCH v3 01/13] elf: Add reloc for OpenRISC Stafford Horne
2021-12-14 20:28   ` Adhemerval Zanella
2021-12-10 23:34 ` [PATCH v3 02/13] linux/syscalls: Add or1k_atomic syscall " Stafford Horne
2021-12-14 20:29   ` Adhemerval Zanella
2021-12-10 23:34 ` [PATCH v3 03/13] or1k: ABI Implementation Stafford Horne
2021-12-14 20:53   ` Adhemerval Zanella
2021-12-14 22:43     ` Joseph Myers
2021-12-15  1:15       ` Adhemerval Zanella
2021-12-15 23:33         ` Stafford Horne
2021-12-16 10:30           ` Adhemerval Zanella
2021-12-16 21:28     ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 04/13] or1k: startup and dynamic linking code Stafford Horne
2021-12-16 10:42   ` Adhemerval Zanella
2021-12-17 23:03     ` Stafford Horne
2021-12-20 19:45       ` Adhemerval Zanella
2021-12-20 21:40         ` Stafford Horne
2021-12-21 11:09           ` Adhemerval Zanella
2021-12-21 11:46             ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 05/13] or1k: Thread Local Storage support Stafford Horne
2021-12-16 11:35   ` Adhemerval Zanella
2021-12-16 12:37   ` Adhemerval Zanella
2021-12-16 19:26     ` Joseph Myers
2021-12-16 19:33       ` Adhemerval Zanella
2021-12-17 14:23     ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 06/13] or1k: Atomics and Locking primitives Stafford Horne
2021-12-16 12:52   ` Adhemerval Zanella
2021-12-16 19:43     ` Adhemerval Zanella
2021-12-17 15:03       ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 07/13] or1k: math soft float support Stafford Horne
2021-12-16 19:48   ` Adhemerval Zanella
2021-12-17 15:02     ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 08/13] or1k: Linux Syscall Interface Stafford Horne
2021-12-16 21:17   ` Adhemerval Zanella
2021-12-17 15:01     ` Stafford Horne
2021-12-17 17:41       ` Adhemerval Zanella
2021-12-20 11:53         ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 09/13] or1k: Linux ABI Stafford Horne
2021-12-21 13:41   ` Adhemerval Zanella
2021-12-21 14:54     ` Stafford Horne
2021-12-22 10:54       ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 10/13] or1k: ABI lists Stafford Horne
2021-12-22 20:20   ` Adhemerval Zanella
2021-12-23  8:36     ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 11/13] or1k: Build Infrastructure Stafford Horne
2021-12-22 21:03   ` Adhemerval Zanella
2021-12-23  7:32     ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 12/13] build-many-glibcs.py: add OpenRISC support Stafford Horne
2021-12-22 21:04   ` Adhemerval Zanella
2021-12-23  7:15     ` Stafford Horne
2021-12-10 23:34 ` [PATCH v3 13/13] Documentation for OpenRISC port Stafford Horne
2021-12-23 12:57   ` Adhemerval Zanella
2021-12-14 20:25 ` [PATCH v3 00/13] Glibc " Adhemerval Zanella
2021-12-15  1:19   ` Adhemerval Zanella
2021-12-15  5:34     ` Stafford Horne
2021-12-15  5:37   ` Stafford Horne
2021-12-23 15:46     ` Stafford Horne
2021-12-23 15:57       ` Andreas Schwab
2021-12-23 21:26         ` Stafford Horne
2021-12-25  7:24           ` Stafford Horne
2021-12-25 22:44             ` Stafford Horne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).