public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/14] GLIBC LoongArch PATCHES
@ 2021-12-31  6:44 caiyinyu
  2021-12-31  6:44 ` [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
                   ` (15 more replies)
  0 siblings, 16 replies; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

Hello, the answers are as follows, and we really need your futher suggestions:

LoongArch patches v1: https://sourceware.org/pipermail/libc-alpha/2021-August/130262.html

1. Is there ABI documentation for the function-calling ABI?  The ELF ABI
document you link to says essentially nothing about that.

LoongArch-Doc:  https://github.com/loongson/LoongArch-Documentation

We add new section: procedure calling convention.
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_procedure_calling_convention

2. Please provide details of the test results for the port with the glibc
testsuite and the binutils / GCC / Linux kernel ports as submitted
upstream (the exact versions of those components proposed for upstream,
not some other version).  You might need to work around some of the issues
currently present building glibc with GCC mainline; if so, please state
the exact patches you are using for that workaround on top of the proposed
port version (you might need to use
<https://sourceware.org/pipermail/libc-alpha/2021-August/130244.html>, for
example).  It's required that the compilation parts of the testsuite must
have fully clean results.  For any test failures in the rest of the
testsuite, make the .out and .test-result files available, along with any
analysis you have done of why those tests are failing.

Source code:
linux:		https://github.com/loongson/linux/tree/loongarch-next
binutils:     	https://github.com/loongson/binutils-gdb/tree/upstream_v3.1
glibc:	      	https://github.com/loongson/glibc/tree/loongarch_2_34_for_upstream_v2.0
gcc:	      	https://github.com/loongson/gcc/tree/loongarch_upstream_v4

test result:

a.
XPASS: conform/UNIX98/ndbm.h/linknamespace
XPASS: conform/XOPEN2K/ndbm.h/linknamespace
XPASS: conform/XOPEN2K8/ndbm.h/linknamespace
XPASS: conform/XPG42/ndbm.h/linknamespace
UNSUPPORTED: crypt/cert
FAIL: elf/ifuncmain1
FAIL: elf/ifuncmain1pic
FAIL: elf/ifuncmain1pie
FAIL: elf/ifuncmain1staticpic
FAIL: elf/ifuncmain1staticpie
FAIL: elf/ifuncmain1vis
FAIL: elf/ifuncmain1vispic
FAIL: elf/ifuncmain1vispie
FAIL: elf/ifuncmain3
FAIL: elf/ifuncmain4
FAIL: elf/ifuncmain6pie
FAIL: elf/ifuncmain7
FAIL: elf/ifuncmain7pic
FAIL: elf/ifuncmain7pie
UNSUPPORTED: elf/tst-env-setuid
UNSUPPORTED: elf/tst-env-setuid-tunables
FAIL: elf/tst-ifunc-fault-bindnow
FAIL: elf/tst-ifunc-fault-lazy
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
FAIL: math/test-double-acos
FAIL: math/test-double-asin
FAIL: math/test-float32x-acos
FAIL: math/test-float32x-asin
FAIL: math/test-float64-acos
FAIL: math/test-float64-asin
UNSUPPORTED: misc/tst-adjtimex
UNSUPPORTED: misc/tst-clock_adjtime
UNSUPPORTED: misc/tst-ntp_adjtime
UNSUPPORTED: misc/tst-pkey
UNSUPPORTED: misc/tst-rseq
UNSUPPORTED: misc/tst-rseq-disable
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
UNSUPPORTED: nptl/tst-rseq-nptl
UNSUPPORTED: stdlib/tst-secure-getenv
UNSUPPORTED: time/tst-clock_settime
UNSUPPORTED: time/tst-settimeofday
Summary of test results:
     22 FAIL
   4488 PASS
     19 UNSUPPORTED
     12 XFAIL
      6 XPASS

b.
FAIL: elf/ifuncmain1
FAIL: elf/ifuncmain1pic
FAIL: elf/ifuncmain1pie
FAIL: elf/ifuncmain1staticpic
FAIL: elf/ifuncmain1staticpie
FAIL: elf/ifuncmain1vis
FAIL: elf/ifuncmain1vispic
FAIL: elf/ifuncmain1vispie
FAIL: elf/ifuncmain3
FAIL: elf/ifuncmain4
FAIL: elf/ifuncmain6pie
FAIL: elf/ifuncmain7
FAIL: elf/ifuncmain7pic
FAIL: elf/ifuncmain7pie
FAIL: elf/tst-ifunc-fault-bindnow
FAIL: elf/tst-ifunc-fault-lazy

ifunc functions are not support yet

c.
FAIL: math/test-double-acos
FAIL: math/test-double-asin
FAIL: math/test-float32x-acos
FAIL: math/test-float32x-asin
FAIL: math/test-float64-acos
FAIL: math/test-float64-asin

These fails are caused by gcc optimizations. if we use -O0 options, these fails
will pass.

sysdeps/ieee754/dbl-64/e_asin.c: 343
===================================================================
337	  if (k>0x7ff00000 || (k == 0x7ff00000 && u.i[LOW_HALF] != 0)) return x + x;
   0x00007ffff7f4daac <+1388>:	lu12i.w     	$t0, 524032(0x7ff00)
   0x00007ffff7f4dab0 <+1392>:	blt         	$t0, $t2, 20(0x14)	# 0x7ffff7f4dac4 <__ieee754_acos+1412>
   0x00007ffff7f4dab4 <+1396>:	bne         	$t2, $t0, 36(0x24)	# 0x7ffff7f4dad8 <__ieee754_acos+1432>
   0x00007ffff7f4dab8 <+1400>:	ld.d        	$t0, $sp, 8(0x8)
   0x00007ffff7f4dabc <+1404>:	slli.w      	$t0, $t0, 0x0
   0x00007ffff7f4dac0 <+1408>:	beqz        	$t0, 24(0x18)	# 0x7ffff7f4dad8 <__ieee754_acos+1432>
   0x00007ffff7f4dac4 <+1412>:	fld.d       	$fa0, $sp, 8(0x8)
   0x00007ffff7f4dac8 <+1416>:	fadd.d      	$fa0, $fa0, $fa0
   0x00007ffff7f4dacc <+1420>:	b           	-788(0xffffcec)	# 0x7ffff7f4d7b8 <__ieee754_acos+632>

338	  else {
339	    u.i[HIGH_HALF]=0x7ff00000;
340	    v.i[HIGH_HALF]=0x7ff00000;
341	    u.i[LOW_HALF]=0;
342	    v.i[LOW_HALF]=0;
343	    return u.x/v.x;			/////////  optimized out

   0x00007ffff7f4dad8 <+1432>:	pcaddu12i   	$t0, 63(0x3f)
   0x00007ffff7f4dadc <+1436>:	addi.d      	$t0, $t0, -1248(0xb20)
   0x00007ffff7f4dae0 <+1440>:	fld.d       	$fa0, $t0, 0
   0x00007ffff7f4dae4 <+1444>:	b           	-812(0xffffcd4)	# 0x7ffff7f4d7b8 <__ieee754_acos+632>

344	  }
345	}
   0x00007ffff7f4d7b8 <+632>:	addi.d      	$sp, $sp, 16(0x10)
   0x00007ffff7f4d7bc <+636>:	jirl        	$zero, $ra, 0
   0x00007ffff7f4d7cc <+652>:	addi.d      	$sp, $sp, 16(0x10)
   0x00007ffff7f4d7d0 <+656>:	jirl        	$zero, $ra, 0
   0x00007ffff7f4d8bc <+892>:	addi.d      	$sp, $sp, 16(0x10)
   0x00007ffff7f4d8c0 <+896>:	jirl        	$zero, $ra, 0
===================================================================


3. I see there's an upstream submission (not yet committed upstream) of
QEMU support for LoongArch, could you describe the status of that?  (See
"There is no requirement for a CPU simulator (free software, e.g. QEMU, or
otherwise) to be available, but if one is available, it is useful to
mention in the summary message (along with any information on available OS
etc. that might help people set up an environment for testing things about
the port)." on the NewPorts page.)

We are donating machine to the GCC Compile Farm Project

4. What ABIs are supported for the port?  You mention 32-bit doesn't work
(so it would be best to remove that code until it's ready), so only 64-bit
ABIs are supported.  Is a soft-float ABI supported, or only hard-float?
You have __loongarch_soft_float or __loongarch_hard_float conditionals in
some places, but other things suggest only hard float is supported (the
lack of any with_fp_cond definition in your preconfigure fragment, in
particular).  Apart from conventional 32-bit and 64-bit ABIs, there's the
question of whether you have or intend to have an ILP32 ABI that uses
64-bit registers and the 64-bit instruction set (like x32 for x86_64);
there's no need to have such an ABI, but if you do plan to have one, you
need to be very careful about what you mean when you say "32-bit" or
"64-bit", to make it clear whether such an ILP32 ABI is included or not.
add loongarch 5. There needs to be at least one entry added to build-many-glibcs.py for
each ABI supported by the port.

Now we only support 64-bit hard-float ABI.

6. You're making local changes to config.sub and config.guess.  Don't do
that; the latest versions from config.git should be imported instead, with
no local changes, outside of the patch series adding the port.

corrected

7. This patch series is missing NEWS and README updates.

corrected

8. We don't use "Contributed by" any more in new source files.  You can
put such information in the NEWS entry for the addition of the port, and
in contrib.texi (the latter listing relevant individuals, not companies),
instead.

corrected

9. Note that new source files should have a one-line description above the
copyright notice.

corrected

10. Note the need for a manual/math.texi update in the list of
configurations supporting _Float128.

not support yet

11. Florian has already noted that GLIBC_2.35 should be the minimum ABI
version for the port.  This has other implications beyond the DEFAULT
setting in shlib-versions.  You're adding some entries to
sysdeps/unix/sysv/linux/loongarch/Versions with old symbol versions; those
should not be present (some of the GLIBC_2.0 entries are for libgcc
functions only relevant for extremely old glibc ports).  If you need any
Versions entries at all, they should be either GLIBC_PRIVATE or
GLIBC_2.35, and you should be able to give an explicit justification for
why such an entry is needed (i.e. the function would not be exported at
all without the entry, and either is part of the architecture-independent
glibc API, or is needed as an architecture-specific function or a
GLIBC_PRIVATE function).

corrected

12. For each ABI supported by the port (see point 4 above) you need a
unique dynamic linker name (not used by any existing ABI listed at
<https://sourceware.org/glibc/wiki/ABIList>; probably mentioning the
architecture name somewhere in the dynamic linker name), as specified with
ld= in shlib-versions.  You have an ldd_rewrite_script setting that only
makes sense with such names (and only makes sense when multiple ABIs are
supported in the same root filesystem, see
<https://sourceware.org/legacy-ml/libc-alpas specified with
ld= in shlib-versionsha/2018-01/msg00008.html> for
more details of what's needed for such support), but I don't see anything
to actually implement such names.  Note the need for the dynamic linker
names to be consistent in GCC and glibc.

corrected

13. arch_minimum_kernel should be set to 10.0.0 until the actual upstream
kernel version that gets the port is known, and then to the actual
upstream version (so 5.14.0 or later).  Accordingly, kernel-features.h
should not have any "before 4.20" conditionals in it (so you don't need an
architecture-specific kernel-features.h at all).

corrected

14. Regarding the optimized functions in patches 12 to 14, see the last
point on the NewPorts page regarding considering carefully (possibly with
benchmarking) whether such functions are actually beneficial compared to
the current generic C versions - and, if beneficial compared to the
current generic C versions, whether helping to get the improved generic
functions linked from that page into glibc would avoid the need for some
or all of the architecture-specific implementations.

optimized function string/memset/memcpy/memmove/sinf/cosf removed


Source code:
LoongArch-Doc:	https://github.com/loongson/LoongArch-Documentation
linux:		https://github.com/loongson/linux/tree/loongarch-next
binutils:     	https://github.com/loongson/binutils-gdb/tree/upstream_v3.1
glibc:	      	https://github.com/loongson/glibc/tree/loongarch_2_34_for_upstream_v2.0
gcc:	      	https://github.com/loongson/gcc/tree/loongarch_upstream_v4


caiyinyu (14):
  LoongArch: Update NEWS and README for the LoongArch port.
  LoongArch: Add LoongArch entries to config.h.in
  LoongArch: Add relocations and ELF flags to elf.h
  LoongArch: ABI Implementation
  LoongArch: Thread-Local Storage Support
  LoongArch: Generic <math.h> and soft-fp Routines
  LoongArch: Atomic and Locking Routines
  LoongArch: Linux Syscall Interface
  LoongArch: Linux ABI
  LoongArch: Linux Startup and Dynamic Loading Code
  LoongArch: Add ABI Lists
  LoongArch: Build Infastructure
  LoongArch: Hard Float Support
  LoongArch: Update build-many-glibcs.py for the LoongArch Port.

 NEWS                                          |    2 +
 README                                        |    1 +
 config.h.in                                   |    6 +
 elf/elf.h                                     |   72 +-
 scripts/build-many-glibcs.py                  |    5 +
 sysdeps/loongarch/Implies                     |    5 +
 sysdeps/loongarch/Makefile                    |   15 +
 sysdeps/loongarch/__longjmp.S                 |   52 +
 sysdeps/loongarch/abort-instr.h               |    2 +
 sysdeps/loongarch/bits/endianness.h           |   11 +
 sysdeps/loongarch/bits/fenv.h                 |   90 +
 sysdeps/loongarch/bits/link.h                 |   58 +
 sysdeps/loongarch/bits/setjmp.h               |   42 +
 sysdeps/loongarch/bits/wordsize.h             |   25 +
 sysdeps/loongarch/bsd-_setjmp.c               |    1 +
 sysdeps/loongarch/bsd-setjmp.c                |    1 +
 sysdeps/loongarch/configure                   |    4 +
 sysdeps/loongarch/configure.ac                |    6 +
 sysdeps/loongarch/dl-irel.h                   |   48 +
 sysdeps/loongarch/dl-machine.h                |  368 +++
 sysdeps/loongarch/dl-tls.h                    |   46 +
 sysdeps/loongarch/dl-trampoline.S             |  103 +
 sysdeps/loongarch/e_sqrtl.c                   |   38 +
 sysdeps/loongarch/fpu/e_sqrt.c                |   26 +
 sysdeps/loongarch/fpu/e_sqrtf.c               |   26 +
 sysdeps/loongarch/fpu/fclrexcpt.c             |   46 +
 sysdeps/loongarch/fpu/fedisblxcpt.c           |   39 +
 sysdeps/loongarch/fpu/feenablxcpt.c           |   39 +
 sysdeps/loongarch/fpu/fegetenv.c              |   31 +
 sysdeps/loongarch/fpu/fegetexcept.c           |   32 +
 sysdeps/loongarch/fpu/fegetmode.c             |   27 +
 sysdeps/loongarch/fpu/fegetround.c            |   33 +
 sysdeps/loongarch/fpu/feholdexcpt.c           |   40 +
 sysdeps/loongarch/fpu/fenv_libc.h             |   30 +
 sysdeps/loongarch/fpu/fesetenv.c              |   42 +
 sysdeps/loongarch/fpu/fesetexcept.c           |   32 +
 sysdeps/loongarch/fpu/fesetmode.c             |   38 +
 sysdeps/loongarch/fpu/fesetround.c            |   44 +
 sysdeps/loongarch/fpu/feupdateenv.c           |   43 +
 sysdeps/loongarch/fpu/fgetexcptflg.c          |   38 +
 sysdeps/loongarch/fpu/fraiseexcpt.c           |   75 +
 sysdeps/loongarch/fpu/fsetexcptflg.c          |   41 +
 sysdeps/loongarch/fpu/ftestexcept.c           |   32 +
 sysdeps/loongarch/fpu_control.h               |  102 +
 sysdeps/loongarch/gccframe.h                  |   21 +
 sysdeps/loongarch/hp-timing.h                 |   42 +
 sysdeps/loongarch/jmpbuf-offsets.h            |   22 +
 sysdeps/loongarch/jmpbuf-unwind.h             |   45 +
 sysdeps/loongarch/ldsodefs.h                  |   41 +
 sysdeps/loongarch/libc-start.h                |   25 +
 sysdeps/loongarch/libc-tls.c                  |   32 +
 sysdeps/loongarch/linkmap.h                   |    4 +
 sysdeps/loongarch/lp64/Implies-after          |    1 +
 sysdeps/loongarch/lp64/libm-test-ulps         | 1411 +++++++++++
 sysdeps/loongarch/lp64/libm-test-ulps-name    |    1 +
 sysdeps/loongarch/machine-gmon.h              |   37 +
 sysdeps/loongarch/math_private.h              |  248 ++
 sysdeps/loongarch/memusage.h                  |   25 +
 sysdeps/loongarch/nptl/Makefile               |   26 +
 .../loongarch/nptl/bits/pthreadtypes-arch.h   |   41 +
 sysdeps/loongarch/nptl/bits/semaphore.h       |   32 +
 sysdeps/loongarch/nptl/bits/struct_rwlock.h   |   44 +
 sysdeps/loongarch/nptl/libc-lowlevellock.c    |    8 +
 sysdeps/loongarch/nptl/nptl-sysdep.S          |    2 +
 sysdeps/loongarch/nptl/pthread-offsets.h      |   15 +
 sysdeps/loongarch/nptl/pthreaddef.h           |   32 +
 sysdeps/loongarch/nptl/tcb-offsets.sym        |    6 +
 sysdeps/loongarch/nptl/tls.h                  |  138 ++
 sysdeps/loongarch/preconfigure                |   47 +
 sysdeps/loongarch/setjmp.S                    |   66 +
 sysdeps/loongarch/sfp-machine.h               |  102 +
 sysdeps/loongarch/sotruss-lib.c               |   50 +
 sysdeps/loongarch/stackinfo.h                 |   33 +
 sysdeps/loongarch/start.S                     |   70 +
 sysdeps/loongarch/sys/asm.h                   |   58 +
 sysdeps/loongarch/sys/regdef.h                |   98 +
 sysdeps/loongarch/tininess.h                  |    1 +
 sysdeps/loongarch/tls-macros.h                |   49 +
 sysdeps/loongarch/tst-audit.h                 |   23 +
 sysdeps/unix/sysv/linux/loongarch/Implies     |    1 +
 sysdeps/unix/sysv/linux/loongarch/Makefile    |   11 +
 .../unix/sysv/linux/loongarch/arch-syscall.h  |  302 +++
 .../sysv/linux/loongarch/atomic-machine.h     |  196 ++
 .../unix/sysv/linux/loongarch/bits/fcntl.h    |   61 +
 sysdeps/unix/sysv/linux/loongarch/bits/mman.h |   42 +
 .../linux/loongarch/bits/pthread_stack_min.h  |   20 +
 .../sysv/linux/loongarch/bits/sigcontext.h    |   54 +
 .../unix/sysv/linux/loongarch/bits/signum.h   |   58 +
 .../unix/sysv/linux/loongarch/bits/sigstack.h |   32 +
 sysdeps/unix/sysv/linux/loongarch/clone.S     |  100 +
 sysdeps/unix/sysv/linux/loongarch/clone3.S    |   87 +
 sysdeps/unix/sysv/linux/loongarch/configure   |  199 ++
 .../unix/sysv/linux/loongarch/configure.ac    |   27 +
 sysdeps/unix/sysv/linux/loongarch/dl-static.c |   80 +
 .../unix/sysv/linux/loongarch/getcontext.S    |   74 +
 sysdeps/unix/sysv/linux/loongarch/ipc_priv.h  |   22 +
 sysdeps/unix/sysv/linux/loongarch/ldconfig.h  |   30 +
 .../unix/sysv/linux/loongarch/ldd-rewrite.sed |    3 +
 sysdeps/unix/sysv/linux/loongarch/ldsodefs.h  |   33 +
 .../unix/sysv/linux/loongarch/localplt.data   |   12 +
 .../unix/sysv/linux/loongarch/lp64/Implies    |    3 +
 .../sysv/linux/loongarch/lp64/c++-types.data  |   67 +
 .../linux/loongarch/lp64/fpu/jmp_buf-macros.h |   44 +
 .../unix/sysv/linux/loongarch/lp64/ld.abilist |    8 +
 .../loongarch/lp64/libBrokenLocale.abilist    |    1 +
 .../sysv/linux/loongarch/lp64/libanl.abilist  |    1 +
 .../sysv/linux/loongarch/lp64/libc.abilist    | 2137 +++++++++++++++++
 .../loongarch/lp64/libc_malloc_debug.abilist  |   26 +
 .../linux/loongarch/lp64/libcrypt.abilist     |    2 +
 .../sysv/linux/loongarch/lp64/libdl.abilist   |    0
 .../sysv/linux/loongarch/lp64/libm.abilist    | 1033 ++++++++
 .../sysv/linux/loongarch/lp64/libnsl.abilist  |  120 +
 .../linux/loongarch/lp64/libpthread.abilist   |    0
 .../linux/loongarch/lp64/libresolv.abilist    |   55 +
 .../sysv/linux/loongarch/lp64/librt.abilist   |    0
 .../linux/loongarch/lp64/libthread_db.abilist |   40 +
 .../sysv/linux/loongarch/lp64/libutil.abilist |    1 +
 .../loongarch/lp64/nofpu/jmp_buf-macros.h     |   41 +
 .../unix/sysv/linux/loongarch/makecontext.c   |   79 +
 .../unix/sysv/linux/loongarch/register-dump.h |   61 +
 .../unix/sysv/linux/loongarch/setcontext.S    |  115 +
 .../unix/sysv/linux/loongarch/shlib-versions  |    7 +
 .../sysv/linux/loongarch/sigcontextinfo.h     |   32 +
 .../unix/sysv/linux/loongarch/swapcontext.S   |  123 +
 .../unix/sysv/linux/loongarch/sys/procfs.h    |  134 ++
 .../unix/sysv/linux/loongarch/sys/ucontext.h  |   90 +
 sysdeps/unix/sysv/linux/loongarch/sys/user.h  |   32 +
 sysdeps/unix/sysv/linux/loongarch/syscall.c   |   35 +
 sysdeps/unix/sysv/linux/loongarch/sysdep.S    |   53 +
 sysdeps/unix/sysv/linux/loongarch/sysdep.h    |  321 +++
 .../sysv/linux/loongarch/ucontext-macros.h    |   42 +
 .../unix/sysv/linux/loongarch/ucontext_i.sym  |   33 +
 sysdeps/unix/sysv/linux/loongarch/vfork.S     |   50 +
 133 files changed, 10982 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/loongarch/Implies
 create mode 100644 sysdeps/loongarch/Makefile
 create mode 100644 sysdeps/loongarch/__longjmp.S
 create mode 100644 sysdeps/loongarch/abort-instr.h
 create mode 100644 sysdeps/loongarch/bits/endianness.h
 create mode 100644 sysdeps/loongarch/bits/fenv.h
 create mode 100644 sysdeps/loongarch/bits/link.h
 create mode 100644 sysdeps/loongarch/bits/setjmp.h
 create mode 100644 sysdeps/loongarch/bits/wordsize.h
 create mode 100644 sysdeps/loongarch/bsd-_setjmp.c
 create mode 100644 sysdeps/loongarch/bsd-setjmp.c
 create mode 100644 sysdeps/loongarch/configure
 create mode 100644 sysdeps/loongarch/configure.ac
 create mode 100644 sysdeps/loongarch/dl-irel.h
 create mode 100644 sysdeps/loongarch/dl-machine.h
 create mode 100644 sysdeps/loongarch/dl-tls.h
 create mode 100644 sysdeps/loongarch/dl-trampoline.S
 create mode 100644 sysdeps/loongarch/e_sqrtl.c
 create mode 100644 sysdeps/loongarch/fpu/e_sqrt.c
 create mode 100644 sysdeps/loongarch/fpu/e_sqrtf.c
 create mode 100644 sysdeps/loongarch/fpu/fclrexcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fedisblxcpt.c
 create mode 100644 sysdeps/loongarch/fpu/feenablxcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fegetenv.c
 create mode 100644 sysdeps/loongarch/fpu/fegetexcept.c
 create mode 100644 sysdeps/loongarch/fpu/fegetmode.c
 create mode 100644 sysdeps/loongarch/fpu/fegetround.c
 create mode 100644 sysdeps/loongarch/fpu/feholdexcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fenv_libc.h
 create mode 100644 sysdeps/loongarch/fpu/fesetenv.c
 create mode 100644 sysdeps/loongarch/fpu/fesetexcept.c
 create mode 100644 sysdeps/loongarch/fpu/fesetmode.c
 create mode 100644 sysdeps/loongarch/fpu/fesetround.c
 create mode 100644 sysdeps/loongarch/fpu/feupdateenv.c
 create mode 100644 sysdeps/loongarch/fpu/fgetexcptflg.c
 create mode 100644 sysdeps/loongarch/fpu/fraiseexcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fsetexcptflg.c
 create mode 100644 sysdeps/loongarch/fpu/ftestexcept.c
 create mode 100644 sysdeps/loongarch/fpu_control.h
 create mode 100644 sysdeps/loongarch/gccframe.h
 create mode 100644 sysdeps/loongarch/hp-timing.h
 create mode 100644 sysdeps/loongarch/jmpbuf-offsets.h
 create mode 100644 sysdeps/loongarch/jmpbuf-unwind.h
 create mode 100644 sysdeps/loongarch/ldsodefs.h
 create mode 100644 sysdeps/loongarch/libc-start.h
 create mode 100644 sysdeps/loongarch/libc-tls.c
 create mode 100644 sysdeps/loongarch/linkmap.h
 create mode 100644 sysdeps/loongarch/lp64/Implies-after
 create mode 100644 sysdeps/loongarch/lp64/libm-test-ulps
 create mode 100644 sysdeps/loongarch/lp64/libm-test-ulps-name
 create mode 100644 sysdeps/loongarch/machine-gmon.h
 create mode 100644 sysdeps/loongarch/math_private.h
 create mode 100644 sysdeps/loongarch/memusage.h
 create mode 100644 sysdeps/loongarch/nptl/Makefile
 create mode 100644 sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
 create mode 100644 sysdeps/loongarch/nptl/bits/semaphore.h
 create mode 100644 sysdeps/loongarch/nptl/bits/struct_rwlock.h
 create mode 100644 sysdeps/loongarch/nptl/libc-lowlevellock.c
 create mode 100644 sysdeps/loongarch/nptl/nptl-sysdep.S
 create mode 100644 sysdeps/loongarch/nptl/pthread-offsets.h
 create mode 100644 sysdeps/loongarch/nptl/pthreaddef.h
 create mode 100644 sysdeps/loongarch/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/loongarch/nptl/tls.h
 create mode 100644 sysdeps/loongarch/preconfigure
 create mode 100644 sysdeps/loongarch/setjmp.S
 create mode 100644 sysdeps/loongarch/sfp-machine.h
 create mode 100644 sysdeps/loongarch/sotruss-lib.c
 create mode 100644 sysdeps/loongarch/stackinfo.h
 create mode 100644 sysdeps/loongarch/start.S
 create mode 100644 sysdeps/loongarch/sys/asm.h
 create mode 100644 sysdeps/loongarch/sys/regdef.h
 create mode 100644 sysdeps/loongarch/tininess.h
 create mode 100644 sysdeps/loongarch/tls-macros.h
 create mode 100644 sysdeps/loongarch/tst-audit.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/Implies
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/fcntl.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/mman.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/pthread_stack_min.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/sigcontext.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/signum.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/sigstack.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone3.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/configure
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/dl-static.c
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldconfig.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/localplt.data
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/Implies
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libc_malloc_debug.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/register-dump.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/shlib-versions
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sys/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall.c
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ucontext_i.sym
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/vfork.S

-- 
2.27.0


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

* [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port.
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 13:30   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 02/14] LoongArch: Add LoongArch entries to config.h.in caiyinyu
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

---
 NEWS   | 2 ++
 README | 1 +
 2 files changed, 3 insertions(+)

diff --git a/NEWS b/NEWS
index 4762bfcc4e..c78143cc67 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ Version 2.35
 
 Major new features:
 
+* Add LoongArch Port.  Loongson Ltd.
+
 * Unicode 14.0.0 Support: Character encoding, character type info, and
   transliteration tables are all updated to Unicode 14.0.0, using
   generator scripts contributed by Mike FABIAN (Red Hat).
diff --git a/README b/README
index d0f0edb393..f0812d7a80 100644
--- a/README
+++ b/README
@@ -31,6 +31,7 @@ The GNU C Library supports these configurations for using Linux kernels:
 	i[4567]86-*-linux-gnu
 	x86_64-*-linux-gnu	Can build either x86_64 or x32
 	ia64-*-linux-gnu
+	loongarch64-*-linux-gnu
 	m68k-*-linux-gnu
 	microblaze*-*-linux-gnu
 	mips-*-linux-gnu
-- 
2.27.0


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

* [PATCH v2 02/14] LoongArch: Add LoongArch entries to config.h.in
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
  2021-12-31  6:44 ` [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2021-12-31  6:44 ` [PATCH v2 03/14] LoongArch: Add relocations and ELF flags to elf.h caiyinyu
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

---
 config.h.in | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/config.h.in b/config.h.in
index 82ade1cec4..d790c22da3 100644
--- a/config.h.in
+++ b/config.h.in
@@ -135,6 +135,12 @@
 /* RISC-V floating-point ABI for ld.so.  */
 #undef RISCV_ABI_FLEN
 
+/* LOONGARCH integer ABI for ld.so.  */
+#undef LOONGARCH_ABI_GRLEN
+
+/* LOONGARCH floating-point ABI for ld.so.  */
+#undef LOONGARCH_ABI_FRLEN
+
 /* Linux specific: minimum supported kernel version.  */
 #undef	__LINUX_KERNEL_VERSION
 
-- 
2.27.0


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

* [PATCH v2 03/14] LoongArch: Add relocations and ELF flags to elf.h
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
  2021-12-31  6:44 ` [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
  2021-12-31  6:44 ` [PATCH v2 02/14] LoongArch: Add LoongArch entries to config.h.in caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2021-12-31  6:44 ` [PATCH v2 04/14] LoongArch: ABI Implementation caiyinyu
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

---
 elf/elf.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/elf/elf.h b/elf/elf.h
index ff5258d065..2cae5d9d82 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -358,8 +358,9 @@ typedef struct
 
 #define EM_BPF		247	/* Linux BPF -- in-kernel virtual machine */
 #define EM_CSKY		252     /* C-SKY */
+#define EM_LOONGARCH	258	/* LoongArch */
 
-#define EM_NUM		253
+#define EM_NUM		259
 
 /* Old spellings/synonyms.  */
 
@@ -4056,6 +4057,75 @@ enum
 #define R_NDS32_TLS_TPOFF	102
 #define R_NDS32_TLS_DESC	119
 
+/* LoongArch ELF Flags */
+#define EF_LARCH_ABI    	0x0003
+#define EF_LARCH_ABI_LP64	0x0003
+#define EF_LARCH_ABI_LP32	0x0001
+
+/* LoongArch specific dynamic relocations */
+#define R_LARCH_NONE		0
+#define R_LARCH_32		1
+#define R_LARCH_64		2
+#define R_LARCH_RELATIVE	3
+#define R_LARCH_COPY		4
+#define R_LARCH_JUMP_SLOT	5
+#define R_LARCH_TLS_DTPMOD32	6
+#define R_LARCH_TLS_DTPMOD64	7
+#define R_LARCH_TLS_DTPREL32	8
+#define R_LARCH_TLS_DTPREL64	9
+#define R_LARCH_TLS_TPREL32	10
+#define R_LARCH_TLS_TPREL64	11
+#define R_LARCH_IRELATIVE	12
+
+/* Reserved for future relocs that the dynamic linker must understand.  */
+
+/* used by the static linker for relocating .text.  */
+#define R_LARCH_MARK_LA  20
+#define R_LARCH_MARK_PCREL  21
+#define R_LARCH_SOP_PUSH_PCREL  22
+#define R_LARCH_SOP_PUSH_ABSOLUTE  23
+#define R_LARCH_SOP_PUSH_DUP  24
+#define R_LARCH_SOP_PUSH_GPREL  25
+#define R_LARCH_SOP_PUSH_TLS_TPREL  26
+#define R_LARCH_SOP_PUSH_TLS_GOT  27
+#define R_LARCH_SOP_PUSH_TLS_GD  28
+#define R_LARCH_SOP_PUSH_PLT_PCREL  29
+
+#define R_LARCH_SOP_ASSERT  30
+#define R_LARCH_SOP_NOT  31
+#define R_LARCH_SOP_SUB  32
+#define R_LARCH_SOP_SL  33
+#define R_LARCH_SOP_SR  34
+#define R_LARCH_SOP_ADD  35
+#define R_LARCH_SOP_AND  36
+#define R_LARCH_SOP_IF_ELSE  37
+#define R_LARCH_SOP_POP_32_S_10_5  38
+#define R_LARCH_SOP_POP_32_U_10_12  39
+#define R_LARCH_SOP_POP_32_S_10_12  40
+#define R_LARCH_SOP_POP_32_S_10_16  41
+#define R_LARCH_SOP_POP_32_S_10_16_S2  42
+#define R_LARCH_SOP_POP_32_S_5_20  43
+#define R_LARCH_SOP_POP_32_S_0_5_10_16_S2  44
+#define R_LARCH_SOP_POP_32_S_0_10_10_16_S2  45
+#define R_LARCH_SOP_POP_32_U  46
+
+/* used by the static linker for relocating non .text.  */
+#define R_LARCH_ADD8  47
+#define R_LARCH_ADD16  48
+#define R_LARCH_ADD24  49
+#define R_LARCH_ADD32  50
+#define R_LARCH_ADD64  51
+#define R_LARCH_SUB8  52
+#define R_LARCH_SUB16  53
+#define R_LARCH_SUB24  54
+#define R_LARCH_SUB32  55
+#define R_LARCH_SUB64  56
+
+  /* I don't know what it is.  Existing in almost all other arch.  */
+#define R_LARCH_GNU_VTINHERIT  57
+#define R_LARCH_GNU_VTENTRY  58
+
+
 /* ARCompact/ARCv2 specific relocs.  */
 #define R_ARC_NONE		0x0
 #define R_ARC_8			0x1
-- 
2.27.0


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

* [PATCH v2 04/14] LoongArch: ABI Implementation
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (2 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 03/14] LoongArch: Add relocations and ELF flags to elf.h caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 13:46   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 05/14] LoongArch: Thread-Local Storage Support caiyinyu
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

This is meant to contain all the LoongArch code that needs to explicitly
name registers or manage in-memory structure layout.  This does not
contain any of the Linux-specific code.
---
 sysdeps/loongarch/__longjmp.S                 |  52 +++
 sysdeps/loongarch/bits/endianness.h           |  11 +
 sysdeps/loongarch/bits/link.h                 |  58 +++
 sysdeps/loongarch/bits/setjmp.h               |  42 ++
 sysdeps/loongarch/bits/wordsize.h             |  25 ++
 sysdeps/loongarch/bsd-_setjmp.c               |   1 +
 sysdeps/loongarch/bsd-setjmp.c                |   1 +
 sysdeps/loongarch/dl-machine.h                | 368 ++++++++++++++++++
 sysdeps/loongarch/dl-trampoline.S             | 103 +++++
 sysdeps/loongarch/gccframe.h                  |  21 +
 sysdeps/loongarch/jmpbuf-offsets.h            |  22 ++
 sysdeps/loongarch/jmpbuf-unwind.h             |  45 +++
 sysdeps/loongarch/ldsodefs.h                  |  41 ++
 sysdeps/loongarch/linkmap.h                   |   4 +
 sysdeps/loongarch/machine-gmon.h              |  37 ++
 sysdeps/loongarch/memusage.h                  |  25 ++
 sysdeps/loongarch/setjmp.S                    |  66 ++++
 sysdeps/loongarch/sotruss-lib.c               |  50 +++
 sysdeps/loongarch/start.S                     |  70 ++++
 sysdeps/loongarch/sys/asm.h                   |  58 +++
 sysdeps/loongarch/tls-macros.h                |  49 +++
 sysdeps/loongarch/tst-audit.h                 |  23 ++
 sysdeps/unix/sysv/linux/loongarch/ldconfig.h  |  30 ++
 .../unix/sysv/linux/loongarch/localplt.data   |  12 +
 .../linux/loongarch/lp64/fpu/jmp_buf-macros.h |  44 +++
 .../loongarch/lp64/nofpu/jmp_buf-macros.h     |  41 ++
 26 files changed, 1299 insertions(+)
 create mode 100644 sysdeps/loongarch/__longjmp.S
 create mode 100644 sysdeps/loongarch/bits/endianness.h
 create mode 100644 sysdeps/loongarch/bits/link.h
 create mode 100644 sysdeps/loongarch/bits/setjmp.h
 create mode 100644 sysdeps/loongarch/bits/wordsize.h
 create mode 100644 sysdeps/loongarch/bsd-_setjmp.c
 create mode 100644 sysdeps/loongarch/bsd-setjmp.c
 create mode 100644 sysdeps/loongarch/dl-machine.h
 create mode 100644 sysdeps/loongarch/dl-trampoline.S
 create mode 100644 sysdeps/loongarch/gccframe.h
 create mode 100644 sysdeps/loongarch/jmpbuf-offsets.h
 create mode 100644 sysdeps/loongarch/jmpbuf-unwind.h
 create mode 100644 sysdeps/loongarch/ldsodefs.h
 create mode 100644 sysdeps/loongarch/linkmap.h
 create mode 100644 sysdeps/loongarch/machine-gmon.h
 create mode 100644 sysdeps/loongarch/memusage.h
 create mode 100644 sysdeps/loongarch/setjmp.S
 create mode 100644 sysdeps/loongarch/sotruss-lib.c
 create mode 100644 sysdeps/loongarch/start.S
 create mode 100644 sysdeps/loongarch/sys/asm.h
 create mode 100644 sysdeps/loongarch/tls-macros.h
 create mode 100644 sysdeps/loongarch/tst-audit.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldconfig.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/localplt.data
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h

diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S
new file mode 100644
index 0000000000..5cc1bc7860
--- /dev/null
+++ b/sysdeps/loongarch/__longjmp.S
@@ -0,0 +1,52 @@
+/* longjmp.
+   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 <sys/asm.h>
+
+ENTRY (__longjmp)
+	REG_L ra, a0, 0*SZREG
+	REG_L sp, a0, 1*SZREG
+	REG_L x,  a0, 2*SZREG
+	REG_L fp, a0, 3*SZREG
+	REG_L s0, a0, 4*SZREG
+	REG_L s1, a0, 5*SZREG
+	REG_L s2, a0, 6*SZREG
+	REG_L s3, a0, 7*SZREG
+	REG_L s4, a0, 8*SZREG
+	REG_L s5, a0, 9*SZREG
+	REG_L s6, a0, 10*SZREG
+	REG_L s7, a0, 11*SZREG
+	REG_L s8, a0, 12*SZREG
+
+#ifndef __loongarch_soft_float
+	FREG_L $f24, a0, 13*SZREG + 0*SZFREG
+	FREG_L $f25, a0, 13*SZREG + 1*SZFREG
+	FREG_L $f26, a0, 13*SZREG + 2*SZFREG
+	FREG_L $f27, a0, 13*SZREG + 3*SZFREG
+	FREG_L $f28, a0, 13*SZREG + 4*SZFREG
+	FREG_L $f29, a0, 13*SZREG + 5*SZFREG
+	FREG_L $f30, a0, 13*SZREG + 6*SZFREG
+	FREG_L $f31, a0, 13*SZREG + 7*SZFREG
+#endif
+
+	sltui	a0,a1,1
+	add.d	a0, a0, a1	 # a0 = (a1 == 0) ? 1 : a1
+	jirl	zero,ra,0
+
+END (__longjmp)
diff --git a/sysdeps/loongarch/bits/endianness.h b/sysdeps/loongarch/bits/endianness.h
new file mode 100644
index 0000000000..7290be7b18
--- /dev/null
+++ b/sysdeps/loongarch/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
+
+/* LoongArch is little-endian.  */
+#define __BYTE_ORDER __LITTLE_ENDIAN
+
+#endif /* bits/endianness.h */
diff --git a/sysdeps/loongarch/bits/link.h b/sysdeps/loongarch/bits/link.h
new file mode 100644
index 0000000000..3f2834d34d
--- /dev/null
+++ b/sysdeps/loongarch/bits/link.h
@@ -0,0 +1,58 @@
+/* Machine-specific declarations for dynamic linker interface.
+   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
+
+typedef struct La_loongarch_regs
+{
+  unsigned long int lr_reg[8]; /* a0 - a7 */
+  double lr_fpreg[8];	       /* fa0 - fa7 */
+  unsigned long int lr_ra;
+  unsigned long int lr_sp;
+} La_loongarch_regs;
+
+/* Return values for calls from PLT on LoongArch.  */
+typedef struct La_loongarch_retval
+{
+  unsigned long int lrv_a0;
+  unsigned long int lrv_a1;
+  double lrv_fa0;
+  double lrv_fa1;
+} La_loongarch_retval;
+
+__BEGIN_DECLS
+
+extern ElfW (Addr) la_loongarch_gnu_pltenter (ElfW (Sym) * __sym,
+					      unsigned int __ndx,
+					      uintptr_t *__refcook,
+					      uintptr_t *__defcook,
+					      La_loongarch_regs *__regs,
+					      unsigned int *__flags,
+					      const char *__symname,
+					      long int *__framesizep);
+extern unsigned int la_loongarch_gnu_pltexit (ElfW (Sym) * __sym,
+					      unsigned int __ndx,
+					      uintptr_t *__refcook,
+					      uintptr_t *__defcook,
+					      const La_loongarch_regs *__inregs,
+					      La_loongarch_retval *__outregs,
+					      const char *__symname);
+
+__END_DECLS
diff --git a/sysdeps/loongarch/bits/setjmp.h b/sysdeps/loongarch/bits/setjmp.h
new file mode 100644
index 0000000000..b098ac6f86
--- /dev/null
+++ b/sysdeps/loongarch/bits/setjmp.h
@@ -0,0 +1,42 @@
+/* Define the machine-dependent type `jmp_buf'.
+   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 _LOONGARCH_BITS_SETJMP_H
+#define _LOONGARCH_BITS_SETJMP_H
+
+typedef struct __jmp_buf_internal_tag
+{
+  /* Program counter.  */
+  long int __pc;
+  /* Stack pointer.  */
+  long int __sp;
+  /* Reserved */
+  long int __x;
+  /* Frame pointer.  */
+  long int __fp;
+  /* Callee-saved registers.  */
+  long int __regs[9];
+
+#ifndef __loongarch_soft_float
+  /* Callee-saved floating point registers.  */
+  double __fpregs[8];
+#endif
+
+} __jmp_buf[1];
+
+#endif /* _LOONGARCH_BITS_SETJMP_H */
diff --git a/sysdeps/loongarch/bits/wordsize.h b/sysdeps/loongarch/bits/wordsize.h
new file mode 100644
index 0000000000..0a83454b08
--- /dev/null
+++ b/sysdeps/loongarch/bits/wordsize.h
@@ -0,0 +1,25 @@
+/* Determine the wordsize from the preprocessor defines.
+   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/>.  */
+
+#ifdef __LP64__
+#define __WORDSIZE 64
+#else
+#define __WORDSIZE 32
+#endif
+
+#define __WORDSIZE_TIME64_COMPAT32 0
diff --git a/sysdeps/loongarch/bsd-_setjmp.c b/sysdeps/loongarch/bsd-_setjmp.c
new file mode 100644
index 0000000000..32f49441c3
--- /dev/null
+++ b/sysdeps/loongarch/bsd-_setjmp.c
@@ -0,0 +1 @@
+/* _setjmp is implemented in setjmp.S.  */
diff --git a/sysdeps/loongarch/bsd-setjmp.c b/sysdeps/loongarch/bsd-setjmp.c
new file mode 100644
index 0000000000..45fd802aac
--- /dev/null
+++ b/sysdeps/loongarch/bsd-setjmp.c
@@ -0,0 +1 @@
+/* setjmp is implemented in setjmp.S.  */
diff --git a/sysdeps/loongarch/dl-machine.h b/sysdeps/loongarch/dl-machine.h
new file mode 100644
index 0000000000..82274f6bc2
--- /dev/null
+++ b/sysdeps/loongarch/dl-machine.h
@@ -0,0 +1,368 @@
+/* Machine-dependent ELF dynamic relocation inline functions.
+   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 "LoongArch"
+
+#include <entry.h>
+#include <elf/elf.h>
+#include <sys/asm.h>
+#include <dl-tls.h>
+#include <dl-static-tls.h>
+#include <dl-machine-rel.h>
+
+#ifndef _RTLD_PROLOGUE
+# define _RTLD_PROLOGUE(entry)					\
+	".globl\t" __STRING (entry) "\n\t"			\
+	".type\t" __STRING (entry) ", @function\n\t"		\
+	CFI_STARTPROC "\n"					\
+	__STRING (entry) ":\n"
+#endif
+
+#ifndef _RTLD_EPILOGUE
+# define _RTLD_EPILOGUE(entry)					\
+	CFI_ENDPROC "\n\t"					\
+	".size\t" __STRING (entry) ", . - " __STRING (entry) "\n"
+#endif
+
+#define ELF_MACHINE_JMP_SLOT R_LARCH_JUMP_SLOT
+#define ELF_MACHINE_IRELATIVE R_LARCH_IRELATIVE
+
+#define elf_machine_type_class(type)				\
+  ((ELF_RTYPE_CLASS_PLT * ((type) == ELF_MACHINE_JMP_SLOT	\
+     || (__WORDSIZE == 32 && (type) == R_LARCH_TLS_DTPREL32)	\
+     || (__WORDSIZE == 32 && (type) == R_LARCH_TLS_DTPMOD32)	\
+     || (__WORDSIZE == 32 && (type) == R_LARCH_TLS_TPREL32)	\
+     || (__WORDSIZE == 64 && (type) == R_LARCH_TLS_DTPREL64)	\
+     || (__WORDSIZE == 64 && (type) == R_LARCH_TLS_DTPMOD64)	\
+     || (__WORDSIZE == 64 && (type) == R_LARCH_TLS_TPREL64)))	\
+   | (ELF_RTYPE_CLASS_COPY * ((type) == R_LARCH_COPY)))
+
+#define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
+
+/* Return nonzero iff ELF header is compatible with the running host.  */
+static inline int __attribute_used__
+elf_machine_matches_host (const ElfW (Ehdr) * ehdr)
+{
+  /* We can only run LoongArch binaries.  */
+  if (ehdr->e_machine != EM_LOONGARCH)
+    return 0;
+
+#ifdef __loongarch_lp64
+  if ((ehdr->e_flags & EF_LARCH_ABI) != EF_LARCH_ABI_LP64)
+#else
+#error "Unknown ABI"
+#endif
+    return 0;
+
+  return 1;
+}
+
+/* Runtime address of .got */
+#define _GLOBAL_OFFSET_TABLE_ \
+  ({ \
+    ElfW (Addr) * r; \
+    asm("la.pcrel %0, _GLOBAL_OFFSET_TABLE_" : "=r"(r)); \
+    r; \
+  })
+
+/* Return the link-time address of _DYNAMIC.  */
+static inline ElfW (Addr) elf_machine_dynamic (void)
+{
+  return _GLOBAL_OFFSET_TABLE_[0];
+}
+
+#define STRINGXP(X) __STRING (X)
+#define STRINGXV(X) STRINGV_ (X)
+#define STRINGV_(...) #__VA_ARGS__
+
+/* Return the run-time load address of the shared object.  */
+static inline ElfW (Addr) elf_machine_load_address (void)
+{
+  ElfW (Addr) got_linktime_addr;
+  asm("la.got %0, _GLOBAL_OFFSET_TABLE_"
+      /* Link-time address in GOT entry before runtime relocation */
+      : "=r"(got_linktime_addr));
+  return (ElfW (Addr)) _GLOBAL_OFFSET_TABLE_ - got_linktime_addr;
+}
+
+/* Initial entry point code for the dynamic linker.
+   The C function `_dl_start' is the real entry point;
+   its return value is the user program's entry point.  */
+
+#define RTLD_START \
+  asm(".text\n\
+      " _RTLD_PROLOGUE (ENTRY_POINT) "\
+      .cfi_label .Ldummy   \n\
+      " CFI_UNDEFINED (1) "   \n\
+      or	$a0, $sp, $zero   \n\
+      bl	_dl_start   \n\
+      # Stash user entry point in s0.   \n\
+      or	$s0, $v0, $zero   \n\
+      # See if we were run as a command with the executable file   \n\
+      # name as an extra leading argument.   \n\
+      la	$a0, _dl_skip_args   \n\
+      ld.w	$a0, $a0, 0   \n\
+      # Load the original argument count.   \n\
+      ld.d	$a1, $sp, 0   \n\
+      # Subtract _dl_skip_args from it.   \n\
+      sub.d	$a1, $a1, $a0   \n\
+      # Adjust the stack pointer to skip _dl_skip_args words.   \n\
+      slli.d	$a0, $a0, 3   \n\
+      add.d	$sp, $sp, $a0   \n\
+      # Save back the modified argument count.   \n\
+      st.d	$a1, $sp, 0   \n\
+      # Call _dl_init (struct link_map *main_map, int argc, char **argv, \
+		       char **env)    \n\
+      la	$a0, _rtld_local   \n\
+      ld.d	$a0, $a0, 0   \n\
+      addi.d	$a2, $sp, 8   \n\
+      slli.d	$a3, $a1, 3   \n\
+      add.d	$a3, $a3, $a2   \n\
+      addi.d	$a3, $a3, 8   \n\
+      # Adjust $sp for 16-aligned   \n\
+      srli.d  $t0, $sp, 4   \n\
+      slli.d  $t0, $t0, 4   \n\
+      ori	$t1, $sp, 0   \n\
+      addi.d  $sp, $t0, -32   \n\
+      st.d	$t1, $sp, 24   \n\
+      # Call the function to run the initializers.   \n\
+      bl	_dl_init   \n\
+      # Pass our finalizer function to _start.   \n\
+      ld.d    $sp, $sp, 24   \n\
+      la	$a0, _dl_fini   \n\
+      # Jump to the user entry point.   \n\
+      jirl	$zero, $s0, 0   \n\
+      " _RTLD_EPILOGUE (ENTRY_POINT) "\
+      .previous");
+
+/* Names of the architecture-specific auditing callback functions.  */
+#define ARCH_LA_PLTENTER loongarch_gnu_pltenter
+#define ARCH_LA_PLTEXIT loongarch_gnu_pltexit
+
+/* Bias .got.plt entry by the offset requested by the PLT header.  */
+#define elf_machine_plt_value(map, reloc, value) (value)
+
+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;
+}
+
+#endif /* !dl_machine_h */
+
+#ifdef RESOLVE_MAP
+
+/* Perform a relocation described by R_INFO at the location pointed to
+   by RELOC_ADDR.  SYM is the relocation symbol specified by R_INFO and
+   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, int skip_ifunc)
+{
+  ElfW (Addr) r_info = reloc->r_info;
+  const unsigned long int r_type = ELFW (R_TYPE) (r_info);
+  ElfW (Addr) *addr_field = (ElfW (Addr) *) reloc_addr;
+  const ElfW (Sym) *const __attribute__ ((unused)) refsym = sym;
+  struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
+  ElfW (Addr) value = 0;
+  if (sym_map != NULL)
+    value = SYMBOL_ADDRESS (sym_map, sym, true) + reloc->r_addend;
+
+  if (sym != NULL
+      && __builtin_expect (ELFW (ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
+      && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
+      && __builtin_expect (!skip_ifunc, 1))
+    value = ((ElfW (Addr) (*) (int)) value) (GLRO (dl_hwcap));
+
+  switch (r_type)
+    {
+#ifndef RTLD_BOOTSTRAP
+    case __WORDSIZE == 64 ? R_LARCH_TLS_DTPMOD64:
+    R_LARCH_TLS_DTPMOD32:
+      if (sym_map)
+	*addr_field = sym_map->l_tls_modid;
+      break;
+
+    case __WORDSIZE == 64 ? R_LARCH_TLS_DTPREL64:
+    R_LARCH_TLS_DTPREL32:
+      if (sym != NULL)
+	*addr_field = TLS_DTPREL_VALUE (sym) + reloc->r_addend;
+      break;
+
+    case __WORDSIZE == 64 ? R_LARCH_TLS_TPREL64:
+    R_LARCH_TLS_TPREL32:
+      if (sym != NULL)
+	{
+	  CHECK_STATIC_TLS (map, sym_map);
+	  *addr_field = TLS_TPREL_VALUE (sym_map, sym) + reloc->r_addend;
+	}
+      break;
+
+    case R_LARCH_COPY:
+      {
+	if (__glibc_unlikely (sym == NULL))
+	  /* This can happen in trace mode if an object could not be
+	     found.  */
+	  break;
+
+	/* Handle TLS copy relocations.  */
+	if (__glibc_unlikely (ELFW (ST_TYPE) (sym->st_info) == STT_TLS))
+	  {
+	    /* There's nothing to do if the symbol is in .tbss.  */
+	    if (__glibc_likely (sym->st_value
+				>= sym_map->l_tls_initimage_size))
+	      break;
+	    value += (ElfW (Addr)) sym_map->l_tls_initimage - sym_map->l_addr;
+	  }
+
+	size_t size = sym->st_size;
+	if (__glibc_unlikely (sym->st_size != refsym->st_size))
+	  {
+	    const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+	    if (sym->st_size > refsym->st_size)
+	      size = refsym->st_size;
+	    if (sym->st_size > refsym->st_size || GLRO (dl_verbose))
+	      _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, (void *) value, size);
+	break;
+      }
+#endif
+
+#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
+    case R_LARCH_RELATIVE:
+      {
+#if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
+	/* This is defined in rtld.c, but nowhere in the static libc.a;
+	   make the reference weak so static programs can still link.
+	   This declaration cannot be done when compiling rtld.c
+	   (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
+	   common defn for _dl_rtld_map, which is incompatible with a
+	   weak decl in the same file.  */
+#ifndef SHARED
+	weak_extern (GL (dl_rtld_map));
+#endif
+	if (map != &GL (dl_rtld_map)) /* Already done in rtld itself.  */
+#endif
+	  *addr_field = map->l_addr + reloc->r_addend;
+	break;
+      }
+#endif
+
+    case R_LARCH_JUMP_SLOT:
+    case __WORDSIZE == 64 ? R_LARCH_64:
+    R_LARCH_32:
+      *addr_field = value;
+      break;
+
+    case R_LARCH_IRELATIVE:
+      value = map->l_addr + reloc->r_addend;
+      value = ((ElfW (Addr) (*) (void)) value) ();
+      *addr_field = value;
+      break;
+
+    case R_LARCH_NONE:
+      break;
+
+    default:
+      _dl_reloc_bad_type (map, r_type, 0);
+      break;
+    }
+}
+
+static inline void __attribute__ ((always_inline))
+elf_machine_rela_relative (ElfW (Addr) l_addr, const ElfW (Rela) * reloc,
+			   void *const reloc_addr)
+{
+  *(ElfW (Addr) *) 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)
+{
+  ElfW (Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset);
+  const unsigned int r_type = ELFW (R_TYPE) (reloc->r_info);
+
+  /* Check for unexpected PLT reloc type.  */
+  if (__glibc_likely (r_type == R_LARCH_JUMP_SLOT))
+    {
+      if (__glibc_unlikely (map->l_mach.plt == 0))
+	{
+	  if (l_addr)
+	    *reloc_addr += l_addr;
+	}
+      else
+	*reloc_addr = map->l_mach.plt;
+    }
+  else if (__glibc_unlikely (r_type == R_LARCH_IRELATIVE))
+    {
+      ElfW (Addr) *value = (void *) (l_addr + reloc->r_addend);
+      if (__glibc_likely (!skip_ifunc))
+	value = (ElfW (Addr) *) ((ElfW (Addr) (*) (void)) value) ();
+      *reloc_addr = (ElfW (Addr)) value;
+    }
+  else
+    _dl_reloc_bad_type (map, r_type, 1);
+}
+
+/* Set up the loaded object described by L so its stub function
+   will jump to the on-demand fixup code __dl_runtime_resolve.  */
+
+static inline int __attribute__ ((always_inline))
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
+			   int lazy, int profile)
+{
+#ifndef RTLD_BOOTSTRAP
+  /* If using PLTs, fill in the first two entries of .got.plt.  */
+  if (l->l_info[DT_JMPREL])
+    {
+      extern void _dl_runtime_resolve (void)
+	__attribute__ ((visibility ("hidden")));
+      ElfW (Addr) *gotplt = (ElfW (Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
+      /* If a library is prelinked but we have to relocate anyway,
+	 we have to be able to undo the prelinking of .got.plt.
+	 The prelinker saved the address of .plt for us here.  */
+      if (gotplt[1])
+	l->l_mach.plt = gotplt[1] + l->l_addr;
+      gotplt[0] = (ElfW (Addr)) & _dl_runtime_resolve;
+      gotplt[1] = (ElfW (Addr)) l;
+    }
+#endif
+
+  return lazy;
+}
+
+#endif /* RESOLVE_MAP */
diff --git a/sysdeps/loongarch/dl-trampoline.S b/sysdeps/loongarch/dl-trampoline.S
new file mode 100644
index 0000000000..84b1fa1f5e
--- /dev/null
+++ b/sysdeps/loongarch/dl-trampoline.S
@@ -0,0 +1,103 @@
+/* PLT trampolines.
+   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 <sys/asm.h>
+
+/* Assembler veneer called from the PLT header code for lazy loading.
+   The PLT header passes its own args in t0-t2.  */
+
+#ifdef __loongarch_soft_float
+# define FRAME_SIZE (-((-10 * SZREG) & ALMASK))
+#else
+# define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK))
+#endif
+
+ENTRY (_dl_runtime_resolve)
+
+	/* Save arguments to stack. */
+#ifdef __loongarch_lp64
+	addi.d	sp, sp, -FRAME_SIZE
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+	REG_S	ra, sp, 9*SZREG
+	REG_S	a0, sp, 1*SZREG
+	REG_S	a1, sp, 2*SZREG
+	REG_S	a2, sp, 3*SZREG
+	REG_S	a3, sp, 4*SZREG
+	REG_S	a4, sp, 5*SZREG
+	REG_S	a5, sp, 6*SZREG
+	REG_S	a6, sp, 7*SZREG
+	REG_S	a7, sp, 8*SZREG
+
+#ifndef __loongarch_soft_float
+	FREG_S	fa0, sp, 10*SZREG + 0*SZFREG
+	FREG_S	fa1, sp, 10*SZREG + 1*SZFREG
+	FREG_S	fa2, sp, 10*SZREG + 2*SZFREG
+	FREG_S	fa3, sp, 10*SZREG + 3*SZFREG
+	FREG_S	fa4, sp, 10*SZREG + 4*SZFREG
+	FREG_S	fa5, sp, 10*SZREG + 5*SZFREG
+	FREG_S	fa6, sp, 10*SZREG + 6*SZFREG
+	FREG_S	fa7, sp, 10*SZREG + 7*SZFREG
+#endif
+
+	/* Update .got.plt and obtain runtime address of callee */
+#ifdef __loongarch_lp64
+	slli.d	a1, t1, 1
+	or	a0, t0, zero
+	add.d	a1, a1, t1
+	la	a2, _dl_fixup
+	jirl	ra, a2, 0
+	or	t1, v0, zero
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+	/* Restore arguments from stack. */
+	REG_L	ra, sp, 9*SZREG
+	REG_L	a0, sp, 1*SZREG
+	REG_L	a1, sp, 2*SZREG
+	REG_L	a2, sp, 3*SZREG
+	REG_L	a3, sp, 4*SZREG
+	REG_L	a4, sp, 5*SZREG
+	REG_L	a5, sp, 6*SZREG
+	REG_L	a6, sp, 7*SZREG
+	REG_L	a7, sp, 8*SZREG
+
+#ifndef __loongarch_soft_float
+	FREG_L	fa0, sp, 10*SZREG + 0*SZFREG
+	FREG_L	fa1, sp, 10*SZREG + 1*SZFREG
+	FREG_L	fa2, sp, 10*SZREG + 2*SZFREG
+	FREG_L	fa3, sp, 10*SZREG + 3*SZFREG
+	FREG_L	fa4, sp, 10*SZREG + 4*SZFREG
+	FREG_L	fa5, sp, 10*SZREG + 5*SZFREG
+	FREG_L	fa6, sp, 10*SZREG + 6*SZFREG
+	FREG_L	fa7, sp, 10*SZREG + 7*SZFREG
+#endif
+
+#ifdef __loongarch_lp64
+	addi.d	sp, sp, FRAME_SIZE
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+	/* Invoke the callee. */
+	jirl		zero, t1, 0
+END (_dl_runtime_resolve)
diff --git a/sysdeps/loongarch/gccframe.h b/sysdeps/loongarch/gccframe.h
new file mode 100644
index 0000000000..19996f3ce3
--- /dev/null
+++ b/sysdeps/loongarch/gccframe.h
@@ -0,0 +1,21 @@
+/* Definition of object in frame unwind info.
+   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 FIRST_PSEUDO_REGISTER 74
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/sysdeps/loongarch/jmpbuf-offsets.h b/sysdeps/loongarch/jmpbuf-offsets.h
new file mode 100644
index 0000000000..4df42dfa84
--- /dev/null
+++ b/sysdeps/loongarch/jmpbuf-offsets.h
@@ -0,0 +1,22 @@
+/* Private macros for accessing __jmp_buf contents.
+   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 <jmpbuf-unwind.h>
+
+/* Helper for generic ____longjmp_chk().  */
+#define JB_FRAME_ADDRESS(buf) ((void *) _jmpbuf_sp (buf))
diff --git a/sysdeps/loongarch/jmpbuf-unwind.h b/sysdeps/loongarch/jmpbuf-unwind.h
new file mode 100644
index 0000000000..a37bef1de7
--- /dev/null
+++ b/sysdeps/loongarch/jmpbuf-unwind.h
@@ -0,0 +1,45 @@
+/* Examine __jmp_buf for unwinding frames.
+   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 <stdint.h>
+#include <unwind.h>
+#include <sysdep.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)[0].__sp))
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+  _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+static inline uintptr_t __attribute__ ((unused)) _jmpbuf_sp (__jmp_buf regs)
+{
+  uintptr_t sp = regs[0].__sp;
+#ifdef PTR_DEMANGLE
+  PTR_DEMANGLE (sp);
+#endif
+  return sp;
+}
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+  ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
+
+/* We use the normal longjmp for unwinding.  */
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/sysdeps/loongarch/ldsodefs.h b/sysdeps/loongarch/ldsodefs.h
new file mode 100644
index 0000000000..ec91f64096
--- /dev/null
+++ b/sysdeps/loongarch/ldsodefs.h
@@ -0,0 +1,41 @@
+/* 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 _LOONGARCH_LDSODEFS_H
+#define _LOONGARCH_LDSODEFS_H 1
+
+#include <elf.h>
+
+struct La_loongarch_regs;
+struct La_loongarch_retval;
+
+#define ARCH_PLTENTER_MEMBERS \
+  ElfW (Addr) (*loongarch_gnu_pltenter) (ElfW (Sym) *, unsigned int, \
+					 uintptr_t *, uintptr_t *, \
+					 const struct La_loongarch_regs *, \
+					 unsigned int *, const char *name, \
+					 long int *framesizep);
+
+#define ARCH_PLTEXIT_MEMBERS \
+  unsigned int (*loongarch_gnu_pltexit) (ElfW (Sym) *, unsigned int, \
+		uintptr_t *, uintptr_t *, const struct La_loongarch_regs *, \
+		struct La_loongarch_retval *, const char *);
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/sysdeps/loongarch/linkmap.h b/sysdeps/loongarch/linkmap.h
new file mode 100644
index 0000000000..f88ce50162
--- /dev/null
+++ b/sysdeps/loongarch/linkmap.h
@@ -0,0 +1,4 @@
+struct link_map_machine
+{
+  ElfW (Addr) plt; /* Address of .plt.  */
+};
diff --git a/sysdeps/loongarch/machine-gmon.h b/sysdeps/loongarch/machine-gmon.h
new file mode 100644
index 0000000000..d330fd6e79
--- /dev/null
+++ b/sysdeps/loongarch/machine-gmon.h
@@ -0,0 +1,37 @@
+/* LoongArch definitions for profiling support.
+   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/>.  */
+
+/* Accept 'frompc' address as argument from the function that calls
+   _mcount for profiling.  Use  __builtin_return_address (0)
+   for the 'selfpc' address.  */
+
+#include <sysdep.h>
+
+static void mcount_internal (unsigned long int frompc,
+			     unsigned long int selfpc);
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+  static inline void mcount_internal (unsigned long int frompc, \
+				      unsigned long int selfpc)
+
+#define MCOUNT \
+  void _mcount (void *frompc) \
+  { \
+    mcount_internal ((unsigned long int) frompc, \
+		     (unsigned long int) RETURN_ADDRESS (0)); \
+  }
diff --git a/sysdeps/loongarch/memusage.h b/sysdeps/loongarch/memusage.h
new file mode 100644
index 0000000000..bdf24bb276
--- /dev/null
+++ b/sysdeps/loongarch/memusage.h
@@ -0,0 +1,25 @@
+/* Machine-specific definitions for memory usage profiling.
+   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("$sp"); \
+    stack_ptr; \
+  })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S
new file mode 100644
index 0000000000..5b51b5799e
--- /dev/null
+++ b/sysdeps/loongarch/setjmp.S
@@ -0,0 +1,66 @@
+/* setjmp for LoongArch.
+   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 <sys/asm.h>
+
+ENTRY (_setjmp)
+	li.w		a1,0
+	b		__sigsetjmp
+END (_setjmp)
+
+ENTRY (setjmp)
+	li.w		a1,1
+END (setjmp)
+
+ENTRY (__sigsetjmp)
+	REG_S ra, a0, 0*SZREG
+	REG_S sp, a0, 1*SZREG
+	REG_S x,  a0, 2*SZREG
+	REG_S fp, a0, 3*SZREG
+	REG_S s0, a0, 4*SZREG
+	REG_S s1, a0, 5*SZREG
+	REG_S s2, a0, 6*SZREG
+	REG_S s3, a0, 7*SZREG
+	REG_S s4, a0, 8*SZREG
+	REG_S s5, a0, 9*SZREG
+	REG_S s6, a0, 10*SZREG
+	REG_S s7, a0, 11*SZREG
+	REG_S s8, a0, 12*SZREG
+
+#ifndef __loongarch_soft_float
+	FREG_S $f24, a0, 13*SZREG + 0*SZFREG
+	FREG_S $f25, a0, 13*SZREG + 1*SZFREG
+	FREG_S $f26, a0, 13*SZREG + 2*SZFREG
+	FREG_S $f27, a0, 13*SZREG + 3*SZFREG
+	FREG_S $f28, a0, 13*SZREG + 4*SZFREG
+	FREG_S $f29, a0, 13*SZREG + 5*SZFREG
+	FREG_S $f30, a0, 13*SZREG + 6*SZFREG
+	FREG_S $f31, a0, 13*SZREG + 7*SZFREG
+#endif
+
+#if !IS_IN (libc) && IS_IN(rtld)
+	li.w		v0, 0
+	jirl		zero,ra,0
+#else
+	b		__sigjmp_save
+#endif
+END (__sigsetjmp)
+
+hidden_def (__sigsetjmp)
+weak_alias (_setjmp, __GI__setjmp)
diff --git a/sysdeps/loongarch/sotruss-lib.c b/sysdeps/loongarch/sotruss-lib.c
new file mode 100644
index 0000000000..8a7a438ba0
--- /dev/null
+++ b/sysdeps/loongarch/sotruss-lib.c
@@ -0,0 +1,50 @@
+/* Override generic sotruss-lib.c to define actual functions for LoongArch.
+   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_loongarch_gnu_pltenter (ElfW (Sym) * sym __attribute__ ((unused)),
+			   unsigned int ndx __attribute__ ((unused)),
+			   uintptr_t *refcook, uintptr_t *defcook,
+			   La_loongarch_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_loongarch_gnu_pltexit (ElfW (Sym) * sym, unsigned int ndx,
+			  uintptr_t *refcook, uintptr_t *defcook,
+			  const struct La_loongarch_regs *inregs,
+			  struct La_loongarch_retval *outregs,
+			  const char *symname)
+{
+  print_exit (refcook, defcook, symname, outregs->lrv_a0);
+
+  return 0;
+}
diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S
new file mode 100644
index 0000000000..9ecfb5e2be
--- /dev/null
+++ b/sysdeps/loongarch/start.S
@@ -0,0 +1,70 @@
+/* Startup code compliant to the ELF LoongArch ABI.
+   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 __ASSEMBLY__ 1
+#include <entry.h>
+#include <sys/asm.h>
+
+/* The entry point's job is to call __libc_start_main.  Per the ABI,
+   a0 contains the address of a function to be passed to atexit.
+   __libc_start_main wants this in a5.  */
+
+/*
+int
+__libc_start_main (int (*main) (int, char **, char **),
+		   int argc,
+		   char **argv,
+		   __typeof (main) init,
+		   void (*fini) (void),
+		   void (*rtld_fini) (void),
+		   void *stack_end);
+ */
+
+ENTRY (ENTRY_POINT)
+
+/* Terminate call stack by noting ra is undefined.  Use a dummy
+   .cfi_label to force starting the FDE.  */
+	.cfi_label .Ldummy
+	cfi_undefined (1)
+	or		a5, a0, zero /* rtld_fini */
+
+/* We must get symbol main through GOT table, since main may not be local.
+   For instance: googletest defines main in dynamic library.  */
+	la.got		a0, t0, main
+#ifdef __loongarch_lp64
+	ld.d		a1, sp, 0
+	addi.d		a2, sp, SZREG
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+	/* Adjust $sp for 16-aligned */
+	srli.d		sp, sp, 4
+	slli.d		sp, sp, 4
+
+	move		a3, zero /* used to be init */
+	move		a4, zero /* used to be fini */
+	or		a6, sp, zero /* stack_end */
+
+	la.got		ra, t0, __libc_start_main
+	jirl		ra, ra, 0
+
+	la.got		ra, t0, abort
+	jirl		ra, ra, 0
+END (ENTRY_POINT)
+
diff --git a/sysdeps/loongarch/sys/asm.h b/sysdeps/loongarch/sys/asm.h
new file mode 100644
index 0000000000..1133f76157
--- /dev/null
+++ b/sysdeps/loongarch/sys/asm.h
@@ -0,0 +1,58 @@
+/* Miscellaneous macros.
+   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_ASM_H
+#define _SYS_ASM_H
+
+#include <sys/regdef.h>
+#include <sysdeps/generic/sysdep.h>
+
+/* Macros to handle different pointer/register sizes for 32/64-bit code.  */
+#ifdef __loongarch_lp64
+#define PTRLOG 3
+#define SZREG 8
+#define SZFREG 8
+#define REG_L ld.d
+#define REG_S st.d
+#define FREG_L fld.d
+#define FREG_S fst.d
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+/* Declare leaf routine.  */
+#define LEAF(symbol) \
+  .text; \
+  .globl symbol; \
+  .align 3; \
+  cfi_startproc; \
+  .type symbol, @function; \
+  symbol:
+
+#define ENTRY(symbol) LEAF (symbol)
+
+/* Mark end of function.  */
+#undef END
+#define END(function) \
+  cfi_endproc; \
+  .size function, .- function;
+
+/* Stack alignment.  */
+#define ALMASK ~15
+
+#endif /* sys/asm.h */
diff --git a/sysdeps/loongarch/tls-macros.h b/sysdeps/loongarch/tls-macros.h
new file mode 100644
index 0000000000..af5eb6b700
--- /dev/null
+++ b/sysdeps/loongarch/tls-macros.h
@@ -0,0 +1,49 @@
+/* Macros to support TLS testing in times of missing compiler support.
+   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 <sys/cdefs.h>
+#include <sys/asm.h>
+#include <sysdep.h>
+#include "dl-tls.h"
+
+#define TLS_GD(x) \
+  ({ \
+    void *__result; \
+    asm("la.tls.gd %0, " #x "\n\t" : "=r"(__result)); \
+    __tls_get_addr (__result); \
+  })
+
+#define TLS_LD(x) TLS_GD (x)
+
+#define TLS_IE(x) \
+  ({ \
+    void *__result; \
+    asm("la.tls.ie %0, " #x "\n\t" \
+	"add.d %0, %0, $tp\n\t" \
+	: "=r"(__result)); \
+    __result; \
+  })
+
+#define TLS_LE(x) \
+  ({ \
+    void *__result; \
+    asm("la.tls.le %0, " #x "\n\t" \
+	"add.d %0, %0, $tp\n\t" \
+	: "=r"(__result)); \
+    __result; \
+  })
diff --git a/sysdeps/loongarch/tst-audit.h b/sysdeps/loongarch/tst-audit.h
new file mode 100644
index 0000000000..de120d8aae
--- /dev/null
+++ b/sysdeps/loongarch/tst-audit.h
@@ -0,0 +1,23 @@
+/* Definitions for testing PLT entry/exit auditing.
+   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_loongarch_gnu_pltenter
+#define pltexit la_loongarch_gnu_pltexit
+#define La_regs La_loongarch_regs
+#define La_retval La_loongarch_retval
+#define int_retval lrv_a0
diff --git a/sysdeps/unix/sysv/linux/loongarch/ldconfig.h b/sysdeps/unix/sysv/linux/loongarch/ldconfig.h
new file mode 100644
index 0000000000..126f0860e9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/ldconfig.h
@@ -0,0 +1,30 @@
+/* ldconfig default paths and libraries.
+   Copyright (C) 2001-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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdeps/generic/ldconfig.h>
+
+#ifdef __loongarch_lp64
+#define SYSDEP_KNOWN_INTERPRETER_NAMES \
+  { "/lib64/ld-linux-loongarch-lp64d.so.1", FLAG_ELF_LIBC6 },
+#else
+#error cannot determine ABI
+#endif
+
+#define SYSDEP_KNOWN_LIBRARY_NAMES	\
+  { "libc.so.6", FLAG_ELF_LIBC6 },	\
+  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/loongarch/localplt.data b/sysdeps/unix/sysv/linux/loongarch/localplt.data
new file mode 100644
index 0000000000..817ab2659a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/localplt.data
@@ -0,0 +1,12 @@
+# 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
+# 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
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
new file mode 100644
index 0000000000..a02865b4a5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
@@ -0,0 +1,44 @@
+/* jump buffer constants for LoongArch.
+   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 304
+#define JMP_BUF_ALIGN 8
+#define SIGJMP_BUF_SIZE 304
+#define SIGJMP_BUF_ALIGN 8
+#define MASK_WAS_SAVED_OFFSET 168
+#define SAVED_MASK_OFFSET 176
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h
new file mode 100644
index 0000000000..835df05ce5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h
@@ -0,0 +1,41 @@
+/* Copyright (C) 2020-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 240
+# define JMP_BUF_ALIGN 8
+# define SIGJMP_BUF_SIZE 240
+# define SIGJMP_BUF_ALIGN 8
+# define MASK_WAS_SAVED_OFFSET 104
+# define SAVED_MASK_OFFSET 112
-- 
2.27.0


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

* [PATCH v2 05/14] LoongArch: Thread-Local Storage Support
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (3 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 04/14] LoongArch: ABI Implementation caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 14:01   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 06/14] LoongArch: Generic <math.h> and soft-fp Routines caiyinyu
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

This patch implements TLS support for LoongArch.  We support all four
standard TLS addressing modes (LE, IE, LD, and GD) when running on
Linux via NPTL.
---
 sysdeps/loongarch/dl-tls.h             |  46 +++++++++
 sysdeps/loongarch/libc-tls.c           |  32 ++++++
 sysdeps/loongarch/nptl/tcb-offsets.sym |   6 ++
 sysdeps/loongarch/nptl/tls.h           | 138 +++++++++++++++++++++++++
 sysdeps/loongarch/stackinfo.h          |  33 ++++++
 5 files changed, 255 insertions(+)
 create mode 100644 sysdeps/loongarch/dl-tls.h
 create mode 100644 sysdeps/loongarch/libc-tls.c
 create mode 100644 sysdeps/loongarch/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/loongarch/nptl/tls.h
 create mode 100644 sysdeps/loongarch/stackinfo.h

diff --git a/sysdeps/loongarch/dl-tls.h b/sysdeps/loongarch/dl-tls.h
new file mode 100644
index 0000000000..ee7d78a3e9
--- /dev/null
+++ b/sysdeps/loongarch/dl-tls.h
@@ -0,0 +1,46 @@
+/* Thread-local storage handling in the ELF dynamic linker.
+   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;
+
+/* The thread pointer points to the first static TLS block.  */
+#define TLS_TP_OFFSET 0
+
+/* Dynamic thread vector pointers point to the start of each
+   TLS block.  */
+#define TLS_DTV_OFFSET 0
+
+/* Compute the value for a GOTTPREL reloc.  */
+#define TLS_TPREL_VALUE(sym_map, sym) \
+  ((sym_map)->l_tls_offset + (sym)->st_value - TLS_TP_OFFSET)
+
+/* Compute the value for a DTPREL reloc.  */
+#define TLS_DTPREL_VALUE(sym) ((sym)->st_value - TLS_DTV_OFFSET)
+
+extern void *__tls_get_addr (tls_index *ti);
+
+#define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET)
+#define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET)
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED ((void *) -1l)
diff --git a/sysdeps/loongarch/libc-tls.c b/sysdeps/loongarch/libc-tls.c
new file mode 100644
index 0000000000..32e303ecd3
--- /dev/null
+++ b/sysdeps/loongarch/libc-tls.c
@@ -0,0 +1,32 @@
+/* Thread-local storage handling in the ELF dynamic linker.
+   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 LoongArch, 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 + GET_ADDR_OFFSET;
+}
diff --git a/sysdeps/loongarch/nptl/tcb-offsets.sym b/sysdeps/loongarch/nptl/tcb-offsets.sym
new file mode 100644
index 0000000000..7d0c7596e8
--- /dev/null
+++ b/sysdeps/loongarch/nptl/tcb-offsets.sym
@@ -0,0 +1,6 @@
+#include <sysdep.h>
+#include <tls.h>
+
+#define thread_offsetof(mem)  (long)(offsetof (struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
+MULTIPLE_THREADS_OFFSET		thread_offsetof (header.multiple_threads)
diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h
new file mode 100644
index 0000000000..3b17e0b7f5
--- /dev/null
+++ b/sysdeps/loongarch/nptl/tls.h
@@ -0,0 +1,138 @@
+/* Definition for thread-local data handling.
+   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 _LOONGARCH_TLS_H
+#define _LOONGARCH_TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <dl-dtv.h>
+
+register void *__thread_self asm("$tp"); /* FIXME */
+#define READ_THREAD_POINTER() ({ __thread_self; })
+
+/* Get system call information.  */
+#include <sysdep.h>
+
+/* The TP points to the start of the thread blocks.  */
+#define TLS_DTV_AT_TP 1
+#define TLS_TCB_AT_TP 0
+
+/* Get the thread descriptor definition.  */
+#include <nptl/descr.h>
+
+typedef struct
+{
+  dtv_t *dtv;
+  void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB.  Because our TCB is before the thread
+   pointer, we don't need this.  */
+#define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB.  */
+#define TLS_INIT_TCB_ALIGN __alignof__(struct pthread)
+
+/* This is the size of the TCB.  Because our TCB is before the thread
+   pointer, we don't need this.  */
+#define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB.  */
+#define TLS_TCB_ALIGN __alignof__(struct pthread)
+
+/* This is the size we need before TCB - actually, it includes the TCB.  */
+#define TLS_PRE_TCB_SIZE \
+  (sizeof (struct pthread) \
+   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+
+/* The thread pointer tp points to the end of the TCB.
+   The pthread_descr structure is immediately in front of the TCB.  */
+#define TLS_TCB_OFFSET 0
+
+/* Install the dtv pointer.  The pointer passed is to the element with
+   index -1 which contain the length.  */
+#define INSTALL_DTV(tcbp, dtvp) (((tcbhead_t *) (tcbp))[-1].dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread.  */
+#define INSTALL_NEW_DTV(dtv) (THREAD_DTV () = (dtv))
+
+/* Return dtv of given thread descriptor.  */
+#define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))[-1].dtv)
+
+/* Code to initially initialize the thread pointer.  */
+#define TLS_INIT_TP(tcbp) \
+  ({ \
+    __thread_self = (char *) tcbp + TLS_TCB_OFFSET; \
+    NULL; \
+  })
+
+/* Return the address of the dtv for the current thread.  */
+#define THREAD_DTV() \
+  (((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))[-1].dtv)
+
+/* Return the thread descriptor for the current thread.  */
+#define THREAD_SELF \
+  ((struct pthread *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET \
+		       - TLS_PRE_TCB_SIZE))
+
+/* Value passed to 'clone' for initialization of the thread register.  */
+#define TLS_DEFINE_INIT_TP(tp, pd) \
+  void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE
+
+/* Informs libthread_db that the thread pointer is register 2, which is used
+ * to know how to do THREAD_SELF.  */
+#define DB_THREAD_SELF \
+  REGISTER (64, 64, 2 * 8, -TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
+/* Access to data in the thread descriptor is easy.  */
+# include <tcb-access.h>
+
+/* l_tls_offset == 0 is perfectly valid, so we have to use some different
+   value to mean unset l_tls_offset.  */
+#define NO_TLS_OFFSET -1
+
+/* Get and set the global scope generation counter in struct pthread.  */
+#define THREAD_GSCOPE_IN_TCB 1
+#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/loongarch/stackinfo.h b/sysdeps/loongarch/stackinfo.h
new file mode 100644
index 0000000000..a990a471f4
--- /dev/null
+++ b/sysdeps/loongarch/stackinfo.h
@@ -0,0 +1,33 @@
+/* Stack environment definitions for LoongArch.
+   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 LoongArch the stack grows down.  */
+#define _STACK_GROWS_DOWN 1
+
+/* Default to a non-executable stack.  */
+#define DEFAULT_STACK_PERMS (PF_R | PF_W)
+
+#endif /* stackinfo.h */
-- 
2.27.0


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

* [PATCH v2 06/14] LoongArch: Generic <math.h> and soft-fp Routines
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (4 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 05/14] LoongArch: Thread-Local Storage Support caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 14:05   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 07/14] LoongArch: Atomic and Locking Routines caiyinyu
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

This patch contains the miscellaneous math routines and headers we have
implemented for LoongArch.  This includes things from <math.h> that aren't
completely ISA-generic, floating-point bit manipulation, and soft-fp
hooks.
---
 sysdeps/loongarch/bits/fenv.h   |  90 ++++++++++++++++++++++++++++
 sysdeps/loongarch/e_sqrtl.c     |  38 ++++++++++++
 sysdeps/loongarch/fpu_control.h | 102 ++++++++++++++++++++++++++++++++
 sysdeps/loongarch/sfp-machine.h | 102 ++++++++++++++++++++++++++++++++
 sysdeps/loongarch/tininess.h    |   1 +
 5 files changed, 333 insertions(+)
 create mode 100644 sysdeps/loongarch/bits/fenv.h
 create mode 100644 sysdeps/loongarch/e_sqrtl.c
 create mode 100644 sysdeps/loongarch/fpu_control.h
 create mode 100644 sysdeps/loongarch/sfp-machine.h
 create mode 100644 sysdeps/loongarch/tininess.h

diff --git a/sysdeps/loongarch/bits/fenv.h b/sysdeps/loongarch/bits/fenv.h
new file mode 100644
index 0000000000..35433becd1
--- /dev/null
+++ b/sysdeps/loongarch/bits/fenv.h
@@ -0,0 +1,90 @@
+/* Floating point environment.
+   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 the exception.  We use the bit positions
+   of the appropriate bits in the FPU control word.  */
+enum
+{
+  FE_INEXACT =
+#define FE_INEXACT 0x010000
+    FE_INEXACT,
+  FE_UNDERFLOW =
+#define FE_UNDERFLOW 0x020000
+    FE_UNDERFLOW,
+  FE_OVERFLOW =
+#define FE_OVERFLOW 0x040000
+    FE_OVERFLOW,
+  FE_DIVBYZERO =
+#define FE_DIVBYZERO 0x080000
+    FE_DIVBYZERO,
+  FE_INVALID =
+#define FE_INVALID 0x100000
+    FE_INVALID,
+};
+
+#define FE_ALL_EXCEPT \
+  (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The LoongArch FPU supports all of the four defined rounding modes.  We
+   use again the bit positions in the FPU control word as the values
+   for the appropriate macros.  */
+enum
+{
+  FE_TONEAREST =
+#define FE_TONEAREST 0x000
+    FE_TONEAREST,
+  FE_TOWARDZERO =
+#define FE_TOWARDZERO 0x100
+    FE_TOWARDZERO,
+  FE_UPWARD =
+#define FE_UPWARD 0x200
+    FE_UPWARD,
+  FE_DOWNWARD =
+#define FE_DOWNWARD 0x300
+    FE_DOWNWARD
+};
+
+/* Type representing exception flags.  */
+typedef unsigned int fexcept_t;
+
+/* Type representing floating-point environment.  This function corresponds
+   to the layout of the block written by the `fstenv'.  */
+typedef struct
+{
+  unsigned int __fp_control_register;
+} fenv_t;
+
+/* If the default argument is used we use this value.  */
+#define FE_DFL_ENV ((const fenv_t *) -1)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exception is masked.  */
+#define FE_NOMASK_ENV ((const fenv_t *) -257)
+#endif
+
+#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
+/* 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/loongarch/e_sqrtl.c b/sysdeps/loongarch/e_sqrtl.c
new file mode 100644
index 0000000000..cbc5802f74
--- /dev/null
+++ b/sysdeps/loongarch/e_sqrtl.c
@@ -0,0 +1,38 @@
+/* long double square root in software floating-point emulation.
+   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 <stdlib.h>
+#include <soft-fp/soft-fp.h>
+#include <soft-fp/quad.h>
+
+long double
+__ieee754_sqrtl (const long double a)
+{
+  FP_DECL_EX;
+  FP_DECL_Q (A);
+  FP_DECL_Q (C);
+  long double c;
+
+  FP_INIT_ROUNDMODE;
+  FP_UNPACK_Q (A, a);
+  FP_SQRT_Q (C, A);
+  FP_PACK_Q (c, C);
+  FP_HANDLE_EXCEPTIONS;
+  return c;
+}
+strong_alias (__ieee754_sqrtl, __sqrtl_finite)
diff --git a/sysdeps/loongarch/fpu_control.h b/sysdeps/loongarch/fpu_control.h
new file mode 100644
index 0000000000..d26e27ab84
--- /dev/null
+++ b/sysdeps/loongarch/fpu_control.h
@@ -0,0 +1,102 @@
+/* FPU control word bits.
+   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 _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/* LoongArch FPU floating point control register bits.
+ *
+ * 31-29  -> reserved (read as 0, can not changed by software)
+ * 28     -> cause bit for invalid exception
+ * 27     -> cause bit for division by zero exception
+ * 26     -> cause bit for overflow exception
+ * 25     -> cause bit for underflow exception
+ * 24     -> cause bit for inexact exception
+ * 23-21  -> reserved (read as 0, can not changed by software)
+ * 20     -> flag invalid exception
+ * 19     -> flag division by zero exception
+ * 18     -> flag overflow exception
+ * 17     -> flag underflow exception
+ * 16     -> flag inexact exception
+ *  9-8   -> rounding control
+ *  7-5   -> reserved (read as 0, can not changed by software)
+ *  4     -> enable exception for invalid exception
+ *  3     -> enable exception for division by zero exception
+ *  2     -> enable exception for overflow exception
+ *  1     -> enable exception for underflow exception
+ *  0     -> enable exception for inexact exception
+ *
+ *
+ * Rounding Control:
+ * 00 - rounding ties to even (RNE)
+ * 01 - rounding toward zero (RZ)
+ * 10 - rounding (up) toward plus infinity (RP)
+ * 11 - rounding (down) toward minus infinity (RM)
+ */
+
+#include <features.h>
+
+#ifdef __loongarch_soft_float
+
+#define _FPU_RESERVED 0xffffffff
+#define _FPU_DEFAULT 0x00000000
+typedef unsigned int fpu_control_t;
+#define _FPU_GETCW(cw) (cw) = 0
+#define _FPU_SETCW(cw) (void) (cw)
+extern fpu_control_t __fpu_control;
+
+#else /* __loongarch_soft_float */
+
+/* Masks for interrupts.  */
+#define _FPU_MASK_V 0x10 /* Invalid operation */
+#define _FPU_MASK_Z 0x08 /* Division by zero  */
+#define _FPU_MASK_O 0x04 /* Overflow */
+#define _FPU_MASK_U 0x02 /* Underflow */
+#define _FPU_MASK_I 0x01 /* Inexact operation */
+
+/* Flush denormalized numbers to zero.  */
+#define _FPU_FLUSH_TZ 0x1000000
+
+/* Rounding control.  */
+#define _FPU_RC_NEAREST 0x000 /* RECOMMENDED */
+#define _FPU_RC_ZERO 0x100
+#define _FPU_RC_UP 0x200
+#define _FPU_RC_DOWN 0x300
+/* Mask for rounding control.  */
+#define _FPU_RC_MASK 0x300
+
+#define _FPU_RESERVED 0x0
+
+#define _FPU_DEFAULT 0x0
+#define _FPU_IEEE 0x1F
+
+/* Type of the control word.  */
+typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
+
+/* Macros for accessing the hardware control word.  */
+extern fpu_control_t __loongarch_fpu_getcw (void) __THROW;
+extern void __loongarch_fpu_setcw (fpu_control_t) __THROW;
+#define _FPU_GETCW(cw) __asm__ volatile("movfcsr2gr %0,$r0" : "=r"(cw))
+#define _FPU_SETCW(cw) __asm__ volatile("movgr2fcsr $r0,%0" : : "r"(cw))
+
+/* Default control word set at startup.  */
+extern fpu_control_t __fpu_control;
+
+#endif /* __loongarch_soft_float */
+
+#endif /* fpu_control.h */
diff --git a/sysdeps/loongarch/sfp-machine.h b/sysdeps/loongarch/sfp-machine.h
new file mode 100644
index 0000000000..61f11dd011
--- /dev/null
+++ b/sysdeps/loongarch/sfp-machine.h
@@ -0,0 +1,102 @@
+/* LoongArch 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/>.  */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#define _FP_W_TYPE_SIZE 64
+#define _FP_W_TYPE unsigned long long
+#define _FP_WS_TYPE signed long long
+#define _FP_I_TYPE long long
+
+#define _FP_MUL_MEAT_S(R, X, Y) _FP_MUL_MEAT_1_imm (_FP_WFRACBITS_S, R, X, Y)
+#define _FP_MUL_MEAT_D(R, X, Y) \
+  _FP_MUL_MEAT_1_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm)
+#define _FP_MUL_MEAT_Q(R, X, Y) \
+  _FP_MUL_MEAT_2_wide_3mul (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm)
+
+#define _FP_MUL_MEAT_DW_S(R, X, Y) \
+  _FP_MUL_MEAT_DW_1_imm (_FP_WFRACBITS_S, R, X, Y)
+#define _FP_MUL_MEAT_DW_D(R, X, Y) \
+  _FP_MUL_MEAT_DW_1_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm)
+#define _FP_MUL_MEAT_DW_Q(R, X, Y) \
+  _FP_MUL_MEAT_DW_2_wide_3mul (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R, X, Y) \
+  _FP_DIV_MEAT_1_imm (S, R, X, Y, _FP_DIV_HELP_imm)
+#define _FP_DIV_MEAT_D(R, X, Y) _FP_DIV_MEAT_1_udiv_norm (D, R, X, Y)
+#define _FP_DIV_MEAT_Q(R, X, Y) _FP_DIV_MEAT_2_udiv (Q, R, X, Y)
+
+#define _FP_NANFRAC_S _FP_QNANBIT_S
+#define _FP_NANFRAC_D _FP_QNANBIT_D
+#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0
+
+#define _FP_NANSIGN_S 0
+#define _FP_NANSIGN_D 0
+#define _FP_NANSIGN_Q 0
+
+#define _FP_KEEPNANFRACP 1
+#define _FP_QNANNEGATEDP 0
+
+/* NaN payloads should be preserved for NAN2008.  */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
+  do \
+    { \
+      R##_s = X##_s; \
+      _FP_FRAC_COPY_##wc (R, X); \
+      R##_c = FP_CLS_NAN; \
+    } \
+  while (0)
+
+#define _FP_DECL_EX fpu_control_t _fcw
+
+#define FP_ROUNDMODE (_fcw & 0x300)
+
+#define FP_RND_NEAREST FE_TONEAREST
+#define FP_RND_ZERO FE_TOWARDZERO
+#define FP_RND_PINF FE_UPWARD
+#define FP_RND_MINF FE_DOWNWARD
+
+#define FP_EX_INVALID FE_INVALID
+#define FP_EX_OVERFLOW FE_OVERFLOW
+#define FP_EX_UNDERFLOW FE_UNDERFLOW
+#define FP_EX_DIVZERO FE_DIVBYZERO
+#define FP_EX_INEXACT FE_INEXACT
+
+#define _FP_TININESS_AFTER_ROUNDING 1
+
+#ifdef __loongarch_hard_float
+#define FP_INIT_ROUNDMODE \
+  do \
+    { \
+      _FPU_GETCW (_fcw); \
+    } \
+  while (0)
+
+#define FP_HANDLE_EXCEPTIONS \
+  do \
+    { \
+      if (__builtin_expect (_fex, 0)) \
+	_FPU_SETCW (_fcw | _fex | (_fex << 8)); \
+    } \
+  while (0)
+#define FP_TRAPPING_EXCEPTIONS ((_fcw << 16) & 0x1f0000)
+#else
+#define FP_INIT_ROUNDMODE _fcw = FP_RND_NEAREST
+#endif
diff --git a/sysdeps/loongarch/tininess.h b/sysdeps/loongarch/tininess.h
new file mode 100644
index 0000000000..90956c35f7
--- /dev/null
+++ b/sysdeps/loongarch/tininess.h
@@ -0,0 +1 @@
+#define TININESS_AFTER_ROUNDING 1
-- 
2.27.0


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

* [PATCH v2 07/14] LoongArch: Atomic and Locking Routines
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (5 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 06/14] LoongArch: Generic <math.h> and soft-fp Routines caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 14:09   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 08/14] LoongArch: Linux Syscall Interface caiyinyu
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

This patch implements various atomic and locking routines on LoongArch.
---
 .../loongarch/nptl/bits/pthreadtypes-arch.h   |  41 ++++
 sysdeps/loongarch/nptl/bits/semaphore.h       |  32 +++
 sysdeps/loongarch/nptl/libc-lowlevellock.c    |   8 +
 .../sysv/linux/loongarch/atomic-machine.h     | 196 ++++++++++++++++++
 4 files changed, 277 insertions(+)
 create mode 100644 sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
 create mode 100644 sysdeps/loongarch/nptl/bits/semaphore.h
 create mode 100644 sysdeps/loongarch/nptl/libc-lowlevellock.c
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/atomic-machine.h

diff --git a/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h b/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
new file mode 100644
index 0000000000..e57f122a98
--- /dev/null
+++ b/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
@@ -0,0 +1,41 @@
+/* Machine-specific pthread type layouts.
+   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_ARCH_H
+#define _BITS_PTHREADTYPES_ARCH_H 1
+
+#include <bits/endian.h>
+
+#ifdef __loongarch_lp64
+#define __SIZEOF_PTHREAD_ATTR_T 56
+#define __SIZEOF_PTHREAD_MUTEX_T 40
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 56
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 32
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+#define __LOCK_ALIGNMENT
+#define __ONCE_ALIGNMENT
+
+#endif /* bits/pthreadtypes.h */
diff --git a/sysdeps/loongarch/nptl/bits/semaphore.h b/sysdeps/loongarch/nptl/bits/semaphore.h
new file mode 100644
index 0000000000..510f3b0e9a
--- /dev/null
+++ b/sysdeps/loongarch/nptl/bits/semaphore.h
@@ -0,0 +1,32 @@
+/* POSIX semaphore type layout
+   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 _SEMAPHORE_H
+#error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#define __SIZEOF_SEM_T (4 * __SIZEOF_POINTER__)
+
+/* Value returned if `sem_open' failed.  */
+#define SEM_FAILED ((sem_t *) 0)
+
+typedef union
+{
+  char __size[__SIZEOF_SEM_T];
+  long int __align;
+} sem_t;
diff --git a/sysdeps/loongarch/nptl/libc-lowlevellock.c b/sysdeps/loongarch/nptl/libc-lowlevellock.c
new file mode 100644
index 0000000000..f4b8b5c193
--- /dev/null
+++ b/sysdeps/loongarch/nptl/libc-lowlevellock.c
@@ -0,0 +1,8 @@
+/* This kludge works around a libpthread static linking problem:
+   https://sourceware.org/bugzilla/show_bug.cgi?id=15648.  */
+
+#ifndef SHARED
+#define __lll_lock_wait_private weak_function __lll_lock_wait_private
+#endif
+
+#include <lowlevellock.c>
diff --git a/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h b/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
new file mode 100644
index 0000000000..dbae608ee5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
@@ -0,0 +1,196 @@
+/* Atomic operations.
+   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_LOONGARCH_BITS_ATOMIC_H
+#define _LINUX_LOONGARCH_BITS_ATOMIC_H 1
+
+#include <stdint.h>
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+
+typedef int64_t atomic64_t;
+typedef uint64_t uatomic64_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+#define atomic_full_barrier() __sync_synchronize ()
+
+#ifdef __LP64__
+#define __HAVE_64B_ATOMICS 1
+#endif
+#define USE_ATOMIC_COMPILER_BUILTINS 1
+#define ATOMIC_EXCHANGE_USES_CAS 0
+
+/* Compare and exchange.
+   For all "bool" routines, we return FALSE if exchange succesful.  */
+
+#define __arch_compare_and_exchange_bool_8_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_16_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_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) \
+  ({ \
+    typeof (*mem) __oldval = (oldval); \
+    !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, model, \
+				  __ATOMIC_RELAXED); \
+  })
+
+#define __arch_compare_and_exchange_val_8_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_16_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_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) \
+  ({ \
+    typeof (*mem) __oldval = (oldval); \
+    __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, model, \
+				 __ATOMIC_RELAXED); \
+    __oldval; \
+  })
+
+/* Atomic compare and exchange.  */
+
+#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_compare_and_exchange_val_rel(mem, new, old) \
+  __atomic_val_bysize (__arch_compare_and_exchange_val, int, mem, new, old, \
+		       __ATOMIC_RELEASE)
+
+/* Atomic exchange (without compare).  */
+
+#define __arch_exchange_8_int(mem, newval, model) \
+  __atomic_exchange_n (mem, newval, model)
+
+#define __arch_exchange_16_int(mem, newval, model) \
+  __atomic_exchange_n (mem, newval, model)
+
+#define __arch_exchange_32_int(mem, newval, model) \
+  __atomic_exchange_n (mem, newval, model)
+
+#define __arch_exchange_64_int(mem, newval, model) \
+  __atomic_exchange_n (mem, newval, model)
+
+#define atomic_exchange_acq(mem, value) \
+  __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_ACQUIRE)
+
+#define atomic_exchange_rel(mem, value) \
+  __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_RELEASE)
+
+/* Atomically add value and return the previous (unincremented) value.  */
+
+#define __arch_exchange_and_add_8_int(mem, value, model) \
+  __atomic_fetch_add (mem, value, model)
+
+#define __arch_exchange_and_add_16_int(mem, value, model) \
+  __atomic_fetch_add (mem, value, model)
+
+#define __arch_exchange_and_add_32_int(mem, value, model) \
+  __atomic_fetch_add (mem, value, model)
+
+#define __arch_exchange_and_add_64_int(mem, value, model) \
+  __atomic_fetch_add (mem, value, model)
+
+#define atomic_exchange_and_add_acq(mem, value) \
+  __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \
+		       __ATOMIC_ACQUIRE)
+
+#define atomic_exchange_and_add_rel(mem, value) \
+  __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \
+		       __ATOMIC_RELEASE)
+
+/* Miscellaneous.  */
+
+#define asm_amo(which, mem, value) \
+  ({ \
+    __atomic_check_size (mem); \
+    typeof (*mem) __tmp; \
+    if (sizeof (__tmp) == 4) \
+      asm volatile(which ".w" \
+			 "\t%0, %z2, %1" \
+		   : "=&r"(__tmp), "+ZB"(*(mem)) \
+		   : "rJ"(value)); \
+    else if (sizeof (__tmp) == 8) \
+      asm volatile(which ".d" \
+			 "\t%0, %z2, %1" \
+		   : "=&r"(__tmp), "+ZB"(*(mem)) \
+		   : "rJ"(value)); \
+    else \
+      abort (); \
+    __tmp; \
+  })
+
+#define atomic_max(mem, value) asm_amo ("ammax_db", mem, value)
+#define atomic_min(mem, value) asm_amo ("ammin_db", mem, value)
+
+#define atomic_bit_test_set(mem, bit) \
+  ({ \
+    typeof (*mem) __mask = (typeof (*mem)) 1 << (bit); \
+    asm_amo ("amor_db", mem, __mask) & __mask; \
+  })
+
+#define catomic_exchange_and_add(mem, value) \
+  atomic_exchange_and_add (mem, value)
+#define catomic_max(mem, value) atomic_max (mem, value)
+
+#endif /* bits/atomic.h */
-- 
2.27.0


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

* [PATCH v2 08/14] LoongArch: Linux Syscall Interface
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (6 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 07/14] LoongArch: Atomic and Locking Routines caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 14:20   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 09/14] LoongArch: Linux ABI caiyinyu
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

Contains the Linux system call interface, as well as the definitions of
a handful of system calls.
---
 sysdeps/loongarch/abort-instr.h               |   2 +
 sysdeps/loongarch/hp-timing.h                 |  42 +++
 sysdeps/loongarch/nptl/nptl-sysdep.S          |   2 +
 .../unix/sysv/linux/loongarch/arch-syscall.h  | 302 ++++++++++++++++
 .../unix/sysv/linux/loongarch/bits/signum.h   |  58 ++++
 sysdeps/unix/sysv/linux/loongarch/clone.S     | 100 ++++++
 sysdeps/unix/sysv/linux/loongarch/clone3.S    |  87 +++++
 sysdeps/unix/sysv/linux/loongarch/ipc_priv.h  |  22 ++
 sysdeps/unix/sysv/linux/loongarch/syscall.c   |  35 ++
 sysdeps/unix/sysv/linux/loongarch/sysdep.S    |  53 +++
 sysdeps/unix/sysv/linux/loongarch/sysdep.h    | 321 ++++++++++++++++++
 sysdeps/unix/sysv/linux/loongarch/vfork.S     |  50 +++
 12 files changed, 1074 insertions(+)
 create mode 100644 sysdeps/loongarch/abort-instr.h
 create mode 100644 sysdeps/loongarch/hp-timing.h
 create mode 100644 sysdeps/loongarch/nptl/nptl-sysdep.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/signum.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone3.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall.c
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/vfork.S

diff --git a/sysdeps/loongarch/abort-instr.h b/sysdeps/loongarch/abort-instr.h
new file mode 100644
index 0000000000..92e22edfea
--- /dev/null
+++ b/sysdeps/loongarch/abort-instr.h
@@ -0,0 +1,2 @@
+/* An instruction which should crash any program is a breakpoint.  */
+#define ABORT_INSTRUCTION asm("break 0")
diff --git a/sysdeps/loongarch/hp-timing.h b/sysdeps/loongarch/hp-timing.h
new file mode 100644
index 0000000000..7b36a539f1
--- /dev/null
+++ b/sysdeps/loongarch/hp-timing.h
@@ -0,0 +1,42 @@
+/* High precision, low overhead timing functions.
+   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 _HP_TIMING_H
+#define _HP_TIMING_H 1
+
+/* We always assume having the timestamp register.  */
+#define HP_TIMING_AVAIL (1)
+#define HP_SMALL_TIMING_AVAIL (1)
+
+/* We indeed have inlined functions.  */
+#define HP_TIMING_INLINE (1)
+
+/* We use 64bit values for the times.  */
+typedef unsigned long long int hp_timing_t;
+
+/* Read the stable counter.  */
+#define HP_TIMING_NOW(Var) \
+  ({ \
+    unsigned long long int _count; \
+    asm volatile("rdtime.d\t%0,$r0" : "=r"(_count)); \
+    (Var) = _count; \
+  })
+
+#include <hp-timing-common.h>
+
+#endif /* hp-timing.h */
diff --git a/sysdeps/loongarch/nptl/nptl-sysdep.S b/sysdeps/loongarch/nptl/nptl-sysdep.S
new file mode 100644
index 0000000000..3f5c2a364a
--- /dev/null
+++ b/sysdeps/loongarch/nptl/nptl-sysdep.S
@@ -0,0 +1,2 @@
+/* Pull in __syscall_error.  */
+#include <sysdep.S>
diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
new file mode 100644
index 0000000000..f28811651f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
@@ -0,0 +1,302 @@
+/* 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_getres 114
+#define __NR_clock_gettime 113
+#define __NR_clock_nanosleep 115
+#define __NR_clock_settime 112
+#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 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_fcntl 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_fstat 80
+#define __NR_fstatfs 44
+#define __NR_fsync 82
+#define __NR_ftruncate 46
+#define __NR_futex 98
+#define __NR_futex_waitv 449
+#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_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_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_lookup_dcookie 18
+#define __NR_lremovexattr 15
+#define __NR_lseek 62
+#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_mmap 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_timedsend 182
+#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_newfstatat 79
+#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_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_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_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_recvmsg 212
+#define __NR_remap_file_pages 234
+#define __NR_removexattr 14
+#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_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_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_sendfile 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_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_statfs 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_settime 110
+#define __NR_timerfd_create 85
+#define __NR_timerfd_gettime 87
+#define __NR_timerfd_settime 86
+#define __NR_times 153
+#define __NR_tkill 130
+#define __NR_truncate 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_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/loongarch/bits/signum.h b/sysdeps/unix/sysv/linux/loongarch/bits/signum.h
new file mode 100644
index 0000000000..111759778b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/bits/signum.h
@@ -0,0 +1,58 @@
+/* Signal number definitions.  Linux 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_SIGNUM_H
+#define _BITS_SIGNUM_H 1
+
+#ifndef _SIGNAL_H
+#error "Never include <bits/signum.h> directly; use <signal.h> instead."
+#endif
+
+#include <bits/signum-generic.h>
+
+/* Adjustments and additions to the signal number constants for
+   most Linux systems.  */
+
+#define SIGSTKFLT 16 /* Stack fault (obsolete).  */
+#define SIGPWR 30    /* Power failure imminent.  */
+
+#undef SIGBUS
+#define SIGBUS 7
+#undef SIGUSR1
+#define SIGUSR1 10
+#undef SIGUSR2
+#define SIGUSR2 12
+#undef SIGCHLD
+#define SIGCHLD 17
+#undef SIGCONT
+#define SIGCONT 18
+#undef SIGSTOP
+#define SIGSTOP 19
+#undef SIGTSTP
+#define SIGTSTP 20
+#undef SIGURG
+#define SIGURG 23
+#undef SIGPOLL
+#define SIGPOLL 29
+#undef SIGSYS
+#define SIGSYS 31
+
+#undef __SIGRTMAX
+#define __SIGRTMAX 64
+
+#endif /* <signal.h> included.  */
diff --git a/sysdeps/unix/sysv/linux/loongarch/clone.S b/sysdeps/unix/sysv/linux/loongarch/clone.S
new file mode 100644
index 0000000000..d2bed24440
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/clone.S
@@ -0,0 +1,100 @@
+/* The clone syscall wrapper.
+   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/>.  */
+
+/* clone() is even more special than fork() as it mucks with stacks
+   and invokes a function in the right context after its all over.  */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#define _ERRNO_H  1
+#include <bits/errno.h>
+#include <tls.h>
+#include "tcb-offsets.h"
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+   void *parent_tidptr, void *tls, void *child_tidptr) */
+
+ENTRY (__clone)
+
+	/* Align stack to 16 or 8 bytes per the ABI.  */
+#ifdef __loongarch_lp64
+	bstrins.d	a1, zero, 3, 0
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+	/* Sanity check arguments.  */
+	beqz		a0, L (invalid) /* No NULL function pointers.  */
+	beqz		a1, L (invalid) /* No NULL stack pointers.  */
+
+	addi.d 		a1, a1, -16 /* Reserve argument save space.  */
+	st.d		a0, a1, 0   /* Save function pointer.  */
+	st.d		a3, a1, SZREG   /* Save argument pointer.  */
+
+	/* The syscall expects the args to be in different slots.  */
+	or		a0, a2, zero
+	or		a2, a4, zero
+	or		a3, a6, zero
+	or		a4, a5, zero
+
+	/* Do the system call.  */
+	li.d		a7,__NR_clone
+	syscall		0
+
+	blt		a0, zero ,L (error)
+	beqz		a0,L (thread_start)
+
+	/* Successful return from the parent.  */
+	ret
+
+L (invalid):
+	li.d		a0, -EINVAL
+
+	/* Something bad happened -- no child created.  */
+L (error):
+	b		__syscall_error
+
+END (__clone)
+
+/* Load up the arguments to the function.  Put this block of code in
+   its own function so that we can terminate the stack trace with our
+   debug info.  */
+ENTRY (__thread_start)
+L (thread_start):
+
+/* Terminate call stack by noting ra is undefined.  Use a dummy
+   .cfi_label to force starting the FDE.  */
+	.cfi_label .Ldummy
+	cfi_undefined (1)
+
+	/* Restore the arg for user's function.  */
+	ld.d		a1, sp, 0   /* Function pointer.  */
+	ld.d		a0, sp, SZREG   /* Argument pointer.  */
+
+	/* Call the user's function.  */
+	jirl		ra, a1, 0
+
+	/* Call exit with the function's return value.  */
+	li.d		a7, __NR_exit
+	syscall		0
+
+	END (__thread_start)
+
+libc_hidden_def (__clone)
+weak_alias (__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/loongarch/clone3.S b/sysdeps/unix/sysv/linux/loongarch/clone3.S
new file mode 100644
index 0000000000..5eaaa5462e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/clone3.S
@@ -0,0 +1,87 @@
+/* The clone3 syscall wrapper.
+   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/>.  */
+
+/* clone3() is even more special than fork() as it mucks with stacks
+   and invokes a function in the right context after its all over.  */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#define _ERRNO_H  1
+#include <bits/errno.h>
+#include <tls.h>
+#include "tcb-offsets.h"
+
+/* int clone3(struct clone_args *cl_args, size_t size,
+   int (*func)(void *arg), void *arg); */
+
+ENTRY (__clone3)
+
+	/* Sanity check arguments.  */
+	beqz		a0, L (invalid)	/* No NULL cl_args pointer.  */
+	beqz		a2, L (invalid)	/* No NULL function pointer.  */
+
+	/* Do the system call.  */
+	li.d		a7, __NR_clone3
+	syscall		0
+
+	blt		a0, zero ,L (error)
+	beqz		a0, L (thread_start3)
+
+	/* Successful return from the parent.  */
+	ret
+
+L (invalid):
+	li.d		a0, -EINVAL
+
+	/* Something bad happened -- no child created.  */
+L (error):
+	b		__syscall_error
+
+END (__clone3)
+
+/* Load up the arguments to the function.  Put this block of code in
+   its own function so that we can terminate the stack trace with our
+   debug info.  */
+ENTRY (__thread_start3)
+L (thread_start3):
+
+/* Terminate call stack by noting ra is undefined.  Use a dummy
+   .cfi_label to force starting the FDE.  */
+	.cfi_label .Ldummy
+	cfi_undefined (1)
+
+	/* Align stack to 16 or 8 bytes per the ABI.  */
+#ifdef __loongarch_lp64
+	bstrins.d	sp, zero, 3, 0
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+	/* Set up arguments for the function call.  */
+	move		a0, a3		/* Argument.  */
+	jirl		ra, a2, 0	/* Call function.  */
+
+	/* Call exit with the function's return value.  */
+	li.d		a7, __NR_exit
+	syscall		0
+
+	END (__thread_start3)
+
+libc_hidden_def (__clone3)
+weak_alias (__clone3, clone3)
diff --git a/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h b/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
new file mode 100644
index 0000000000..dde8fa6989
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
@@ -0,0 +1,22 @@
+/* Old SysV permission definition for Linux.
+   Copyright (C) 2021 Loongson Technology, 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 <sys/ipc.h> /* For __key_t  */
+
+#define __IPC_64 0x0
+#include <sysdeps/unix/sysv/linux/ipc_priv.h>
diff --git a/sysdeps/unix/sysv/linux/loongarch/syscall.c b/sysdeps/unix/sysv/linux/loongarch/syscall.c
new file mode 100644
index 0000000000..d0067bc2d0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/syscall.c
@@ -0,0 +1,35 @@
+/* system call interface.
+   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>
+
+long int
+syscall (long int syscall_number, long int arg1, long int arg2, long int arg3,
+	 long int arg4, long int arg5, long int arg6, long int arg7)
+{
+  long int ret;
+
+  ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4, arg5,
+			      arg6, arg7);
+
+  if (INTERNAL_SYSCALL_ERROR_P (ret))
+    return __syscall_error (ret);
+
+  return ret;
+}
diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.S b/sysdeps/unix/sysv/linux/loongarch/sysdep.S
new file mode 100644
index 0000000000..865de9b235
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.S
@@ -0,0 +1,53 @@
+/* syscall error handlers
+   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>
+
+#if IS_IN (libc)
+# define errno __libc_errno
+#endif
+
+ENTRY (__syscall_error)
+/* Fall through to __syscall_set_errno */
+END (__syscall_error)
+
+/* Non-standard calling convention: argument in a0, return address in t0,
+   and clobber only t1.
+ */
+ENTRY (__syscall_set_errno)
+
+/* We got here because a0 < 0, but only codes in the range [-4095, -1]
+   represent errors.	Otherwise, just return the result normally.
+ */
+	li.d		t1, -4096
+	bgeu		t1, a0, L (out)
+	sub.w		a0, zero, a0
+#if RTLD_PRIVATE_ERRNO
+	la		t1, rtld_errno
+#elif defined(__PIC__)
+	la.tls.ie	t1, errno
+	add.d		t1, tp, t1
+#else
+	la.tls.le	t1, errno
+	add.d		t1, tp, t1
+#endif
+	st.w		a0, t1, 0
+	li.d		a0, -1
+L (out):
+	ret
+END (__syscall_set_errno)
diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
new file mode 100644
index 0000000000..ec98870a74
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
@@ -0,0 +1,321 @@
+/* Assembly macros for LoongArch.
+   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_LOONGARCH_SYSDEP_H
+#define _LINUX_LOONGARCH_SYSDEP_H 1
+
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
+#include <tls.h>
+
+#ifdef __ASSEMBLER__
+
+#include <sys/asm.h>
+#define ret jirl zero, ra, 0
+#define L(label) .L##label
+
+/* Performs a system call, handling errors by setting errno.  Linux indicates
+   errors by setting a0 to a value between -1 and -4095.  */
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+  ENTRY (name); \
+  li.d a7, SYS_ify (syscall_name); \
+  syscall 0; \
+  li.d a7, -4096; \
+  bltu a7, a0, .Lsyscall_error##name;
+
+#undef PSEUDO_END
+#define PSEUDO_END(sym) \
+  SYSCALL_ERROR_HANDLER (sym); \
+  ret; \
+  END (sym);
+
+#if !IS_IN(libc)
+#if RTLD_PRIVATE_ERRNO
+
+#define SYSCALL_ERROR_HANDLER(name) \
+  .Lsyscall_error##name : la t0, rtld_errno; \
+  sub.w a0, zero, a0; \
+  st.w a0, t0, 0; \
+  li.d a0, -1;
+
+#else
+
+#define SYSCALL_ERROR_HANDLER(name) \
+  .Lsyscall_error##name : la.tls.ie t0, errno; \
+  add.d t0, tp, t0; \
+  sub.w a0, zero, a0; \
+  st.w a0, t0, 0; \
+  li.d a0, -1;
+
+#endif
+#else
+
+#define SYSCALL_ERROR_HANDLER(name) .Lsyscall_error##name : b __syscall_error;
+
+#endif
+
+/* Performs a system call, not setting errno.  */
+#undef PSEUDO_NEORRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+  ENTRY (name); \
+  li.d a7, SYS_ify (syscall_name); \
+  syscall 0;
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) END (name);
+
+#undef ret_NOERRNO
+#define ret_NOERRNO ret
+
+/* Perfroms a system call, returning the error code.  */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+  PSEUDO_NOERRNO (name, syscall_name, args); \
+  slli.d a0, a0, 32; \
+  srai.d a0, a0, 32; /* sign_ext */ \
+  sub.d a0, zero, a0;
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) END (name);
+
+#undef ret_ERRVAL
+#define ret_ERRVAL ret
+
+#endif /* __ASSEMBLER__ */
+
+/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
+#ifndef __ASSEMBLER__
+#include <errno.h>
+#endif
+
+#include <sysdeps/unix/sysdep.h>
+
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
+
+#ifndef __ASSEMBLER__
+
+#define VDSO_NAME "LINUX_2.6"
+#define VDSO_HASH 61765110
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
+#define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
+#define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
+#define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
+
+#define HAVE_CLONE3_WRAPPER 1
+
+#define INTERNAL_SYSCALL(name, nr, args...) \
+  internal_syscall##nr (SYS_ify (name), args)
+
+#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
+  internal_syscall##nr (number, args)
+
+#define internal_syscall0(number, dummy...) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0"); \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "=r"(__a0) \
+		       : "r"(__a7) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define internal_syscall1(number, arg0) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      long int _arg0 = (long int) (arg0); \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0") = _arg0; \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "+r"(__a0) \
+		       : "r"(__a7) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define internal_syscall2(number, arg0, arg1) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      long int _arg0 = (long int) (arg0); \
+      long int _arg1 = (long int) (arg1); \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0") = _arg0; \
+      register long int __a1 asm("$a1") = _arg1; \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "+r"(__a0) \
+		       : "r"(__a7), "r"(__a1) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define internal_syscall3(number, arg0, arg1, arg2) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      long int _arg0 = (long int) (arg0); \
+      long int _arg1 = (long int) (arg1); \
+      long int _arg2 = (long int) (arg2); \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0") = _arg0; \
+      register long int __a1 asm("$a1") = _arg1; \
+      register long int __a2 asm("$a2") = _arg2; \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "+r"(__a0) \
+		       : "r"(__a7), "r"(__a1), "r"(__a2) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define internal_syscall4(number, arg0, arg1, arg2, arg3) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      long int _arg0 = (long int) (arg0); \
+      long int _arg1 = (long int) (arg1); \
+      long int _arg2 = (long int) (arg2); \
+      long int _arg3 = (long int) (arg3); \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0") = _arg0; \
+      register long int __a1 asm("$a1") = _arg1; \
+      register long int __a2 asm("$a2") = _arg2; \
+      register long int __a3 asm("$a3") = _arg3; \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "+r"(__a0) \
+		       : "r"(__a7), "r"(__a1), "r"(__a2), "r"(__a3) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define internal_syscall5(number, arg0, arg1, arg2, arg3, arg4) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      long int _arg0 = (long int) (arg0); \
+      long int _arg1 = (long int) (arg1); \
+      long int _arg2 = (long int) (arg2); \
+      long int _arg3 = (long int) (arg3); \
+      long int _arg4 = (long int) (arg4); \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0") = _arg0; \
+      register long int __a1 asm("$a1") = _arg1; \
+      register long int __a2 asm("$a2") = _arg2; \
+      register long int __a3 asm("$a3") = _arg3; \
+      register long int __a4 asm("$a4") = _arg4; \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "+r"(__a0) \
+		       : "r"(__a7), "r"(__a1), "r"(__a2), \
+			 "r"(__a3), "r"(__a4) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define internal_syscall6(number, arg0, arg1, arg2, arg3, arg4, arg5) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      long int _arg0 = (long int) (arg0); \
+      long int _arg1 = (long int) (arg1); \
+      long int _arg2 = (long int) (arg2); \
+      long int _arg3 = (long int) (arg3); \
+      long int _arg4 = (long int) (arg4); \
+      long int _arg5 = (long int) (arg5); \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0") = _arg0; \
+      register long int __a1 asm("$a1") = _arg1; \
+      register long int __a2 asm("$a2") = _arg2; \
+      register long int __a3 asm("$a3") = _arg3; \
+      register long int __a4 asm("$a4") = _arg4; \
+      register long int __a5 asm("$a5") = _arg5; \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "+r"(__a0) \
+		       : "r"(__a7), "r"(__a1), "r"(__a2), "r"(__a3), \
+			 "r"(__a4), "r"(__a5) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define internal_syscall7(number, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
+  ({ \
+    long int _sys_result; \
+\
+    { \
+      long int _arg0 = (long int) (arg0); \
+      long int _arg1 = (long int) (arg1); \
+      long int _arg2 = (long int) (arg2); \
+      long int _arg3 = (long int) (arg3); \
+      long int _arg4 = (long int) (arg4); \
+      long int _arg5 = (long int) (arg5); \
+      long int _arg6 = (long int) (arg6); \
+      register long int __a7 asm("$a7") = number; \
+      register long int __a0 asm("$a0") = _arg0; \
+      register long int __a1 asm("$a1") = _arg1; \
+      register long int __a2 asm("$a2") = _arg2; \
+      register long int __a3 asm("$a3") = _arg3; \
+      register long int __a4 asm("$a4") = _arg4; \
+      register long int __a5 asm("$a5") = _arg5; \
+      register long int __a6 asm("$a6") = _arg6; \
+      __asm__ volatile("syscall	0\n\t" \
+		       : "+r"(__a0) \
+		       : "r"(__a7), "r"(__a1), "r"(__a2), "r"(__a3), \
+			 "r"(__a4), "r"(__a5), "r"(__a6) \
+		       : __SYSCALL_CLOBBERS); \
+      _sys_result = __a0; \
+    } \
+    _sys_result; \
+  })
+
+#define __SYSCALL_CLOBBERS \
+  "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "memory"
+
+extern long int __syscall_error (long int neg_errno);
+
+#endif /* ! __ASSEMBLER__ */
+
+/* Pointer mangling is not supported.  */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
+#endif /* linux/loongarch/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/loongarch/vfork.S b/sysdeps/unix/sysv/linux/loongarch/vfork.S
new file mode 100644
index 0000000000..585f98eef7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/vfork.S
@@ -0,0 +1,50 @@
+/* vfork for Linux.
+   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 _ERRNO_H  1
+#include <bits/errno.h>
+
+/* Clone the calling process, but without copying the whole address space.
+   The calling process is suspended until the new process exits or is
+   replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
+   and the process ID of the new process to the old process.  */
+
+ENTRY (__vfork)
+
+	li.d	a0, 0x4111 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
+	add.d   a1, zero, sp
+
+	/* Do the system call.  */
+	li.d	a7, __NR_clone
+	syscall	0
+
+	blt	a0, zero ,L (error)
+
+	ret
+
+L (error):
+	b	__syscall_error
+
+END (__vfork)
+
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
+strong_alias (__vfork, __libc_vfork)
-- 
2.27.0


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

* [PATCH v2 09/14] LoongArch: Linux ABI
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (7 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 08/14] LoongArch: Linux Syscall Interface caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2021-12-31 17:37   ` Joseph Myers
  2022-01-04 14:24   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 10/14] LoongArch: Linux Startup and Dynamic Loading Code caiyinyu
                   ` (6 subsequent siblings)
  15 siblings, 2 replies; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

Linux-specific code that is required for maintaining ABI compatibility.
---
 sysdeps/loongarch/dl-irel.h                   |  48 +++++++
 sysdeps/loongarch/libc-start.h                |  25 ++++
 sysdeps/loongarch/nptl/bits/struct_rwlock.h   |  44 ++++++
 sysdeps/loongarch/nptl/pthread-offsets.h      |  15 ++
 sysdeps/loongarch/nptl/pthreaddef.h           |  32 +++++
 .../unix/sysv/linux/loongarch/bits/fcntl.h    |  61 ++++++++
 sysdeps/unix/sysv/linux/loongarch/bits/mman.h |  42 ++++++
 .../linux/loongarch/bits/pthread_stack_min.h  |  20 +++
 .../sysv/linux/loongarch/bits/sigcontext.h    |  54 +++++++
 .../unix/sysv/linux/loongarch/bits/sigstack.h |  32 +++++
 .../unix/sysv/linux/loongarch/getcontext.S    |  74 ++++++++++
 .../unix/sysv/linux/loongarch/makecontext.c   |  79 +++++++++++
 .../unix/sysv/linux/loongarch/register-dump.h |  61 ++++++++
 .../unix/sysv/linux/loongarch/setcontext.S    | 115 +++++++++++++++
 .../sysv/linux/loongarch/sigcontextinfo.h     |  32 +++++
 .../unix/sysv/linux/loongarch/swapcontext.S   | 123 ++++++++++++++++
 .../unix/sysv/linux/loongarch/sys/procfs.h    | 134 ++++++++++++++++++
 .../unix/sysv/linux/loongarch/sys/ucontext.h  |  90 ++++++++++++
 sysdeps/unix/sysv/linux/loongarch/sys/user.h  |  32 +++++
 .../sysv/linux/loongarch/ucontext-macros.h    |  42 ++++++
 .../unix/sysv/linux/loongarch/ucontext_i.sym  |  33 +++++
 21 files changed, 1188 insertions(+)
 create mode 100644 sysdeps/loongarch/dl-irel.h
 create mode 100644 sysdeps/loongarch/libc-start.h
 create mode 100644 sysdeps/loongarch/nptl/bits/struct_rwlock.h
 create mode 100644 sysdeps/loongarch/nptl/pthread-offsets.h
 create mode 100644 sysdeps/loongarch/nptl/pthreaddef.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/fcntl.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/mman.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/pthread_stack_min.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/sigcontext.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/sigstack.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/register-dump.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sys/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ucontext_i.sym

diff --git a/sysdeps/loongarch/dl-irel.h b/sysdeps/loongarch/dl-irel.h
new file mode 100644
index 0000000000..9fd106a308
--- /dev/null
+++ b/sysdeps/loongarch/dl-irel.h
@@ -0,0 +1,48 @@
+/* Machine-dependent ELF indirect relocation inline functions.
+   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_IREL_H
+#define _DL_IREL_H
+
+#include <stdio.h>
+#include <unistd.h>
+
+#define ELF_MACHINE_IRELA 1
+
+static inline ElfW (Addr) __attribute ((always_inline))
+elf_ifunc_invoke (ElfW (Addr) addr)
+{
+  return ((ElfW (Addr) (*) (void)) (addr)) ();
+}
+
+static inline void __attribute ((always_inline))
+elf_irela (const ElfW (Rela) * reloc)
+{
+  ElfW (Addr) *const reloc_addr = (void *) reloc->r_offset;
+  const unsigned long int r_type = ELFW (R_TYPE) (reloc->r_info);
+
+  if (__glibc_likely (r_type == R_LARCH_IRELATIVE))
+    {
+      ElfW (Addr) value = elf_ifunc_invoke (reloc->r_addend);
+      *reloc_addr = value;
+    }
+  else
+    __libc_fatal ("Unexpected reloc type in static binary.\n");
+}
+
+#endif /* dl-irel.h */
diff --git a/sysdeps/loongarch/libc-start.h b/sysdeps/loongarch/libc-start.h
new file mode 100644
index 0000000000..961d0b4d76
--- /dev/null
+++ b/sysdeps/loongarch/libc-start.h
@@ -0,0 +1,25 @@
+/* LoongArch definitions for libc main startup.
+   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 SHARED
+#define ARCH_SETUP_IREL()
+#define ARCH_APPLY_IREL() apply_irel ()
+#ifndef ARCH_SETUP_TLS
+#define ARCH_SETUP_TLS() __libc_setup_tls ()
+#endif
+#endif /* !SHARED */
diff --git a/sysdeps/loongarch/nptl/bits/struct_rwlock.h b/sysdeps/loongarch/nptl/bits/struct_rwlock.h
new file mode 100644
index 0000000000..12b6a469bd
--- /dev/null
+++ b/sysdeps/loongarch/nptl/bits/struct_rwlock.h
@@ -0,0 +1,44 @@
+/* LoongArch internal rwlock struct 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/>.  */
+
+#ifndef _RWLOCK_INTERNAL_H
+#define _RWLOCK_INTERNAL_H
+
+/* There is a lot of padding in this structure.  While it's not strictly
+   necessary on LoongArch, we're going to leave it in to be on the safe side in
+   case it's needed in the future.  Most other architectures have the padding,
+   so this gives us the same extensibility as everyone else has.  */
+struct __pthread_rwlock_arch_t
+{
+  unsigned int __readers;
+  unsigned int __writers;
+  unsigned int __wrphase_futex;
+  unsigned int __writers_futex;
+  unsigned int __pad3;
+  unsigned int __pad4;
+  int __cur_writer;
+  int __shared;
+  unsigned long int __pad1;
+  unsigned long int __pad2;
+  unsigned int __flags;
+};
+
+#define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, __flags
+
+#endif
diff --git a/sysdeps/loongarch/nptl/pthread-offsets.h b/sysdeps/loongarch/nptl/pthread-offsets.h
new file mode 100644
index 0000000000..415c3c113f
--- /dev/null
+++ b/sysdeps/loongarch/nptl/pthread-offsets.h
@@ -0,0 +1,15 @@
+#if __WORDSIZE == 64
+#define __PTHREAD_MUTEX_KIND_OFFSET 16
+#else
+#define __PTHREAD_MUTEX_KIND_OFFSET 12
+#endif
+
+#if __WORDSIZE == 64
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+#else
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+#else
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
+#endif
+#endif
diff --git a/sysdeps/loongarch/nptl/pthreaddef.h b/sysdeps/loongarch/nptl/pthreaddef.h
new file mode 100644
index 0000000000..f13c947917
--- /dev/null
+++ b/sysdeps/loongarch/nptl/pthreaddef.h
@@ -0,0 +1,32 @@
+/* pthread machine parameter 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/>.  */
+
+/* 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
+
+/* Location of current stack frame.  */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/fcntl.h b/sysdeps/unix/sysv/linux/loongarch/bits/fcntl.h
new file mode 100644
index 0000000000..a39985e1a7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/bits/fcntl.h
@@ -0,0 +1,61 @@
+/* O_*, F_*, FD_* bit values for the generic Linux/LoongArch ABI.
+   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 _FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+#include <bits/wordsize.h>
+
+/* In 64-bit ISA files are always with 64bit off_t and F_*LK64 are the same as
+   non-64-bit versions.  It will need to be revised for 128-bit.  */
+#if __WORDSIZE == 64
+#define __O_LARGEFILE 0
+
+#define F_GETLK64 5  /* Get record locking info.  */
+#define F_SETLK64 6  /* Set record locking info (non-blocking).  */
+#define F_SETLKW64 7 /* Set record locking info (blocking).  */
+#endif
+
+struct flock
+{
+  short int l_type;   /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+  short int l_whence; /* Where `l_start' is relative to (like `lseek').  */
+#ifndef __USE_FILE_OFFSET64
+  __off_t l_start; /* Offset where the lock begins.  */
+  __off_t l_len;   /* Size of the locked area; zero means until EOF.  */
+#else
+  __off64_t l_start; /* Offset where the lock begins.  */
+  __off64_t l_len;   /* Size of the locked area; zero means until EOF.  */
+#endif
+  __pid_t l_pid; /* Process holding the lock.  */
+};
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+{
+  short int l_type;   /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+  short int l_whence; /* Where `l_start' is relative to (like `lseek').  */
+  __off64_t l_start;  /* Offset where the lock begins.  */
+  __off64_t l_len;    /* Size of the locked area; zero means until EOF.  */
+  __pid_t l_pid;      /* Process holding the lock.  */
+};
+#endif
+
+/* Include generic Linux declarations.  */
+#include <bits/fcntl-linux.h>
diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/mman.h b/sysdeps/unix/sysv/linux/loongarch/bits/mman.h
new file mode 100644
index 0000000000..1f2f76fc8a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/bits/mman.h
@@ -0,0 +1,42 @@
+/* Definitions for POSIX memory map interface.
+   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_MMAN_H
+#error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+#ifdef __USE_MISC
+#define MAP_GROWSDOWN 0x00100  /* Stack-like segment.  */
+#define MAP_DENYWRITE 0x00800  /* ETXTBSY.  */
+#define MAP_EXECUTABLE 0x01000 /* Mark it as an executable.  */
+#define MAP_LOCKED 0x02000     /* Lock the mapping.  */
+#define MAP_NORESERVE 0x04000  /* Don't check for reservations.  */
+#define MAP_POPULATE 0x08000   /* Populate (prefault) pagetables.  */
+#define MAP_NONBLOCK 0x10000   /* Do not block on IO.  */
+#define MAP_STACK 0x20000      /* Allocation is for a stack.  */
+#define MAP_HUGETLB 0x40000    /* Create huge page mapping.  */
+#define MAP_SYNC \
+  0x80000 /* Perform synchronous page \
+	     faults for the mapping.  */
+#define MAP_FIXED_NOREPLACE \
+  0x100000 /* MAP_FIXED but do not unmap \
+	      underlying mapping.  */
+#endif
+
+/* Include generic Linux declarations.  */
+#include <bits/mman-linux.h>
diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/loongarch/bits/pthread_stack_min.h
new file mode 100644
index 0000000000..ccab36caca
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/bits/pthread_stack_min.h
@@ -0,0 +1,20 @@
+/* Definition of PTHREAD_STACK_MIN.  LoongArch Linux 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/>.  */
+
+/* Minimum size for a thread.  At least two pages with 64k pages.  */
+#define PTHREAD_STACK_MIN	131072
diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/sigcontext.h b/sysdeps/unix/sysv/linux/loongarch/bits/sigcontext.h
new file mode 100644
index 0000000000..95357adaf3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/bits/sigcontext.h
@@ -0,0 +1,54 @@
+/* Machine-dependent signal context structure for Linux.
+   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_SIGCONTEXT_H
+#define _BITS_SIGCONTEXT_H
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#define FPU_REG_WIDTH 256
+#define FPU_ALIGN __attribute__ ((aligned (32)))
+
+struct sigcontext
+{
+  unsigned long long sc_pc;
+  unsigned long long sc_regs[32];
+  unsigned int sc_flags;
+
+  unsigned int sc_fcsr;
+  unsigned int sc_vcsr;
+  unsigned long long sc_fcc;
+
+  /* For Binary Translation */
+  unsigned long long sc_scr[4];
+  unsigned int sc_eflags;
+
+  union
+  {
+    unsigned int val32[FPU_REG_WIDTH / 32];
+    unsigned long long val64[FPU_REG_WIDTH / 64];
+  } sc_fpregs[32] FPU_ALIGN;
+
+  /* Reserved for future scalable vectors */
+  unsigned int sc_svsize;
+  unsigned long long sc_svregs[0] __attribute__((__aligned__(16)));
+};
+
+#endif /* _BITS_SIGCONTEXT_H */
diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/sigstack.h b/sysdeps/unix/sysv/linux/loongarch/bits/sigstack.h
new file mode 100644
index 0000000000..d59632dea0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/bits/sigstack.h
@@ -0,0 +1,32 @@
+/* sigstack, sigaltstack definitions.
+   Copyright (C) 1998-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_SIGSTACK_H
+#define _BITS_SIGSTACK_H 1
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never include this file directly.  Use <signal.h> instead"
+#endif
+
+/* Minimum stack size for a signal handler.  */
+#define MINSIGSTKSZ	4096
+
+/* System default stack size.  */
+#define SIGSTKSZ	16384
+
+#endif /* bits/sigstack.h */
diff --git a/sysdeps/unix/sysv/linux/loongarch/getcontext.S b/sysdeps/unix/sysv/linux/loongarch/getcontext.S
new file mode 100644
index 0000000000..3a64857a42
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/getcontext.S
@@ -0,0 +1,74 @@
+/* Save current context.
+   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 "ucontext-macros.h"
+
+/* int getcontext (ucontext_t *ucp) */
+
+	.text
+LEAF (__getcontext)
+	SAVE_INT_REG (ra,   1, a0)
+	SAVE_INT_REG (sp,   3, a0)
+	SAVE_INT_REG (zero, 4, a0) /* return 0 by overwriting a0.  */
+	SAVE_INT_REG (x,   21, a0)
+	SAVE_INT_REG (fp,  22, a0)
+	SAVE_INT_REG (s0,  23, a0)
+	SAVE_INT_REG (s1,  24, a0)
+	SAVE_INT_REG (s2,  25, a0)
+	SAVE_INT_REG (s3,  26, a0)
+	SAVE_INT_REG (s4,  27, a0)
+	SAVE_INT_REG (s5,  28, a0)
+	SAVE_INT_REG (s6,  29, a0)
+	SAVE_INT_REG (s7,  30, a0)
+	SAVE_INT_REG (s8,  31, a0)
+	st.d		ra, a0, MCONTEXT_PC
+
+#ifndef __loongarch_soft_float
+	movfcsr2gr	a1, $r0
+
+	SAVE_FP_REG (fs0,  24, a0)
+	SAVE_FP_REG (fs1,  25, a0)
+	SAVE_FP_REG (fs2,  26, a0)
+	SAVE_FP_REG (fs3,  27, a0)
+	SAVE_FP_REG (fs4,  28, a0)
+	SAVE_FP_REG (fs5,  29, a0)
+	SAVE_FP_REG (fs6,  30, a0)
+	SAVE_FP_REG (fs7,  31, a0)
+
+	st.w		a1, a0, MCONTEXT_FCSR
+#endif /* __loongarch_soft_float */
+
+/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
+	li.d		a3, _NSIG8
+	li.d		a2, UCONTEXT_SIGMASK
+	add.d		a2, a2, a0
+	ori		a1, zero,0
+	li.d		a0, SIG_BLOCK
+
+	li.d		a7, SYS_ify (rt_sigprocmask)
+	syscall		0
+	blt		a0, zero, 99f
+
+	jirl		$r0, $r1, 0
+
+99:
+	b		__syscall_error
+
+PSEUDO_END (__getcontext)
+
+weak_alias (__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/loongarch/makecontext.c b/sysdeps/unix/sysv/linux/loongarch/makecontext.c
new file mode 100644
index 0000000000..1ad8807517
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/makecontext.c
@@ -0,0 +1,79 @@
+/* Create new context.
+   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 <sys/asm.h>
+#include <sys/ucontext.h>
+#include <stdarg.h>
+#include <assert.h>
+
+void
+__makecontext (ucontext_t *ucp, void (*func) (void), int argc, long int a0,
+	       long int a1, long int a2, long int a3, long int a4, ...)
+{
+  extern void __start_context (void) attribute_hidden;
+  long int i, sp;
+
+  _Static_assert(LARCH_REG_NARGS == 8,
+		 "__makecontext assumes 8 argument registers");
+
+  /* Set up the stack.  */
+  sp = ((long int) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ALMASK;
+
+  /* Set up the register context.
+     ra = s0 = 0, terminating the stack for backtracing purposes.
+     s1 = the function we must call.
+     s2 = the subsequent context to run.  */
+  ucp->uc_mcontext.__gregs[LARCH_REG_RA] = 0;
+  ucp->uc_mcontext.__gregs[LARCH_REG_S0] = 0;
+  ucp->uc_mcontext.__gregs[LARCH_REG_S1] = (long int) func;
+  ucp->uc_mcontext.__gregs[LARCH_REG_S2] = (long int) ucp->uc_link;
+  ucp->uc_mcontext.__gregs[LARCH_REG_SP] = sp;
+  ucp->uc_mcontext.__pc = (long int) &__start_context;
+
+  /* Put args in a0-a7, then put any remaining args on the stack.  */
+  ucp->uc_mcontext.__gregs[LARCH_REG_A0 + 0] = a0;
+  ucp->uc_mcontext.__gregs[LARCH_REG_A0 + 1] = a1;
+  ucp->uc_mcontext.__gregs[LARCH_REG_A0 + 2] = a2;
+  ucp->uc_mcontext.__gregs[LARCH_REG_A0 + 3] = a3;
+  ucp->uc_mcontext.__gregs[LARCH_REG_A0 + 4] = a4;
+
+  if (__glibc_unlikely (argc > 5))
+    {
+      va_list vl;
+      va_start (vl, a4);
+
+      long reg_args = argc < LARCH_REG_NARGS ? argc : LARCH_REG_NARGS;
+      for (i = 5; i < reg_args; i++)
+	ucp->uc_mcontext.__gregs[LARCH_REG_A0 + i] = va_arg (vl, long);
+
+      long int stack_args = argc - reg_args;
+      if (stack_args > 0)
+	{
+	  sp = (sp - stack_args * sizeof (long int)) & ALMASK;
+	  ucp->uc_mcontext.__gregs[LARCH_REG_SP] = sp;
+	  for (i = 0; i < stack_args; i++)
+	    ((long int *) sp)[i] = va_arg (vl, long int);
+	}
+
+      va_end (vl);
+    }
+}
+
+weak_alias (__makecontext, makecontext)
diff --git a/sysdeps/unix/sysv/linux/loongarch/register-dump.h b/sysdeps/unix/sysv/linux/loongarch/register-dump.h
new file mode 100644
index 0000000000..9000fc3184
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/register-dump.h
@@ -0,0 +1,61 @@
+/* Dump registers.
+   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 <unistd.h>
+#include <string.h>
+#include <_itoa.h>
+
+static void
+hexvalue (unsigned long int value, char *buf, size_t len)
+{
+  char *cp = _itoa_word (value, buf + len, 16, 0);
+  while (cp > buf)
+    *--cp = '0';
+}
+
+#define REGDUMP_NREGS 32
+#define REGDUMP_PER_LINE (80 / (__WORDSIZE / 4 + 4))
+
+static void
+register_dump (int fd, ucontext_t *ctx)
+{
+  int i;
+  char regvalue[__WORDSIZE / 4 + 1];
+  char str[82 * ((REGDUMP_NREGS + REGDUMP_PER_LINE - 1) / REGDUMP_PER_LINE)];
+
+  static const char names[REGDUMP_NREGS][4]
+    = {"pc", "ra", "tp", "sp", "a0", "a1", "a2", "a3", "a4", "a5", "a6",
+       "a7", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "x",
+       "fp", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8"};
+
+  str[0] = 0;
+  for (i = 0; i < REGDUMP_NREGS; i++)
+    {
+      strcat (str, names[i]);
+      strcat (str, " ");
+      hexvalue (ctx->uc_mcontext.__gregs[i], regvalue, __WORDSIZE / 4);
+      strcat (str, regvalue);
+
+      if ((i + 1) % REGDUMP_PER_LINE == 0)
+	strcat (str, "\n");
+    }
+
+  write (fd, str, strlen (str));
+}
+
+#define REGISTER_DUMP register_dump (fd, ctx)
diff --git a/sysdeps/unix/sysv/linux/loongarch/setcontext.S b/sysdeps/unix/sysv/linux/loongarch/setcontext.S
new file mode 100644
index 0000000000..0070829261
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/setcontext.S
@@ -0,0 +1,115 @@
+/* Set current context.
+   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 "sys/regdef.h"
+#include "ucontext-macros.h"
+
+/*  int __setcontext (const ucontext_t *ucp)
+
+  Restores the machine context in UCP and thereby resumes execution
+  in that context.
+
+  This implementation is intended to be used for *synchronous* context
+  switches only.  Therefore, it does not have to restore anything
+  other than the PRESERVED state.  */
+
+	.text
+LEAF (__setcontext)
+
+	addi.d		sp, sp, -16
+	st.d		a0, sp, 0	/* Save ucp to stack */
+
+/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
+	li.d		a3, _NSIG8
+	li.d		a2, 0
+	li.d		a1, UCONTEXT_SIGMASK
+	add.d		a1, a1, a0
+	li.d		a0, SIG_SETMASK
+
+	li.d		a7, SYS_ify (rt_sigprocmask)
+	syscall		0
+
+	blt		a0, $r0, 99f
+
+	ld.d		t0, sp, 0	/* Load ucp to t0 */
+	cfi_def_cfa (12, 0)
+
+#ifndef __loongarch_soft_float
+	ld.w		t1, t0, MCONTEXT_FCSR
+
+	RESTORE_FP_REG(fs0,  24, t0)
+	RESTORE_FP_REG(fs1,  25, t0)
+	RESTORE_FP_REG(fs2,  26, t0)
+	RESTORE_FP_REG(fs3,  27, t0)
+	RESTORE_FP_REG(fs4,  28, t0)
+	RESTORE_FP_REG(fs5,  29, t0)
+	RESTORE_FP_REG(fs6,  30, t0)
+	RESTORE_FP_REG(fs7,  31, t0)
+
+	movgr2fcsr	$r0, t1
+#endif /* __loongarch_soft_float */
+
+/* Note the contents of argument registers will be random
+   unless makecontext() has been called.  */
+	RESTORE_INT_REG(ra,   1, t0)
+	RESTORE_INT_REG(sp,   3, t0)
+	RESTORE_INT_REG(a0,   4, t0)
+	RESTORE_INT_REG(a1,   5, t0)
+	RESTORE_INT_REG(a2,   6, t0)
+	RESTORE_INT_REG(a3,   7, t0)
+	RESTORE_INT_REG(a4,   8, t0)
+	RESTORE_INT_REG(a5,   9, t0)
+	RESTORE_INT_REG(a6,  10, t0)
+	RESTORE_INT_REG(a7,  11, t0)
+	RESTORE_INT_REG(x,   21, t0)
+	RESTORE_INT_REG(fp,  22, t0)
+	RESTORE_INT_REG(s0,  23, t0)
+	RESTORE_INT_REG(s1,  24, t0)
+	RESTORE_INT_REG(s2,  25, t0)
+	RESTORE_INT_REG(s3,  26, t0)
+	RESTORE_INT_REG(s4,  27, t0)
+	RESTORE_INT_REG(s5,  28, t0)
+	RESTORE_INT_REG(s6,  29, t0)
+	RESTORE_INT_REG(s7,  30, t0)
+	RESTORE_INT_REG(s8,  31, t0)
+
+	ld.d		t1, t0, MCONTEXT_PC
+	jirl		$r0,t1,0
+
+99:
+	addi.d		sp, sp, 16
+	b		__syscall_error
+
+PSEUDO_END (__setcontext)
+weak_alias (__setcontext, setcontext)
+
+LEAF (__start_context)
+
+	/* Terminate call stack by noting ra == 0.  Happily, s0 == 0 here.  */
+	cfi_register (1, 23)
+
+	/* Call the function passed to makecontext.  */
+	jirl		$r1,s1,0
+
+	/* Invoke subsequent context if present, else exit(0).  */
+	ori		a0, s2, 0
+	beqz		s2, 1f
+	bl		__setcontext
+1:
+	b		exit
+
+PSEUDO_END (__start_context)
diff --git a/sysdeps/unix/sysv/linux/loongarch/sigcontextinfo.h b/sysdeps/unix/sysv/linux/loongarch/sigcontextinfo.h
new file mode 100644
index 0000000000..8b31839cf9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/sigcontextinfo.h
@@ -0,0 +1,32 @@
+/* LoongArch definitions for signal handling calling conventions.
+   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
+
+#include <stdint.h>
+#include <sys/ucontext.h>
+
+static inline uintptr_t
+sigcontext_get_pc (const ucontext_t *ctx)
+{
+  return ctx->uc_mcontext.__pc;
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/loongarch/swapcontext.S b/sysdeps/unix/sysv/linux/loongarch/swapcontext.S
new file mode 100644
index 0000000000..1f6e3d815a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/swapcontext.S
@@ -0,0 +1,123 @@
+/* Save and set current context.
+   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 "ucontext-macros.h"
+
+/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
+
+LEAF (__swapcontext)
+	ori		a2, sp, 0		/* Save sp to a2 */
+	addi.d		sp, sp, -16
+	st.d		a1, sp, 0
+	ori		t0, a1, 0
+
+	SAVE_INT_REG (ra,   1, a0)
+	SAVE_INT_REG (a2,   3, a0)		/* Store sp */
+	SAVE_INT_REG (zero, 4, a0)		/* return 0 by overwriting a0 */
+	SAVE_INT_REG (x,   21, a0)
+	SAVE_INT_REG (fp,  22, a0)
+	SAVE_INT_REG (s0,  23, a0)
+	SAVE_INT_REG (s1,  24, a0)
+	SAVE_INT_REG (s2,  25, a0)
+	SAVE_INT_REG (s3,  26, a0)
+	SAVE_INT_REG (s4,  27, a0)
+	SAVE_INT_REG (s5,  28, a0)
+	SAVE_INT_REG (s6,  29, a0)
+	SAVE_INT_REG (s7,  30, a0)
+	SAVE_INT_REG (s8,  31, a0)
+
+	st.d		ra, a0, MCONTEXT_PC
+#ifndef __loongarch_soft_float
+	movfcsr2gr	a1, $r0
+
+	SAVE_FP_REG (fs0,  24, a0)
+	SAVE_FP_REG (fs1,  25, a0)
+	SAVE_FP_REG (fs2,  26, a0)
+	SAVE_FP_REG (fs3,  27, a0)
+	SAVE_FP_REG (fs4,  28, a0)
+	SAVE_FP_REG (fs5,  29, a0)
+	SAVE_FP_REG (fs6,  30, a0)
+	SAVE_FP_REG (fs7,  31, a0)
+
+	st.w		a1, a0, MCONTEXT_FCSR
+#endif /* __loongarch_soft_float */
+
+/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, _NSIG8) */
+	li.d		a3, _NSIG8
+	li.d		a2, UCONTEXT_SIGMASK
+	add.d		a2, a2, a0
+	li.d		a1, UCONTEXT_SIGMASK
+	add.d		a1, a1, t0
+	li.d		a0, SIG_SETMASK
+
+	li.d		a7, SYS_ify (rt_sigprocmask)
+	syscall		0
+
+	blt		a0, zero, 99f
+
+#ifndef __loongarch_soft_float
+	ld.d		t0, sp, 0		/* Load a1 to t0 */
+	ld.w		t1, t0, MCONTEXT_FCSR
+
+	RESTORE_FP_REG (fs0,  24, t0)
+	RESTORE_FP_REG (fs1,  25, t0)
+	RESTORE_FP_REG (fs2,  26, t0)
+	RESTORE_FP_REG (fs3,  27, t0)
+	RESTORE_FP_REG (fs4,  28, t0)
+	RESTORE_FP_REG (fs5,  29, t0)
+	RESTORE_FP_REG (fs6,  30, t0)
+	RESTORE_FP_REG (fs7,  31, t0)
+
+	movgr2fcsr	$r0, t1
+#endif /* __loongarch_soft_float */
+
+/* Note the contents of argument registers will be random
+   unless makecontext() has been called.  */
+	RESTORE_INT_REG (ra,   1, t0)
+	RESTORE_INT_REG (sp,   3, t0)
+	RESTORE_INT_REG (a0,   4, t0)
+	RESTORE_INT_REG (a1,   5, t0)
+	RESTORE_INT_REG (a2,   6, t0)
+	RESTORE_INT_REG (a3,   7, t0)
+	RESTORE_INT_REG (a4,   8, t0)
+	RESTORE_INT_REG (a5,   9, t0)
+	RESTORE_INT_REG (a6,  10, t0)
+	RESTORE_INT_REG (a7,  11, t0)
+	RESTORE_INT_REG (x,   21, t0)
+	RESTORE_INT_REG (fp,  22, t0)
+	RESTORE_INT_REG (s0,  23, t0)
+	RESTORE_INT_REG (s1,  24, t0)
+	RESTORE_INT_REG (s2,  25, t0)
+	RESTORE_INT_REG (s3,  26, t0)
+	RESTORE_INT_REG (s4,  27, t0)
+	RESTORE_INT_REG (s5,  28, t0)
+	RESTORE_INT_REG (s6,  29, t0)
+	RESTORE_INT_REG (s7,  30, t0)
+	RESTORE_INT_REG (s8,  31, t0)
+
+	ld.d		t1, t0, MCONTEXT_PC
+	jirl		$r0, t1, 0
+
+
+99:
+	addi.d		sp, sp, 16
+	b		__syscall_error
+
+PSEUDO_END (__swapcontext)
+
+weak_alias (__swapcontext, swapcontext)
diff --git a/sysdeps/unix/sysv/linux/loongarch/sys/procfs.h b/sysdeps/unix/sysv/linux/loongarch/sys/procfs.h
new file mode 100644
index 0000000000..7fe24dd8a1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/sys/procfs.h
@@ -0,0 +1,134 @@
+/* Types for registers for sys/procfs.h.
+   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
+#define _SYS_PROCFS_H 1
+
+/* This is somehow modelled after the file of the same name on SysVr4
+   systems.  It provides a definition of the core file format for ELF
+   used on Linux.  */
+
+#include <features.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/ucontext.h>
+
+__BEGIN_DECLS
+
+/* Type for a general-purpose register.  */
+typedef uint64_t elf_greg_t;
+
+/* And the whole bunch of them.  We could have used `struct
+   pt_regs' directly in the typedef, but tradition says that
+   the register set is an array, which does have some peculiar
+   semantics, so leave it that way.  */
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+#define ELF_NFPREG 34 /* 32 FPRs + 8-byte byte-vec for fcc + 4-byte FCR */
+typedef union
+{
+  double d;
+  float f;
+} elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+typedef union
+{
+  double d[2];
+  float f[4];
+} __attribute__ ((__aligned__ (16))) elf_lsxregset_t[32];
+typedef union
+{
+  double d[4];
+  float f[8];
+} __attribute__ ((__aligned__ (32))) elf_lasxregset_t[32];
+
+struct elf_siginfo
+{
+  int si_signo; /* Signal number.  */
+  int si_code;	/* Extra code.  */
+  int si_errno; /* Errno.  */
+};
+
+/* Definitions to generate Intel SVR4-like core files.  These mostly
+   have the same names as the SVR4 types with "elf_" tacked on the
+   front to prevent clashes with linux definitions, and the typedef
+   forms have been avoided.  This is mostly like the SVR4 structure,
+   but more Linuxy, with things that Linux does not support and which
+   gdb doesn't really use excluded.  Fields present but not used are
+   marked with "XXX".  */
+struct elf_prstatus
+{
+  struct elf_siginfo pr_info;	/* Info associated with signal.  */
+  short int pr_cursig;		/* Current signal.  */
+  unsigned long int pr_sigpend; /* Set of pending signals.  */
+  unsigned long int pr_sighold; /* Set of held signals.  */
+  __pid_t pr_pid;
+  __pid_t pr_ppid;
+  __pid_t pr_pgrp;
+  __pid_t pr_sid;
+  struct timeval pr_utime;  /* User time.  */
+  struct timeval pr_stime;  /* System time.  */
+  struct timeval pr_cutime; /* Cumulative user time.  */
+  struct timeval pr_cstime; /* Cumulative system time.  */
+  elf_gregset_t pr_reg;	    /* GP registers.  */
+  int pr_fpvalid;	    /* True if math copro being used.  */
+};
+
+#define ELF_PRARGSZ (80) /* Number of chars for args */
+
+struct elf_prpsinfo
+{
+  char pr_state;	     /* Numeric process state.  */
+  char pr_sname;	     /* Char for pr_state.  */
+  char pr_zomb;		     /* Zombie.  */
+  char pr_nice;		     /* Nice val.  */
+  unsigned long int pr_flag; /* Flags.  */
+  unsigned int pr_uid;
+  unsigned int pr_gid;
+  int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+  /* Lots missing */
+  char pr_fname[16];	       /* Filename of executable.  */
+  char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list.  */
+};
+
+/* The rest of this file provides the types for emulation of the
+   Solaris <proc_service.h> interfaces that should be implemented by
+   users of libthread_db.  */
+
+/* Addresses.  */
+typedef void *psaddr_t;
+
+/* Register sets.  Linux has different names.  */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+   therefore habe only ine PID type.  */
+typedef __pid_t lwpid_t;
+
+/* Process status and info.  In the end we do provide typedefs for them.  */
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h b/sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
new file mode 100644
index 0000000000..f9192e63c2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
@@ -0,0 +1,90 @@
+/* struct ucontext definition.
+   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/>.  */
+
+/* Don't rely on this, the interface is currently messed up and may need to
+   be broken to be fixed.  */
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+
+#include <bits/types/sigset_t.h>
+#include <bits/types/stack_t.h>
+
+typedef unsigned long int __loongarch_mc_gp_state[32];
+
+#ifdef __USE_MISC
+#define LARCH_NGREG 32
+
+#define LARCH_REG_RA 1
+#define LARCH_REG_SP 3
+#define LARCH_REG_S0 23
+#define LARCH_REG_S1 24
+#define LARCH_REG_A0 4
+#define LARCH_REG_S2 25
+#define LARCH_REG_NARGS 8
+
+typedef unsigned long int greg_t;
+
+/* Container for all general registers.  */
+typedef __loongarch_mc_gp_state gregset_t;
+
+/* Container for floating-point state.  */
+typedef union __loongarch_mc_fp_state fpregset_t;
+#endif
+
+union __loongarch_mc_fp_state
+{
+  unsigned int __val32[256 / 32];
+  unsigned long long __val64[256 / 64];
+};
+
+typedef struct mcontext_t
+{
+  unsigned long long __pc;
+  unsigned long long __gregs[32];
+  unsigned int __flags;
+
+  unsigned int __fcsr;
+  unsigned int __vcsr;
+  unsigned long long __fcc;
+
+  /* For Binary Translation */
+  unsigned long long __scr[4];
+  unsigned int __eflags;
+
+  union __loongarch_mc_fp_state __fpregs[32] __attribute__ ((__aligned__ (32)));
+
+  /* Reserved for future scalable vectors */
+  unsigned int __svsize;
+  unsigned long long __svregs[0] __attribute__((__aligned__(16)));
+
+} mcontext_t;
+
+/* Userlevel context.  */
+typedef struct ucontext_t
+{
+  unsigned long int __uc_flags;
+  struct ucontext_t *uc_link;
+  stack_t uc_stack;
+  sigset_t uc_sigmask;
+  mcontext_t uc_mcontext;
+} ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/sysdeps/unix/sysv/linux/loongarch/sys/user.h b/sysdeps/unix/sysv/linux/loongarch/sys/user.h
new file mode 100644
index 0000000000..4a55990e55
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/sys/user.h
@@ -0,0 +1,32 @@
+/* struct user_regs_struct definition for LoongArch.
+   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_USER_H
+#define _SYS_USER_H 1
+
+#include <stdint.h>
+
+struct user_regs_struct
+{
+  uint64_t gpr[32];
+  uint64_t pc;
+  uint64_t badvaddr;
+  uint64_t reserved[11];
+};
+
+#endif /* _SYS_USER_H */
diff --git a/sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h b/sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h
new file mode 100644
index 0000000000..2a8d70fee6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/ucontext-macros.h
@@ -0,0 +1,42 @@
+/* Macros for ucontext routines.
+   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_LOONGARCH_UCONTEXT_MACROS_H
+#define _LINUX_LOONGARCH_UCONTEXT_MACROS_H
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+#include "ucontext_i.h"
+
+#define SAVE_FP_REG(name, num, base) \
+  FREG_S name, base, ((num) *SZFREG + MCONTEXT_FPREGS)
+
+#define RESTORE_FP_REG(name, num, base) \
+  FREG_L name, base, ((num) *SZFREG + MCONTEXT_FPREGS)
+
+#define SAVE_INT_REG(name, num, base) \
+  REG_S name, base, ((num) *SZREG + MCONTEXT_GREGS)
+
+#define RESTORE_INT_REG(name, num, base) \
+  REG_L name, base, ((num) *SZREG + MCONTEXT_GREGS)
+
+#define SAVE_REG(name, offset, base) REG_S name, base, (offset)
+
+#define RESTORE_REG(name, offset, base) REG_L name, base, (offset)
+#endif /* _LINUX_LOONGARCH_UCONTEXT_MACROS_H */
diff --git a/sysdeps/unix/sysv/linux/loongarch/ucontext_i.sym b/sysdeps/unix/sysv/linux/loongarch/ucontext_i.sym
new file mode 100644
index 0000000000..d7f612fea2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/ucontext_i.sym
@@ -0,0 +1,33 @@
+#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)
+#define mcontext(member)	ucontext (uc_mcontext.member)
+
+UCONTEXT_FLAGS			ucontext (__uc_flags)
+UCONTEXT_LINK			ucontext (uc_link)
+UCONTEXT_STACK			ucontext (uc_stack)
+UCONTEXT_MCONTEXT		ucontext (uc_mcontext)
+UCONTEXT_SIGMASK		ucontext (uc_sigmask)
+
+STACK_SP			stack (ss_sp)
+STACK_SIZE			stack (ss_size)
+STACK_FLAGS			stack (ss_flags)
+
+MCONTEXT_PC			mcontext (__pc)
+MCONTEXT_FCSR 			mcontext (__fcsr)
+MCONTEXT_GREGS			mcontext (__gregs)
+MCONTEXT_FPREGS			mcontext (__fpregs)
+
+UCONTEXT_SIZE			sizeof (ucontext_t)
-- 
2.27.0


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

* [PATCH v2 10/14] LoongArch: Linux Startup and Dynamic Loading Code
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (8 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 09/14] LoongArch: Linux ABI caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 14:27   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 11/14] LoongArch: Add ABI Lists caiyinyu
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

This contains the Linux-specific code for loading programs on LoongArch.
---
 sysdeps/unix/sysv/linux/loongarch/dl-static.c | 80 +++++++++++++++++++
 sysdeps/unix/sysv/linux/loongarch/ldsodefs.h  | 33 ++++++++
 2 files changed, 113 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/dl-static.c
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldsodefs.h

diff --git a/sysdeps/unix/sysv/linux/loongarch/dl-static.c b/sysdeps/unix/sysv/linux/loongarch/dl-static.c
new file mode 100644
index 0000000000..b9a7b2a61f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/dl-static.c
@@ -0,0 +1,80 @@
+/* dl_static_init for loongarch.
+   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 <ldsodefs.h>
+
+#ifdef SHARED
+
+void
+_dl_var_init (void *array[])
+{
+  /* It has to match "variables" below.  */
+  enum
+  {
+    DL_PAGESIZE = 0
+  };
+
+  GLRO (dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
+}
+
+#else
+
+static void *variables[] = {&GLRO (dl_pagesize)};
+
+static void _dl_unprotect_relro (struct link_map *l)
+{
+  ElfW (Addr) start = ((l->l_addr + l->l_relro_addr)
+			& ~(GLRO (dl_pagesize) - 1));
+  ElfW (Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
+		      & ~(GLRO (dl_pagesize) - 1));
+
+  if (start != end)
+    __mprotect ((void *) start, end - start, PROT_READ | PROT_WRITE);
+}
+
+void dl_static_init (struct link_map *l)
+{
+  struct link_map *rtld_map = l;
+  struct r_scope_elem **scope;
+  const ElfW (Sym) *ref = NULL;
+  lookup_t loadbase;
+  void (*f) (void *[]);
+  size_t i;
+
+  loadbase = _dl_lookup_symbol_x ("_dl_var_init", l, &ref, l->l_local_scope,
+				  NULL, 0, 1, NULL);
+
+  for (scope = l->l_local_scope; *scope != NULL; scope++)
+    for (i = 0; i < (*scope)->r_nlist; i++)
+      if ((*scope)->r_list[i] == loadbase)
+	{
+	  rtld_map = (*scope)->r_list[i];
+	  break;
+	}
+
+  if (ref != NULL)
+    {
+      f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
+      _dl_unprotect_relro (rtld_map);
+      f (variables);
+      _dl_protect_relro (rtld_map);
+    }
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h b/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
new file mode 100644
index 0000000000..680baf2edc
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
@@ -0,0 +1,33 @@
+/* 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 _LDSODEFS_H
+
+/* Get the real definitions.  */
+#include_next <ldsodefs.h>
+
+/* Now define our stuff.  */
+
+/* We need special support to initialize DSO loaded for statically linked
+   binaries.  */
+extern void _dl_static_init (struct link_map *map);
+#undef DL_STATIC_INIT
+#define DL_STATIC_INIT(map) _dl_static_init (map)
+
+#endif /* ldsodefs.h */
-- 
2.27.0


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

* [PATCH v2 11/14] LoongArch: Add ABI Lists
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (9 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 10/14] LoongArch: Linux Startup and Dynamic Loading Code caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2021-12-31 17:43   ` Joseph Myers
  2021-12-31  6:44 ` [PATCH v2 12/14] LoongArch: Build Infastructure caiyinyu
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

---
 .../sysv/linux/loongarch/lp64/c++-types.data  |   67 +
 .../unix/sysv/linux/loongarch/lp64/ld.abilist |    8 +
 .../loongarch/lp64/libBrokenLocale.abilist    |    1 +
 .../sysv/linux/loongarch/lp64/libanl.abilist  |    1 +
 .../sysv/linux/loongarch/lp64/libc.abilist    | 2137 +++++++++++++++++
 .../loongarch/lp64/libc_malloc_debug.abilist  |   26 +
 .../linux/loongarch/lp64/libcrypt.abilist     |    2 +
 .../sysv/linux/loongarch/lp64/libdl.abilist   |    0
 .../sysv/linux/loongarch/lp64/libm.abilist    | 1033 ++++++++
 .../sysv/linux/loongarch/lp64/libnsl.abilist  |  120 +
 .../linux/loongarch/lp64/libpthread.abilist   |    0
 .../linux/loongarch/lp64/libresolv.abilist    |   55 +
 .../sysv/linux/loongarch/lp64/librt.abilist   |    0
 .../linux/loongarch/lp64/libthread_db.abilist |   40 +
 .../sysv/linux/loongarch/lp64/libutil.abilist |    1 +
 15 files changed, 3491 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libc_malloc_debug.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist

diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/c++-types.data b/sysdeps/unix/sysv/linux/loongarch/lp64/c++-types.data
new file mode 100644
index 0000000000..ac925ccb36
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/c++-types.data
@@ -0,0 +1,67 @@
+blkcnt64_t:l
+blkcnt_t:l
+blksize_t:i
+caddr_t:Pc
+clockid_t:i
+clock_t:l
+daddr_t:i
+dev_t:m
+fd_mask:l
+fsblkcnt64_t:m
+fsblkcnt_t:m
+fsfilcnt64_t:m
+fsfilcnt_t:m
+fsid_t:8__fsid_t
+gid_t:j
+id_t:j
+ino64_t:m
+ino_t:m
+int16_t:s
+int32_t:i
+int64_t:l
+int8_t:a
+intptr_t:l
+key_t:i
+loff_t:l
+mode_t:j
+nlink_t:j
+off64_t:l
+off_t:l
+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:l
+register_t:l
+rlim64_t:m
+rlim_t:m
+sigset_t:10__sigset_t
+size_t:m
+socklen_t:j
+ssize_t:l
+suseconds_t:l
+time_t:l
+u_char:h
+uid_t:j
+uint:j
+u_int:j
+u_int16_t:t
+u_int32_t:j
+u_int64_t:m
+u_int8_t:h
+ulong:m
+u_long:m
+u_quad_t:m
+useconds_t:j
+ushort:t
+u_short:t
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/ld.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/ld.abilist
new file mode 100644
index 0000000000..cb229294ae
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/ld.abilist
@@ -0,0 +1,8 @@
+GLIBC_2.35 __libc_stack_end D 0x8
+GLIBC_2.35 __rseq_flags D 0x4
+GLIBC_2.35 __rseq_offset D 0x4
+GLIBC_2.35 __rseq_size D 0x4
+GLIBC_2.35 __stack_chk_guard D 0x8
+GLIBC_2.35 __tls_get_addr F
+GLIBC_2.35 _dl_mcount F
+GLIBC_2.35 _r_debug D 0x28
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libBrokenLocale.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libBrokenLocale.abilist
new file mode 100644
index 0000000000..366c393274
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libBrokenLocale.abilist
@@ -0,0 +1 @@
+GLIBC_2.35 __ctype_get_mb_cur_max F
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist
new file mode 100644
index 0000000000..c6437809db
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist
@@ -0,0 +1 @@
+GLIBC_2.35 __libanl_version_placeholder F
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
new file mode 100644
index 0000000000..7f671212c6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
@@ -0,0 +1,2137 @@
+GLIBC_2.35 _Exit F
+GLIBC_2.35 _Fork F
+GLIBC_2.35 _IO_2_1_stderr_ D 0xe0
+GLIBC_2.35 _IO_2_1_stdin_ D 0xe0
+GLIBC_2.35 _IO_2_1_stdout_ D 0xe0
+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 0xa8
+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 0x8
+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 0xa8
+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 0x8
+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 0x8
+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 __finitel 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 __isinfl 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 __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 0x8
+GLIBC_2.35 __progname_full D 0x8
+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 0x8
+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 __signbitl 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 0x8
+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 0x10
+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_find_object F
+GLIBC_2.35 _dl_mcount_wrapper F
+GLIBC_2.35 _dl_mcount_wrapper_check F
+GLIBC_2.35 _environ D 0x8
+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 0x8
+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 0x238
+GLIBC_2.35 _res_hconf D 0x48
+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 0x8
+GLIBC_2.35 argp_program_version D 0x8
+GLIBC_2.35 argp_program_version_hook D 0x8
+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 0x8
+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 0x8
+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 0x28
+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 0x8
+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 0x8
+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 0x8
+GLIBC_2.35 program_invocation_short_name D 0x8
+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 0x8
+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 0x8
+GLIBC_2.35 stdin D 0x8
+GLIBC_2.35 stdout D 0x8
+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 strfromf128 F
+GLIBC_2.35 strfromf32 F
+GLIBC_2.35 strfromf32x F
+GLIBC_2.35 strfromf64 F
+GLIBC_2.35 strfromf64x 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 strtof128 F
+GLIBC_2.35 strtof128_l 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 strtof64x F
+GLIBC_2.35 strtof64x_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 0x8
+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 0x10
+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 wcstof128 F
+GLIBC_2.35 wcstof128_l 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 wcstof64x F
+GLIBC_2.35 wcstof64x_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/loongarch/lp64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc_malloc_debug.abilist
new file mode 100644
index 0000000000..b6df2463cf
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc_malloc_debug.abilist
@@ -0,0 +1,26 @@
+GLIBC_2.35 __free_hook D 0x8
+GLIBC_2.35 __malloc_hook D 0x8
+GLIBC_2.35 __memalign_hook D 0x8
+GLIBC_2.35 __realloc_hook D 0x8
+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/loongarch/lp64/libcrypt.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libcrypt.abilist
new file mode 100644
index 0000000000..fc9c3d5428
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libcrypt.abilist
@@ -0,0 +1,2 @@
+GLIBC_2.35 crypt F
+GLIBC_2.35 crypt_r F
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist
new file mode 100644
index 0000000000..63ab4b261c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist
@@ -0,0 +1,1033 @@
+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 __finitel F
+GLIBC_2.35 __fpclassify F
+GLIBC_2.35 __fpclassifyf F
+GLIBC_2.35 __fpclassifyl F
+GLIBC_2.35 __iseqsig F
+GLIBC_2.35 __iseqsigf F
+GLIBC_2.35 __iseqsigl F
+GLIBC_2.35 __issignaling F
+GLIBC_2.35 __issignalingf F
+GLIBC_2.35 __issignalingl F
+GLIBC_2.35 __signbit F
+GLIBC_2.35 __signbitf F
+GLIBC_2.35 __signbitl F
+GLIBC_2.35 __signgam D 0x4
+GLIBC_2.35 __sqrt_finite F
+GLIBC_2.35 __sqrtf_finite F
+GLIBC_2.35 __sqrtl_finite F
+GLIBC_2.35 acos F
+GLIBC_2.35 acosf F
+GLIBC_2.35 acosf128 F
+GLIBC_2.35 acosf32 F
+GLIBC_2.35 acosf32x F
+GLIBC_2.35 acosf64 F
+GLIBC_2.35 acosf64x F
+GLIBC_2.35 acosh F
+GLIBC_2.35 acoshf F
+GLIBC_2.35 acoshf128 F
+GLIBC_2.35 acoshf32 F
+GLIBC_2.35 acoshf32x F
+GLIBC_2.35 acoshf64 F
+GLIBC_2.35 acoshf64x F
+GLIBC_2.35 acoshl F
+GLIBC_2.35 acosl F
+GLIBC_2.35 asin F
+GLIBC_2.35 asinf F
+GLIBC_2.35 asinf128 F
+GLIBC_2.35 asinf32 F
+GLIBC_2.35 asinf32x F
+GLIBC_2.35 asinf64 F
+GLIBC_2.35 asinf64x F
+GLIBC_2.35 asinh F
+GLIBC_2.35 asinhf F
+GLIBC_2.35 asinhf128 F
+GLIBC_2.35 asinhf32 F
+GLIBC_2.35 asinhf32x F
+GLIBC_2.35 asinhf64 F
+GLIBC_2.35 asinhf64x 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 atan2f128 F
+GLIBC_2.35 atan2f32 F
+GLIBC_2.35 atan2f32x F
+GLIBC_2.35 atan2f64 F
+GLIBC_2.35 atan2f64x F
+GLIBC_2.35 atan2l F
+GLIBC_2.35 atanf F
+GLIBC_2.35 atanf128 F
+GLIBC_2.35 atanf32 F
+GLIBC_2.35 atanf32x F
+GLIBC_2.35 atanf64 F
+GLIBC_2.35 atanf64x F
+GLIBC_2.35 atanh F
+GLIBC_2.35 atanhf F
+GLIBC_2.35 atanhf128 F
+GLIBC_2.35 atanhf32 F
+GLIBC_2.35 atanhf32x F
+GLIBC_2.35 atanhf64 F
+GLIBC_2.35 atanhf64x F
+GLIBC_2.35 atanhl F
+GLIBC_2.35 atanl F
+GLIBC_2.35 cabs F
+GLIBC_2.35 cabsf F
+GLIBC_2.35 cabsf128 F
+GLIBC_2.35 cabsf32 F
+GLIBC_2.35 cabsf32x F
+GLIBC_2.35 cabsf64 F
+GLIBC_2.35 cabsf64x F
+GLIBC_2.35 cabsl F
+GLIBC_2.35 cacos F
+GLIBC_2.35 cacosf F
+GLIBC_2.35 cacosf128 F
+GLIBC_2.35 cacosf32 F
+GLIBC_2.35 cacosf32x F
+GLIBC_2.35 cacosf64 F
+GLIBC_2.35 cacosf64x F
+GLIBC_2.35 cacosh F
+GLIBC_2.35 cacoshf F
+GLIBC_2.35 cacoshf128 F
+GLIBC_2.35 cacoshf32 F
+GLIBC_2.35 cacoshf32x F
+GLIBC_2.35 cacoshf64 F
+GLIBC_2.35 cacoshf64x F
+GLIBC_2.35 cacoshl F
+GLIBC_2.35 cacosl F
+GLIBC_2.35 canonicalize F
+GLIBC_2.35 canonicalizef F
+GLIBC_2.35 canonicalizef128 F
+GLIBC_2.35 canonicalizef32 F
+GLIBC_2.35 canonicalizef32x F
+GLIBC_2.35 canonicalizef64 F
+GLIBC_2.35 canonicalizef64x F
+GLIBC_2.35 canonicalizel F
+GLIBC_2.35 carg F
+GLIBC_2.35 cargf F
+GLIBC_2.35 cargf128 F
+GLIBC_2.35 cargf32 F
+GLIBC_2.35 cargf32x F
+GLIBC_2.35 cargf64 F
+GLIBC_2.35 cargf64x F
+GLIBC_2.35 cargl F
+GLIBC_2.35 casin F
+GLIBC_2.35 casinf F
+GLIBC_2.35 casinf128 F
+GLIBC_2.35 casinf32 F
+GLIBC_2.35 casinf32x F
+GLIBC_2.35 casinf64 F
+GLIBC_2.35 casinf64x F
+GLIBC_2.35 casinh F
+GLIBC_2.35 casinhf F
+GLIBC_2.35 casinhf128 F
+GLIBC_2.35 casinhf32 F
+GLIBC_2.35 casinhf32x F
+GLIBC_2.35 casinhf64 F
+GLIBC_2.35 casinhf64x F
+GLIBC_2.35 casinhl F
+GLIBC_2.35 casinl F
+GLIBC_2.35 catan F
+GLIBC_2.35 catanf F
+GLIBC_2.35 catanf128 F
+GLIBC_2.35 catanf32 F
+GLIBC_2.35 catanf32x F
+GLIBC_2.35 catanf64 F
+GLIBC_2.35 catanf64x F
+GLIBC_2.35 catanh F
+GLIBC_2.35 catanhf F
+GLIBC_2.35 catanhf128 F
+GLIBC_2.35 catanhf32 F
+GLIBC_2.35 catanhf32x F
+GLIBC_2.35 catanhf64 F
+GLIBC_2.35 catanhf64x F
+GLIBC_2.35 catanhl F
+GLIBC_2.35 catanl F
+GLIBC_2.35 cbrt F
+GLIBC_2.35 cbrtf F
+GLIBC_2.35 cbrtf128 F
+GLIBC_2.35 cbrtf32 F
+GLIBC_2.35 cbrtf32x F
+GLIBC_2.35 cbrtf64 F
+GLIBC_2.35 cbrtf64x F
+GLIBC_2.35 cbrtl F
+GLIBC_2.35 ccos F
+GLIBC_2.35 ccosf F
+GLIBC_2.35 ccosf128 F
+GLIBC_2.35 ccosf32 F
+GLIBC_2.35 ccosf32x F
+GLIBC_2.35 ccosf64 F
+GLIBC_2.35 ccosf64x F
+GLIBC_2.35 ccosh F
+GLIBC_2.35 ccoshf F
+GLIBC_2.35 ccoshf128 F
+GLIBC_2.35 ccoshf32 F
+GLIBC_2.35 ccoshf32x F
+GLIBC_2.35 ccoshf64 F
+GLIBC_2.35 ccoshf64x F
+GLIBC_2.35 ccoshl F
+GLIBC_2.35 ccosl F
+GLIBC_2.35 ceil F
+GLIBC_2.35 ceilf F
+GLIBC_2.35 ceilf128 F
+GLIBC_2.35 ceilf32 F
+GLIBC_2.35 ceilf32x F
+GLIBC_2.35 ceilf64 F
+GLIBC_2.35 ceilf64x F
+GLIBC_2.35 ceill F
+GLIBC_2.35 cexp F
+GLIBC_2.35 cexpf F
+GLIBC_2.35 cexpf128 F
+GLIBC_2.35 cexpf32 F
+GLIBC_2.35 cexpf32x F
+GLIBC_2.35 cexpf64 F
+GLIBC_2.35 cexpf64x F
+GLIBC_2.35 cexpl F
+GLIBC_2.35 cimag F
+GLIBC_2.35 cimagf F
+GLIBC_2.35 cimagf128 F
+GLIBC_2.35 cimagf32 F
+GLIBC_2.35 cimagf32x F
+GLIBC_2.35 cimagf64 F
+GLIBC_2.35 cimagf64x F
+GLIBC_2.35 cimagl F
+GLIBC_2.35 clog F
+GLIBC_2.35 clog10 F
+GLIBC_2.35 clog10f F
+GLIBC_2.35 clog10f128 F
+GLIBC_2.35 clog10f32 F
+GLIBC_2.35 clog10f32x F
+GLIBC_2.35 clog10f64 F
+GLIBC_2.35 clog10f64x F
+GLIBC_2.35 clog10l F
+GLIBC_2.35 clogf F
+GLIBC_2.35 clogf128 F
+GLIBC_2.35 clogf32 F
+GLIBC_2.35 clogf32x F
+GLIBC_2.35 clogf64 F
+GLIBC_2.35 clogf64x F
+GLIBC_2.35 clogl F
+GLIBC_2.35 conj F
+GLIBC_2.35 conjf F
+GLIBC_2.35 conjf128 F
+GLIBC_2.35 conjf32 F
+GLIBC_2.35 conjf32x F
+GLIBC_2.35 conjf64 F
+GLIBC_2.35 conjf64x F
+GLIBC_2.35 conjl F
+GLIBC_2.35 copysign F
+GLIBC_2.35 copysignf F
+GLIBC_2.35 copysignf128 F
+GLIBC_2.35 copysignf32 F
+GLIBC_2.35 copysignf32x F
+GLIBC_2.35 copysignf64 F
+GLIBC_2.35 copysignf64x F
+GLIBC_2.35 copysignl F
+GLIBC_2.35 cos F
+GLIBC_2.35 cosf F
+GLIBC_2.35 cosf128 F
+GLIBC_2.35 cosf32 F
+GLIBC_2.35 cosf32x F
+GLIBC_2.35 cosf64 F
+GLIBC_2.35 cosf64x F
+GLIBC_2.35 cosh F
+GLIBC_2.35 coshf F
+GLIBC_2.35 coshf128 F
+GLIBC_2.35 coshf32 F
+GLIBC_2.35 coshf32x F
+GLIBC_2.35 coshf64 F
+GLIBC_2.35 coshf64x F
+GLIBC_2.35 coshl F
+GLIBC_2.35 cosl F
+GLIBC_2.35 cpow F
+GLIBC_2.35 cpowf F
+GLIBC_2.35 cpowf128 F
+GLIBC_2.35 cpowf32 F
+GLIBC_2.35 cpowf32x F
+GLIBC_2.35 cpowf64 F
+GLIBC_2.35 cpowf64x F
+GLIBC_2.35 cpowl F
+GLIBC_2.35 cproj F
+GLIBC_2.35 cprojf F
+GLIBC_2.35 cprojf128 F
+GLIBC_2.35 cprojf32 F
+GLIBC_2.35 cprojf32x F
+GLIBC_2.35 cprojf64 F
+GLIBC_2.35 cprojf64x F
+GLIBC_2.35 cprojl F
+GLIBC_2.35 creal F
+GLIBC_2.35 crealf F
+GLIBC_2.35 crealf128 F
+GLIBC_2.35 crealf32 F
+GLIBC_2.35 crealf32x F
+GLIBC_2.35 crealf64 F
+GLIBC_2.35 crealf64x F
+GLIBC_2.35 creall F
+GLIBC_2.35 csin F
+GLIBC_2.35 csinf F
+GLIBC_2.35 csinf128 F
+GLIBC_2.35 csinf32 F
+GLIBC_2.35 csinf32x F
+GLIBC_2.35 csinf64 F
+GLIBC_2.35 csinf64x F
+GLIBC_2.35 csinh F
+GLIBC_2.35 csinhf F
+GLIBC_2.35 csinhf128 F
+GLIBC_2.35 csinhf32 F
+GLIBC_2.35 csinhf32x F
+GLIBC_2.35 csinhf64 F
+GLIBC_2.35 csinhf64x F
+GLIBC_2.35 csinhl F
+GLIBC_2.35 csinl F
+GLIBC_2.35 csqrt F
+GLIBC_2.35 csqrtf F
+GLIBC_2.35 csqrtf128 F
+GLIBC_2.35 csqrtf32 F
+GLIBC_2.35 csqrtf32x F
+GLIBC_2.35 csqrtf64 F
+GLIBC_2.35 csqrtf64x F
+GLIBC_2.35 csqrtl F
+GLIBC_2.35 ctan F
+GLIBC_2.35 ctanf F
+GLIBC_2.35 ctanf128 F
+GLIBC_2.35 ctanf32 F
+GLIBC_2.35 ctanf32x F
+GLIBC_2.35 ctanf64 F
+GLIBC_2.35 ctanf64x F
+GLIBC_2.35 ctanh F
+GLIBC_2.35 ctanhf F
+GLIBC_2.35 ctanhf128 F
+GLIBC_2.35 ctanhf32 F
+GLIBC_2.35 ctanhf32x F
+GLIBC_2.35 ctanhf64 F
+GLIBC_2.35 ctanhf64x 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 erfcf128 F
+GLIBC_2.35 erfcf32 F
+GLIBC_2.35 erfcf32x F
+GLIBC_2.35 erfcf64 F
+GLIBC_2.35 erfcf64x F
+GLIBC_2.35 erfcl F
+GLIBC_2.35 erff F
+GLIBC_2.35 erff128 F
+GLIBC_2.35 erff32 F
+GLIBC_2.35 erff32x F
+GLIBC_2.35 erff64 F
+GLIBC_2.35 erff64x F
+GLIBC_2.35 erfl F
+GLIBC_2.35 exp F
+GLIBC_2.35 exp10 F
+GLIBC_2.35 exp10f F
+GLIBC_2.35 exp10f128 F
+GLIBC_2.35 exp10f32 F
+GLIBC_2.35 exp10f32x F
+GLIBC_2.35 exp10f64 F
+GLIBC_2.35 exp10f64x F
+GLIBC_2.35 exp10l F
+GLIBC_2.35 exp2 F
+GLIBC_2.35 exp2f F
+GLIBC_2.35 exp2f128 F
+GLIBC_2.35 exp2f32 F
+GLIBC_2.35 exp2f32x F
+GLIBC_2.35 exp2f64 F
+GLIBC_2.35 exp2f64x F
+GLIBC_2.35 exp2l F
+GLIBC_2.35 expf F
+GLIBC_2.35 expf128 F
+GLIBC_2.35 expf32 F
+GLIBC_2.35 expf32x F
+GLIBC_2.35 expf64 F
+GLIBC_2.35 expf64x F
+GLIBC_2.35 expl F
+GLIBC_2.35 expm1 F
+GLIBC_2.35 expm1f F
+GLIBC_2.35 expm1f128 F
+GLIBC_2.35 expm1f32 F
+GLIBC_2.35 expm1f32x F
+GLIBC_2.35 expm1f64 F
+GLIBC_2.35 expm1f64x F
+GLIBC_2.35 expm1l F
+GLIBC_2.35 f32addf128 F
+GLIBC_2.35 f32addf32x F
+GLIBC_2.35 f32addf64 F
+GLIBC_2.35 f32addf64x F
+GLIBC_2.35 f32divf128 F
+GLIBC_2.35 f32divf32x F
+GLIBC_2.35 f32divf64 F
+GLIBC_2.35 f32divf64x F
+GLIBC_2.35 f32fmaf128 F
+GLIBC_2.35 f32fmaf32x F
+GLIBC_2.35 f32fmaf64 F
+GLIBC_2.35 f32fmaf64x F
+GLIBC_2.35 f32mulf128 F
+GLIBC_2.35 f32mulf32x F
+GLIBC_2.35 f32mulf64 F
+GLIBC_2.35 f32mulf64x F
+GLIBC_2.35 f32sqrtf128 F
+GLIBC_2.35 f32sqrtf32x F
+GLIBC_2.35 f32sqrtf64 F
+GLIBC_2.35 f32sqrtf64x F
+GLIBC_2.35 f32subf128 F
+GLIBC_2.35 f32subf32x F
+GLIBC_2.35 f32subf64 F
+GLIBC_2.35 f32subf64x F
+GLIBC_2.35 f32xaddf128 F
+GLIBC_2.35 f32xaddf64 F
+GLIBC_2.35 f32xaddf64x F
+GLIBC_2.35 f32xdivf128 F
+GLIBC_2.35 f32xdivf64 F
+GLIBC_2.35 f32xdivf64x F
+GLIBC_2.35 f32xfmaf128 F
+GLIBC_2.35 f32xfmaf64 F
+GLIBC_2.35 f32xfmaf64x F
+GLIBC_2.35 f32xmulf128 F
+GLIBC_2.35 f32xmulf64 F
+GLIBC_2.35 f32xmulf64x F
+GLIBC_2.35 f32xsqrtf128 F
+GLIBC_2.35 f32xsqrtf64 F
+GLIBC_2.35 f32xsqrtf64x F
+GLIBC_2.35 f32xsubf128 F
+GLIBC_2.35 f32xsubf64 F
+GLIBC_2.35 f32xsubf64x F
+GLIBC_2.35 f64addf128 F
+GLIBC_2.35 f64addf64x F
+GLIBC_2.35 f64divf128 F
+GLIBC_2.35 f64divf64x F
+GLIBC_2.35 f64fmaf128 F
+GLIBC_2.35 f64fmaf64x F
+GLIBC_2.35 f64mulf128 F
+GLIBC_2.35 f64mulf64x F
+GLIBC_2.35 f64sqrtf128 F
+GLIBC_2.35 f64sqrtf64x F
+GLIBC_2.35 f64subf128 F
+GLIBC_2.35 f64subf64x F
+GLIBC_2.35 f64xaddf128 F
+GLIBC_2.35 f64xdivf128 F
+GLIBC_2.35 f64xfmaf128 F
+GLIBC_2.35 f64xmulf128 F
+GLIBC_2.35 f64xsqrtf128 F
+GLIBC_2.35 f64xsubf128 F
+GLIBC_2.35 fabs F
+GLIBC_2.35 fabsf F
+GLIBC_2.35 fabsf128 F
+GLIBC_2.35 fabsf32 F
+GLIBC_2.35 fabsf32x F
+GLIBC_2.35 fabsf64 F
+GLIBC_2.35 fabsf64x 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 fdimf128 F
+GLIBC_2.35 fdimf32 F
+GLIBC_2.35 fdimf32x F
+GLIBC_2.35 fdimf64 F
+GLIBC_2.35 fdimf64x 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 floorf128 F
+GLIBC_2.35 floorf32 F
+GLIBC_2.35 floorf32x F
+GLIBC_2.35 floorf64 F
+GLIBC_2.35 floorf64x F
+GLIBC_2.35 floorl F
+GLIBC_2.35 fma F
+GLIBC_2.35 fmaf F
+GLIBC_2.35 fmaf128 F
+GLIBC_2.35 fmaf32 F
+GLIBC_2.35 fmaf32x F
+GLIBC_2.35 fmaf64 F
+GLIBC_2.35 fmaf64x F
+GLIBC_2.35 fmal F
+GLIBC_2.35 fmax F
+GLIBC_2.35 fmaxf F
+GLIBC_2.35 fmaxf128 F
+GLIBC_2.35 fmaxf32 F
+GLIBC_2.35 fmaxf32x F
+GLIBC_2.35 fmaxf64 F
+GLIBC_2.35 fmaxf64x 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_numf128 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_numf64x F
+GLIBC_2.35 fmaximum_mag_numl F
+GLIBC_2.35 fmaximum_magf F
+GLIBC_2.35 fmaximum_magf128 F
+GLIBC_2.35 fmaximum_magf32 F
+GLIBC_2.35 fmaximum_magf32x F
+GLIBC_2.35 fmaximum_magf64 F
+GLIBC_2.35 fmaximum_magf64x F
+GLIBC_2.35 fmaximum_magl F
+GLIBC_2.35 fmaximum_num F
+GLIBC_2.35 fmaximum_numf F
+GLIBC_2.35 fmaximum_numf128 F
+GLIBC_2.35 fmaximum_numf32 F
+GLIBC_2.35 fmaximum_numf32x F
+GLIBC_2.35 fmaximum_numf64 F
+GLIBC_2.35 fmaximum_numf64x F
+GLIBC_2.35 fmaximum_numl F
+GLIBC_2.35 fmaximumf F
+GLIBC_2.35 fmaximumf128 F
+GLIBC_2.35 fmaximumf32 F
+GLIBC_2.35 fmaximumf32x F
+GLIBC_2.35 fmaximumf64 F
+GLIBC_2.35 fmaximumf64x F
+GLIBC_2.35 fmaximuml F
+GLIBC_2.35 fmaxl F
+GLIBC_2.35 fmaxmag F
+GLIBC_2.35 fmaxmagf F
+GLIBC_2.35 fmaxmagf128 F
+GLIBC_2.35 fmaxmagf32 F
+GLIBC_2.35 fmaxmagf32x F
+GLIBC_2.35 fmaxmagf64 F
+GLIBC_2.35 fmaxmagf64x F
+GLIBC_2.35 fmaxmagl F
+GLIBC_2.35 fmin F
+GLIBC_2.35 fminf F
+GLIBC_2.35 fminf128 F
+GLIBC_2.35 fminf32 F
+GLIBC_2.35 fminf32x F
+GLIBC_2.35 fminf64 F
+GLIBC_2.35 fminf64x 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_numf128 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_numf64x F
+GLIBC_2.35 fminimum_mag_numl F
+GLIBC_2.35 fminimum_magf F
+GLIBC_2.35 fminimum_magf128 F
+GLIBC_2.35 fminimum_magf32 F
+GLIBC_2.35 fminimum_magf32x F
+GLIBC_2.35 fminimum_magf64 F
+GLIBC_2.35 fminimum_magf64x F
+GLIBC_2.35 fminimum_magl F
+GLIBC_2.35 fminimum_num F
+GLIBC_2.35 fminimum_numf F
+GLIBC_2.35 fminimum_numf128 F
+GLIBC_2.35 fminimum_numf32 F
+GLIBC_2.35 fminimum_numf32x F
+GLIBC_2.35 fminimum_numf64 F
+GLIBC_2.35 fminimum_numf64x F
+GLIBC_2.35 fminimum_numl F
+GLIBC_2.35 fminimumf F
+GLIBC_2.35 fminimumf128 F
+GLIBC_2.35 fminimumf32 F
+GLIBC_2.35 fminimumf32x F
+GLIBC_2.35 fminimumf64 F
+GLIBC_2.35 fminimumf64x F
+GLIBC_2.35 fminimuml F
+GLIBC_2.35 fminl F
+GLIBC_2.35 fminmag F
+GLIBC_2.35 fminmagf F
+GLIBC_2.35 fminmagf128 F
+GLIBC_2.35 fminmagf32 F
+GLIBC_2.35 fminmagf32x F
+GLIBC_2.35 fminmagf64 F
+GLIBC_2.35 fminmagf64x F
+GLIBC_2.35 fminmagl F
+GLIBC_2.35 fmod F
+GLIBC_2.35 fmodf F
+GLIBC_2.35 fmodf128 F
+GLIBC_2.35 fmodf32 F
+GLIBC_2.35 fmodf32x F
+GLIBC_2.35 fmodf64 F
+GLIBC_2.35 fmodf64x 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 frexpf128 F
+GLIBC_2.35 frexpf32 F
+GLIBC_2.35 frexpf32x F
+GLIBC_2.35 frexpf64 F
+GLIBC_2.35 frexpf64x F
+GLIBC_2.35 frexpl F
+GLIBC_2.35 fromfp F
+GLIBC_2.35 fromfpf F
+GLIBC_2.35 fromfpf128 F
+GLIBC_2.35 fromfpf32 F
+GLIBC_2.35 fromfpf32x F
+GLIBC_2.35 fromfpf64 F
+GLIBC_2.35 fromfpf64x F
+GLIBC_2.35 fromfpl F
+GLIBC_2.35 fromfpx F
+GLIBC_2.35 fromfpxf F
+GLIBC_2.35 fromfpxf128 F
+GLIBC_2.35 fromfpxf32 F
+GLIBC_2.35 fromfpxf32x F
+GLIBC_2.35 fromfpxf64 F
+GLIBC_2.35 fromfpxf64x 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 getpayloadf128 F
+GLIBC_2.35 getpayloadf32 F
+GLIBC_2.35 getpayloadf32x F
+GLIBC_2.35 getpayloadf64 F
+GLIBC_2.35 getpayloadf64x F
+GLIBC_2.35 getpayloadl F
+GLIBC_2.35 hypot F
+GLIBC_2.35 hypotf F
+GLIBC_2.35 hypotf128 F
+GLIBC_2.35 hypotf32 F
+GLIBC_2.35 hypotf32x F
+GLIBC_2.35 hypotf64 F
+GLIBC_2.35 hypotf64x F
+GLIBC_2.35 hypotl F
+GLIBC_2.35 ilogb F
+GLIBC_2.35 ilogbf F
+GLIBC_2.35 ilogbf128 F
+GLIBC_2.35 ilogbf32 F
+GLIBC_2.35 ilogbf32x F
+GLIBC_2.35 ilogbf64 F
+GLIBC_2.35 ilogbf64x F
+GLIBC_2.35 ilogbl F
+GLIBC_2.35 j0 F
+GLIBC_2.35 j0f F
+GLIBC_2.35 j0f128 F
+GLIBC_2.35 j0f32 F
+GLIBC_2.35 j0f32x F
+GLIBC_2.35 j0f64 F
+GLIBC_2.35 j0f64x F
+GLIBC_2.35 j0l F
+GLIBC_2.35 j1 F
+GLIBC_2.35 j1f F
+GLIBC_2.35 j1f128 F
+GLIBC_2.35 j1f32 F
+GLIBC_2.35 j1f32x F
+GLIBC_2.35 j1f64 F
+GLIBC_2.35 j1f64x F
+GLIBC_2.35 j1l F
+GLIBC_2.35 jn F
+GLIBC_2.35 jnf F
+GLIBC_2.35 jnf128 F
+GLIBC_2.35 jnf32 F
+GLIBC_2.35 jnf32x F
+GLIBC_2.35 jnf64 F
+GLIBC_2.35 jnf64x F
+GLIBC_2.35 jnl F
+GLIBC_2.35 ldexp F
+GLIBC_2.35 ldexpf F
+GLIBC_2.35 ldexpf128 F
+GLIBC_2.35 ldexpf32 F
+GLIBC_2.35 ldexpf32x F
+GLIBC_2.35 ldexpf64 F
+GLIBC_2.35 ldexpf64x 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 lgammaf128 F
+GLIBC_2.35 lgammaf128_r 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 lgammaf64x F
+GLIBC_2.35 lgammaf64x_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 llogbf128 F
+GLIBC_2.35 llogbf32 F
+GLIBC_2.35 llogbf32x F
+GLIBC_2.35 llogbf64 F
+GLIBC_2.35 llogbf64x F
+GLIBC_2.35 llogbl F
+GLIBC_2.35 llrint F
+GLIBC_2.35 llrintf F
+GLIBC_2.35 llrintf128 F
+GLIBC_2.35 llrintf32 F
+GLIBC_2.35 llrintf32x F
+GLIBC_2.35 llrintf64 F
+GLIBC_2.35 llrintf64x F
+GLIBC_2.35 llrintl F
+GLIBC_2.35 llround F
+GLIBC_2.35 llroundf F
+GLIBC_2.35 llroundf128 F
+GLIBC_2.35 llroundf32 F
+GLIBC_2.35 llroundf32x F
+GLIBC_2.35 llroundf64 F
+GLIBC_2.35 llroundf64x F
+GLIBC_2.35 llroundl F
+GLIBC_2.35 log F
+GLIBC_2.35 log10 F
+GLIBC_2.35 log10f F
+GLIBC_2.35 log10f128 F
+GLIBC_2.35 log10f32 F
+GLIBC_2.35 log10f32x F
+GLIBC_2.35 log10f64 F
+GLIBC_2.35 log10f64x F
+GLIBC_2.35 log10l F
+GLIBC_2.35 log1p F
+GLIBC_2.35 log1pf F
+GLIBC_2.35 log1pf128 F
+GLIBC_2.35 log1pf32 F
+GLIBC_2.35 log1pf32x F
+GLIBC_2.35 log1pf64 F
+GLIBC_2.35 log1pf64x F
+GLIBC_2.35 log1pl F
+GLIBC_2.35 log2 F
+GLIBC_2.35 log2f F
+GLIBC_2.35 log2f128 F
+GLIBC_2.35 log2f32 F
+GLIBC_2.35 log2f32x F
+GLIBC_2.35 log2f64 F
+GLIBC_2.35 log2f64x F
+GLIBC_2.35 log2l F
+GLIBC_2.35 logb F
+GLIBC_2.35 logbf F
+GLIBC_2.35 logbf128 F
+GLIBC_2.35 logbf32 F
+GLIBC_2.35 logbf32x F
+GLIBC_2.35 logbf64 F
+GLIBC_2.35 logbf64x F
+GLIBC_2.35 logbl F
+GLIBC_2.35 logf F
+GLIBC_2.35 logf128 F
+GLIBC_2.35 logf32 F
+GLIBC_2.35 logf32x F
+GLIBC_2.35 logf64 F
+GLIBC_2.35 logf64x F
+GLIBC_2.35 logl F
+GLIBC_2.35 lrint F
+GLIBC_2.35 lrintf F
+GLIBC_2.35 lrintf128 F
+GLIBC_2.35 lrintf32 F
+GLIBC_2.35 lrintf32x F
+GLIBC_2.35 lrintf64 F
+GLIBC_2.35 lrintf64x F
+GLIBC_2.35 lrintl F
+GLIBC_2.35 lround F
+GLIBC_2.35 lroundf F
+GLIBC_2.35 lroundf128 F
+GLIBC_2.35 lroundf32 F
+GLIBC_2.35 lroundf32x F
+GLIBC_2.35 lroundf64 F
+GLIBC_2.35 lroundf64x F
+GLIBC_2.35 lroundl F
+GLIBC_2.35 modf F
+GLIBC_2.35 modff F
+GLIBC_2.35 modff128 F
+GLIBC_2.35 modff32 F
+GLIBC_2.35 modff32x F
+GLIBC_2.35 modff64 F
+GLIBC_2.35 modff64x F
+GLIBC_2.35 modfl F
+GLIBC_2.35 nan F
+GLIBC_2.35 nanf F
+GLIBC_2.35 nanf128 F
+GLIBC_2.35 nanf32 F
+GLIBC_2.35 nanf32x F
+GLIBC_2.35 nanf64 F
+GLIBC_2.35 nanf64x F
+GLIBC_2.35 nanl F
+GLIBC_2.35 nearbyint F
+GLIBC_2.35 nearbyintf F
+GLIBC_2.35 nearbyintf128 F
+GLIBC_2.35 nearbyintf32 F
+GLIBC_2.35 nearbyintf32x F
+GLIBC_2.35 nearbyintf64 F
+GLIBC_2.35 nearbyintf64x F
+GLIBC_2.35 nearbyintl F
+GLIBC_2.35 nextafter F
+GLIBC_2.35 nextafterf F
+GLIBC_2.35 nextafterf128 F
+GLIBC_2.35 nextafterf32 F
+GLIBC_2.35 nextafterf32x F
+GLIBC_2.35 nextafterf64 F
+GLIBC_2.35 nextafterf64x F
+GLIBC_2.35 nextafterl F
+GLIBC_2.35 nextdown F
+GLIBC_2.35 nextdownf F
+GLIBC_2.35 nextdownf128 F
+GLIBC_2.35 nextdownf32 F
+GLIBC_2.35 nextdownf32x F
+GLIBC_2.35 nextdownf64 F
+GLIBC_2.35 nextdownf64x 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 nextupf128 F
+GLIBC_2.35 nextupf32 F
+GLIBC_2.35 nextupf32x F
+GLIBC_2.35 nextupf64 F
+GLIBC_2.35 nextupf64x F
+GLIBC_2.35 nextupl F
+GLIBC_2.35 pow F
+GLIBC_2.35 powf F
+GLIBC_2.35 powf128 F
+GLIBC_2.35 powf32 F
+GLIBC_2.35 powf32x F
+GLIBC_2.35 powf64 F
+GLIBC_2.35 powf64x F
+GLIBC_2.35 powl F
+GLIBC_2.35 remainder F
+GLIBC_2.35 remainderf F
+GLIBC_2.35 remainderf128 F
+GLIBC_2.35 remainderf32 F
+GLIBC_2.35 remainderf32x F
+GLIBC_2.35 remainderf64 F
+GLIBC_2.35 remainderf64x F
+GLIBC_2.35 remainderl F
+GLIBC_2.35 remquo F
+GLIBC_2.35 remquof F
+GLIBC_2.35 remquof128 F
+GLIBC_2.35 remquof32 F
+GLIBC_2.35 remquof32x F
+GLIBC_2.35 remquof64 F
+GLIBC_2.35 remquof64x F
+GLIBC_2.35 remquol F
+GLIBC_2.35 rint F
+GLIBC_2.35 rintf F
+GLIBC_2.35 rintf128 F
+GLIBC_2.35 rintf32 F
+GLIBC_2.35 rintf32x F
+GLIBC_2.35 rintf64 F
+GLIBC_2.35 rintf64x F
+GLIBC_2.35 rintl F
+GLIBC_2.35 round F
+GLIBC_2.35 roundeven F
+GLIBC_2.35 roundevenf F
+GLIBC_2.35 roundevenf128 F
+GLIBC_2.35 roundevenf32 F
+GLIBC_2.35 roundevenf32x F
+GLIBC_2.35 roundevenf64 F
+GLIBC_2.35 roundevenf64x F
+GLIBC_2.35 roundevenl F
+GLIBC_2.35 roundf F
+GLIBC_2.35 roundf128 F
+GLIBC_2.35 roundf32 F
+GLIBC_2.35 roundf32x F
+GLIBC_2.35 roundf64 F
+GLIBC_2.35 roundf64x 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 scalblnf128 F
+GLIBC_2.35 scalblnf32 F
+GLIBC_2.35 scalblnf32x F
+GLIBC_2.35 scalblnf64 F
+GLIBC_2.35 scalblnf64x F
+GLIBC_2.35 scalblnl F
+GLIBC_2.35 scalbn F
+GLIBC_2.35 scalbnf F
+GLIBC_2.35 scalbnf128 F
+GLIBC_2.35 scalbnf32 F
+GLIBC_2.35 scalbnf32x F
+GLIBC_2.35 scalbnf64 F
+GLIBC_2.35 scalbnf64x F
+GLIBC_2.35 scalbnl F
+GLIBC_2.35 setpayload F
+GLIBC_2.35 setpayloadf F
+GLIBC_2.35 setpayloadf128 F
+GLIBC_2.35 setpayloadf32 F
+GLIBC_2.35 setpayloadf32x F
+GLIBC_2.35 setpayloadf64 F
+GLIBC_2.35 setpayloadf64x F
+GLIBC_2.35 setpayloadl F
+GLIBC_2.35 setpayloadsig F
+GLIBC_2.35 setpayloadsigf F
+GLIBC_2.35 setpayloadsigf128 F
+GLIBC_2.35 setpayloadsigf32 F
+GLIBC_2.35 setpayloadsigf32x F
+GLIBC_2.35 setpayloadsigf64 F
+GLIBC_2.35 setpayloadsigf64x 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 sincosf128 F
+GLIBC_2.35 sincosf32 F
+GLIBC_2.35 sincosf32x F
+GLIBC_2.35 sincosf64 F
+GLIBC_2.35 sincosf64x F
+GLIBC_2.35 sincosl F
+GLIBC_2.35 sinf F
+GLIBC_2.35 sinf128 F
+GLIBC_2.35 sinf32 F
+GLIBC_2.35 sinf32x F
+GLIBC_2.35 sinf64 F
+GLIBC_2.35 sinf64x F
+GLIBC_2.35 sinh F
+GLIBC_2.35 sinhf F
+GLIBC_2.35 sinhf128 F
+GLIBC_2.35 sinhf32 F
+GLIBC_2.35 sinhf32x F
+GLIBC_2.35 sinhf64 F
+GLIBC_2.35 sinhf64x F
+GLIBC_2.35 sinhl F
+GLIBC_2.35 sinl F
+GLIBC_2.35 sqrt F
+GLIBC_2.35 sqrtf F
+GLIBC_2.35 sqrtf128 F
+GLIBC_2.35 sqrtf32 F
+GLIBC_2.35 sqrtf32x F
+GLIBC_2.35 sqrtf64 F
+GLIBC_2.35 sqrtf64x F
+GLIBC_2.35 sqrtl F
+GLIBC_2.35 tan F
+GLIBC_2.35 tanf F
+GLIBC_2.35 tanf128 F
+GLIBC_2.35 tanf32 F
+GLIBC_2.35 tanf32x F
+GLIBC_2.35 tanf64 F
+GLIBC_2.35 tanf64x F
+GLIBC_2.35 tanh F
+GLIBC_2.35 tanhf F
+GLIBC_2.35 tanhf128 F
+GLIBC_2.35 tanhf32 F
+GLIBC_2.35 tanhf32x F
+GLIBC_2.35 tanhf64 F
+GLIBC_2.35 tanhf64x F
+GLIBC_2.35 tanhl F
+GLIBC_2.35 tanl F
+GLIBC_2.35 tgamma F
+GLIBC_2.35 tgammaf F
+GLIBC_2.35 tgammaf128 F
+GLIBC_2.35 tgammaf32 F
+GLIBC_2.35 tgammaf32x F
+GLIBC_2.35 tgammaf64 F
+GLIBC_2.35 tgammaf64x F
+GLIBC_2.35 tgammal F
+GLIBC_2.35 totalorder F
+GLIBC_2.35 totalorderf F
+GLIBC_2.35 totalorderf128 F
+GLIBC_2.35 totalorderf32 F
+GLIBC_2.35 totalorderf32x F
+GLIBC_2.35 totalorderf64 F
+GLIBC_2.35 totalorderf64x F
+GLIBC_2.35 totalorderl F
+GLIBC_2.35 totalordermag F
+GLIBC_2.35 totalordermagf F
+GLIBC_2.35 totalordermagf128 F
+GLIBC_2.35 totalordermagf32 F
+GLIBC_2.35 totalordermagf32x F
+GLIBC_2.35 totalordermagf64 F
+GLIBC_2.35 totalordermagf64x F
+GLIBC_2.35 totalordermagl F
+GLIBC_2.35 trunc F
+GLIBC_2.35 truncf F
+GLIBC_2.35 truncf128 F
+GLIBC_2.35 truncf32 F
+GLIBC_2.35 truncf32x F
+GLIBC_2.35 truncf64 F
+GLIBC_2.35 truncf64x F
+GLIBC_2.35 truncl F
+GLIBC_2.35 ufromfp F
+GLIBC_2.35 ufromfpf F
+GLIBC_2.35 ufromfpf128 F
+GLIBC_2.35 ufromfpf32 F
+GLIBC_2.35 ufromfpf32x F
+GLIBC_2.35 ufromfpf64 F
+GLIBC_2.35 ufromfpf64x F
+GLIBC_2.35 ufromfpl F
+GLIBC_2.35 ufromfpx F
+GLIBC_2.35 ufromfpxf F
+GLIBC_2.35 ufromfpxf128 F
+GLIBC_2.35 ufromfpxf32 F
+GLIBC_2.35 ufromfpxf32x F
+GLIBC_2.35 ufromfpxf64 F
+GLIBC_2.35 ufromfpxf64x F
+GLIBC_2.35 ufromfpxl F
+GLIBC_2.35 y0 F
+GLIBC_2.35 y0f F
+GLIBC_2.35 y0f128 F
+GLIBC_2.35 y0f32 F
+GLIBC_2.35 y0f32x F
+GLIBC_2.35 y0f64 F
+GLIBC_2.35 y0f64x F
+GLIBC_2.35 y0l F
+GLIBC_2.35 y1 F
+GLIBC_2.35 y1f F
+GLIBC_2.35 y1f128 F
+GLIBC_2.35 y1f32 F
+GLIBC_2.35 y1f32x F
+GLIBC_2.35 y1f64 F
+GLIBC_2.35 y1f64x F
+GLIBC_2.35 y1l F
+GLIBC_2.35 yn F
+GLIBC_2.35 ynf F
+GLIBC_2.35 ynf128 F
+GLIBC_2.35 ynf32 F
+GLIBC_2.35 ynf32x F
+GLIBC_2.35 ynf64 F
+GLIBC_2.35 ynf64x F
+GLIBC_2.35 ynl F
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist
new file mode 100644
index 0000000000..0767472d06
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist
@@ -0,0 +1,120 @@
+GLIBC_2.27 __free_fdresult F
+GLIBC_2.27 __nis_default_access F
+GLIBC_2.27 __nis_default_group F
+GLIBC_2.27 __nis_default_owner F
+GLIBC_2.27 __nis_default_ttl F
+GLIBC_2.27 __nis_finddirectory F
+GLIBC_2.27 __nisbind_connect F
+GLIBC_2.27 __nisbind_create F
+GLIBC_2.27 __nisbind_destroy F
+GLIBC_2.27 __nisbind_next F
+GLIBC_2.27 __yp_check F
+GLIBC_2.27 nis_add F
+GLIBC_2.27 nis_add_entry F
+GLIBC_2.27 nis_addmember F
+GLIBC_2.27 nis_checkpoint F
+GLIBC_2.27 nis_clone_directory F
+GLIBC_2.27 nis_clone_object F
+GLIBC_2.27 nis_clone_result F
+GLIBC_2.27 nis_creategroup F
+GLIBC_2.27 nis_destroy_object F
+GLIBC_2.27 nis_destroygroup F
+GLIBC_2.27 nis_dir_cmp F
+GLIBC_2.27 nis_domain_of F
+GLIBC_2.27 nis_domain_of_r F
+GLIBC_2.27 nis_first_entry F
+GLIBC_2.27 nis_free_directory F
+GLIBC_2.27 nis_free_object F
+GLIBC_2.27 nis_free_request F
+GLIBC_2.27 nis_freenames F
+GLIBC_2.27 nis_freeresult F
+GLIBC_2.27 nis_freeservlist F
+GLIBC_2.27 nis_freetags F
+GLIBC_2.27 nis_getnames F
+GLIBC_2.27 nis_getservlist F
+GLIBC_2.27 nis_ismember F
+GLIBC_2.27 nis_leaf_of F
+GLIBC_2.27 nis_leaf_of_r F
+GLIBC_2.27 nis_lerror F
+GLIBC_2.27 nis_list F
+GLIBC_2.27 nis_local_directory F
+GLIBC_2.27 nis_local_group F
+GLIBC_2.27 nis_local_host F
+GLIBC_2.27 nis_local_principal F
+GLIBC_2.27 nis_lookup F
+GLIBC_2.27 nis_mkdir F
+GLIBC_2.27 nis_modify F
+GLIBC_2.27 nis_modify_entry F
+GLIBC_2.27 nis_name_of F
+GLIBC_2.27 nis_name_of_r F
+GLIBC_2.27 nis_next_entry F
+GLIBC_2.27 nis_perror F
+GLIBC_2.27 nis_ping F
+GLIBC_2.27 nis_print_directory F
+GLIBC_2.27 nis_print_entry F
+GLIBC_2.27 nis_print_group F
+GLIBC_2.27 nis_print_group_entry F
+GLIBC_2.27 nis_print_link F
+GLIBC_2.27 nis_print_object F
+GLIBC_2.27 nis_print_result F
+GLIBC_2.27 nis_print_rights F
+GLIBC_2.27 nis_print_table F
+GLIBC_2.27 nis_read_obj F
+GLIBC_2.27 nis_remove F
+GLIBC_2.27 nis_remove_entry F
+GLIBC_2.27 nis_removemember F
+GLIBC_2.27 nis_rmdir F
+GLIBC_2.27 nis_servstate F
+GLIBC_2.27 nis_sperrno F
+GLIBC_2.27 nis_sperror F
+GLIBC_2.27 nis_sperror_r F
+GLIBC_2.27 nis_stats F
+GLIBC_2.27 nis_verifygroup F
+GLIBC_2.27 nis_write_obj F
+GLIBC_2.27 readColdStartFile F
+GLIBC_2.27 writeColdStartFile F
+GLIBC_2.27 xdr_cback_data F
+GLIBC_2.27 xdr_domainname F
+GLIBC_2.27 xdr_keydat F
+GLIBC_2.27 xdr_mapname F
+GLIBC_2.27 xdr_obj_p F
+GLIBC_2.27 xdr_peername F
+GLIBC_2.27 xdr_valdat F
+GLIBC_2.27 xdr_yp_buf F
+GLIBC_2.27 xdr_ypall F
+GLIBC_2.27 xdr_ypbind_binding F
+GLIBC_2.27 xdr_ypbind_resp F
+GLIBC_2.27 xdr_ypbind_resptype F
+GLIBC_2.27 xdr_ypbind_setdom F
+GLIBC_2.27 xdr_ypdelete_args F
+GLIBC_2.27 xdr_ypmap_parms F
+GLIBC_2.27 xdr_ypmaplist F
+GLIBC_2.27 xdr_yppush_status F
+GLIBC_2.27 xdr_yppushresp_xfr F
+GLIBC_2.27 xdr_ypreq_key F
+GLIBC_2.27 xdr_ypreq_nokey F
+GLIBC_2.27 xdr_ypreq_xfr F
+GLIBC_2.27 xdr_ypresp_all F
+GLIBC_2.27 xdr_ypresp_key_val F
+GLIBC_2.27 xdr_ypresp_maplist F
+GLIBC_2.27 xdr_ypresp_master F
+GLIBC_2.27 xdr_ypresp_order F
+GLIBC_2.27 xdr_ypresp_val F
+GLIBC_2.27 xdr_ypresp_xfr F
+GLIBC_2.27 xdr_ypstat F
+GLIBC_2.27 xdr_ypupdate_args F
+GLIBC_2.27 xdr_ypxfrstat F
+GLIBC_2.27 yp_all F
+GLIBC_2.27 yp_bind F
+GLIBC_2.27 yp_first F
+GLIBC_2.27 yp_get_default_domain F
+GLIBC_2.27 yp_maplist F
+GLIBC_2.27 yp_master F
+GLIBC_2.27 yp_match F
+GLIBC_2.27 yp_next F
+GLIBC_2.27 yp_order F
+GLIBC_2.27 yp_unbind F
+GLIBC_2.27 yp_update F
+GLIBC_2.27 ypbinderr_string F
+GLIBC_2.27 yperr_string F
+GLIBC_2.27 ypprot_err F
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libpthread.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libpthread.abilist
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libresolv.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libresolv.abilist
new file mode 100644
index 0000000000..8dac5c54af
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/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 0xa8
+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 0x450
+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/loongarch/lp64/librt.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/librt.abilist
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libthread_db.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libthread_db.abilist
new file mode 100644
index 0000000000..9607e70c16
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/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/loongarch/lp64/libutil.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist
new file mode 100644
index 0000000000..c2cbef8fce
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist
@@ -0,0 +1 @@
+GLIBC_2.27 __libutil_version_placeholder F
-- 
2.27.0


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

* [PATCH v2 12/14] LoongArch: Build Infastructure
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (10 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 11/14] LoongArch: Add ABI Lists caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2022-01-04 14:33   ` Adhemerval Zanella
  2021-12-31  6:44 ` [PATCH v2 13/14] LoongArch: Hard Float Support caiyinyu
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

---
 sysdeps/loongarch/Implies                     |   5 +
 sysdeps/loongarch/Makefile                    |  15 ++
 sysdeps/loongarch/configure                   |   4 +
 sysdeps/loongarch/configure.ac                |   6 +
 sysdeps/loongarch/lp64/Implies-after          |   1 +
 sysdeps/loongarch/nptl/Makefile               |  26 +++
 sysdeps/loongarch/preconfigure                |  47 +++++
 sysdeps/loongarch/sys/regdef.h                |  98 +++++++++
 sysdeps/unix/sysv/linux/loongarch/Implies     |   1 +
 sysdeps/unix/sysv/linux/loongarch/Makefile    |  11 +
 sysdeps/unix/sysv/linux/loongarch/configure   | 199 ++++++++++++++++++
 .../unix/sysv/linux/loongarch/configure.ac    |  27 +++
 .../unix/sysv/linux/loongarch/ldd-rewrite.sed |   3 +
 .../unix/sysv/linux/loongarch/lp64/Implies    |   3 +
 .../unix/sysv/linux/loongarch/shlib-versions  |   7 +
 15 files changed, 453 insertions(+)
 create mode 100644 sysdeps/loongarch/Implies
 create mode 100644 sysdeps/loongarch/Makefile
 create mode 100644 sysdeps/loongarch/configure
 create mode 100644 sysdeps/loongarch/configure.ac
 create mode 100644 sysdeps/loongarch/lp64/Implies-after
 create mode 100644 sysdeps/loongarch/nptl/Makefile
 create mode 100644 sysdeps/loongarch/preconfigure
 create mode 100644 sysdeps/loongarch/sys/regdef.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/Implies
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/configure
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/lp64/Implies
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/shlib-versions

diff --git a/sysdeps/loongarch/Implies b/sysdeps/loongarch/Implies
new file mode 100644
index 0000000000..c88325b8be
--- /dev/null
+++ b/sysdeps/loongarch/Implies
@@ -0,0 +1,5 @@
+init_array
+
+ieee754/ldbl-128
+ieee754/dbl-64
+ieee754/flt-32
diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile
new file mode 100644
index 0000000000..41c3449670
--- /dev/null
+++ b/sysdeps/loongarch/Makefile
@@ -0,0 +1,15 @@
+ifeq ($(subdir),misc)
+sysdep_headers += sys/asm.h
+endif
+
+# LoongArch's assembler also needs to know about PIC as it changes the
+# definition of some assembler macros.
+ASFLAGS-.os += $(pic-ccflag)
+
+abi-variants := lp64
+
+ifeq (,$(filter $(default-abi),$(abi-variants)))
+$(error Unknown ABI $(default-abi), must be one of $(abi-variants))
+endif
+
+abi-lp64-condition    := defined __loongarch_lp64
diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure
new file mode 100644
index 0000000000..1e5abf81a7
--- /dev/null
+++ b/sysdeps/loongarch/configure
@@ -0,0 +1,4 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/loongarch/elf.
+
+#AC_DEFINE(PI_STATIC_AND_HIDDEN)
diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac
new file mode 100644
index 0000000000..67b46ce048
--- /dev/null
+++ b/sysdeps/loongarch/configure.ac
@@ -0,0 +1,6 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/loongarch/elf.
+
+dnl It is always possible to access static and hidden symbols in an
+dnl position independent way.
+#AC_DEFINE(PI_STATIC_AND_HIDDEN)
diff --git a/sysdeps/loongarch/lp64/Implies-after b/sysdeps/loongarch/lp64/Implies-after
new file mode 100644
index 0000000000..a8cae95f9d
--- /dev/null
+++ b/sysdeps/loongarch/lp64/Implies-after
@@ -0,0 +1 @@
+wordsize-64
diff --git a/sysdeps/loongarch/nptl/Makefile b/sysdeps/loongarch/nptl/Makefile
new file mode 100644
index 0000000000..c6c773b179
--- /dev/null
+++ b/sysdeps/loongarch/nptl/Makefile
@@ -0,0 +1,26 @@
+# Makefile for sysdeps/loongarch/nptl.
+# 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
+
+ifeq ($(subdir),nptl)
+libpthread-sysdep_routines += nptl-sysdep
+libpthread-shared-only-routines += nptl-sysdep
+endif
diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure
new file mode 100644
index 0000000000..19983538ed
--- /dev/null
+++ b/sysdeps/loongarch/preconfigure
@@ -0,0 +1,47 @@
+case "$machine" in
+loongarch*)
+
+    grlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_grlen \(.*\)/\1/p'`
+    float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_\(soft\|single\|double\)_float.*/\1/p'`
+
+    with_fp_cond="!defined __loongarch_soft_float"
+
+    case "$float_abi" in
+    soft)
+	abi_flen=0
+	echo "loongarch does not yet support soft floating-point  ABI!!" >&2
+	exit 1
+	;;
+    single)
+	echo "glibc does not yet support the single floating-point ABI" >&2
+	exit 1
+	;;
+    double)
+	abi_flen=64
+	;;
+    *)
+	echo "Unable to determine floating-point ABI" >&2
+	exit 1
+	;;
+    esac
+
+    case "$grlen" in
+    32)
+	echo "loongarch does not yet support ilp32 ABI!!" >&2
+	;;
+    64)
+	machine=loongarch/lp64
+	;;
+    *)
+	echo "Unable to determine GRLEN" >&2
+	exit 1
+	;;
+    esac
+
+    $as_echo "#define LOONGARCH_ABI_GRLEN $grlen" >>confdefs.h
+    $as_echo "#define LOONGARCH_ABI_FRLEN $abi_flen" >>confdefs.h
+
+    base_machine=loongarch
+    ;;
+esac
+
diff --git a/sysdeps/loongarch/sys/regdef.h b/sysdeps/loongarch/sys/regdef.h
new file mode 100644
index 0000000000..f53447db62
--- /dev/null
+++ b/sysdeps/loongarch/sys/regdef.h
@@ -0,0 +1,98 @@
+/* Register Macro 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/>.  */
+
+#ifndef _SYS_REGDEF_H
+#define _SYS_REGDEF_H
+
+#ifdef __loongarch_lp64
+#define zero $r0
+#define ra $r1
+#define tp $r2
+#define sp $r3
+#define a0 $r4
+#define a1 $r5
+#define a2 $r6
+#define a3 $r7
+#define a4 $r8
+#define a5 $r9
+#define a6 $r10
+#define a7 $r11
+#define v0 $r4
+#define v1 $r5
+#define t0 $r12
+#define t1 $r13
+#define t2 $r14
+#define t3 $r15
+#define t4 $r16
+#define t5 $r17
+#define t6 $r18
+#define t7 $r19
+#define t8 $r20
+#define x $r21
+#define fp $r22
+#define s0 $r23
+#define s1 $r24
+#define s2 $r25
+#define s3 $r26
+#define s4 $r27
+#define s5 $r28
+#define s6 $r29
+#define s7 $r30
+#define s8 $r31
+
+#define fa0 $f0
+#define fa1 $f1
+#define fa2 $f2
+#define fa3 $f3
+#define fa4 $f4
+#define fa5 $f5
+#define fa6 $f6
+#define fa7 $f7
+#define fv0 $f0
+#define fv1 $f1
+#define ft0 $f8
+#define ft1 $f9
+#define ft2 $f10
+#define ft3 $f11
+#define ft4 $f12
+#define ft5 $f13
+#define ft6 $f14
+#define ft7 $f15
+#define ft8 $f16
+#define ft9 $f17
+#define ft10 $f18
+#define ft11 $f19
+#define ft12 $f20
+#define ft13 $f21
+#define ft14 $f22
+#define ft15 $f23
+#define fs0 $f24
+#define fs1 $f25
+#define fs2 $f26
+#define fs3 $f27
+#define fs4 $f28
+#define fs5 $f29
+#define fs6 $f30
+#define fs7 $f31
+
+#else
+#error "32bit LoongArch systems are not supported"
+#endif
+
+#endif /* _SYS_REGDEF_H */
diff --git a/sysdeps/unix/sysv/linux/loongarch/Implies b/sysdeps/unix/sysv/linux/loongarch/Implies
new file mode 100644
index 0000000000..e52b1ac310
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/Implies
@@ -0,0 +1 @@
+loongarch/nptl
diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile
new file mode 100644
index 0000000000..99ac734f91
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/Makefile
@@ -0,0 +1,11 @@
+ifeq ($(subdir),elf)
+ifeq ($(build-shared),yes)
+# This is needed for DSO loading from static binaries.
+sysdep-dl-routines += dl-static
+endif
+endif
+
+ifeq ($(subdir),stdlib)
+gen-as-const-headers += ucontext_i.sym
+endif
+
diff --git a/sysdeps/unix/sysv/linux/loongarch/configure b/sysdeps/unix/sysv/linux/loongarch/configure
new file mode 100644
index 0000000000..f4adec4ed9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/configure
@@ -0,0 +1,199 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/loongarch.
+
+arch_minimum_kernel=5.15.0
+
+libc_cv_loongarch_int_abi=no
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "4 4 4" >/dev/null 2>&1; then :
+  libc_cv_loongarch_int_abi=lp32
+fi
+rm -f conftest*
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "4 8 8" >/dev/null 2>&1; then :
+  libc_cv_loongarch_int_abi=lp64
+fi
+rm -f conftest*
+
+if test $libc_cv_loongarch_int_abi = no; then
+  as_fn_error $? "Unable to determine integer ABI" "$LINENO" 5
+fi
+
+config_vars="$config_vars
+default-abi = $libc_cv_loongarch_int_abi"
+
+case $libc_cv_loongarch_int_abi in
+lp32)
+  test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir='/lib32'
+  libc_cv_rtlddir='/lib32'
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib32';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_complocaledir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
+  ;;
+lp64)
+  test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir='/lib64'
+  libc_cv_rtlddir='/lib64'
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib64';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_complocaledir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
+  ;;
+esac
+
+ldd_rewrite_script=sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
diff --git a/sysdeps/unix/sysv/linux/loongarch/configure.ac b/sysdeps/unix/sysv/linux/loongarch/configure.ac
new file mode 100644
index 0000000000..25fda13b09
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/configure.ac
@@ -0,0 +1,27 @@
+sinclude(./aclocal.m4)dnl Autoconf lossage
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/loongarch.
+
+arch_minimum_kernel=5.15.0
+
+libc_cv_loongarch_int_abi=no
+AC_EGREP_CPP(4 4 4, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
+  ], libc_cv_loongarch_int_abi=ilp32)
+AC_EGREP_CPP(4 8 8, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
+  ], libc_cv_loongarch_int_abi=lp64)
+if test $libc_cv_loongarch_int_abi = no; then
+  AC_MSG_ERROR([Unable to determine integer ABI])
+fi
+
+LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi])
+
+case $libc_cv_loongarch_int_abi in
+ilp32)
+  LIBC_SLIBDIR_RTLDDIR([lib32], [lib32])
+  ;;
+lp64)
+  LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
+  ;;
+esac
+
+ldd_rewrite_script=sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
diff --git a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
new file mode 100644
index 0000000000..d42a13e08c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
@@ -0,0 +1,3 @@
+/LD_TRACE_LOADED_OBJECTS=1/a\
+add_env="$add_env LD_LIBRARY_VERSION=\\$verify_out"
+s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/[^/]*\)\(-loongarch\)\(64\|32\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\2\4\7 \264\4-loongarch64\7 \232\4-loongarch32\7"_
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/Implies b/sysdeps/unix/sysv/linux/loongarch/lp64/Implies
new file mode 100644
index 0000000000..117c2b8efe
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/Implies
@@ -0,0 +1,3 @@
+unix/sysv/linux/loongarch
+unix/sysv/linux/generic
+unix/sysv/linux/wordsize-64
diff --git a/sysdeps/unix/sysv/linux/loongarch/shlib-versions b/sysdeps/unix/sysv/linux/loongarch/shlib-versions
new file mode 100644
index 0000000000..aa9257fc61
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/shlib-versions
@@ -0,0 +1,7 @@
+DEFAULT		GLIBC_2.35
+
+%if LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64
+ld=ld-linux-loongarch-lp64d.so.1
+%else
+%error cannot determine ABI
+%endif
-- 
2.27.0


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

* [PATCH v2 13/14] LoongArch: Hard Float Support
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (11 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 12/14] LoongArch: Build Infastructure caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2021-12-31 17:47   ` Joseph Myers
  2021-12-31  6:44 ` [PATCH v2 14/14] LoongArch: Update build-many-glibcs.py for the LoongArch Port caiyinyu
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

This patch contains hardware floating-point support for the LoongArch ISA.
---
 sysdeps/loongarch/fpu/e_sqrt.c             |   26 +
 sysdeps/loongarch/fpu/e_sqrtf.c            |   26 +
 sysdeps/loongarch/fpu/fclrexcpt.c          |   46 +
 sysdeps/loongarch/fpu/fedisblxcpt.c        |   39 +
 sysdeps/loongarch/fpu/feenablxcpt.c        |   39 +
 sysdeps/loongarch/fpu/fegetenv.c           |   31 +
 sysdeps/loongarch/fpu/fegetexcept.c        |   32 +
 sysdeps/loongarch/fpu/fegetmode.c          |   27 +
 sysdeps/loongarch/fpu/fegetround.c         |   33 +
 sysdeps/loongarch/fpu/feholdexcpt.c        |   40 +
 sysdeps/loongarch/fpu/fenv_libc.h          |   30 +
 sysdeps/loongarch/fpu/fesetenv.c           |   42 +
 sysdeps/loongarch/fpu/fesetexcept.c        |   32 +
 sysdeps/loongarch/fpu/fesetmode.c          |   38 +
 sysdeps/loongarch/fpu/fesetround.c         |   44 +
 sysdeps/loongarch/fpu/feupdateenv.c        |   43 +
 sysdeps/loongarch/fpu/fgetexcptflg.c       |   38 +
 sysdeps/loongarch/fpu/fraiseexcpt.c        |   75 ++
 sysdeps/loongarch/fpu/fsetexcptflg.c       |   41 +
 sysdeps/loongarch/fpu/ftestexcept.c        |   32 +
 sysdeps/loongarch/lp64/libm-test-ulps      | 1411 ++++++++++++++++++++
 sysdeps/loongarch/lp64/libm-test-ulps-name |    1 +
 sysdeps/loongarch/math_private.h           |  248 ++++
 23 files changed, 2414 insertions(+)
 create mode 100644 sysdeps/loongarch/fpu/e_sqrt.c
 create mode 100644 sysdeps/loongarch/fpu/e_sqrtf.c
 create mode 100644 sysdeps/loongarch/fpu/fclrexcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fedisblxcpt.c
 create mode 100644 sysdeps/loongarch/fpu/feenablxcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fegetenv.c
 create mode 100644 sysdeps/loongarch/fpu/fegetexcept.c
 create mode 100644 sysdeps/loongarch/fpu/fegetmode.c
 create mode 100644 sysdeps/loongarch/fpu/fegetround.c
 create mode 100644 sysdeps/loongarch/fpu/feholdexcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fenv_libc.h
 create mode 100644 sysdeps/loongarch/fpu/fesetenv.c
 create mode 100644 sysdeps/loongarch/fpu/fesetexcept.c
 create mode 100644 sysdeps/loongarch/fpu/fesetmode.c
 create mode 100644 sysdeps/loongarch/fpu/fesetround.c
 create mode 100644 sysdeps/loongarch/fpu/feupdateenv.c
 create mode 100644 sysdeps/loongarch/fpu/fgetexcptflg.c
 create mode 100644 sysdeps/loongarch/fpu/fraiseexcpt.c
 create mode 100644 sysdeps/loongarch/fpu/fsetexcptflg.c
 create mode 100644 sysdeps/loongarch/fpu/ftestexcept.c
 create mode 100644 sysdeps/loongarch/lp64/libm-test-ulps
 create mode 100644 sysdeps/loongarch/lp64/libm-test-ulps-name
 create mode 100644 sysdeps/loongarch/math_private.h

diff --git a/sysdeps/loongarch/fpu/e_sqrt.c b/sysdeps/loongarch/fpu/e_sqrt.c
new file mode 100644
index 0000000000..352e1cd30f
--- /dev/null
+++ b/sysdeps/loongarch/fpu/e_sqrt.c
@@ -0,0 +1,26 @@
+/* Double-precision floating point square root.
+   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/>.  */
+
+double
+__ieee754_sqrt (double x)
+{
+  double z;
+  __asm__("fsqrt.d %0,%1" : "=f"(z) : "f"(x));
+  return z;
+}
+strong_alias (__ieee754_sqrt, __sqrt_finite)
diff --git a/sysdeps/loongarch/fpu/e_sqrtf.c b/sysdeps/loongarch/fpu/e_sqrtf.c
new file mode 100644
index 0000000000..950156e9f8
--- /dev/null
+++ b/sysdeps/loongarch/fpu/e_sqrtf.c
@@ -0,0 +1,26 @@
+/* Single-precision floating point square root.
+   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/>.  */
+
+float
+__ieee754_sqrtf (float x)
+{
+  float z;
+  __asm__("fsqrt.s %0,%1" : "=f"(z) : "f"(x));
+  return z;
+}
+strong_alias (__ieee754_sqrtf, __sqrtf_finite)
diff --git a/sysdeps/loongarch/fpu/fclrexcpt.c b/sysdeps/loongarch/fpu/fclrexcpt.c
new file mode 100644
index 0000000000..6f77e9a391
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fclrexcpt.c
@@ -0,0 +1,46 @@
+/* Clear given exceptions in current floating-point environment.
+   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 <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+feclearexcept (int excepts)
+{
+  int cw;
+
+  /* Mask out unsupported bits/exceptions.  */
+  excepts &= FE_ALL_EXCEPT;
+
+  /* Read the complete control word.  */
+  _FPU_GETCW (cw);
+
+  /* Clear exception flag bits and cause bits.  If the cause bit is not
+     cleared, the next CTC instruction (just below) will re-generate the
+     exception.  */
+
+  cw &= ~(excepts | (excepts << CAUSE_SHIFT));
+
+  /* Put the new data in effect.  */
+  _FPU_SETCW (cw);
+
+  /* Success.  */
+  return 0;
+}
+libm_hidden_def (feclearexcept)
diff --git a/sysdeps/loongarch/fpu/fedisblxcpt.c b/sysdeps/loongarch/fpu/fedisblxcpt.c
new file mode 100644
index 0000000000..532274bc19
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fedisblxcpt.c
@@ -0,0 +1,39 @@
+/* Disable floating-point exceptions.
+   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 <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fedisableexcept (int excepts)
+{
+  unsigned int new_exc, old_exc;
+
+  /* Get the current control word.  */
+  _FPU_GETCW (new_exc);
+
+  old_exc = (new_exc & ENABLE_MASK) << ENABLE_SHIFT;
+
+  excepts &= FE_ALL_EXCEPT;
+
+  new_exc &= ~(excepts >> ENABLE_SHIFT);
+  _FPU_SETCW (new_exc);
+
+  return old_exc;
+}
diff --git a/sysdeps/loongarch/fpu/feenablxcpt.c b/sysdeps/loongarch/fpu/feenablxcpt.c
new file mode 100644
index 0000000000..565ebd4d29
--- /dev/null
+++ b/sysdeps/loongarch/fpu/feenablxcpt.c
@@ -0,0 +1,39 @@
+/* Enable floating-point exceptions.
+   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 <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+feenableexcept (int excepts)
+{
+  unsigned int new_exc, old_exc;
+
+  /* Get the current control word.  */
+  _FPU_GETCW (new_exc);
+
+  old_exc = (new_exc & ENABLE_MASK) << ENABLE_SHIFT;
+
+  excepts &= FE_ALL_EXCEPT;
+
+  new_exc |= excepts >> ENABLE_SHIFT;
+  _FPU_SETCW (new_exc);
+
+  return old_exc;
+}
diff --git a/sysdeps/loongarch/fpu/fegetenv.c b/sysdeps/loongarch/fpu/fegetenv.c
new file mode 100644
index 0000000000..5e8c095fe5
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fegetenv.c
@@ -0,0 +1,31 @@
+/* Store current floating-point environment.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fegetenv (fenv_t *envp)
+{
+  _FPU_GETCW (*envp);
+
+  /* Success.  */
+  return 0;
+}
+libm_hidden_def (__fegetenv) weak_alias (__fegetenv, fegetenv)
+libm_hidden_weak (fegetenv)
diff --git a/sysdeps/loongarch/fpu/fegetexcept.c b/sysdeps/loongarch/fpu/fegetexcept.c
new file mode 100644
index 0000000000..782e9d806d
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fegetexcept.c
@@ -0,0 +1,32 @@
+/* Get enabled floating-point exceptions.
+   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 <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fegetexcept (void)
+{
+  unsigned int exc;
+
+  /* Get the current control word.  */
+  _FPU_GETCW (exc);
+
+  return (exc & ENABLE_MASK) << ENABLE_SHIFT;
+}
diff --git a/sysdeps/loongarch/fpu/fegetmode.c b/sysdeps/loongarch/fpu/fegetmode.c
new file mode 100644
index 0000000000..f39c4c31a2
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fegetmode.c
@@ -0,0 +1,27 @@
+/* Store current floating-point control modes.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetmode (femode_t *modep)
+{
+  _FPU_GETCW (*modep);
+  return 0;
+}
diff --git a/sysdeps/loongarch/fpu/fegetround.c b/sysdeps/loongarch/fpu/fegetround.c
new file mode 100644
index 0000000000..61a793a8c7
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fegetround.c
@@ -0,0 +1,33 @@
+/* Return current rounding direction.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fegetround (void)
+{
+  int cw;
+
+  /* Get control word.  */
+  _FPU_GETCW (cw);
+
+  return cw & _FPU_RC_MASK;
+}
+libm_hidden_def (__fegetround) weak_alias (__fegetround, fegetround)
+libm_hidden_weak (fegetround)
diff --git a/sysdeps/loongarch/fpu/feholdexcpt.c b/sysdeps/loongarch/fpu/feholdexcpt.c
new file mode 100644
index 0000000000..59791ba965
--- /dev/null
+++ b/sysdeps/loongarch/fpu/feholdexcpt.c
@@ -0,0 +1,40 @@
+/* Store current floating-point environment and clear exceptions.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__feholdexcept (fenv_t *envp)
+{
+  fpu_control_t cw;
+
+  /* Save the current state.  */
+  _FPU_GETCW (cw);
+  envp->__fp_control_register = cw;
+
+  /* Clear all exception enable bits and flags.  */
+  cw &= ~(_FPU_MASK_V | _FPU_MASK_Z | _FPU_MASK_O | _FPU_MASK_U | _FPU_MASK_I
+	  | FE_ALL_EXCEPT);
+  _FPU_SETCW (cw);
+
+  return 0;
+}
+
+libm_hidden_def (__feholdexcept) weak_alias (__feholdexcept, feholdexcept)
+libm_hidden_weak (feholdexcept)
diff --git a/sysdeps/loongarch/fpu/fenv_libc.h b/sysdeps/loongarch/fpu/fenv_libc.h
new file mode 100644
index 0000000000..60eedc93c2
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fenv_libc.h
@@ -0,0 +1,30 @@
+/* Internal libc stuff for floating point environment routines.
+   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_LIBC_H
+#define _FENV_LIBC_H 1
+
+/* Mask for enabling exceptions and for the CAUSE bits.  */
+#define ENABLE_MASK 0x0000001FU
+#define CAUSE_MASK 0x1F000000U
+
+/* Shift for FE_* flags to get up to the ENABLE bits and the CAUSE bits.  */
+#define ENABLE_SHIFT 16
+#define CAUSE_SHIFT 8
+
+#endif /* _FENV_LIBC_H */
diff --git a/sysdeps/loongarch/fpu/fesetenv.c b/sysdeps/loongarch/fpu/fesetenv.c
new file mode 100644
index 0000000000..2a73a17db8
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fesetenv.c
@@ -0,0 +1,42 @@
+/* Install given floating-point environment.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fesetenv (const fenv_t *envp)
+{
+  fpu_control_t cw;
+
+  /* Read first current state to flush fpu pipeline.  */
+  _FPU_GETCW (cw);
+
+  if (envp == FE_DFL_ENV)
+    _FPU_SETCW (_FPU_DEFAULT);
+  else if (envp == FE_NOMASK_ENV)
+    _FPU_SETCW (_FPU_IEEE);
+  else
+    _FPU_SETCW (envp->__fp_control_register);
+
+  /* Success.  */
+  return 0;
+}
+
+libm_hidden_def (__fesetenv) weak_alias (__fesetenv, fesetenv)
+libm_hidden_weak (fesetenv)
diff --git a/sysdeps/loongarch/fpu/fesetexcept.c b/sysdeps/loongarch/fpu/fesetexcept.c
new file mode 100644
index 0000000000..63c65e8f80
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fesetexcept.c
@@ -0,0 +1,32 @@
+/* Set given exception flags.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetexcept (int excepts)
+{
+  fpu_control_t temp;
+
+  _FPU_GETCW (temp);
+  temp |= excepts & FE_ALL_EXCEPT;
+  _FPU_SETCW (temp);
+
+  return 0;
+}
diff --git a/sysdeps/loongarch/fpu/fesetmode.c b/sysdeps/loongarch/fpu/fesetmode.c
new file mode 100644
index 0000000000..8948876a0f
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fesetmode.c
@@ -0,0 +1,38 @@
+/* Install given floating-point control modes.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+#define FCSR_STATUS 0x1f1f0000
+
+int
+fesetmode (const femode_t *modep)
+{
+  fpu_control_t cw;
+
+  _FPU_GETCW (cw);
+  cw &= FCSR_STATUS;
+  if (modep == FE_DFL_MODE)
+    cw |= _FPU_DEFAULT;
+  else
+    cw |= *modep & ~FCSR_STATUS;
+  _FPU_SETCW (cw);
+
+  return 0;
+}
diff --git a/sysdeps/loongarch/fpu/fesetround.c b/sysdeps/loongarch/fpu/fesetround.c
new file mode 100644
index 0000000000..dddac1ccf7
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fesetround.c
@@ -0,0 +1,44 @@
+/* Set current rounding direction.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fesetround (int round)
+{
+  fpu_control_t cw;
+
+  if ((round & ~_FPU_RC_MASK) != 0)
+    /* ROUND is no valid rounding mode.  */
+    return 1;
+
+  /* Get current state.  */
+  _FPU_GETCW (cw);
+
+  /* Set rounding bits.  */
+  cw &= ~_FPU_RC_MASK;
+  cw |= round;
+  /* Set new state.  */
+  _FPU_SETCW (cw);
+
+  return 0;
+}
+
+libm_hidden_def (__fesetround) weak_alias (__fesetround, fesetround)
+libm_hidden_weak (fesetround)
diff --git a/sysdeps/loongarch/fpu/feupdateenv.c b/sysdeps/loongarch/fpu/feupdateenv.c
new file mode 100644
index 0000000000..ad147cbd46
--- /dev/null
+++ b/sysdeps/loongarch/fpu/feupdateenv.c
@@ -0,0 +1,43 @@
+/* Install given floating-point environment and raise exceptions.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__feupdateenv (const fenv_t *envp)
+{
+  int temp;
+
+  /* Save current exceptions.  */
+  _FPU_GETCW (temp);
+  temp &= FE_ALL_EXCEPT;
+
+  /* Install new environment.  */
+  __fesetenv (envp);
+
+  /* Raise the safed exception.  Incidently for us the implementation
+     defined format of the values in objects of type fexcept_t is the
+     same as the ones specified using the FE_* constants.  */
+  __feraiseexcept (temp);
+
+  /* Success.  */
+  return 0;
+}
+libm_hidden_def (__feupdateenv) weak_alias (__feupdateenv, feupdateenv)
+libm_hidden_weak (feupdateenv)
diff --git a/sysdeps/loongarch/fpu/fgetexcptflg.c b/sysdeps/loongarch/fpu/fgetexcptflg.c
new file mode 100644
index 0000000000..85733765ea
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fgetexcptflg.c
@@ -0,0 +1,38 @@
+/* Store current representation for exceptions.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+  fpu_control_t temp;
+
+  /* Get the current exceptions.  */
+  _FPU_GETCW (temp);
+
+  /* We only save the relevant bits here.  In particular, care has to be
+     taken with the CAUSE bits, as an inadvertent restore later on could
+     generate unexpected exceptions.  */
+
+  *flagp = temp & excepts & FE_ALL_EXCEPT;
+
+  /* Success.  */
+  return 0;
+}
diff --git a/sysdeps/loongarch/fpu/fraiseexcpt.c b/sysdeps/loongarch/fpu/fraiseexcpt.c
new file mode 100644
index 0000000000..ac01dc7077
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fraiseexcpt.c
@@ -0,0 +1,75 @@
+/* Raise given exceptions.
+   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 <fenv.h>
+#include <fpu_control.h>
+#include <float.h>
+
+int
+__feraiseexcept (int excepts)
+{
+  const float fp_zero = 0.0, fp_one = 1.0, fp_max = FLT_MAX, fp_min = FLT_MIN,
+		  fp_1e32 = 1.0e32f, fp_two = 2.0, fp_three = 3.0;
+
+  /* Raise exceptions represented by EXPECTS.  But we must raise only
+     one signal at a time.  It is important that if the overflow/underflow
+     exception and the inexact exception are given at the same time,
+     the overflow/underflow exception follows the inexact exception.  */
+
+  /* First: invalid exception.  */
+  if (FE_INVALID & excepts)
+    __asm__ __volatile__("fdiv.s $f0,%0,%0\n\t"
+			 :
+			 : "f"(fp_zero)
+			 : "$f0");
+
+  /* Next: division by zero.  */
+  if (FE_DIVBYZERO & excepts)
+    __asm__ __volatile__("fdiv.s $f0,%0,%1\n\t"
+			 :
+			 : "f"(fp_one), "f"(fp_zero)
+			 : "$f0");
+
+  /* Next: overflow.  */
+  if (FE_OVERFLOW & excepts)
+    /* There's no way to raise overflow without also raising inexact.  */
+    __asm__ __volatile__("fadd.s $f0,%0,%1\n\t"
+			 :
+			 : "f"(fp_max), "f"(fp_1e32)
+			 : "$f0");
+
+  /* Next: underflow.  */
+  if (FE_UNDERFLOW & excepts)
+    __asm__ __volatile__("fdiv.s $f0,%0,%1\n\t"
+			 :
+			 : "f"(fp_min), "f"(fp_three)
+			 : "$f0");
+
+  /* Last: inexact.  */
+  if (FE_INEXACT & excepts)
+    __asm__ __volatile__("fdiv.s $f0, %0, %1\n\t"
+			 :
+			 : "f"(fp_two), "f"(fp_three)
+			 : "$f0");
+
+  /* Success.  */
+  return 0;
+}
+
+libm_hidden_def (__feraiseexcept) weak_alias (__feraiseexcept, feraiseexcept)
+libm_hidden_weak (feraiseexcept)
diff --git a/sysdeps/loongarch/fpu/fsetexcptflg.c b/sysdeps/loongarch/fpu/fsetexcptflg.c
new file mode 100644
index 0000000000..eef2faa6f4
--- /dev/null
+++ b/sysdeps/loongarch/fpu/fsetexcptflg.c
@@ -0,0 +1,41 @@
+/* Set floating-point environment exception handling.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+  fpu_control_t temp;
+
+  /* Get the current exceptions.  */
+  _FPU_GETCW (temp);
+
+  /* Make sure the flags we want restored are legal.  */
+  excepts &= FE_ALL_EXCEPT;
+
+  /* Now clear the bits called for, and copy them in from flagp.  Note that
+     we ignore all non-flag bits from *flagp, so they don't matter.  */
+  temp = (temp & ~excepts) | (*flagp & excepts);
+
+  _FPU_SETCW (temp);
+
+  /* Success.  */
+  return 0;
+}
diff --git a/sysdeps/loongarch/fpu/ftestexcept.c b/sysdeps/loongarch/fpu/ftestexcept.c
new file mode 100644
index 0000000000..3abd75ee42
--- /dev/null
+++ b/sysdeps/loongarch/fpu/ftestexcept.c
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+  int cw;
+
+  /* Get current control word.  */
+  _FPU_GETCW (cw);
+
+  return cw & excepts & FE_ALL_EXCEPT;
+}
+libm_hidden_def (fetestexcept)
diff --git a/sysdeps/loongarch/lp64/libm-test-ulps b/sysdeps/loongarch/lp64/libm-test-ulps
new file mode 100644
index 0000000000..d0dfd076f2
--- /dev/null
+++ b/sysdeps/loongarch/lp64/libm-test-ulps
@@ -0,0 +1,1411 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acos":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "acos_downward":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "acos_towardzero":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "acos_upward":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "acosh":
+double: 2
+float: 2
+ldouble: 4
+
+Function: "acosh_downward":
+double: 2
+float: 2
+ldouble: 3
+
+Function: "acosh_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "acosh_upward":
+double: 2
+float: 2
+ldouble: 3
+
+Function: "asin":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "asin_downward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "asin_upward":
+double: 2
+float: 1
+ldouble: 2
+
+Function: "asinh":
+double: 2
+float: 2
+ldouble: 4
+
+Function: "asinh_downward":
+double: 3
+float: 3
+ldouble: 4
+
+Function: "asinh_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "asinh_upward":
+double: 3
+float: 3
+ldouble: 4
+
+Function: "atan":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "atan2":
+float: 1
+ldouble: 2
+
+Function: "atan2_downward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: "atan2_towardzero":
+double: 1
+float: 2
+ldouble: 3
+
+Function: "atan2_upward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "atan_downward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: "atan_towardzero":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "atan_upward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: "atanh":
+double: 2
+float: 2
+ldouble: 4
+
+Function: "atanh_downward":
+double: 3
+float: 3
+ldouble: 4
+
+Function: "atanh_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "atanh_upward":
+double: 3
+float: 3
+ldouble: 4
+
+Function: "cabs":
+double: 1
+ldouble: 1
+
+Function: "cabs_downward":
+double: 1
+ldouble: 1
+
+Function: "cabs_towardzero":
+double: 1
+ldouble: 1
+
+Function: "cabs_upward":
+double: 1
+ldouble: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "cacos_downward":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "cacos_downward":
+double: 5
+float: 3
+ldouble: 6
+
+Function: Real part of "cacos_towardzero":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "cacos_towardzero":
+double: 4
+float: 2
+ldouble: 5
+
+Function: Real part of "cacos_upward":
+double: 2
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "cacos_upward":
+double: 5
+float: 5
+ldouble: 7
+
+Function: Real part of "cacosh":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Real part of "cacosh_downward":
+double: 4
+float: 2
+ldouble: 5
+
+Function: Imaginary part of "cacosh_downward":
+double: 3
+float: 3
+ldouble: 4
+
+Function: Real part of "cacosh_towardzero":
+double: 4
+float: 2
+ldouble: 5
+
+Function: Imaginary part of "cacosh_towardzero":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Real part of "cacosh_upward":
+double: 4
+float: 3
+ldouble: 6
+
+Function: Imaginary part of "cacosh_upward":
+double: 3
+float: 2
+ldouble: 4
+
+Function: "carg":
+float: 1
+ldouble: 2
+
+Function: "carg_downward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: "carg_towardzero":
+double: 1
+float: 2
+ldouble: 3
+
+Function: "carg_upward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: Real part of "casin":
+double: 1
+float: 1
+ldouble: 2
+
+Function: Imaginary part of "casin":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "casin_downward":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "casin_downward":
+double: 5
+float: 3
+ldouble: 6
+
+Function: Real part of "casin_towardzero":
+double: 3
+float: 1
+ldouble: 3
+
+Function: Imaginary part of "casin_towardzero":
+double: 4
+float: 2
+ldouble: 5
+
+Function: Real part of "casin_upward":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "casin_upward":
+double: 5
+float: 5
+ldouble: 7
+
+Function: Real part of "casinh":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "casinh":
+double: 1
+float: 1
+ldouble: 2
+
+Function: Real part of "casinh_downward":
+double: 5
+float: 3
+ldouble: 6
+
+Function: Imaginary part of "casinh_downward":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Real part of "casinh_towardzero":
+double: 4
+float: 2
+ldouble: 5
+
+Function: Imaginary part of "casinh_towardzero":
+double: 3
+float: 1
+ldouble: 3
+
+Function: Real part of "casinh_upward":
+double: 5
+float: 5
+ldouble: 7
+
+Function: Imaginary part of "casinh_upward":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Real part of "catan":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Real part of "catan_downward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "catan_downward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "catan_towardzero":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "catan_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "catan_upward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: Imaginary part of "catan_upward":
+double: 2
+float: 2
+ldouble: 3
+
+Function: Real part of "catanh":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Real part of "catanh_downward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "catanh_downward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Real part of "catanh_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "catanh_towardzero":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Real part of "catanh_upward":
+double: 4
+float: 4
+ldouble: 4
+
+Function: Imaginary part of "catanh_upward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "cbrt":
+double: 4
+float: 1
+ldouble: 1
+
+Function: "cbrt_downward":
+double: 4
+float: 1
+ldouble: 1
+
+Function: "cbrt_towardzero":
+double: 3
+float: 1
+ldouble: 1
+
+Function: "cbrt_upward":
+double: 5
+float: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Real part of "ccos_downward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: Imaginary part of "ccos_downward":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "ccos_towardzero":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "ccos_towardzero":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "ccos_upward":
+double: 1
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "ccos_upward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Real part of "ccosh_downward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "ccosh_downward":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "ccosh_towardzero":
+double: 2
+float: 3
+ldouble: 2
+
+Function: Imaginary part of "ccosh_towardzero":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "ccosh_upward":
+double: 1
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "ccosh_upward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "cexp":
+double: 2
+float: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+double: 1
+float: 2
+ldouble: 1
+
+Function: Real part of "cexp_downward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "cexp_downward":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "cexp_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "cexp_towardzero":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "cexp_upward":
+double: 1
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "cexp_upward":
+double: 3
+float: 2
+ldouble: 3
+
+Function: Real part of "clog":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Imaginary part of "clog":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 3
+float: 4
+ldouble: 2
+
+Function: Imaginary part of "clog10":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "clog10_downward":
+double: 5
+float: 5
+ldouble: 3
+
+Function: Imaginary part of "clog10_downward":
+double: 2
+float: 4
+ldouble: 3
+
+Function: Real part of "clog10_towardzero":
+double: 5
+float: 6
+ldouble: 4
+
+Function: Imaginary part of "clog10_towardzero":
+double: 2
+float: 4
+ldouble: 3
+
+Function: Real part of "clog10_upward":
+double: 6
+float: 5
+ldouble: 4
+
+Function: Imaginary part of "clog10_upward":
+double: 2
+float: 4
+ldouble: 3
+
+Function: Real part of "clog_downward":
+double: 4
+float: 3
+ldouble: 3
+
+Function: Imaginary part of "clog_downward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Real part of "clog_towardzero":
+double: 4
+float: 4
+ldouble: 3
+
+Function: Imaginary part of "clog_towardzero":
+double: 1
+float: 3
+ldouble: 2
+
+Function: Real part of "clog_upward":
+double: 4
+float: 3
+ldouble: 4
+
+Function: Imaginary part of "clog_upward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: "cos":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "cos_downward":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "cos_towardzero":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "cos_upward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "cosh":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "cosh_downward":
+double: 3
+float: 1
+ldouble: 3
+
+Function: "cosh_towardzero":
+double: 3
+float: 1
+ldouble: 3
+
+Function: "cosh_upward":
+double: 2
+float: 2
+ldouble: 3
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+ldouble: 4
+
+Function: Imaginary part of "cpow":
+float: 2
+ldouble: 1
+
+Function: Real part of "cpow_downward":
+double: 5
+float: 8
+ldouble: 6
+
+Function: Imaginary part of "cpow_downward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Real part of "cpow_towardzero":
+double: 5
+float: 8
+ldouble: 6
+
+Function: Imaginary part of "cpow_towardzero":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Real part of "cpow_upward":
+double: 4
+float: 1
+ldouble: 3
+
+Function: Imaginary part of "cpow_upward":
+double: 1
+float: 2
+ldouble: 2
+
+Function: Real part of "csin":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+ldouble: 1
+
+Function: Real part of "csin_downward":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Imaginary part of "csin_downward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: Real part of "csin_towardzero":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Imaginary part of "csin_towardzero":
+double: 1
+float: 1
+ldouble: 2
+
+Function: Real part of "csin_upward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "csin_upward":
+double: 1
+float: 2
+ldouble: 3
+
+Function: Real part of "csinh":
+float: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+ldouble: 1
+
+Function: Real part of "csinh_downward":
+double: 2
+float: 1
+ldouble: 2
+
+Function: Imaginary part of "csinh_downward":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "csinh_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "csinh_towardzero":
+double: 3
+float: 3
+ldouble: 2
+
+Function: Real part of "csinh_upward":
+double: 1
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "csinh_upward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "csqrt":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Imaginary part of "csqrt":
+double: 2
+float: 2
+ldouble: 2
+
+Function: Real part of "csqrt_downward":
+double: 5
+float: 4
+ldouble: 4
+
+Function: Imaginary part of "csqrt_downward":
+double: 4
+float: 3
+ldouble: 3
+
+Function: Real part of "csqrt_towardzero":
+double: 4
+float: 3
+ldouble: 3
+
+Function: Imaginary part of "csqrt_towardzero":
+double: 4
+float: 3
+ldouble: 3
+
+Function: Real part of "csqrt_upward":
+double: 5
+float: 4
+ldouble: 4
+
+Function: Imaginary part of "csqrt_upward":
+double: 3
+float: 3
+ldouble: 3
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+ldouble: 3
+
+Function: Imaginary part of "ctan":
+double: 2
+float: 2
+ldouble: 3
+
+Function: Real part of "ctan_downward":
+double: 6
+float: 5
+ldouble: 4
+
+Function: Imaginary part of "ctan_downward":
+double: 2
+float: 2
+ldouble: 5
+
+Function: Real part of "ctan_towardzero":
+double: 5
+float: 2
+ldouble: 4
+
+Function: Imaginary part of "ctan_towardzero":
+double: 2
+float: 2
+ldouble: 5
+
+Function: Real part of "ctan_upward":
+double: 2
+float: 4
+ldouble: 5
+
+Function: Imaginary part of "ctan_upward":
+double: 2
+float: 2
+ldouble: 5
+
+Function: Real part of "ctanh":
+double: 2
+float: 2
+ldouble: 3
+
+Function: Imaginary part of "ctanh":
+double: 2
+float: 1
+ldouble: 3
+
+Function: Real part of "ctanh_downward":
+double: 4
+float: 2
+ldouble: 5
+
+Function: Imaginary part of "ctanh_downward":
+double: 6
+float: 5
+ldouble: 4
+
+Function: Real part of "ctanh_towardzero":
+double: 2
+float: 2
+ldouble: 5
+
+Function: Imaginary part of "ctanh_towardzero":
+double: 5
+float: 2
+ldouble: 3
+
+Function: Real part of "ctanh_upward":
+double: 2
+float: 2
+ldouble: 5
+
+Function: Imaginary part of "ctanh_upward":
+double: 2
+float: 3
+ldouble: 5
+
+Function: "erf":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "erf_downward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "erf_towardzero":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "erf_upward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "erfc":
+double: 2
+float: 2
+ldouble: 4
+
+Function: "erfc_downward":
+double: 4
+float: 4
+ldouble: 5
+
+Function: "erfc_towardzero":
+double: 3
+float: 3
+ldouble: 4
+
+Function: "erfc_upward":
+double: 4
+float: 4
+ldouble: 5
+
+Function: "exp":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "exp10":
+double: 2
+ldouble: 2
+
+Function: "exp10_downward":
+double: 3
+float: 1
+ldouble: 3
+
+Function: "exp10_towardzero":
+double: 3
+float: 1
+ldouble: 3
+
+Function: "exp10_upward":
+double: 2
+float: 1
+ldouble: 3
+
+Function: "exp2":
+double: 1
+ldouble: 1
+
+Function: "exp2_downward":
+double: 1
+ldouble: 1
+
+Function: "exp2_towardzero":
+double: 1
+ldouble: 1
+
+Function: "exp2_upward":
+double: 1
+float: 1
+ldouble: 2
+
+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
+ldouble: 2
+
+Function: "expm1_downward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "expm1_towardzero":
+double: 1
+float: 2
+ldouble: 4
+
+Function: "expm1_upward":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "gamma":
+double: 3
+float: 3
+ldouble: 5
+
+Function: "gamma_downward":
+double: 4
+float: 4
+ldouble: 8
+
+Function: "gamma_towardzero":
+double: 4
+float: 3
+ldouble: 5
+
+Function: "gamma_upward":
+double: 4
+float: 5
+ldouble: 8
+
+Function: "hypot":
+double: 1
+ldouble: 1
+
+Function: "hypot_downward":
+double: 1
+ldouble: 1
+
+Function: "hypot_towardzero":
+double: 1
+ldouble: 1
+
+Function: "hypot_upward":
+double: 1
+ldouble: 1
+
+Function: "j0":
+double: 3
+float: 9
+ldouble: 2
+
+Function: "j0_downward":
+double: 6
+float: 9
+ldouble: 9
+
+Function: "j0_towardzero":
+double: 7
+float: 9
+ldouble: 9
+
+Function: "j0_upward":
+double: 9
+float: 9
+ldouble: 7
+
+Function: "j1":
+double: 4
+float: 9
+ldouble: 4
+
+Function: "j1_downward":
+double: 3
+float: 8
+ldouble: 4
+
+Function: "j1_towardzero":
+double: 4
+float: 8
+ldouble: 4
+
+Function: "j1_upward":
+double: 9
+float: 9
+ldouble: 3
+
+Function: "jn":
+double: 4
+float: 4
+ldouble: 7
+
+Function: "jn_downward":
+double: 4
+float: 5
+ldouble: 8
+
+Function: "jn_towardzero":
+double: 4
+float: 5
+ldouble: 8
+
+Function: "jn_upward":
+double: 5
+float: 4
+ldouble: 7
+
+Function: "lgamma":
+double: 3
+float: 3
+ldouble: 5
+
+Function: "lgamma_downward":
+double: 4
+float: 4
+ldouble: 8
+
+Function: "lgamma_towardzero":
+double: 4
+float: 3
+ldouble: 5
+
+Function: "lgamma_upward":
+double: 4
+float: 5
+ldouble: 8
+
+Function: "log":
+double: 1
+ldouble: 1
+
+Function: "log10":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "log10_downward":
+double: 2
+float: 3
+ldouble: 1
+
+Function: "log10_towardzero":
+double: 2
+float: 1
+ldouble: 1
+
+Function: "log10_upward":
+double: 2
+float: 2
+ldouble: 1
+
+Function: "log1p":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "log1p_downward":
+double: 1
+float: 2
+ldouble: 3
+
+Function: "log1p_towardzero":
+double: 2
+float: 2
+ldouble: 3
+
+Function: "log1p_upward":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "log2":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "log2_downward":
+double: 3
+ldouble: 3
+
+Function: "log2_towardzero":
+double: 2
+ldouble: 1
+
+Function: "log2_upward":
+double: 3
+ldouble: 1
+
+Function: "log_downward":
+ldouble: 1
+
+Function: "log_towardzero":
+ldouble: 2
+
+Function: "log_upward":
+double: 1
+ldouble: 2
+
+Function: "pow":
+double: 1
+ldouble: 2
+
+Function: "pow_downward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "pow_towardzero":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "pow_upward":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "sin":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "sin_downward":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "sin_towardzero":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "sin_upward":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "sincos":
+double: 1
+ldouble: 1
+
+Function: "sincos_downward":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "sincos_towardzero":
+double: 1
+float: 1
+ldouble: 2
+
+Function: "sincos_upward":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "sinh":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "sinh_downward":
+double: 3
+float: 3
+ldouble: 3
+
+Function: "sinh_towardzero":
+double: 3
+float: 2
+ldouble: 3
+
+Function: "sinh_upward":
+double: 3
+float: 3
+ldouble: 4
+
+Function: "tan":
+float: 1
+ldouble: 1
+
+Function: "tan_downward":
+double: 1
+float: 2
+ldouble: 1
+
+Function: "tan_towardzero":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "tan_upward":
+double: 1
+float: 1
+ldouble: 1
+
+Function: "tanh":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "tanh_downward":
+double: 3
+float: 3
+ldouble: 4
+
+Function: "tanh_towardzero":
+double: 2
+float: 2
+ldouble: 3
+
+Function: "tanh_upward":
+double: 3
+float: 3
+ldouble: 3
+
+Function: "tgamma":
+double: 9
+float: 8
+ldouble: 4
+
+Function: "tgamma_downward":
+double: 9
+float: 7
+ldouble: 5
+
+Function: "tgamma_towardzero":
+double: 9
+float: 7
+ldouble: 5
+
+Function: "tgamma_upward":
+double: 9
+float: 8
+ldouble: 4
+
+Function: "y0":
+double: 2
+float: 8
+ldouble: 3
+
+Function: "y0_downward":
+double: 3
+float: 8
+ldouble: 7
+
+Function: "y0_towardzero":
+double: 3
+float: 8
+ldouble: 3
+
+Function: "y0_upward":
+double: 2
+float: 8
+ldouble: 4
+
+Function: "y1":
+double: 3
+float: 9
+ldouble: 5
+
+Function: "y1_downward":
+double: 6
+float: 8
+ldouble: 5
+
+Function: "y1_towardzero":
+double: 3
+float: 9
+ldouble: 2
+
+Function: "y1_upward":
+double: 6
+float: 9
+ldouble: 5
+
+Function: "yn":
+double: 3
+float: 3
+ldouble: 5
+
+Function: "yn_downward":
+double: 3
+float: 4
+ldouble: 5
+
+Function: "yn_towardzero":
+double: 3
+float: 3
+ldouble: 5
+
+Function: "yn_upward":
+double: 4
+float: 5
+ldouble: 5
+
+# end of automatic generation
diff --git a/sysdeps/loongarch/lp64/libm-test-ulps-name b/sysdeps/loongarch/lp64/libm-test-ulps-name
new file mode 100644
index 0000000000..ce02281eab
--- /dev/null
+++ b/sysdeps/loongarch/lp64/libm-test-ulps-name
@@ -0,0 +1 @@
+LoongArch 64-bit
diff --git a/sysdeps/loongarch/math_private.h b/sysdeps/loongarch/math_private.h
new file mode 100644
index 0000000000..5665624b23
--- /dev/null
+++ b/sysdeps/loongarch/math_private.h
@@ -0,0 +1,248 @@
+/* Internal math stuff.
+   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 LOONGARCH_MATH_PRIVATE_H
+#define LOONGARCH_MATH_PRIVATE_H 1
+
+/* Inline functions to speed up the math library implementation.  The
+   default versions of these routines are in generic/math_private.h
+   and call fesetround, feholdexcept, etc.  These routines use inlined
+   code instead.  */
+
+#ifdef __loongarch_hard_float
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+#define _FPU_MASK_ALL \
+  (_FPU_MASK_V | _FPU_MASK_Z | _FPU_MASK_O | _FPU_MASK_U | _FPU_MASK_I \
+   | FE_ALL_EXCEPT)
+
+static __always_inline void
+libc_feholdexcept_loongarch (fenv_t *envp)
+{
+  fpu_control_t cw;
+
+  /* Save the current state.  */
+  _FPU_GETCW (cw);
+  envp->__fp_control_register = cw;
+
+  /* Clear all exception enable bits and flags.  */
+  cw &= ~(_FPU_MASK_ALL);
+  _FPU_SETCW (cw);
+}
+#define libc_feholdexcept libc_feholdexcept_loongarch
+#define libc_feholdexceptf libc_feholdexcept_loongarch
+#define libc_feholdexceptl libc_feholdexcept_loongarch
+
+static __always_inline void
+libc_fesetround_loongarch (int round)
+{
+  fpu_control_t cw;
+
+  /* Get current state.  */
+  _FPU_GETCW (cw);
+
+  /* Set rounding bits.  */
+  cw &= ~_FPU_RC_MASK;
+  cw |= round;
+
+  /* Set new state.  */
+  _FPU_SETCW (cw);
+}
+#define libc_fesetround libc_fesetround_loongarch
+#define libc_fesetroundf libc_fesetround_loongarch
+#define libc_fesetroundl libc_fesetround_loongarch
+
+static __always_inline void
+libc_feholdexcept_setround_loongarch (fenv_t *envp, int round)
+{
+  fpu_control_t cw;
+
+  /* Save the current state.  */
+  _FPU_GETCW (cw);
+  envp->__fp_control_register = cw;
+
+  /* Clear all exception enable bits and flags.  */
+  cw &= ~(_FPU_MASK_ALL);
+
+  /* Set rounding bits.  */
+  cw &= ~_FPU_RC_MASK;
+  cw |= round;
+
+  /* Set new state.  */
+  _FPU_SETCW (cw);
+}
+#define libc_feholdexcept_setround libc_feholdexcept_setround_loongarch
+#define libc_feholdexcept_setroundf libc_feholdexcept_setround_loongarch
+#define libc_feholdexcept_setroundl libc_feholdexcept_setround_loongarch
+
+#define libc_feholdsetround libc_feholdexcept_setround_loongarch
+#define libc_feholdsetroundf libc_feholdexcept_setround_loongarch
+#define libc_feholdsetroundl libc_feholdexcept_setround_loongarch
+
+static __always_inline void
+libc_fesetenv_loongarch (fenv_t *envp)
+{
+  fpu_control_t cw __attribute__ ((unused));
+
+  /* Read current state to flush fpu pipeline.  */
+  _FPU_GETCW (cw);
+
+  _FPU_SETCW (envp->__fp_control_register);
+}
+#define libc_fesetenv libc_fesetenv_loongarch
+#define libc_fesetenvf libc_fesetenv_loongarch
+#define libc_fesetenvl libc_fesetenv_loongarch
+
+static __always_inline int
+libc_feupdateenv_test_loongarch (fenv_t *envp, int excepts)
+{
+  /* int ret = fetestexcept (excepts); feupdateenv (envp); return ret; */
+  int cw, temp;
+
+  /* Get current control word.  */
+  _FPU_GETCW (cw);
+
+  /* Set flag bits (which are accumulative), and *also* set the
+     cause bits.  The setting of the cause bits is what actually causes
+     the hardware to generate the exception, if the corresponding enable
+     bit is set as well.  */
+  temp = cw & FE_ALL_EXCEPT;
+  temp |= envp->__fp_control_register | (temp << CAUSE_SHIFT);
+
+  /* Set new state.  */
+  _FPU_SETCW (temp);
+
+  return cw & excepts & FE_ALL_EXCEPT;
+}
+#define libc_feupdateenv_test libc_feupdateenv_test_loongarch
+#define libc_feupdateenv_testf libc_feupdateenv_test_loongarch
+#define libc_feupdateenv_testl libc_feupdateenv_test_loongarch
+
+static __always_inline void
+libc_feupdateenv_loongarch (fenv_t *envp)
+{
+  libc_feupdateenv_test_loongarch (envp, 0);
+}
+#define libc_feupdateenv libc_feupdateenv_loongarch
+#define libc_feupdateenvf libc_feupdateenv_loongarch
+#define libc_feupdateenvl libc_feupdateenv_loongarch
+
+#define libc_feresetround libc_feupdateenv_loongarch
+#define libc_feresetroundf libc_feupdateenv_loongarch
+#define libc_feresetroundl libc_feupdateenv_loongarch
+
+static __always_inline int
+libc_fetestexcept_loongarch (int excepts)
+{
+  int cw;
+
+  /* Get current control word.  */
+  _FPU_GETCW (cw);
+
+  return cw & excepts & FE_ALL_EXCEPT;
+}
+#define libc_fetestexcept libc_fetestexcept_loongarch
+#define libc_fetestexceptf libc_fetestexcept_loongarch
+#define libc_fetestexceptl libc_fetestexcept_loongarch
+
+/*  Enable support for rounding mode context.  */
+#define HAVE_RM_CTX 1
+
+static __always_inline void
+libc_feholdexcept_setround_loongarch_ctx (struct rm_ctx *ctx, int round)
+{
+  fpu_control_t old, new;
+
+  /* Save the current state.  */
+  _FPU_GETCW (old);
+  ctx->env.__fp_control_register = old;
+
+  /* Clear all exception enable bits and flags.  */
+  new = old & ~(_FPU_MASK_ALL);
+
+  /* Set rounding bits.  */
+  new = (new & ~_FPU_RC_MASK) | round;
+
+  if (__glibc_unlikely (new != old))
+    {
+      _FPU_SETCW (new);
+      ctx->updated_status = true;
+    }
+  else
+    ctx->updated_status = false;
+}
+#define libc_feholdexcept_setround_ctx libc_feholdexcept_setround_loongarch_ctx
+#define libc_feholdexcept_setroundf_ctx \
+  libc_feholdexcept_setround_loongarch_ctx
+#define libc_feholdexcept_setroundl_ctx \
+  libc_feholdexcept_setround_loongarch_ctx
+
+static __always_inline void
+libc_fesetenv_loongarch_ctx (struct rm_ctx *ctx)
+{
+  libc_fesetenv_loongarch (&ctx->env);
+}
+#define libc_fesetenv_ctx libc_fesetenv_loongarch_ctx
+#define libc_fesetenvf_ctx libc_fesetenv_loongarch_ctx
+#define libc_fesetenvl_ctx libc_fesetenv_loongarch_ctx
+
+static __always_inline void
+libc_feupdateenv_loongarch_ctx (struct rm_ctx *ctx)
+{
+  if (__glibc_unlikely (ctx->updated_status))
+    libc_feupdateenv_test_loongarch (&ctx->env, 0);
+}
+#define libc_feupdateenv_ctx libc_feupdateenv_loongarch_ctx
+#define libc_feupdateenvf_ctx libc_feupdateenv_loongarch_ctx
+#define libc_feupdateenvl_ctx libc_feupdateenv_loongarch_ctx
+#define libc_feresetround_ctx libc_feupdateenv_loongarch_ctx
+#define libc_feresetroundf_ctx libc_feupdateenv_loongarch_ctx
+#define libc_feresetroundl_ctx libc_feupdateenv_loongarch_ctx
+
+static __always_inline void
+libc_feholdsetround_loongarch_ctx (struct rm_ctx *ctx, int round)
+{
+  fpu_control_t old, new;
+
+  /* Save the current state.  */
+  _FPU_GETCW (old);
+  ctx->env.__fp_control_register = old;
+
+  /* Set rounding bits.  */
+  new = (old & ~_FPU_RC_MASK) | round;
+
+  if (__glibc_unlikely (new != old))
+    {
+      _FPU_SETCW (new);
+      ctx->updated_status = true;
+    }
+  else
+    ctx->updated_status = false;
+}
+#define libc_feholdsetround_ctx libc_feholdsetround_loongarch_ctx
+#define libc_feholdsetroundf_ctx libc_feholdsetround_loongarch_ctx
+#define libc_feholdsetroundl_ctx libc_feholdsetround_loongarch_ctx
+
+#endif
+
+#include_next <math_private.h>
+
+#endif
-- 
2.27.0


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

* [PATCH v2 14/14] LoongArch: Update build-many-glibcs.py for the LoongArch Port.
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (12 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 13/14] LoongArch: Hard Float Support caiyinyu
@ 2021-12-31  6:44 ` caiyinyu
  2021-12-31 17:34 ` [PATCH v2 00/14] GLIBC LoongArch PATCHES Joseph Myers
  2022-01-04 13:27 ` Adhemerval Zanella
  15 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2021-12-31  6:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph_myers, xuchenghua, caiyinyu

---
 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 b83bc159fd..aa69fdcdc6 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -218,6 +218,10 @@ class Context(object):
                         os_name='linux-gnu',
                         first_gcc_cfg=['--with-system-libunwind'],
                         binutils_cfg=['--enable-obsolete'])
+        self.add_config(arch='loongarch64',
+                        os_name='linux-gnu',
+                        variant='hard',
+                        gcc_cfg=['--with-abi=lp64d','--disable-multilib'])
         self.add_config(arch='m68k',
                         os_name='linux-gnu',
                         gcc_cfg=['--disable-multilib'])
@@ -1267,6 +1271,7 @@ def install_linux_headers(policy, cmdlist):
                 'i686': 'x86',
                 'i786': 'x86',
                 'ia64': 'ia64',
+                'loongarch64': 'loongarch',
                 'm68k': 'm68k',
                 'microblaze': 'microblaze',
                 'mips': 'mips',
-- 
2.27.0


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

* Re: [PATCH v2 00/14] GLIBC LoongArch PATCHES
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (13 preceding siblings ...)
  2021-12-31  6:44 ` [PATCH v2 14/14] LoongArch: Update build-many-glibcs.py for the LoongArch Port caiyinyu
@ 2021-12-31 17:34 ` Joseph Myers
  2022-04-15  1:27   ` caiyinyu
  2022-01-04 13:27 ` Adhemerval Zanella
  15 siblings, 1 reply; 42+ messages in thread
From: Joseph Myers @ 2021-12-31 17:34 UTC (permalink / raw)
  To: caiyinyu; +Cc: libc-alpha, xuchenghua

On Fri, 31 Dec 2021, caiyinyu wrote:

> b.
> FAIL: elf/ifuncmain1
> FAIL: elf/ifuncmain1pic
> FAIL: elf/ifuncmain1pie
> FAIL: elf/ifuncmain1staticpic
> FAIL: elf/ifuncmain1staticpie
> FAIL: elf/ifuncmain1vis
> FAIL: elf/ifuncmain1vispic
> FAIL: elf/ifuncmain1vispie
> FAIL: elf/ifuncmain3
> FAIL: elf/ifuncmain4
> FAIL: elf/ifuncmain6pie
> FAIL: elf/ifuncmain7
> FAIL: elf/ifuncmain7pic
> FAIL: elf/ifuncmain7pie
> FAIL: elf/tst-ifunc-fault-bindnow
> FAIL: elf/tst-ifunc-fault-lazy
> 
> ifunc functions are not support yet

If IFUNC isn't supported, the configure test 
(libc_cv_ld_gnu_indirect_function) should fail, have-ifunc should be no 
and elf/Makefile should disable the tests.

Those failures suggest you have partial support in the toolchain - enough 
binutils support for the tests to be enabled - but are either missing 
glibc support, or some of the toolchain support is broken.  In that case, 
you should fix/add the broken/missing support so that the tests pass.  (Or 
if it's wrong that the libc_cv_ld_gnu_indirect_function test passes at 
all, maybe that's a binutils bug and you need to fix the binutils port so 
that that configure test fails.)

> c.
> FAIL: math/test-double-acos
> FAIL: math/test-double-asin
> FAIL: math/test-float32x-acos
> FAIL: math/test-float32x-asin
> FAIL: math/test-float64-acos
> FAIL: math/test-float64-asin
> 
> These fails are caused by gcc optimizations. if we use -O0 options, these fails
> will pass.

So that issue needs fixing in GCC upstream.

> 10. Note the need for a manual/math.texi update in the list of
> configurations supporting _Float128.
> 
> not support yet

It's supported by the port (with the same ABI as long double, via the 
ieee754/ldbl-128 inclusion in sysdeps/loongarch/Implies) - the functions 
are in the ABI test baselines.  So you need to update math.texi to reflect 
that.

> 13. arch_minimum_kernel should be set to 10.0.0 until the actual upstream
> kernel version that gets the port is known, and then to the actual
> upstream version (so 5.14.0 or later).  Accordingly, kernel-features.h
> should not have any "before 4.20" conditionals in it (so you don't need an
> architecture-specific kernel-features.h at all).
> 
> corrected

You have arch_minimum_kernel=5.15.0, but the support isn't in 5.15.0, and 
indeed isn't in Linus's git tree for 5.16 either.

Once it's in Linus's git tree, you can set arch_minimum_kernel to the 
actual version that will have the port.  Until then, you should use 10.0.0 
as a placeholder.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v2 09/14] LoongArch: Linux ABI
  2021-12-31  6:44 ` [PATCH v2 09/14] LoongArch: Linux ABI caiyinyu
@ 2021-12-31 17:37   ` Joseph Myers
  2022-04-15  1:27     ` caiyinyu
  2022-01-04 14:24   ` Adhemerval Zanella
  1 sibling, 1 reply; 42+ messages in thread
From: Joseph Myers @ 2021-12-31 17:37 UTC (permalink / raw)
  To: caiyinyu; +Cc: libc-alpha, xuchenghua

On Fri, 31 Dec 2021, caiyinyu wrote:

> diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/mman.h b/sysdeps/unix/sysv/linux/loongarch/bits/mman.h

The constants here look like those in bits/mman-map-flags-generic.h.  
I.e., you shouldn't need this header at all; the default 
architecture-independent version should suffice.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v2 11/14] LoongArch: Add ABI Lists
  2021-12-31  6:44 ` [PATCH v2 11/14] LoongArch: Add ABI Lists caiyinyu
@ 2021-12-31 17:43   ` Joseph Myers
  2022-04-15  1:27     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Joseph Myers @ 2021-12-31 17:43 UTC (permalink / raw)
  To: caiyinyu; +Cc: libc-alpha, xuchenghua

On Fri, 31 Dec 2021, caiyinyu wrote:

> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist

You shouldn't have this library at all, since Adhemerval's recent commit, 
so shouldn't have an ABI test baseline for it.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist

Likewise, there should be no libdl for a new port.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist

Likewise, since --enable-obsolete-nsl was removed.  This shows up an issue 
with the OpenRISC port submission, which shouldn't have libnsl.abilist 
either.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist

Likewise, there should be no libutil for a new port.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v2 13/14] LoongArch: Hard Float Support
  2021-12-31  6:44 ` [PATCH v2 13/14] LoongArch: Hard Float Support caiyinyu
@ 2021-12-31 17:47   ` Joseph Myers
  2022-04-15  1:27     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Joseph Myers @ 2021-12-31 17:47 UTC (permalink / raw)
  To: caiyinyu; +Cc: libc-alpha, xuchenghua

On Fri, 31 Dec 2021, caiyinyu wrote:

>  sysdeps/loongarch/fpu/e_sqrt.c             |   26 +
>  sysdeps/loongarch/fpu/e_sqrtf.c            |   26 +

Set up a math-use-builtins-sqrt.h header for LoongArch and ensure that 
your GCC port can expand __builtin_sqrt and __builtin_sqrtf inline, and 
then you shouldn't need these files because the generic files with their 
USE_SQRTF_BUILTIN and USE_SQRT_BUILTIN conditionals will suffice instead.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v2 00/14] GLIBC LoongArch PATCHES
  2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
                   ` (14 preceding siblings ...)
  2021-12-31 17:34 ` [PATCH v2 00/14] GLIBC LoongArch PATCHES Joseph Myers
@ 2022-01-04 13:27 ` Adhemerval Zanella
  2022-04-15  1:28   ` caiyinyu
  15 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 13:27 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:
> FAIL: elf/ifuncmain1
> FAIL: elf/ifuncmain1pic
> FAIL: elf/ifuncmain1pie
> FAIL: elf/ifuncmain1staticpic
> FAIL: elf/ifuncmain1staticpie
> FAIL: elf/ifuncmain1vis
> FAIL: elf/ifuncmain1vispic
> FAIL: elf/ifuncmain1vispie
> FAIL: elf/ifuncmain3
> FAIL: elf/ifuncmain4
> FAIL: elf/ifuncmain6pie
> FAIL: elf/ifuncmain7
> FAIL: elf/ifuncmain7pic
> FAIL: elf/ifuncmain7pie
> FAIL: elf/tst-ifunc-fault-bindnow
> FAIL: elf/tst-ifunc-fault-lazy
> 
> ifunc functions are not support yet

If the target does not support ifunc, why libc_cv_ld_gnu_indirect_function is being
set then? I think you will need to disable the usage of %gnu_indirect_function
on static linker.

> 
> c.
> FAIL: math/test-double-acos
> FAIL: math/test-double-asin
> FAIL: math/test-float32x-acos
> FAIL: math/test-float32x-asin
> FAIL: math/test-float64-acos
> FAIL: math/test-float64-asin
> 
> These fails are caused by gcc optimizations. if we use -O0 options, these fails
> will pass.
> 
> sysdeps/ieee754/dbl-64/e_asin.c: 343
> ===================================================================
> 337	  if (k>0x7ff00000 || (k == 0x7ff00000 && u.i[LOW_HALF] != 0)) return x + x;
>    0x00007ffff7f4daac <+1388>:	lu12i.w     	$t0, 524032(0x7ff00)
>    0x00007ffff7f4dab0 <+1392>:	blt         	$t0, $t2, 20(0x14)	# 0x7ffff7f4dac4 <__ieee754_acos+1412>
>    0x00007ffff7f4dab4 <+1396>:	bne         	$t2, $t0, 36(0x24)	# 0x7ffff7f4dad8 <__ieee754_acos+1432>
>    0x00007ffff7f4dab8 <+1400>:	ld.d        	$t0, $sp, 8(0x8)
>    0x00007ffff7f4dabc <+1404>:	slli.w      	$t0, $t0, 0x0
>    0x00007ffff7f4dac0 <+1408>:	beqz        	$t0, 24(0x18)	# 0x7ffff7f4dad8 <__ieee754_acos+1432>
>    0x00007ffff7f4dac4 <+1412>:	fld.d       	$fa0, $sp, 8(0x8)
>    0x00007ffff7f4dac8 <+1416>:	fadd.d      	$fa0, $fa0, $fa0
>    0x00007ffff7f4dacc <+1420>:	b           	-788(0xffffcec)	# 0x7ffff7f4d7b8 <__ieee754_acos+632>
> 
> 338	  else {
> 339	    u.i[HIGH_HALF]=0x7ff00000;
> 340	    v.i[HIGH_HALF]=0x7ff00000;
> 341	    u.i[LOW_HALF]=0;
> 342	    v.i[LOW_HALF]=0;
> 343	    return u.x/v.x;			/////////  optimized out
> 
>    0x00007ffff7f4dad8 <+1432>:	pcaddu12i   	$t0, 63(0x3f)
>    0x00007ffff7f4dadc <+1436>:	addi.d      	$t0, $t0, -1248(0xb20)
>    0x00007ffff7f4dae0 <+1440>:	fld.d       	$fa0, $t0, 0
>    0x00007ffff7f4dae4 <+1444>:	b           	-812(0xffffcd4)	# 0x7ffff7f4d7b8 <__ieee754_acos+632>
> 
> 344	  }
> 345	}
>    0x00007ffff7f4d7b8 <+632>:	addi.d      	$sp, $sp, 16(0x10)
>    0x00007ffff7f4d7bc <+636>:	jirl        	$zero, $ra, 0
>    0x00007ffff7f4d7cc <+652>:	addi.d      	$sp, $sp, 16(0x10)
>    0x00007ffff7f4d7d0 <+656>:	jirl        	$zero, $ra, 0
>    0x00007ffff7f4d8bc <+892>:	addi.d      	$sp, $sp, 16(0x10)
>    0x00007ffff7f4d8c0 <+896>:	jirl        	$zero, $ra, 0
> ===================================================================

Is this being tracked by a GCC bug report? We need to understand if we 
require to use math_force_eval to avoid such issue on other ports as
well.

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

* Re: [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port.
  2021-12-31  6:44 ` [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
@ 2022-01-04 13:30   ` Adhemerval Zanella
  2022-04-15  1:28     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 13:30 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:
> ---
>  NEWS   | 2 ++
>  README | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/NEWS b/NEWS
> index 4762bfcc4e..c78143cc67 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,6 +9,8 @@ Version 2.35
>  
>  Major new features:
>  
> +* Add LoongArch Port.  Loongson Ltd.
> +
>  * Unicode 14.0.0 Support: Character encoding, character type info, and
>    transliteration tables are all updated to Unicode 14.0.0, using
>    generator scripts contributed by Mike FABIAN (Red Hat).

Please follow other ports description, such the recent one for or1k [1],
by adding the minimum binutils, gcc, and Linux version required along
with the triple name and any other relevant information (32/64-bit, 
endianess, time_t, LFS support, etc).

Also put the addition at the end of the list.

> diff --git a/README b/README
> index d0f0edb393..f0812d7a80 100644
> --- a/README
> +++ b/README
> @@ -31,6 +31,7 @@ The GNU C Library supports these configurations for using Linux kernels:
>  	i[4567]86-*-linux-gnu
>  	x86_64-*-linux-gnu	Can build either x86_64 or x32
>  	ia64-*-linux-gnu
> +	loongarch64-*-linux-gnu
>  	m68k-*-linux-gnu
>  	microblaze*-*-linux-gnu
>  	mips-*-linux-gnu

[1] https://patchwork.sourceware.org/project/glibc/patch/20220104031414.2416928-14-shorne@gmail.com/

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

* Re: [PATCH v2 04/14] LoongArch: ABI Implementation
  2021-12-31  6:44 ` [PATCH v2 04/14] LoongArch: ABI Implementation caiyinyu
@ 2022-01-04 13:46   ` Adhemerval Zanella
  2022-04-15  1:28     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 13:46 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:

> diff --git a/sysdeps/loongarch/bits/wordsize.h b/sysdeps/loongarch/bits/wordsize.h
> new file mode 100644
> index 0000000000..0a83454b08
> --- /dev/null
> +++ b/sysdeps/loongarch/bits/wordsize.h
> @@ -0,0 +1,25 @@
> +/* Determine the wordsize from the preprocessor defines.
> +   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/>.  */
> +
> +#ifdef __LP64__
> +#define __WORDSIZE 64
> +#else
> +#define __WORDSIZE 32
> +#endif
> +
> +#define __WORDSIZE_TIME64_COMPAT32 0

You stated you only supported 64-bit ABI and it should imply in wordsize-64,
so why do you need to provide an arch-specific wordsize.h?

> +END (_dl_runtime_resolve)
> diff --git a/sysdeps/loongarch/gccframe.h b/sysdeps/loongarch/gccframe.h
> new file mode 100644
> index 0000000000..19996f3ce3
> --- /dev/null
> +++ b/sysdeps/loongarch/gccframe.h
> @@ -0,0 +1,21 @@
> +/* Definition of object in frame unwind info.
> +   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 FIRST_PSEUDO_REGISTER 74
> +
> +#include <sysdeps/generic/gccframe.h>

Why do you need to add it? It is used solely on unwind code used only for
compat code on old ABIs.

> diff --git a/sysdeps/loongarch/memusage.h b/sysdeps/loongarch/memusage.h
> new file mode 100644
> index 0000000000..bdf24bb276
> --- /dev/null
> +++ b/sysdeps/loongarch/memusage.h
> @@ -0,0 +1,25 @@
> +/* Machine-specific definitions for memory usage profiling.
> +   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("$sp"); \
> +    stack_ptr; \
> +  })
> +
> +#include <sysdeps/generic/memusage.h>

There is no need to add this header.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/ldconfig.h b/sysdeps/unix/sysv/linux/loongarch/ldconfig.h
> new file mode 100644
> index 0000000000..126f0860e9
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/ldconfig.h
> @@ -0,0 +1,30 @@
> +/* ldconfig default paths and libraries.
> +   Copyright (C) 2001-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
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <sysdeps/generic/ldconfig.h>
> +
> +#ifdef __loongarch_lp64
> +#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> +  { "/lib64/ld-linux-loongarch-lp64d.so.1", FLAG_ELF_LIBC6 },
> +#else
> +#error cannot determine ABI
> +#endif
> +

Do you plan to support multilib with different ABIs in the same system? Otherwise
I think adding another SYSDEP_KNOWN_INTERPRETER_NAMES does not add much.

> +#define SYSDEP_KNOWN_LIBRARY_NAMES	\
> +  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> +  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/loongarch/localplt.data b/sysdeps/unix/sysv/linux/loongarch/localplt.data
> new file mode 100644
> index 0000000000..817ab2659a
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/localplt.data
> @@ -0,0 +1,12 @@
> +# 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
> +# 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

I think this file should be moved to the Linux ABI patch.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
> new file mode 100644
> index 0000000000..a02865b4a5
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
> @@ -0,0 +1,44 @@
> +/* jump buffer constants for LoongArch.
> +   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 304
> +#define JMP_BUF_ALIGN 8
> +#define SIGJMP_BUF_SIZE 304
> +#define SIGJMP_BUF_ALIGN 8
> +#define MASK_WAS_SAVED_OFFSET 168
> +#define SAVED_MASK_OFFSET 176

Same as before.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h
> new file mode 100644
> index 0000000000..835df05ce5
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h
> @@ -0,0 +1,41 @@
> +/* Copyright (C) 2020-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 240
> +# define JMP_BUF_ALIGN 8
> +# define SIGJMP_BUF_SIZE 240
> +# define SIGJMP_BUF_ALIGN 8
> +# define MASK_WAS_SAVED_OFFSET 104
> +# define SAVED_MASK_OFFSET 112

Same as before.

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

* Re: [PATCH v2 05/14] LoongArch: Thread-Local Storage Support
  2021-12-31  6:44 ` [PATCH v2 05/14] LoongArch: Thread-Local Storage Support caiyinyu
@ 2022-01-04 14:01   ` Adhemerval Zanella
  2022-04-15  1:28     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 14:01 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:
> diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h
> new file mode 100644
> index 0000000000..3b17e0b7f5
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/tls.h
> @@ -0,0 +1,138 @@
> +/* Definition for thread-local data handling.
> +   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 _LOONGARCH_TLS_H
> +#define _LOONGARCH_TLS_H 1
> +
> +#include <dl-sysdep.h>
> +
> +#ifndef __ASSEMBLER__
> +#include <stdbool.h>
> +#include <stddef.h>
> +#include <stdint.h>
> +#include <dl-dtv.h>
> +
> +register void *__thread_self asm("$tp"); /* FIXME */

What exactly needs to be fixed here?

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

* Re: [PATCH v2 06/14] LoongArch: Generic <math.h> and soft-fp Routines
  2021-12-31  6:44 ` [PATCH v2 06/14] LoongArch: Generic <math.h> and soft-fp Routines caiyinyu
@ 2022-01-04 14:05   ` Adhemerval Zanella
  2022-01-04 20:31     ` Joseph Myers
  0 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 14:05 UTC (permalink / raw)
  To: libc-alpha



On 31/12/2021 03:44, caiyinyu wrote:
> diff --git a/sysdeps/loongarch/e_sqrtl.c b/sysdeps/loongarch/e_sqrtl.c
> new file mode 100644
> index 0000000000..cbc5802f74
> --- /dev/null
> +++ b/sysdeps/loongarch/e_sqrtl.c
> @@ -0,0 +1,38 @@
> +/* long double square root in software floating-point emulation.
> +   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 <stdlib.h>
> +#include <soft-fp/soft-fp.h>
> +#include <soft-fp/quad.h>
> +
> +long double
> +__ieee754_sqrtl (const long double a)
> +{
> +  FP_DECL_EX;
> +  FP_DECL_Q (A);
> +  FP_DECL_Q (C);
> +  long double c;
> +
> +  FP_INIT_ROUNDMODE;
> +  FP_UNPACK_Q (A, a);
> +  FP_SQRT_Q (C, A);
> +  FP_PACK_Q (c, C);
> +  FP_HANDLE_EXCEPTIONS;
> +  return c;
> +}
> +strong_alias (__ieee754_sqrtl, __sqrtl_finite)

Use libm_alias_finite, the finite alias are deprecated and only provided 
as compat symbols.

This is being replicated already on aarch64 and mips64, maybe we could
add on a generic folder and use it instead.

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

* Re: [PATCH v2 07/14] LoongArch: Atomic and Locking Routines
  2021-12-31  6:44 ` [PATCH v2 07/14] LoongArch: Atomic and Locking Routines caiyinyu
@ 2022-01-04 14:09   ` Adhemerval Zanella
  2022-04-15  1:28     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 14:09 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:
> This patch implements various atomic and locking routines on LoongArch.
> ---
>  .../loongarch/nptl/bits/pthreadtypes-arch.h   |  41 ++++
>  sysdeps/loongarch/nptl/bits/semaphore.h       |  32 +++
>  sysdeps/loongarch/nptl/libc-lowlevellock.c    |   8 +
>  .../sysv/linux/loongarch/atomic-machine.h     | 196 ++++++++++++++++++
>  4 files changed, 277 insertions(+)
>  create mode 100644 sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
>  create mode 100644 sysdeps/loongarch/nptl/bits/semaphore.h
>  create mode 100644 sysdeps/loongarch/nptl/libc-lowlevellock.c
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
> 
> diff --git a/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h b/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
> new file mode 100644
> index 0000000000..e57f122a98
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
> @@ -0,0 +1,41 @@
> +/* Machine-specific pthread type layouts.
> +   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_ARCH_H
> +#define _BITS_PTHREADTYPES_ARCH_H 1
> +
> +#include <bits/endian.h>
> +
> +#ifdef __loongarch_lp64
> +#define __SIZEOF_PTHREAD_ATTR_T 56
> +#define __SIZEOF_PTHREAD_MUTEX_T 40
> +#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
> +#define __SIZEOF_PTHREAD_COND_T 48
> +#define __SIZEOF_PTHREAD_CONDATTR_T 4
> +#define __SIZEOF_PTHREAD_RWLOCK_T 56
> +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
> +#define __SIZEOF_PTHREAD_BARRIER_T 32
> +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
> +#else
> +#error "32bit LoongArch systems are not supported"
> +#endif
> +
> +#define __LOCK_ALIGNMENT
> +#define __ONCE_ALIGNMENT
> +
> +#endif /* bits/pthreadtypes.h */

Why can't you use the generic definition?   Also, I think all the __loongarch_lp64
tests to avoid 32-bit build should be moved to a configure test instead.

> diff --git a/sysdeps/loongarch/nptl/bits/semaphore.h b/sysdeps/loongarch/nptl/bits/semaphore.h
> new file mode 100644
> index 0000000000..510f3b0e9a
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/bits/semaphore.h
> @@ -0,0 +1,32 @@
> +/* POSIX semaphore type layout
> +   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 _SEMAPHORE_H
> +#error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
> +#endif
> +
> +#define __SIZEOF_SEM_T (4 * __SIZEOF_POINTER__)
> +
> +/* Value returned if `sem_open' failed.  */
> +#define SEM_FAILED ((sem_t *) 0)
> +
> +typedef union
> +{
> +  char __size[__SIZEOF_SEM_T];
> +  long int __align;
> +} sem_t;

Why can't you use the generic linux header interface?

> diff --git a/sysdeps/loongarch/nptl/libc-lowlevellock.c b/sysdeps/loongarch/nptl/libc-lowlevellock.c
> new file mode 100644
> index 0000000000..f4b8b5c193
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/libc-lowlevellock.c
> @@ -0,0 +1,8 @@
> +/* This kludge works around a libpthread static linking problem:
> +   https://sourceware.org/bugzilla/show_bug.cgi?id=15648.  */
> +
> +#ifndef SHARED
> +#define __lll_lock_wait_private weak_function __lll_lock_wait_private
> +#endif
> +
> +#include <lowlevellock.c>

Why this file is required?

> diff --git a/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h b/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
> new file mode 100644
> index 0000000000..dbae608ee5
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
> @@ -0,0 +1,196 @@
> +/* Atomic operations.
> +   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_LOONGARCH_BITS_ATOMIC_H
> +#define _LINUX_LOONGARCH_BITS_ATOMIC_H 1
> +
> +#include <stdint.h>
> +
> +typedef int32_t atomic32_t;
> +typedef uint32_t uatomic32_t;
> +
> +typedef int64_t atomic64_t;
> +typedef uint64_t uatomic64_t;
> +
> +typedef intptr_t atomicptr_t;
> +typedef uintptr_t uatomicptr_t;
> +typedef intmax_t atomic_max_t;
> +typedef uintmax_t uatomic_max_t;

These definition are not required any longer.

> +
> +#define atomic_full_barrier() __sync_synchronize ()
> +
> +#ifdef __LP64__
> +#define __HAVE_64B_ATOMICS 1
> +#endif

I think there is no need to guard it for __LP64__.

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

* Re: [PATCH v2 08/14] LoongArch: Linux Syscall Interface
  2021-12-31  6:44 ` [PATCH v2 08/14] LoongArch: Linux Syscall Interface caiyinyu
@ 2022-01-04 14:20   ` Adhemerval Zanella
  2022-04-15  1:28     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 14:20 UTC (permalink / raw)
  To: libc-alpha, caiyinyu; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:
> Contains the Linux system call interface, as well as the definitions of
> a handful of system calls.
> ---
>  sysdeps/loongarch/abort-instr.h               |   2 +
>  sysdeps/loongarch/hp-timing.h                 |  42 +++
>  sysdeps/loongarch/nptl/nptl-sysdep.S          |   2 +
>  .../unix/sysv/linux/loongarch/arch-syscall.h  | 302 ++++++++++++++++
>  .../unix/sysv/linux/loongarch/bits/signum.h   |  58 ++++
>  sysdeps/unix/sysv/linux/loongarch/clone.S     | 100 ++++++
>  sysdeps/unix/sysv/linux/loongarch/clone3.S    |  87 +++++
>  sysdeps/unix/sysv/linux/loongarch/ipc_priv.h  |  22 ++
>  sysdeps/unix/sysv/linux/loongarch/syscall.c   |  35 ++
>  sysdeps/unix/sysv/linux/loongarch/sysdep.S    |  53 +++
>  sysdeps/unix/sysv/linux/loongarch/sysdep.h    | 321 ++++++++++++++++++
>  sysdeps/unix/sysv/linux/loongarch/vfork.S     |  50 +++
>  12 files changed, 1074 insertions(+)
>  create mode 100644 sysdeps/loongarch/abort-instr.h
>  create mode 100644 sysdeps/loongarch/hp-timing.h
>  create mode 100644 sysdeps/loongarch/nptl/nptl-sysdep.S
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/signum.h
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone.S
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone3.S
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall.c
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.S
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.h
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/vfork.S
> 
> diff --git a/sysdeps/loongarch/abort-instr.h b/sysdeps/loongarch/abort-instr.h
> new file mode 100644
> index 0000000000..92e22edfea
> --- /dev/null
> +++ b/sysdeps/loongarch/abort-instr.h
> @@ -0,0 +1,2 @@
> +/* An instruction which should crash any program is a breakpoint.  */
> +#define ABORT_INSTRUCTION asm("break 0")

Missing space after asm.

> diff --git a/sysdeps/loongarch/hp-timing.h b/sysdeps/loongarch/hp-timing.h
> new file mode 100644
> index 0000000000..7b36a539f1
> --- /dev/null
> +++ b/sysdeps/loongarch/hp-timing.h
> @@ -0,0 +1,42 @@
> +/* High precision, low overhead timing functions.
> +   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 _HP_TIMING_H
> +#define _HP_TIMING_H 1
> +
> +/* We always assume having the timestamp register.  */
> +#define HP_TIMING_AVAIL (1)
> +#define HP_SMALL_TIMING_AVAIL (1)
> +
> +/* We indeed have inlined functions.  */
> +#define HP_TIMING_INLINE (1)
> +
> +/* We use 64bit values for the times.  */
> +typedef unsigned long long int hp_timing_t;
> +
> +/* Read the stable counter.  */
> +#define HP_TIMING_NOW(Var) \
> +  ({ \
> +    unsigned long long int _count; \
> +    asm volatile("rdtime.d\t%0,$r0" : "=r"(_count)); \

Missing space after volatile.

> +    (Var) = _count; \
> +  })
> +
> +#include <hp-timing-common.h>
> +
> +#endif /* hp-timing.h */
> diff --git a/sysdeps/loongarch/nptl/nptl-sysdep.S b/sysdeps/loongarch/nptl/nptl-sysdep.S
> new file mode 100644
> index 0000000000..3f5c2a364a
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/nptl-sysdep.S
> @@ -0,0 +1,2 @@
> +/* Pull in __syscall_error.  */
> +#include <sysdep.S>

Why do you need this file?  Newer Linux ports should have libpthread function
on libc.so.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/signum.h b/sysdeps/unix/sysv/linux/loongarch/bits/signum.h
> new file mode 100644
> index 0000000000..111759778b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/bits/signum.h
> @@ -0,0 +1,58 @@
> +/* Signal number definitions.  Linux 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_SIGNUM_H
> +#define _BITS_SIGNUM_H 1
> +
> +#ifndef _SIGNAL_H
> +#error "Never include <bits/signum.h> directly; use <signal.h> instead."
> +#endif
> +
> +#include <bits/signum-generic.h>
> +
> +/* Adjustments and additions to the signal number constants for
> +   most Linux systems.  */
> +
> +#define SIGSTKFLT 16 /* Stack fault (obsolete).  */
> +#define SIGPWR 30    /* Power failure imminent.  */
> +
> +#undef SIGBUS
> +#define SIGBUS 7
> +#undef SIGUSR1
> +#define SIGUSR1 10
> +#undef SIGUSR2
> +#define SIGUSR2 12
> +#undef SIGCHLD
> +#define SIGCHLD 17
> +#undef SIGCONT
> +#define SIGCONT 18
> +#undef SIGSTOP
> +#define SIGSTOP 19
> +#undef SIGTSTP
> +#define SIGTSTP 20
> +#undef SIGURG
> +#define SIGURG 23
> +#undef SIGPOLL
> +#define SIGPOLL 29
> +#undef SIGSYS
> +#define SIGSYS 31
> +
> +#undef __SIGRTMAX
> +#define __SIGRTMAX 64
> +
> +#endif /* <signal.h> included.  */

This file has been refactore by e4e11b1dba261cb650e6 (2.32), now ports that
deviate from Linux generic ABI should provide a signum-arch.h header. And
this seems not to be the case here.


> diff --git a/sysdeps/unix/sysv/linux/loongarch/clone.S b/sysdeps/unix/sysv/linux/loongarch/clone.S
> new file mode 100644
> index 0000000000..d2bed24440
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/clone.S
> @@ -0,0 +1,100 @@
> +/* The clone syscall wrapper.
> +   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/>.  */
> +
> +/* clone() is even more special than fork() as it mucks with stacks
> +   and invokes a function in the right context after its all over.  */
> +
> +#include <sys/asm.h>
> +#include <sysdep.h>
> +#define _ERRNO_H  1
> +#include <bits/errno.h>
> +#include <tls.h>
> +#include "tcb-offsets.h"
> +
> +/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
> +   void *parent_tidptr, void *tls, void *child_tidptr) */
> +
> +ENTRY (__clone)
> +
> +	/* Align stack to 16 or 8 bytes per the ABI.  */
> +#ifdef __loongarch_lp64
> +	bstrins.d	a1, zero, 3, 0
> +#else
> +#error "32bit LoongArch systems are not supported"
> +#endif

As before, I think we should move the LP64 ABI tests to configure time
instead of adding multiple checks on arch-specific code.

> +
> +	/* Sanity check arguments.  */
> +	beqz		a0, L (invalid) /* No NULL function pointers.  */
> +	beqz		a1, L (invalid) /* No NULL stack pointers.  */
> +
> +	addi.d 		a1, a1, -16 /* Reserve argument save space.  */
> +	st.d		a0, a1, 0   /* Save function pointer.  */
> +	st.d		a3, a1, SZREG   /* Save argument pointer.  */
> +
> +	/* The syscall expects the args to be in different slots.  */
> +	or		a0, a2, zero
> +	or		a2, a4, zero
> +	or		a3, a6, zero
> +	or		a4, a5, zero
> +
> +	/* Do the system call.  */
> +	li.d		a7,__NR_clone
> +	syscall		0
> +
> +	blt		a0, zero ,L (error)
> +	beqz		a0,L (thread_start)
> +
> +	/* Successful return from the parent.  */
> +	ret
> +
> +L (invalid):
> +	li.d		a0, -EINVAL
> +
> +	/* Something bad happened -- no child created.  */
> +L (error):
> +	b		__syscall_error
> +
> +END (__clone)
> +
> +/* Load up the arguments to the function.  Put this block of code in
> +   its own function so that we can terminate the stack trace with our
> +   debug info.  */
> +ENTRY (__thread_start)
> +L (thread_start):
> +
> +/* Terminate call stack by noting ra is undefined.  Use a dummy
> +   .cfi_label to force starting the FDE.  */
> +	.cfi_label .Ldummy
> +	cfi_undefined (1)
> +
> +	/* Restore the arg for user's function.  */
> +	ld.d		a1, sp, 0   /* Function pointer.  */
> +	ld.d		a0, sp, SZREG   /* Argument pointer.  */
> +
> +	/* Call the user's function.  */
> +	jirl		ra, a1, 0
> +
> +	/* Call exit with the function's return value.  */
> +	li.d		a7, __NR_exit
> +	syscall		0
> +
> +	END (__thread_start)
> +
> +libc_hidden_def (__clone)
> +weak_alias (__clone, clone)
> diff --git a/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h b/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
> new file mode 100644
> index 0000000000..dde8fa6989
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
> @@ -0,0 +1,22 @@
> +/* Old SysV permission definition for Linux.
> +   Copyright (C) 2021 Loongson Technology, 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 <sys/ipc.h> /* For __key_t  */
> +
> +#define __IPC_64 0x0
> +#include <sysdeps/unix/sysv/linux/ipc_priv.h>

Why can't you use the generic sysdeps/unix/sysv/linux/ipc_priv.h here?
I woudl asusme that LoongArch will have __ASSUME_SYSVIPC_DEFAULT_IPC_64
defined and thus __IPC_64 will be 0x0.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/syscall.c b/sysdeps/unix/sysv/linux/loongarch/syscall.c
> new file mode 100644
> index 0000000000..d0067bc2d0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/syscall.c
> @@ -0,0 +1,35 @@
> +/* system call interface.
> +   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>
> +
> +long int
> +syscall (long int syscall_number, long int arg1, long int arg2, long int arg3,
> +	 long int arg4, long int arg5, long int arg6, long int arg7)
> +{
> +  long int ret;
> +
> +  ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4, arg5,
> +			      arg6, arg7);
> +
> +  if (INTERNAL_SYSCALL_ERROR_P (ret))
> +    return __syscall_error (ret);
> +
> +  return ret;
> +}

Do you really need 7 arguments for syscall? Otherwise you should use the generic
interface.

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

* Re: [PATCH v2 09/14] LoongArch: Linux ABI
  2021-12-31  6:44 ` [PATCH v2 09/14] LoongArch: Linux ABI caiyinyu
  2021-12-31 17:37   ` Joseph Myers
@ 2022-01-04 14:24   ` Adhemerval Zanella
  2022-04-15  1:28     ` caiyinyu
  1 sibling, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 14:24 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:

> diff --git a/sysdeps/loongarch/nptl/bits/struct_rwlock.h b/sysdeps/loongarch/nptl/bits/struct_rwlock.h
> new file mode 100644
> index 0000000000..12b6a469bd
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/bits/struct_rwlock.h
> @@ -0,0 +1,44 @@
> +/* LoongArch internal rwlock struct 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/>.  */
> +
> +#ifndef _RWLOCK_INTERNAL_H
> +#define _RWLOCK_INTERNAL_H
> +
> +/* There is a lot of padding in this structure.  While it's not strictly
> +   necessary on LoongArch, we're going to leave it in to be on the safe side in
> +   case it's needed in the future.  Most other architectures have the padding,
> +   so this gives us the same extensibility as everyone else has.  */
> +struct __pthread_rwlock_arch_t
> +{
> +  unsigned int __readers;
> +  unsigned int __writers;
> +  unsigned int __wrphase_futex;
> +  unsigned int __writers_futex;
> +  unsigned int __pad3;
> +  unsigned int __pad4;
> +  int __cur_writer;
> +  int __shared;
> +  unsigned long int __pad1;
> +  unsigned long int __pad2;
> +  unsigned int __flags;
> +};
> +
> +#define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
> +  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, __flags
> +
> +#endif

Why can't you use the generic Linux sysdeps/nptl/bits/struct_rwlock.h ?

> diff --git a/sysdeps/loongarch/nptl/pthread-offsets.h b/sysdeps/loongarch/nptl/pthread-offsets.h
> new file mode 100644
> index 0000000000..415c3c113f
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/pthread-offsets.h
> @@ -0,0 +1,15 @@
> +#if __WORDSIZE == 64
> +#define __PTHREAD_MUTEX_KIND_OFFSET 16
> +#else
> +#define __PTHREAD_MUTEX_KIND_OFFSET 12
> +#endif
> +
> +#if __WORDSIZE == 64
> +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
> +#else
> +#if __BYTE_ORDER == __BIG_ENDIAN
> +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
> +#else
> +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
> +#endif
> +#endif

Ditto.

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

* Re: [PATCH v2 10/14] LoongArch: Linux Startup and Dynamic Loading Code
  2021-12-31  6:44 ` [PATCH v2 10/14] LoongArch: Linux Startup and Dynamic Loading Code caiyinyu
@ 2022-01-04 14:27   ` Adhemerval Zanella
  2022-04-15  1:28     ` caiyinyu
  0 siblings, 1 reply; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 14:27 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:
> This contains the Linux-specific code for loading programs on LoongArch.
> ---
>  sysdeps/unix/sysv/linux/loongarch/dl-static.c | 80 +++++++++++++++++++
>  sysdeps/unix/sysv/linux/loongarch/ldsodefs.h  | 33 ++++++++
>  2 files changed, 113 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/dl-static.c
>  create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
> 
> diff --git a/sysdeps/unix/sysv/linux/loongarch/dl-static.c b/sysdeps/unix/sysv/linux/loongarch/dl-static.c
> new file mode 100644
> index 0000000000..b9a7b2a61f
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/dl-static.c
> @@ -0,0 +1,80 @@
> +/* dl_static_init for loongarch.
> +   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 <ldsodefs.h>
> +
> +#ifdef SHARED
> +
> +void
> +_dl_var_init (void *array[])
> +{
> +  /* It has to match "variables" below.  */
> +  enum
> +  {
> +    DL_PAGESIZE = 0
> +  };
> +
> +  GLRO (dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
> +}
> +
> +#else
> +
> +static void *variables[] = {&GLRO (dl_pagesize)};
> +
> +static void _dl_unprotect_relro (struct link_map *l)
> +{
> +  ElfW (Addr) start = ((l->l_addr + l->l_relro_addr)
> +			& ~(GLRO (dl_pagesize) - 1));
> +  ElfW (Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
> +		      & ~(GLRO (dl_pagesize) - 1));
> +
> +  if (start != end)
> +    __mprotect ((void *) start, end - start, PROT_READ | PROT_WRITE);
> +}
> +
> +void dl_static_init (struct link_map *l)
> +{
> +  struct link_map *rtld_map = l;
> +  struct r_scope_elem **scope;
> +  const ElfW (Sym) *ref = NULL;
> +  lookup_t loadbase;
> +  void (*f) (void *[]);
> +  size_t i;
> +
> +  loadbase = _dl_lookup_symbol_x ("_dl_var_init", l, &ref, l->l_local_scope,
> +				  NULL, 0, 1, NULL);
> +
> +  for (scope = l->l_local_scope; *scope != NULL; scope++)
> +    for (i = 0; i < (*scope)->r_nlist; i++)
> +      if ((*scope)->r_list[i] == loadbase)
> +	{
> +	  rtld_map = (*scope)->r_list[i];
> +	  break;
> +	}
> +
> +  if (ref != NULL)
> +    {
> +      f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
> +      _dl_unprotect_relro (rtld_map);
> +      f (variables);
> +      _dl_protect_relro (rtld_map);
> +    }
> +}
> +
> +#endif

This file should not be required, Florian has refactored it to avoid this
boilerplate code (check bdc90abc48f0528588600df37eebdc04ce01b2f0 and
related commits).


> diff --git a/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h b/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
> new file mode 100644
> index 0000000000..680baf2edc
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
> @@ -0,0 +1,33 @@
> +/* 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 _LDSODEFS_H
> +
> +/* Get the real definitions.  */
> +#include_next <ldsodefs.h>
> +
> +/* Now define our stuff.  */
> +
> +/* We need special support to initialize DSO loaded for statically linked
> +   binaries.  */
> +extern void _dl_static_init (struct link_map *map);
> +#undef DL_STATIC_INIT
> +#define DL_STATIC_INIT(map) _dl_static_init (map)
> +
> +#endif /* ldsodefs.h */

Same as before.

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

* Re: [PATCH v2 12/14] LoongArch: Build Infastructure
  2021-12-31  6:44 ` [PATCH v2 12/14] LoongArch: Build Infastructure caiyinyu
@ 2022-01-04 14:33   ` Adhemerval Zanella
  0 siblings, 0 replies; 42+ messages in thread
From: Adhemerval Zanella @ 2022-01-04 14:33 UTC (permalink / raw)
  To: caiyinyu, libc-alpha; +Cc: xuchenghua, joseph_myers



On 31/12/2021 03:44, caiyinyu wrote:
> diff --git a/sysdeps/loongarch/nptl/Makefile b/sysdeps/loongarch/nptl/Makefile
> new file mode 100644
> index 0000000000..c6c773b179
> --- /dev/null
> +++ b/sysdeps/loongarch/nptl/Makefile
> @@ -0,0 +1,26 @@
> +# Makefile for sysdeps/loongarch/nptl.
> +# 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
> +
> +ifeq ($(subdir),nptl)
> +libpthread-sysdep_routines += nptl-sysdep
> +libpthread-shared-only-routines += nptl-sysdep
> +endif

You should not need the nptl-sysdep, the tcb-offsets.h should be suffice.

> diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure
> new file mode 100644
> index 0000000000..19983538ed
> --- /dev/null
> +++ b/sysdeps/loongarch/preconfigure
> @@ -0,0 +1,47 @@
> +case "$machine" in
> +loongarch*)
> +
> +    grlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_grlen \(.*\)/\1/p'`
> +    float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_\(soft\|single\|double\)_float.*/\1/p'`
> +
> +    with_fp_cond="!defined __loongarch_soft_float"
> +
> +    case "$float_abi" in
> +    soft)
> +	abi_flen=0
> +	echo "loongarch does not yet support soft floating-point  ABI!!" >&2

Extra whitespace here.

> +	exit 1
> +	;;
> +    single)
> +	echo "glibc does not yet support the single floating-point ABI" >&2
> +	exit 1
> +	;;
> +    double)
> +	abi_flen=64
> +	;;
> +    *)
> +	echo "Unable to determine floating-point ABI" >&2
> +	exit 1
> +	;;
> +    esac
> +
> +    case "$grlen" in
> +    32)
> +	echo "loongarch does not yet support ilp32 ABI!!" >&2
> +	;;
> +    64)
> +	machine=loongarch/lp64
> +	;;
> +    *)
> +	echo "Unable to determine GRLEN" >&2
> +	exit 1
> +	;;
> +    esac
> +
> +    $as_echo "#define LOONGARCH_ABI_GRLEN $grlen" >>confdefs.h
> +    $as_echo "#define LOONGARCH_ABI_FRLEN $abi_flen" >>confdefs.h
> +
> +    base_machine=loongarch
> +    ;;
> +esac
> +
> diff --git a/sysdeps/loongarch/sys/regdef.h b/sysdeps/loongarch/sys/regdef.h
> new file mode 100644
> index 0000000000..f53447db62
> --- /dev/null
> +++ b/sysdeps/loongarch/sys/regdef.h
> @@ -0,0 +1,98 @@
> +/* Register Macro 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/>.  */
> +
> +#ifndef _SYS_REGDEF_H
> +#define _SYS_REGDEF_H
> +
> +#ifdef __loongarch_lp64
> +#define zero $r0
> +#define ra $r1
> +#define tp $r2
> +#define sp $r3
> +#define a0 $r4
> +#define a1 $r5
> +#define a2 $r6
> +#define a3 $r7
> +#define a4 $r8
> +#define a5 $r9
> +#define a6 $r10
> +#define a7 $r11
> +#define v0 $r4
> +#define v1 $r5
> +#define t0 $r12
> +#define t1 $r13
> +#define t2 $r14
> +#define t3 $r15
> +#define t4 $r16
> +#define t5 $r17
> +#define t6 $r18
> +#define t7 $r19
> +#define t8 $r20
> +#define x $r21
> +#define fp $r22
> +#define s0 $r23
> +#define s1 $r24
> +#define s2 $r25
> +#define s3 $r26
> +#define s4 $r27
> +#define s5 $r28
> +#define s6 $r29
> +#define s7 $r30
> +#define s8 $r31
> +
> +#define fa0 $f0
> +#define fa1 $f1
> +#define fa2 $f2
> +#define fa3 $f3
> +#define fa4 $f4
> +#define fa5 $f5
> +#define fa6 $f6
> +#define fa7 $f7
> +#define fv0 $f0
> +#define fv1 $f1
> +#define ft0 $f8
> +#define ft1 $f9
> +#define ft2 $f10
> +#define ft3 $f11
> +#define ft4 $f12
> +#define ft5 $f13
> +#define ft6 $f14
> +#define ft7 $f15
> +#define ft8 $f16
> +#define ft9 $f17
> +#define ft10 $f18
> +#define ft11 $f19
> +#define ft12 $f20
> +#define ft13 $f21
> +#define ft14 $f22
> +#define ft15 $f23
> +#define fs0 $f24
> +#define fs1 $f25
> +#define fs2 $f26
> +#define fs3 $f27
> +#define fs4 $f28
> +#define fs5 $f29
> +#define fs6 $f30
> +#define fs7 $f31
> +
> +#else
> +#error "32bit LoongArch systems are not supported"
> +#endif
> +
> +#endif /* _SYS_REGDEF_H */
> diff --git a/sysdeps/unix/sysv/linux/loongarch/Implies b/sysdeps/unix/sysv/linux/loongarch/Implies
> new file mode 100644
> index 0000000000..e52b1ac310
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/Implies
> @@ -0,0 +1 @@
> +loongarch/nptl

Why do you need this Imply folder?

> diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile
> new file mode 100644
> index 0000000000..99ac734f91
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/Makefile
> @@ -0,0 +1,11 @@
> +ifeq ($(subdir),elf)
> +ifeq ($(build-shared),yes)
> +# This is needed for DSO loading from static binaries.
> +sysdep-dl-routines += dl-static
> +endif
> +endif
> +

There is no need of this file.

> +ifeq ($(subdir),stdlib)
> +gen-as-const-headers += ucontext_i.sym
> +endif
> +
> diff --git a/sysdeps/unix/sysv/linux/loongarch/configure b/sysdeps/unix/sysv/linux/loongarch/configure
> new file mode 100644
> index 0000000000..f4adec4ed9
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/configure
> @@ -0,0 +1,199 @@
> +# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
> + # Local configure fragment for sysdeps/unix/sysv/linux/loongarch.
> +
> +arch_minimum_kernel=5.15.0
> +
> +libc_cv_loongarch_int_abi=no
> +
> +
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
> +$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
> +if ${ac_cv_path_GREP+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$GREP"; then
> +  ac_path_GREP_found=false
> +  # Loop through the user's path and test for each of PROGNAME-LIST
> +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_prog in grep ggrep; do
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
> +      as_fn_executable_p "$ac_path_GREP" || continue
> +# Check for GNU ac_path_GREP and select it if it is found.
> +  # Check for GNU $ac_path_GREP
> +case `"$ac_path_GREP" --version 2>&1` in
> +*GNU*)
> +  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
> +*)
> +  ac_count=0
> +  $as_echo_n 0123456789 >"conftest.in"
> +  while :
> +  do
> +    cat "conftest.in" "conftest.in" >"conftest.tmp"
> +    mv "conftest.tmp" "conftest.in"
> +    cp "conftest.in" "conftest.nl"
> +    $as_echo 'GREP' >> "conftest.nl"
> +    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
> +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
> +    as_fn_arith $ac_count + 1 && ac_count=$as_val
> +    if test $ac_count -gt ${ac_path_GREP_max-0}; then
> +      # Best one so far, save it but keep looking for a better one
> +      ac_cv_path_GREP="$ac_path_GREP"
> +      ac_path_GREP_max=$ac_count
> +    fi
> +    # 10*(2^10) chars as input seems more than enough
> +    test $ac_count -gt 10 && break
> +  done
> +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
> +esac
> +
> +      $ac_path_GREP_found && break 3
> +    done
> +  done
> +  done
> +IFS=$as_save_IFS
> +  if test -z "$ac_cv_path_GREP"; then
> +    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
> +  fi
> +else
> +  ac_cv_path_GREP=$GREP
> +fi
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
> +$as_echo "$ac_cv_path_GREP" >&6; }
> + GREP="$ac_cv_path_GREP"
> +
> +
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
> +$as_echo_n "checking for egrep... " >&6; }
> +if ${ac_cv_path_EGREP+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
> +   then ac_cv_path_EGREP="$GREP -E"
> +   else
> +     if test -z "$EGREP"; then
> +  ac_path_EGREP_found=false
> +  # Loop through the user's path and test for each of PROGNAME-LIST
> +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_prog in egrep; do
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
> +      as_fn_executable_p "$ac_path_EGREP" || continue
> +# Check for GNU ac_path_EGREP and select it if it is found.
> +  # Check for GNU $ac_path_EGREP
> +case `"$ac_path_EGREP" --version 2>&1` in
> +*GNU*)
> +  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
> +*)
> +  ac_count=0
> +  $as_echo_n 0123456789 >"conftest.in"
> +  while :
> +  do
> +    cat "conftest.in" "conftest.in" >"conftest.tmp"
> +    mv "conftest.tmp" "conftest.in"
> +    cp "conftest.in" "conftest.nl"
> +    $as_echo 'EGREP' >> "conftest.nl"
> +    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
> +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
> +    as_fn_arith $ac_count + 1 && ac_count=$as_val
> +    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
> +      # Best one so far, save it but keep looking for a better one
> +      ac_cv_path_EGREP="$ac_path_EGREP"
> +      ac_path_EGREP_max=$ac_count
> +    fi
> +    # 10*(2^10) chars as input seems more than enough
> +    test $ac_count -gt 10 && break
> +  done
> +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
> +esac
> +
> +      $ac_path_EGREP_found && break 3
> +    done
> +  done
> +  done
> +IFS=$as_save_IFS
> +  if test -z "$ac_cv_path_EGREP"; then
> +    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
> +  fi
> +else
> +  ac_cv_path_EGREP=$EGREP
> +fi
> +
> +   fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
> +$as_echo "$ac_cv_path_EGREP" >&6; }
> + EGREP="$ac_cv_path_EGREP"
> +
> +
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
> +
> +_ACEOF
> +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
> +  $EGREP "4 4 4" >/dev/null 2>&1; then :
> +  libc_cv_loongarch_int_abi=lp32
> +fi
> +rm -f conftest*
> +
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
> +
> +_ACEOF
> +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
> +  $EGREP "4 8 8" >/dev/null 2>&1; then :
> +  libc_cv_loongarch_int_abi=lp64
> +fi
> +rm -f conftest*
> +
> +if test $libc_cv_loongarch_int_abi = no; then
> +  as_fn_error $? "Unable to determine integer ABI" "$LINENO" 5
> +fi
> +
> +config_vars="$config_vars
> +default-abi = $libc_cv_loongarch_int_abi"
> +
> +case $libc_cv_loongarch_int_abi in
> +lp32)
> +  test -n "$libc_cv_slibdir" ||
> +case "$prefix" in
> +/usr | /usr/)
> +  libc_cv_slibdir='/lib32'
> +  libc_cv_rtlddir='/lib32'
> +  if test "$libdir" = '${exec_prefix}/lib'; then
> +    libdir='${exec_prefix}/lib32';
> +    # Locale data can be shared between 32-bit and 64-bit libraries.
> +    libc_cv_complocaledir='${exec_prefix}/lib/locale'
> +  fi
> +  ;;
> +esac
> +  ;;
> +lp64)
> +  test -n "$libc_cv_slibdir" ||
> +case "$prefix" in
> +/usr | /usr/)
> +  libc_cv_slibdir='/lib64'
> +  libc_cv_rtlddir='/lib64'
> +  if test "$libdir" = '${exec_prefix}/lib'; then
> +    libdir='${exec_prefix}/lib64';
> +    # Locale data can be shared between 32-bit and 64-bit libraries.
> +    libc_cv_complocaledir='${exec_prefix}/lib/locale'
> +  fi
> +  ;;
> +esac
> +  ;;
> +esac
> +
> +ldd_rewrite_script=sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
> diff --git a/sysdeps/unix/sysv/linux/loongarch/configure.ac b/sysdeps/unix/sysv/linux/loongarch/configure.ac
> new file mode 100644
> index 0000000000..25fda13b09
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/configure.ac
> @@ -0,0 +1,27 @@
> +sinclude(./aclocal.m4)dnl Autoconf lossage
> +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> +# Local configure fragment for sysdeps/unix/sysv/linux/loongarch.
> +
> +arch_minimum_kernel=5.15.0
> +
> +libc_cv_loongarch_int_abi=no
> +AC_EGREP_CPP(4 4 4, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
> +  ], libc_cv_loongarch_int_abi=ilp32)
> +AC_EGREP_CPP(4 8 8, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__
> +  ], libc_cv_loongarch_int_abi=lp64)
> +if test $libc_cv_loongarch_int_abi = no; then
> +  AC_MSG_ERROR([Unable to determine integer ABI])
> +fi
> +
> +LIBC_CONFIG_VAR([default-abi], [$libc_cv_loongarch_int_abi])
> +
> +case $libc_cv_loongarch_int_abi in
> +ilp32)
> +  LIBC_SLIBDIR_RTLDDIR([lib32], [lib32])
> +  ;;
> +lp64)
> +  LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
> +  ;;
> +esac
> +
> +ldd_rewrite_script=sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed

So is the idea to evetually support ILP32 as well? My understanding it
is not currently supported, so I think it should not be handled it
yet.

> diff --git a/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
> new file mode 100644
> index 0000000000..d42a13e08c
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/ldd-rewrite.sed
> @@ -0,0 +1,3 @@
> +/LD_TRACE_LOADED_OBJECTS=1/a\
> +add_env="$add_env LD_LIBRARY_VERSION=\\$verify_out"
> +s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|32\)\(/[^/]*\)\(-loongarch\)\(64\|32\)\(\.so\.[0-9.]*\)[[:blank:]]*$_\1"\2\4\7 \264\4-loongarch64\7 \232\4-loongarch32\7"_
> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/Implies b/sysdeps/unix/sysv/linux/loongarch/lp64/Implies
> new file mode 100644
> index 0000000000..117c2b8efe
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/Implies
> @@ -0,0 +1,3 @@
> +unix/sysv/linux/loongarch
> +unix/sysv/linux/generic
> +unix/sysv/linux/wordsize-64
> diff --git a/sysdeps/unix/sysv/linux/loongarch/shlib-versions b/sysdeps/unix/sysv/linux/loongarch/shlib-versions
> new file mode 100644
> index 0000000000..aa9257fc61
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/loongarch/shlib-versions
> @@ -0,0 +1,7 @@
> +DEFAULT		GLIBC_2.35
> +
> +%if LOONGARCH_ABI_GRLEN == 64 && LOONGARCH_ABI_FRLEN == 64
> +ld=ld-linux-loongarch-lp64d.so.1
> +%else
> +%error cannot determine ABI
> +%endif

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

* Re: [PATCH v2 06/14] LoongArch: Generic <math.h> and soft-fp Routines
  2022-01-04 14:05   ` Adhemerval Zanella
@ 2022-01-04 20:31     ` Joseph Myers
  0 siblings, 0 replies; 42+ messages in thread
From: Joseph Myers @ 2022-01-04 20:31 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Tue, 4 Jan 2022, Adhemerval Zanella via Libc-alpha wrote:

> This is being replicated already on aarch64 and mips64, maybe we could
> add on a generic folder and use it instead.

We have sysdeps/ieee754/soft-fp/ for something similar, but that's only 
intended to be used via Implies in cases where software floating point 
with no exceptions / rounding modes support is in use and so the generic 
round-to-odd function implementations would be incorrect.

However, particular functions in that directory can be used via #include 
from elsewhere in sysdeps if appropriate - whether because of the lack of 
another generic implementation to use (as in the case of ldbl-128 sqrtl) 
or because it's more efficient (see how sysdeps/mips/ieee754/s_fmal.c 
includes sysdeps/ieee754/soft-fp/s_fmal.c because long double is always 
implemented in software for MIPS64).  So you could add sqrtl to that 
directory then #include it from individual architectures.  Or you could 
have e.g. ldbl-128-soft-fp that can go in sysdeps when appropriate, with 
the option to use it also for cases like MIPS fmal where the soft-fp 
implementation is more efficient than using the ldbl-128 version when all 
the underlying arithmetic operations used are themselves soft-fp 
operations.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v2 00/14] GLIBC LoongArch PATCHES
  2021-12-31 17:34 ` [PATCH v2 00/14] GLIBC LoongArch PATCHES Joseph Myers
@ 2022-04-15  1:27   ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:27 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, xuchenghua


在 2022/1/1 上午1:34, Joseph Myers 写道:
> On Fri, 31 Dec 2021, caiyinyu wrote:
>
>> b.
>> FAIL: elf/ifuncmain1
>> FAIL: elf/ifuncmain1pic
>> FAIL: elf/ifuncmain1pie
>> FAIL: elf/ifuncmain1staticpic
>> FAIL: elf/ifuncmain1staticpie
>> FAIL: elf/ifuncmain1vis
>> FAIL: elf/ifuncmain1vispic
>> FAIL: elf/ifuncmain1vispie
>> FAIL: elf/ifuncmain3
>> FAIL: elf/ifuncmain4
>> FAIL: elf/ifuncmain6pie
>> FAIL: elf/ifuncmain7
>> FAIL: elf/ifuncmain7pic
>> FAIL: elf/ifuncmain7pie
>> FAIL: elf/tst-ifunc-fault-bindnow
>> FAIL: elf/tst-ifunc-fault-lazy
>>
>> ifunc functions are not support yet
> If IFUNC isn't supported, the configure test
> (libc_cv_ld_gnu_indirect_function) should fail, have-ifunc should be no
> and elf/Makefile should disable the tests.
>
> Those failures suggest you have partial support in the toolchain - enough
> binutils support for the tests to be enabled - but are either missing
> glibc support, or some of the toolchain support is broken.  In that case,
> you should fix/add the broken/missing support so that the tests pass.  (Or
> if it's wrong that the libc_cv_ld_gnu_indirect_function test passes at
> all, maybe that's a binutils bug and you need to fix the binutils port so
> that that configure test fails.)
All ifunc problems are fixed.
>> c.
>> FAIL: math/test-double-acos
>> FAIL: math/test-double-asin
>> FAIL: math/test-float32x-acos
>> FAIL: math/test-float32x-asin
>> FAIL: math/test-float64-acos
>> FAIL: math/test-float64-asin
>>
>> These fails are caused by gcc optimizations. if we use -O0 options, these fails
>> will pass.
> So that issue needs fixing in GCC upstream.

GCC fixed.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95115

>> 10. Note the need for a manual/math.texi update in the list of
>> configurations supporting _Float128.
>>
>> not support yet
> It's supported by the port (with the same ABI as long double, via the
> ieee754/ldbl-128 inclusion in sysdeps/loongarch/Implies) - the functions
> are in the ABI test baselines.  So you need to update math.texi to reflect
> that.
Fixed.
>> 13. arch_minimum_kernel should be set to 10.0.0 until the actual upstream
>> kernel version that gets the port is known, and then to the actual
>> upstream version (so 5.14.0 or later).  Accordingly, kernel-features.h
>> should not have any "before 4.20" conditionals in it (so you don't need an
>> architecture-specific kernel-features.h at all).
>>
>> corrected
> You have arch_minimum_kernel=5.15.0, but the support isn't in 5.15.0, and
> indeed isn't in Linus's git tree for 5.16 either.
>
> Once it's in Linus's git tree, you can set arch_minimum_kernel to the
> actual version that will have the port.  Until then, you should use 10.0.0
> as a placeholder.
Fixed.


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

* Re: [PATCH v2 09/14] LoongArch: Linux ABI
  2021-12-31 17:37   ` Joseph Myers
@ 2022-04-15  1:27     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:27 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, xuchenghua


在 2022/1/1 上午1:37, Joseph Myers 写道:
> On Fri, 31 Dec 2021, caiyinyu wrote:
>
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/mman.h b/sysdeps/unix/sysv/linux/loongarch/bits/mman.h
> The constants here look like those in bits/mman-map-flags-generic.h.
> I.e., you shouldn't need this header at all; the default
> architecture-independent version should suffice.
>
Fixed by removing mman.h.


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

* Re: [PATCH v2 11/14] LoongArch: Add ABI Lists
  2021-12-31 17:43   ` Joseph Myers
@ 2022-04-15  1:27     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:27 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, xuchenghua


在 2022/1/1 上午1:43, Joseph Myers 写道:
> On Fri, 31 Dec 2021, caiyinyu wrote:
>
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libanl.abilist
> You shouldn't have this library at all, since Adhemerval's recent commit,
> so shouldn't have an ABI test baseline for it.
Removed.
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libdl.abilist
> Likewise, there should be no libdl for a new port.
Removed.
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libnsl.abilist
> Likewise, since --enable-obsolete-nsl was removed.  This shows up an issue
> with the OpenRISC port submission, which shouldn't have libnsl.abilist
> either.
Removed.
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libutil.abilist
> Likewise, there should be no libutil for a new port.
Removed.


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

* Re: [PATCH v2 13/14] LoongArch: Hard Float Support
  2021-12-31 17:47   ` Joseph Myers
@ 2022-04-15  1:27     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:27 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, xuchenghua


在 2022/1/1 上午1:47, Joseph Myers 写道:
> On Fri, 31 Dec 2021, caiyinyu wrote:
>
>>   sysdeps/loongarch/fpu/e_sqrt.c             |   26 +
>>   sysdeps/loongarch/fpu/e_sqrtf.c            |   26 +
> Set up a math-use-builtins-sqrt.h header for LoongArch and ensure that
> your GCC port can expand __builtin_sqrt and __builtin_sqrtf inline, and
> then you shouldn't need these files because the generic files with their
> USE_SQRTF_BUILTIN and USE_SQRT_BUILTIN conditionals will suffice instead.
Fixed by setting up a math-use-builtins-sqrt.h header for LoongArch.


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

* Re: [PATCH v2 00/14] GLIBC LoongArch PATCHES
  2022-01-04 13:27 ` Adhemerval Zanella
@ 2022-04-15  1:28   ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua


在 2022/1/4 下午9:27, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>> FAIL: elf/ifuncmain1
>> FAIL: elf/ifuncmain1pic
>> FAIL: elf/ifuncmain1pie
>> FAIL: elf/ifuncmain1staticpic
>> FAIL: elf/ifuncmain1staticpie
>> FAIL: elf/ifuncmain1vis
>> FAIL: elf/ifuncmain1vispic
>> FAIL: elf/ifuncmain1vispie
>> FAIL: elf/ifuncmain3
>> FAIL: elf/ifuncmain4
>> FAIL: elf/ifuncmain6pie
>> FAIL: elf/ifuncmain7
>> FAIL: elf/ifuncmain7pic
>> FAIL: elf/ifuncmain7pie
>> FAIL: elf/tst-ifunc-fault-bindnow
>> FAIL: elf/tst-ifunc-fault-lazy
>>
>> ifunc functions are not support yet
> If the target does not support ifunc, why libc_cv_ld_gnu_indirect_function is being
> set then? I think you will need to disable the usage of %gnu_indirect_function
> on static linker.


All ifunc problems are solved.

>> c.
>> FAIL: math/test-double-acos
>> FAIL: math/test-double-asin
>> FAIL: math/test-float32x-acos
>> FAIL: math/test-float32x-asin
>> FAIL: math/test-float64-acos
>> FAIL: math/test-float64-asin
>>
>> These fails are caused by gcc optimizations. if we use -O0 options, these fails
>> will pass.
>>
>> sysdeps/ieee754/dbl-64/e_asin.c: 343
>> ===================================================================
>> 337	  if (k>0x7ff00000 || (k == 0x7ff00000 && u.i[LOW_HALF] != 0)) return x + x;
>>     0x00007ffff7f4daac <+1388>:	lu12i.w     	$t0, 524032(0x7ff00)
>>     0x00007ffff7f4dab0 <+1392>:	blt         	$t0, $t2, 20(0x14)	# 0x7ffff7f4dac4 <__ieee754_acos+1412>
>>     0x00007ffff7f4dab4 <+1396>:	bne         	$t2, $t0, 36(0x24)	# 0x7ffff7f4dad8 <__ieee754_acos+1432>
>>     0x00007ffff7f4dab8 <+1400>:	ld.d        	$t0, $sp, 8(0x8)
>>     0x00007ffff7f4dabc <+1404>:	slli.w      	$t0, $t0, 0x0
>>     0x00007ffff7f4dac0 <+1408>:	beqz        	$t0, 24(0x18)	# 0x7ffff7f4dad8 <__ieee754_acos+1432>
>>     0x00007ffff7f4dac4 <+1412>:	fld.d       	$fa0, $sp, 8(0x8)
>>     0x00007ffff7f4dac8 <+1416>:	fadd.d      	$fa0, $fa0, $fa0
>>     0x00007ffff7f4dacc <+1420>:	b           	-788(0xffffcec)	# 0x7ffff7f4d7b8 <__ieee754_acos+632>
>>
>> 338	  else {
>> 339	    u.i[HIGH_HALF]=0x7ff00000;
>> 340	    v.i[HIGH_HALF]=0x7ff00000;
>> 341	    u.i[LOW_HALF]=0;
>> 342	    v.i[LOW_HALF]=0;
>> 343	    return u.x/v.x;			/////////  optimized out
>>
>>     0x00007ffff7f4dad8 <+1432>:	pcaddu12i   	$t0, 63(0x3f)
>>     0x00007ffff7f4dadc <+1436>:	addi.d      	$t0, $t0, -1248(0xb20)
>>     0x00007ffff7f4dae0 <+1440>:	fld.d       	$fa0, $t0, 0
>>     0x00007ffff7f4dae4 <+1444>:	b           	-812(0xffffcd4)	# 0x7ffff7f4d7b8 <__ieee754_acos+632>
>>
>> 344	  }
>> 345	}
>>     0x00007ffff7f4d7b8 <+632>:	addi.d      	$sp, $sp, 16(0x10)
>>     0x00007ffff7f4d7bc <+636>:	jirl        	$zero, $ra, 0
>>     0x00007ffff7f4d7cc <+652>:	addi.d      	$sp, $sp, 16(0x10)
>>     0x00007ffff7f4d7d0 <+656>:	jirl        	$zero, $ra, 0
>>     0x00007ffff7f4d8bc <+892>:	addi.d      	$sp, $sp, 16(0x10)
>>     0x00007ffff7f4d8c0 <+896>:	jirl        	$zero, $ra, 0
>> ===================================================================
> Is this being tracked by a GCC bug report? We need to understand if we
> require to use math_force_eval to avoid such issue on other ports as
> well.

GCC upstream Fixed.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95115



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

* Re: [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port.
  2022-01-04 13:30   ` Adhemerval Zanella
@ 2022-04-15  1:28     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua


在 2022/1/4 下午9:30, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>> ---
>>   NEWS   | 2 ++
>>   README | 1 +
>>   2 files changed, 3 insertions(+)
>>
>> diff --git a/NEWS b/NEWS
>> index 4762bfcc4e..c78143cc67 100644
>> --- a/NEWS
>> +++ b/NEWS
>> @@ -9,6 +9,8 @@ Version 2.35
>>   
>>   Major new features:
>>   
>> +* Add LoongArch Port.  Loongson Ltd.
>> +
>>   * Unicode 14.0.0 Support: Character encoding, character type info, and
>>     transliteration tables are all updated to Unicode 14.0.0, using
>>     generator scripts contributed by Mike FABIAN (Red Hat).
> Please follow other ports description, such the recent one for or1k [1],
> by adding the minimum binutils, gcc, and Linux version required along
> with the triple name and any other relevant information (32/64-bit,
> endianess, time_t, LFS support, etc).
>
> Also put the addition at the end of the list.
>
>> diff --git a/README b/README
>> index d0f0edb393..f0812d7a80 100644
>> --- a/README
>> +++ b/README
>> @@ -31,6 +31,7 @@ The GNU C Library supports these configurations for using Linux kernels:
>>   	i[4567]86-*-linux-gnu
>>   	x86_64-*-linux-gnu	Can build either x86_64 or x32
>>   	ia64-*-linux-gnu
>> +	loongarch64-*-linux-gnu
>>   	m68k-*-linux-gnu
>>   	microblaze*-*-linux-gnu
>>   	mips-*-linux-gnu
> [1]https://patchwork.sourceware.org/project/glibc/patch/20220104031414.2416928-14-shorne@gmail.com/


Fixed.


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

* Re: [PATCH v2 04/14] LoongArch: ABI Implementation
  2022-01-04 13:46   ` Adhemerval Zanella
@ 2022-04-15  1:28     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua


在 2022/1/4 下午9:46, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>
>> diff --git a/sysdeps/loongarch/bits/wordsize.h b/sysdeps/loongarch/bits/wordsize.h
>> new file mode 100644
>> index 0000000000..0a83454b08
>> --- /dev/null
>> +++ b/sysdeps/loongarch/bits/wordsize.h
>> @@ -0,0 +1,25 @@
>> +/* Determine the wordsize from the preprocessor defines.
>> +   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/>.  */
>> +
>> +#ifdef __LP64__
>> +#define __WORDSIZE 64
>> +#else
>> +#define __WORDSIZE 32
>> +#endif
>> +
>> +#define __WORDSIZE_TIME64_COMPAT32 0
> You stated you only supported 64-bit ABI and it should imply in wordsize-64,
> so why do you need to provide an arch-specific wordsize.h?

Fixed by using generic code.

>> +END (_dl_runtime_resolve)
>> diff --git a/sysdeps/loongarch/gccframe.h b/sysdeps/loongarch/gccframe.h
>> new file mode 100644
>> index 0000000000..19996f3ce3
>> --- /dev/null
>> +++ b/sysdeps/loongarch/gccframe.h
>> @@ -0,0 +1,21 @@
>> +/* Definition of object in frame unwind info.
>> +   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 FIRST_PSEUDO_REGISTER 74
>> +
>> +#include <sysdeps/generic/gccframe.h>
> Why do you need to add it? It is used solely on unwind code used only for
> compat code on old ABIs.
Fixed by removing gccframe.h.
>> diff --git a/sysdeps/loongarch/memusage.h b/sysdeps/loongarch/memusage.h
>> new file mode 100644
>> index 0000000000..bdf24bb276
>> --- /dev/null
>> +++ b/sysdeps/loongarch/memusage.h
>> @@ -0,0 +1,25 @@
>> +/* Machine-specific definitions for memory usage profiling.
>> +   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("$sp"); \
>> +    stack_ptr; \
>> +  })
>> +
>> +#include <sysdeps/generic/memusage.h>
> There is no need to add this header.
Fixed by removing memusage.h
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/ldconfig.h b/sysdeps/unix/sysv/linux/loongarch/ldconfig.h
>> new file mode 100644
>> index 0000000000..126f0860e9
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/ldconfig.h
>> @@ -0,0 +1,30 @@
>> +/* ldconfig default paths and libraries.
>> +   Copyright (C) 2001-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
>> +<http://www.gnu.org/licenses/>.  */
>> +
>> +#include <sysdeps/generic/ldconfig.h>
>> +
>> +#ifdef __loongarch_lp64
>> +#define SYSDEP_KNOWN_INTERPRETER_NAMES \
>> +  { "/lib64/ld-linux-loongarch-lp64d.so.1", FLAG_ELF_LIBC6 },
>> +#else
>> +#error cannot determine ABI
>> +#endif
>> +
> Do you plan to support multilib with different ABIs in the same system? Otherwise
> I think adding another SYSDEP_KNOWN_INTERPRETER_NAMES does not add much.
Fixed.
>> +#define SYSDEP_KNOWN_LIBRARY_NAMES	\
>> +  { "libc.so.6", FLAG_ELF_LIBC6 },	\
>> +  { "libm.so.6", FLAG_ELF_LIBC6 },
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/localplt.data b/sysdeps/unix/sysv/linux/loongarch/localplt.data
>> new file mode 100644
>> index 0000000000..817ab2659a
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/localplt.data
>> @@ -0,0 +1,12 @@
>> +# 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
>> +# 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
> I think this file should be moved to the Linux ABI patch.

Fixed.

>> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
>> new file mode 100644
>> index 0000000000..a02865b4a5
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/fpu/jmp_buf-macros.h
>> @@ -0,0 +1,44 @@
>> +/* jump buffer constants for LoongArch.
>> +   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 304
>> +#define JMP_BUF_ALIGN 8
>> +#define SIGJMP_BUF_SIZE 304
>> +#define SIGJMP_BUF_ALIGN 8
>> +#define MASK_WAS_SAVED_OFFSET 168
>> +#define SAVED_MASK_OFFSET 176
> Same as before.
Removed.
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h
>> new file mode 100644
>> index 0000000000..835df05ce5
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/nofpu/jmp_buf-macros.h
>> @@ -0,0 +1,41 @@
>> +/* Copyright (C) 2020-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 240
>> +# define JMP_BUF_ALIGN 8
>> +# define SIGJMP_BUF_SIZE 240
>> +# define SIGJMP_BUF_ALIGN 8
>> +# define MASK_WAS_SAVED_OFFSET 104
>> +# define SAVED_MASK_OFFSET 112
> Same as before.
Removed.


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

* Re: [PATCH v2 05/14] LoongArch: Thread-Local Storage Support
  2022-01-04 14:01   ` Adhemerval Zanella
@ 2022-04-15  1:28     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua


在 2022/1/4 下午10:01, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>> diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h
>> new file mode 100644
>> index 0000000000..3b17e0b7f5
>> --- /dev/null
>> +++ b/sysdeps/loongarch/nptl/tls.h
>> @@ -0,0 +1,138 @@
>> +/* Definition for thread-local data handling.
>> +   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 _LOONGARCH_TLS_H
>> +#define _LOONGARCH_TLS_H 1
>> +
>> +#include <dl-sysdep.h>
>> +
>> +#ifndef __ASSEMBLER__
>> +#include <stdbool.h>
>> +#include <stddef.h>
>> +#include <stdint.h>
>> +#include <dl-dtv.h>
>> +
>> +register void *__thread_self asm("$tp"); /* FIXME */
> What exactly needs to be fixed here?
Nothing. Useless comment.


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

* Re: [PATCH v2 07/14] LoongArch: Atomic and Locking Routines
  2022-01-04 14:09   ` Adhemerval Zanella
@ 2022-04-15  1:28     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua


在 2022/1/4 下午10:09, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>> This patch implements various atomic and locking routines on LoongArch.
>> ---
>>   .../loongarch/nptl/bits/pthreadtypes-arch.h   |  41 ++++
>>   sysdeps/loongarch/nptl/bits/semaphore.h       |  32 +++
>>   sysdeps/loongarch/nptl/libc-lowlevellock.c    |   8 +
>>   .../sysv/linux/loongarch/atomic-machine.h     | 196 ++++++++++++++++++
>>   4 files changed, 277 insertions(+)
>>   create mode 100644 sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
>>   create mode 100644 sysdeps/loongarch/nptl/bits/semaphore.h
>>   create mode 100644 sysdeps/loongarch/nptl/libc-lowlevellock.c
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
>>
>> diff --git a/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h b/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
>> new file mode 100644
>> index 0000000000..e57f122a98
>> --- /dev/null
>> +++ b/sysdeps/loongarch/nptl/bits/pthreadtypes-arch.h
>> @@ -0,0 +1,41 @@
>> +/* Machine-specific pthread type layouts.
>> +   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_ARCH_H
>> +#define _BITS_PTHREADTYPES_ARCH_H 1
>> +
>> +#include <bits/endian.h>
>> +
>> +#ifdef __loongarch_lp64
>> +#define __SIZEOF_PTHREAD_ATTR_T 56
>> +#define __SIZEOF_PTHREAD_MUTEX_T 40
>> +#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
>> +#define __SIZEOF_PTHREAD_COND_T 48
>> +#define __SIZEOF_PTHREAD_CONDATTR_T 4
>> +#define __SIZEOF_PTHREAD_RWLOCK_T 56
>> +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
>> +#define __SIZEOF_PTHREAD_BARRIER_T 32
>> +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
>> +#else
>> +#error "32bit LoongArch systems are not supported"
>> +#endif
>> +
>> +#define __LOCK_ALIGNMENT
>> +#define __ONCE_ALIGNMENT
>> +
>> +#endif /* bits/pthreadtypes.h */
> Why can't you use the generic definition?   Also, I think all the __loongarch_lp64
> tests to avoid 32-bit build should be moved to a configure test instead.
Fixed by using generic definition and __loongarch_lp64 tests have been 
moved to configure test.
>> diff --git a/sysdeps/loongarch/nptl/bits/semaphore.h b/sysdeps/loongarch/nptl/bits/semaphore.h
>> new file mode 100644
>> index 0000000000..510f3b0e9a
>> --- /dev/null
>> +++ b/sysdeps/loongarch/nptl/bits/semaphore.h
>> @@ -0,0 +1,32 @@
>> +/* POSIX semaphore type layout
>> +   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 _SEMAPHORE_H
>> +#error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
>> +#endif
>> +
>> +#define __SIZEOF_SEM_T (4 * __SIZEOF_POINTER__)
>> +
>> +/* Value returned if `sem_open' failed.  */
>> +#define SEM_FAILED ((sem_t *) 0)
>> +
>> +typedef union
>> +{
>> +  char __size[__SIZEOF_SEM_T];
>> +  long int __align;
>> +} sem_t;
> Why can't you use the generic linux header interface?
Fixed by using generic linux header interface.
>> diff --git a/sysdeps/loongarch/nptl/libc-lowlevellock.c b/sysdeps/loongarch/nptl/libc-lowlevellock.c
>> new file mode 100644
>> index 0000000000..f4b8b5c193
>> --- /dev/null
>> +++ b/sysdeps/loongarch/nptl/libc-lowlevellock.c
>> @@ -0,0 +1,8 @@
>> +/* This kludge works around a libpthread static linking problem:
>> +https://sourceware.org/bugzilla/show_bug.cgi?id=15648.  */
>> +
>> +#ifndef SHARED
>> +#define __lll_lock_wait_private weak_function __lll_lock_wait_private
>> +#endif
>> +
>> +#include <lowlevellock.c>
> Why this file is required?
Fixed by removing libc-lowlevellock.c
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h b/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
>> new file mode 100644
>> index 0000000000..dbae608ee5
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/atomic-machine.h
>> @@ -0,0 +1,196 @@
>> +/* Atomic operations.
>> +   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_LOONGARCH_BITS_ATOMIC_H
>> +#define _LINUX_LOONGARCH_BITS_ATOMIC_H 1
>> +
>> +#include <stdint.h>
>> +
>> +typedef int32_t atomic32_t;
>> +typedef uint32_t uatomic32_t;
>> +
>> +typedef int64_t atomic64_t;
>> +typedef uint64_t uatomic64_t;
>> +
>> +typedef intptr_t atomicptr_t;
>> +typedef uintptr_t uatomicptr_t;
>> +typedef intmax_t atomic_max_t;
>> +typedef uintmax_t uatomic_max_t;
> These definition are not required any longer.
Fixed.
>> +
>> +#define atomic_full_barrier() __sync_synchronize ()
>> +
>> +#ifdef __LP64__
>> +#define __HAVE_64B_ATOMICS 1
>> +#endif
> I think there is no need to guard it for __LP64__.
Fixed.


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

* Re: [PATCH v2 08/14] LoongArch: Linux Syscall Interface
  2022-01-04 14:20   ` Adhemerval Zanella
@ 2022-04-15  1:28     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua, joseph_myers


在 2022/1/4 下午10:20, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>> Contains the Linux system call interface, as well as the definitions of
>> a handful of system calls.
>> ---
>>   sysdeps/loongarch/abort-instr.h               |   2 +
>>   sysdeps/loongarch/hp-timing.h                 |  42 +++
>>   sysdeps/loongarch/nptl/nptl-sysdep.S          |   2 +
>>   .../unix/sysv/linux/loongarch/arch-syscall.h  | 302 ++++++++++++++++
>>   .../unix/sysv/linux/loongarch/bits/signum.h   |  58 ++++
>>   sysdeps/unix/sysv/linux/loongarch/clone.S     | 100 ++++++
>>   sysdeps/unix/sysv/linux/loongarch/clone3.S    |  87 +++++
>>   sysdeps/unix/sysv/linux/loongarch/ipc_priv.h  |  22 ++
>>   sysdeps/unix/sysv/linux/loongarch/syscall.c   |  35 ++
>>   sysdeps/unix/sysv/linux/loongarch/sysdep.S    |  53 +++
>>   sysdeps/unix/sysv/linux/loongarch/sysdep.h    | 321 ++++++++++++++++++
>>   sysdeps/unix/sysv/linux/loongarch/vfork.S     |  50 +++
>>   12 files changed, 1074 insertions(+)
>>   create mode 100644 sysdeps/loongarch/abort-instr.h
>>   create mode 100644 sysdeps/loongarch/hp-timing.h
>>   create mode 100644 sysdeps/loongarch/nptl/nptl-sysdep.S
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/signum.h
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone.S
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/clone3.S
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall.c
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.S
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/sysdep.h
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/vfork.S
>>
>> diff --git a/sysdeps/loongarch/abort-instr.h b/sysdeps/loongarch/abort-instr.h
>> new file mode 100644
>> index 0000000000..92e22edfea
>> --- /dev/null
>> +++ b/sysdeps/loongarch/abort-instr.h
>> @@ -0,0 +1,2 @@
>> +/* An instruction which should crash any program is a breakpoint.  */
>> +#define ABORT_INSTRUCTION asm("break 0")
> Missing space after asm.
Fixed.
>> diff --git a/sysdeps/loongarch/hp-timing.h b/sysdeps/loongarch/hp-timing.h
>> new file mode 100644
>> index 0000000000..7b36a539f1
>> --- /dev/null
>> +++ b/sysdeps/loongarch/hp-timing.h
>> @@ -0,0 +1,42 @@
>> +/* High precision, low overhead timing functions.
>> +   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 _HP_TIMING_H
>> +#define _HP_TIMING_H 1
>> +
>> +/* We always assume having the timestamp register.  */
>> +#define HP_TIMING_AVAIL (1)
>> +#define HP_SMALL_TIMING_AVAIL (1)
>> +
>> +/* We indeed have inlined functions.  */
>> +#define HP_TIMING_INLINE (1)
>> +
>> +/* We use 64bit values for the times.  */
>> +typedef unsigned long long int hp_timing_t;
>> +
>> +/* Read the stable counter.  */
>> +#define HP_TIMING_NOW(Var) \
>> +  ({ \
>> +    unsigned long long int _count; \
>> +    asm volatile("rdtime.d\t%0,$r0" : "=r"(_count)); \
> Missing space after volatile.
Fixed.
>> +    (Var) = _count; \
>> +  })
>> +
>> +#include <hp-timing-common.h>
>> +
>> +#endif /* hp-timing.h */
>> diff --git a/sysdeps/loongarch/nptl/nptl-sysdep.S b/sysdeps/loongarch/nptl/nptl-sysdep.S
>> new file mode 100644
>> index 0000000000..3f5c2a364a
>> --- /dev/null
>> +++ b/sysdeps/loongarch/nptl/nptl-sysdep.S
>> @@ -0,0 +1,2 @@
>> +/* Pull in __syscall_error.  */
>> +#include <sysdep.S>
> Why do you need this file?  Newer Linux ports should have libpthread function
> on libc.so.
Removed.
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/signum.h b/sysdeps/unix/sysv/linux/loongarch/bits/signum.h
>> new file mode 100644
>> index 0000000000..111759778b
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/bits/signum.h
>> @@ -0,0 +1,58 @@
>> +/* Signal number definitions.  Linux 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_SIGNUM_H
>> +#define _BITS_SIGNUM_H 1
>> +
>> +#ifndef _SIGNAL_H
>> +#error "Never include <bits/signum.h> directly; use <signal.h> instead."
>> +#endif
>> +
>> +#include <bits/signum-generic.h>
>> +
>> +/* Adjustments and additions to the signal number constants for
>> +   most Linux systems.  */
>> +
>> +#define SIGSTKFLT 16 /* Stack fault (obsolete).  */
>> +#define SIGPWR 30    /* Power failure imminent.  */
>> +
>> +#undef SIGBUS
>> +#define SIGBUS 7
>> +#undef SIGUSR1
>> +#define SIGUSR1 10
>> +#undef SIGUSR2
>> +#define SIGUSR2 12
>> +#undef SIGCHLD
>> +#define SIGCHLD 17
>> +#undef SIGCONT
>> +#define SIGCONT 18
>> +#undef SIGSTOP
>> +#define SIGSTOP 19
>> +#undef SIGTSTP
>> +#define SIGTSTP 20
>> +#undef SIGURG
>> +#define SIGURG 23
>> +#undef SIGPOLL
>> +#define SIGPOLL 29
>> +#undef SIGSYS
>> +#define SIGSYS 31
>> +
>> +#undef __SIGRTMAX
>> +#define __SIGRTMAX 64
>> +
>> +#endif /* <signal.h> included.  */
> This file has been refactore by e4e11b1dba261cb650e6 (2.32), now ports that
> deviate from Linux generic ABI should provide a signum-arch.h header. And
> this seems not to be the case here.
Removed.
>
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/clone.S b/sysdeps/unix/sysv/linux/loongarch/clone.S
>> new file mode 100644
>> index 0000000000..d2bed24440
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/clone.S
>> @@ -0,0 +1,100 @@
>> +/* The clone syscall wrapper.
>> +   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/>.  */
>> +
>> +/* clone() is even more special than fork() as it mucks with stacks
>> +   and invokes a function in the right context after its all over.  */
>> +
>> +#include <sys/asm.h>
>> +#include <sysdep.h>
>> +#define _ERRNO_H  1
>> +#include <bits/errno.h>
>> +#include <tls.h>
>> +#include "tcb-offsets.h"
>> +
>> +/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
>> +   void *parent_tidptr, void *tls, void *child_tidptr) */
>> +
>> +ENTRY (__clone)
>> +
>> +	/* Align stack to 16 or 8 bytes per the ABI.  */
>> +#ifdef __loongarch_lp64
>> +	bstrins.d	a1, zero, 3, 0
>> +#else
>> +#error "32bit LoongArch systems are not supported"
>> +#endif
> As before, I think we should move the LP64 ABI tests to configure time
> instead of adding multiple checks on arch-specific code.
Fixed.
>> +
>> +	/* Sanity check arguments.  */
>> +	beqz		a0, L (invalid) /* No NULL function pointers.  */
>> +	beqz		a1, L (invalid) /* No NULL stack pointers.  */
>> +
>> +	addi.d 		a1, a1, -16 /* Reserve argument save space.  */
>> +	st.d		a0, a1, 0   /* Save function pointer.  */
>> +	st.d		a3, a1, SZREG   /* Save argument pointer.  */
>> +
>> +	/* The syscall expects the args to be in different slots.  */
>> +	or		a0, a2, zero
>> +	or		a2, a4, zero
>> +	or		a3, a6, zero
>> +	or		a4, a5, zero
>> +
>> +	/* Do the system call.  */
>> +	li.d		a7,__NR_clone
>> +	syscall		0
>> +
>> +	blt		a0, zero ,L (error)
>> +	beqz		a0,L (thread_start)
>> +
>> +	/* Successful return from the parent.  */
>> +	ret
>> +
>> +L (invalid):
>> +	li.d		a0, -EINVAL
>> +
>> +	/* Something bad happened -- no child created.  */
>> +L (error):
>> +	b		__syscall_error
>> +
>> +END (__clone)
>> +
>> +/* Load up the arguments to the function.  Put this block of code in
>> +   its own function so that we can terminate the stack trace with our
>> +   debug info.  */
>> +ENTRY (__thread_start)
>> +L (thread_start):
>> +
>> +/* Terminate call stack by noting ra is undefined.  Use a dummy
>> +   .cfi_label to force starting the FDE.  */
>> +	.cfi_label .Ldummy
>> +	cfi_undefined (1)
>> +
>> +	/* Restore the arg for user's function.  */
>> +	ld.d		a1, sp, 0   /* Function pointer.  */
>> +	ld.d		a0, sp, SZREG   /* Argument pointer.  */
>> +
>> +	/* Call the user's function.  */
>> +	jirl		ra, a1, 0
>> +
>> +	/* Call exit with the function's return value.  */
>> +	li.d		a7, __NR_exit
>> +	syscall		0
>> +
>> +	END (__thread_start)
>> +
>> +libc_hidden_def (__clone)
>> +weak_alias (__clone, clone)
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h b/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
>> new file mode 100644
>> index 0000000000..dde8fa6989
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/ipc_priv.h
>> @@ -0,0 +1,22 @@
>> +/* Old SysV permission definition for Linux.
>> +   Copyright (C) 2021 Loongson Technology, 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 <sys/ipc.h> /* For __key_t  */
>> +
>> +#define __IPC_64 0x0
>> +#include <sysdeps/unix/sysv/linux/ipc_priv.h>
> Why can't you use the generic sysdeps/unix/sysv/linux/ipc_priv.h here?
> I woudl asusme that LoongArch will have __ASSUME_SYSVIPC_DEFAULT_IPC_64
> defined and thus __IPC_64 will be 0x0.
Fixed by using generic Linux files.
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/syscall.c b/sysdeps/unix/sysv/linux/loongarch/syscall.c
>> new file mode 100644
>> index 0000000000..d0067bc2d0
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/syscall.c
>> @@ -0,0 +1,35 @@
>> +/* system call interface.
>> +   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>
>> +
>> +long int
>> +syscall (long int syscall_number, long int arg1, long int arg2, long int arg3,
>> +	 long int arg4, long int arg5, long int arg6, long int arg7)
>> +{
>> +  long int ret;
>> +
>> +  ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4, arg5,
>> +			      arg6, arg7);
>> +
>> +  if (INTERNAL_SYSCALL_ERROR_P (ret))
>> +    return __syscall_error (ret);
>> +
>> +  return ret;
>> +}
> Do you really need 7 arguments for syscall? Otherwise you should use the generic
> interface.
Fixed by removing syscall.c.


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

* Re: [PATCH v2 09/14] LoongArch: Linux ABI
  2022-01-04 14:24   ` Adhemerval Zanella
@ 2022-04-15  1:28     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua, joseph_myers


在 2022/1/4 下午10:24, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>
>> diff --git a/sysdeps/loongarch/nptl/bits/struct_rwlock.h b/sysdeps/loongarch/nptl/bits/struct_rwlock.h
>> new file mode 100644
>> index 0000000000..12b6a469bd
>> --- /dev/null
>> +++ b/sysdeps/loongarch/nptl/bits/struct_rwlock.h
>> @@ -0,0 +1,44 @@
>> +/* LoongArch internal rwlock struct 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/>.  */
>> +
>> +#ifndef _RWLOCK_INTERNAL_H
>> +#define _RWLOCK_INTERNAL_H
>> +
>> +/* There is a lot of padding in this structure.  While it's not strictly
>> +   necessary on LoongArch, we're going to leave it in to be on the safe side in
>> +   case it's needed in the future.  Most other architectures have the padding,
>> +   so this gives us the same extensibility as everyone else has.  */
>> +struct __pthread_rwlock_arch_t
>> +{
>> +  unsigned int __readers;
>> +  unsigned int __writers;
>> +  unsigned int __wrphase_futex;
>> +  unsigned int __writers_futex;
>> +  unsigned int __pad3;
>> +  unsigned int __pad4;
>> +  int __cur_writer;
>> +  int __shared;
>> +  unsigned long int __pad1;
>> +  unsigned long int __pad2;
>> +  unsigned int __flags;
>> +};
>> +
>> +#define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
>> +  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, __flags
>> +
>> +#endif
> Why can't you use the generic Linux sysdeps/nptl/bits/struct_rwlock.h ?
Fixed by using generic Linux file.
>> diff --git a/sysdeps/loongarch/nptl/pthread-offsets.h b/sysdeps/loongarch/nptl/pthread-offsets.h
>> new file mode 100644
>> index 0000000000..415c3c113f
>> --- /dev/null
>> +++ b/sysdeps/loongarch/nptl/pthread-offsets.h
>> @@ -0,0 +1,15 @@
>> +#if __WORDSIZE == 64
>> +#define __PTHREAD_MUTEX_KIND_OFFSET 16
>> +#else
>> +#define __PTHREAD_MUTEX_KIND_OFFSET 12
>> +#endif
>> +
>> +#if __WORDSIZE == 64
>> +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
>> +#else
>> +#if __BYTE_ORDER == __BIG_ENDIAN
>> +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
>> +#else
>> +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
>> +#endif
>> +#endif
> Ditto.
Fixed by using generic Linux file.


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

* Re: [PATCH v2 10/14] LoongArch: Linux Startup and Dynamic Loading Code
  2022-01-04 14:27   ` Adhemerval Zanella
@ 2022-04-15  1:28     ` caiyinyu
  0 siblings, 0 replies; 42+ messages in thread
From: caiyinyu @ 2022-04-15  1:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: xuchenghua, joseph_myers


在 2022/1/4 下午10:27, Adhemerval Zanella 写道:
> On 31/12/2021 03:44, caiyinyu wrote:
>> This contains the Linux-specific code for loading programs on LoongArch.
>> ---
>>   sysdeps/unix/sysv/linux/loongarch/dl-static.c | 80 +++++++++++++++++++
>>   sysdeps/unix/sysv/linux/loongarch/ldsodefs.h  | 33 ++++++++
>>   2 files changed, 113 insertions(+)
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/dl-static.c
>>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
>>
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/dl-static.c b/sysdeps/unix/sysv/linux/loongarch/dl-static.c
>> new file mode 100644
>> index 0000000000..b9a7b2a61f
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/dl-static.c
>> @@ -0,0 +1,80 @@
>> +/* dl_static_init for loongarch.
>> +   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 <ldsodefs.h>
>> +
>> +#ifdef SHARED
>> +
>> +void
>> +_dl_var_init (void *array[])
>> +{
>> +  /* It has to match "variables" below.  */
>> +  enum
>> +  {
>> +    DL_PAGESIZE = 0
>> +  };
>> +
>> +  GLRO (dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
>> +}
>> +
>> +#else
>> +
>> +static void *variables[] = {&GLRO (dl_pagesize)};
>> +
>> +static void _dl_unprotect_relro (struct link_map *l)
>> +{
>> +  ElfW (Addr) start = ((l->l_addr + l->l_relro_addr)
>> +			& ~(GLRO (dl_pagesize) - 1));
>> +  ElfW (Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
>> +		      & ~(GLRO (dl_pagesize) - 1));
>> +
>> +  if (start != end)
>> +    __mprotect ((void *) start, end - start, PROT_READ | PROT_WRITE);
>> +}
>> +
>> +void dl_static_init (struct link_map *l)
>> +{
>> +  struct link_map *rtld_map = l;
>> +  struct r_scope_elem **scope;
>> +  const ElfW (Sym) *ref = NULL;
>> +  lookup_t loadbase;
>> +  void (*f) (void *[]);
>> +  size_t i;
>> +
>> +  loadbase = _dl_lookup_symbol_x ("_dl_var_init", l, &ref, l->l_local_scope,
>> +				  NULL, 0, 1, NULL);
>> +
>> +  for (scope = l->l_local_scope; *scope != NULL; scope++)
>> +    for (i = 0; i < (*scope)->r_nlist; i++)
>> +      if ((*scope)->r_list[i] == loadbase)
>> +	{
>> +	  rtld_map = (*scope)->r_list[i];
>> +	  break;
>> +	}
>> +
>> +  if (ref != NULL)
>> +    {
>> +      f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
>> +      _dl_unprotect_relro (rtld_map);
>> +      f (variables);
>> +      _dl_protect_relro (rtld_map);
>> +    }
>> +}
>> +
>> +#endif
> This file should not be required, Florian has refactored it to avoid this
> boilerplate code (check bdc90abc48f0528588600df37eebdc04ce01b2f0 and
> related commits).
Removed and modified related code.
>
>> diff --git a/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h b/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
>> new file mode 100644
>> index 0000000000..680baf2edc
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/loongarch/ldsodefs.h
>> @@ -0,0 +1,33 @@
>> +/* 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 _LDSODEFS_H
>> +
>> +/* Get the real definitions.  */
>> +#include_next <ldsodefs.h>
>> +
>> +/* Now define our stuff.  */
>> +
>> +/* We need special support to initialize DSO loaded for statically linked
>> +   binaries.  */
>> +extern void _dl_static_init (struct link_map *map);
>> +#undef DL_STATIC_INIT
>> +#define DL_STATIC_INIT(map) _dl_static_init (map)
>> +
>> +#endif /* ldsodefs.h */
> Same as before.
Removed.


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

end of thread, other threads:[~2022-04-15  1:28 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-31  6:44 [PATCH v2 00/14] GLIBC LoongArch PATCHES caiyinyu
2021-12-31  6:44 ` [PATCH v2 01/14] LoongArch: Update NEWS and README for the LoongArch port caiyinyu
2022-01-04 13:30   ` Adhemerval Zanella
2022-04-15  1:28     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 02/14] LoongArch: Add LoongArch entries to config.h.in caiyinyu
2021-12-31  6:44 ` [PATCH v2 03/14] LoongArch: Add relocations and ELF flags to elf.h caiyinyu
2021-12-31  6:44 ` [PATCH v2 04/14] LoongArch: ABI Implementation caiyinyu
2022-01-04 13:46   ` Adhemerval Zanella
2022-04-15  1:28     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 05/14] LoongArch: Thread-Local Storage Support caiyinyu
2022-01-04 14:01   ` Adhemerval Zanella
2022-04-15  1:28     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 06/14] LoongArch: Generic <math.h> and soft-fp Routines caiyinyu
2022-01-04 14:05   ` Adhemerval Zanella
2022-01-04 20:31     ` Joseph Myers
2021-12-31  6:44 ` [PATCH v2 07/14] LoongArch: Atomic and Locking Routines caiyinyu
2022-01-04 14:09   ` Adhemerval Zanella
2022-04-15  1:28     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 08/14] LoongArch: Linux Syscall Interface caiyinyu
2022-01-04 14:20   ` Adhemerval Zanella
2022-04-15  1:28     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 09/14] LoongArch: Linux ABI caiyinyu
2021-12-31 17:37   ` Joseph Myers
2022-04-15  1:27     ` caiyinyu
2022-01-04 14:24   ` Adhemerval Zanella
2022-04-15  1:28     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 10/14] LoongArch: Linux Startup and Dynamic Loading Code caiyinyu
2022-01-04 14:27   ` Adhemerval Zanella
2022-04-15  1:28     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 11/14] LoongArch: Add ABI Lists caiyinyu
2021-12-31 17:43   ` Joseph Myers
2022-04-15  1:27     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 12/14] LoongArch: Build Infastructure caiyinyu
2022-01-04 14:33   ` Adhemerval Zanella
2021-12-31  6:44 ` [PATCH v2 13/14] LoongArch: Hard Float Support caiyinyu
2021-12-31 17:47   ` Joseph Myers
2022-04-15  1:27     ` caiyinyu
2021-12-31  6:44 ` [PATCH v2 14/14] LoongArch: Update build-many-glibcs.py for the LoongArch Port caiyinyu
2021-12-31 17:34 ` [PATCH v2 00/14] GLIBC LoongArch PATCHES Joseph Myers
2022-04-15  1:27   ` caiyinyu
2022-01-04 13:27 ` Adhemerval Zanella
2022-04-15  1:28   ` caiyinyu

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).