Fixup LoongArch Port errors after the fstatat64 backport

(cherry picked from commit a11d8db8e5f44a5dd6b482483ae6dc2cdf4397fb)
This commit is contained in:
Xing Li 2023-11-13 12:01:27 +08:00 committed by openeuler-sync-bot
parent a3d4a3b0ea
commit 3d89829d16
5 changed files with 116 additions and 190 deletions

View File

@ -1,7 +1,7 @@
From 82aa8c58156bbaab18bc44a80ca00159557c7f27 Mon Sep 17 00:00:00 2001 From d12d80cdcafd2f84321d311d6ce3e291f0e7b9a9 Mon Sep 17 00:00:00 2001
From: XingLi <lixing@loongson.cn> From: XingLi <lixing@loongson.cn>
Date: Thu, 27 Jul 2023 09:25:19 +0800 Date: Thu, 27 Jul 2023 09:25:19 +0800
Subject: [PATCH 1/3] LoongArch: Add static PIE support Subject: [PATCH 2/3] LoongArch: Add static PIE support
If the compiler is new enough, enable static PIE support. In the static If the compiler is new enough, enable static PIE support. In the static
PIE version of _start (in rcrt1.o), use la.pcrel instead of la.got PIE version of _start (in rcrt1.o), use la.pcrel instead of la.got
@ -13,8 +13,8 @@ Date: Sat, 24 Sep 2022 15:45:34 +0800
--- ---
sysdeps/loongarch/configure | 51 ++++++++++++++++++++++++++++++++++ sysdeps/loongarch/configure | 51 ++++++++++++++++++++++++++++++++++
sysdeps/loongarch/configure.ac | 38 ++++++++++++++++++++++++- sysdeps/loongarch/configure.ac | 38 ++++++++++++++++++++++++-
sysdeps/loongarch/start.S | 14 ++++++++-- sysdeps/loongarch/start.S | 16 +++++++----
3 files changed, 99 insertions(+), 4 deletions(-) 3 files changed, 99 insertions(+), 6 deletions(-)
diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure
index 1e5abf81..db6341e8 100644 index 1e5abf81..db6341e8 100644
@ -122,21 +122,21 @@ index 67b46ce0..603085cd 100644
+ AC_DEFINE(SUPPORT_STATIC_PIE) + AC_DEFINE(SUPPORT_STATIC_PIE)
+fi +fi
diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S
index 9ecfb5e2..cb2b6c5b 100644 index 0deda78a..1b15fc9c 100644
--- a/sysdeps/loongarch/start.S --- a/sysdeps/loongarch/start.S
+++ b/sysdeps/loongarch/start.S +++ b/sysdeps/loongarch/start.S
@@ -44,9 +44,17 @@ ENTRY (ENTRY_POINT) @@ -44,9 +44,15 @@ ENTRY (ENTRY_POINT)
cfi_undefined (1) cfi_undefined (1)
or a5, a0, zero /* rtld_fini */ 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
+#if defined(PIC) && !defined(SHARED) +#if defined(PIC) && !defined(SHARED)
+/* For static PIE, the GOT cannot be used in _start because the GOT entries are +/* For static PIE, the GOT cannot be used in _start because the GOT entries are
+ offsets instead of real addresses before __libc_start_main. */ + offsets instead of real addresses before __libc_start_main. */
+# define LA la.pcrel +# define LA la.pcrel
+#else +#else
/* 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
+# define LA la.got +# define LA la.got
+#endif +#endif
+ +
@ -144,7 +144,7 @@ index 9ecfb5e2..cb2b6c5b 100644
#ifdef __loongarch_lp64 #ifdef __loongarch_lp64
ld.d a1, sp, 0 ld.d a1, sp, 0
addi.d a2, sp, SZREG addi.d a2, sp, SZREG
@@ -61,10 +69,10 @@ ENTRY (ENTRY_POINT) @@ -61,9 +67,9 @@ ENTRY (ENTRY_POINT)
move a4, zero /* used to be fini */ move a4, zero /* used to be fini */
or a6, sp, zero /* stack_end */ or a6, sp, zero /* stack_end */
@ -156,7 +156,6 @@ index 9ecfb5e2..cb2b6c5b 100644
+ LA ra, t0, abort + LA ra, t0, abort
jirl ra, ra, 0 jirl ra, ra, 0
END (ENTRY_POINT) END (ENTRY_POINT)
-- --
2.27.0 2.33.0

View File

@ -1,3 +1,16 @@
From 6698be0ce3a7877d68468c56a9217c4d87f74e23 Mon Sep 17 00:00:00 2001
From: XingLi <lixing@loongson.cn>
Date: Fri, 10 Nov 2023 15:00:28 +0800
Subject: [PATCH 1/3] LoongArch Fix ptr mangling demangling and SHMLBA
---
sysdeps/loongarch/__longjmp.S | 7 +++
sysdeps/loongarch/setjmp.S | 7 +++
.../unix/sysv/linux/loongarch/bits/shmlba.h | 24 +++++++
sysdeps/unix/sysv/linux/loongarch/sysdep.h | 62 ++++++++++++++++++-
4 files changed, 97 insertions(+), 3 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/shmlba.h
diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S
index 5cc1bc78..fa86f797 100644 index 5cc1bc78..fa86f797 100644
--- a/sysdeps/loongarch/__longjmp.S --- a/sysdeps/loongarch/__longjmp.S
@ -140,3 +153,6 @@ index b2587091..3f2d691b 100644
+#endif +#endif
#endif /* linux/loongarch/sysdep.h */ #endif /* linux/loongarch/sysdep.h */
--
2.33.0

View File

@ -1,7 +1,7 @@
From d29ac2028078612c6b4c25fb5be857ca35b37a3b Mon Sep 17 00:00:00 2001 From dba920d34797ea8e44fca1d2cfc6a08dbe9bb759 Mon Sep 17 00:00:00 2001
From: XingLi <lixing@loongson.cn> From: XingLi <lixing@loongson.cn>
Date: Thu, 27 Jul 2023 09:32:21 +0800 Date: Thu, 27 Jul 2023 09:32:21 +0800
Subject: [PATCH 2/3] LoongArch: Fix the condition to use PC-relative Subject: [PATCH 3/3] LoongArch: Fix the condition to use PC-relative
addressing in start.S addressing in start.S
A start.o compiled from start.S with -DPIC and no -DSHARED is used by A start.o compiled from start.S with -DPIC and no -DSHARED is used by
@ -47,8 +47,8 @@ Date: Sun, 2 Oct 2022 22:23:09 +0800
--- ---
sysdeps/loongarch/configure | 29 +++++++++++++++++++++++++---- sysdeps/loongarch/configure | 29 +++++++++++++++++++++++++----
sysdeps/loongarch/configure.ac | 18 ++++++++++++++---- sysdeps/loongarch/configure.ac | 18 ++++++++++++++----
sysdeps/loongarch/start.S | 11 +++++++---- sysdeps/loongarch/start.S | 9 +++++++--
3 files changed, 46 insertions(+), 12 deletions(-) 3 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure
index db6341e8..4f0ac252 100644 index db6341e8..4f0ac252 100644
@ -152,10 +152,10 @@ index 603085cd..bfe4e0f2 100644
if test "$libc_cv_static_pie_on_loongarch" = yes; then if test "$libc_cv_static_pie_on_loongarch" = yes; then
AC_DEFINE(SUPPORT_STATIC_PIE) AC_DEFINE(SUPPORT_STATIC_PIE)
diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S
index cb2b6c5b..11e4cede 100644 index 1b15fc9c..87bb1d4e 100644
--- a/sysdeps/loongarch/start.S --- a/sysdeps/loongarch/start.S
+++ b/sysdeps/loongarch/start.S +++ b/sysdeps/loongarch/start.S
@@ -44,13 +44,16 @@ ENTRY (ENTRY_POINT) @@ -44,11 +44,16 @@ ENTRY (ENTRY_POINT)
cfi_undefined (1) cfi_undefined (1)
or a5, a0, zero /* rtld_fini */ or a5, a0, zero /* rtld_fini */
@ -168,8 +168,6 @@ index cb2b6c5b..11e4cede 100644
+ produce PLT entries for them. GNU ld >= 2.40 supports this. */ + produce PLT entries for them. GNU ld >= 2.40 supports this. */
# define LA la.pcrel # define LA la.pcrel
#else #else
-/* We must get symbol main through GOT table, since main may not be local.
- For instance: googletest defines main in dynamic library. */
+/* Old GNU ld (< 2.40) cannot handle PC relative address against a non-local +/* Old GNU ld (< 2.40) cannot handle PC relative address against a non-local
+ function correctly. We deem these old linkers failing to support static PIE + function correctly. We deem these old linkers failing to support static PIE
+ and load the addresses from GOT. */ + and load the addresses from GOT. */
@ -177,5 +175,5 @@ index cb2b6c5b..11e4cede 100644
#endif #endif
-- --
2.27.0 2.33.0

View File

@ -1,4 +1,4 @@
From 23e0c7122bb0510d9375d4cbf365720e3ce63a91 Mon Sep 17 00:00:00 2001 From c79112989afeadee37d64698eb4a922290b4e436 Mon Sep 17 00:00:00 2001
From: wanghongliang <wanghongliang@loongson.cn> From: wanghongliang <wanghongliang@loongson.cn>
Date: Wed, 21 Dec 2022 14:39:59 +0800 Date: Wed, 21 Dec 2022 14:39:59 +0800
Subject: [PATCH] LoongArch Port. Subject: [PATCH] LoongArch Port.
@ -24,7 +24,7 @@ Change-Id: Ia618b0101a483a2e07b8ecd114130907eb8ca5db
sysdeps/loongarch/configure | 4 + sysdeps/loongarch/configure | 4 +
sysdeps/loongarch/configure.ac | 6 + sysdeps/loongarch/configure.ac | 6 +
sysdeps/loongarch/dl-irel.h | 48 + sysdeps/loongarch/dl-irel.h | 48 +
sysdeps/loongarch/dl-machine.h | 359 +++ sysdeps/loongarch/dl-machine.h | 305 +++
sysdeps/loongarch/dl-tls.h | 46 + sysdeps/loongarch/dl-tls.h | 46 +
sysdeps/loongarch/dl-trampoline.S | 103 + sysdeps/loongarch/dl-trampoline.S | 103 +
sysdeps/loongarch/e_sqrtl.c | 39 + sysdeps/loongarch/e_sqrtl.c | 39 +
@ -70,21 +70,20 @@ Change-Id: Ia618b0101a483a2e07b8ecd114130907eb8ca5db
sysdeps/loongarch/nptl/pthreaddef.h | 34 + sysdeps/loongarch/nptl/pthreaddef.h | 34 +
sysdeps/loongarch/nptl/tcb-offsets.sym | 6 + sysdeps/loongarch/nptl/tcb-offsets.sym | 6 +
sysdeps/loongarch/nptl/tls.h | 138 ++ sysdeps/loongarch/nptl/tls.h | 138 ++
sysdeps/loongarch/preconfigure | 53 + sysdeps/loongarch/preconfigure | 52 +
sysdeps/loongarch/setjmp.S | 66 + sysdeps/loongarch/setjmp.S | 66 +
sysdeps/loongarch/sfp-machine.h | 102 + sysdeps/loongarch/sfp-machine.h | 102 +
sysdeps/loongarch/sotruss-lib.c | 50 + sysdeps/loongarch/sotruss-lib.c | 50 +
sysdeps/loongarch/stackinfo.h | 33 + sysdeps/loongarch/stackinfo.h | 33 +
sysdeps/loongarch/start.S | 70 + sysdeps/loongarch/start.S | 69 +
sysdeps/loongarch/sys/asm.h | 58 + sysdeps/loongarch/sys/asm.h | 58 +
sysdeps/loongarch/sys/ifunc.h | 30 + sysdeps/loongarch/sys/ifunc.h | 30 +
sysdeps/loongarch/sys/regdef.h | 98 + sysdeps/loongarch/sys/regdef.h | 98 +
sysdeps/loongarch/tininess.h | 1 + sysdeps/loongarch/tininess.h | 1 +
sysdeps/loongarch/tls-macros.h | 49 + sysdeps/loongarch/tls-macros.h | 49 +
sysdeps/loongarch/tst-audit.h | 23 + sysdeps/loongarch/tst-audit.h | 23 +
sysdeps/unix/sysv/linux/fstatat64.c | 12 +-
sysdeps/unix/sysv/linux/loongarch/Implies | 1 + sysdeps/unix/sysv/linux/loongarch/Implies | 1 +
sysdeps/unix/sysv/linux/loongarch/Makefile | 11 + sysdeps/unix/sysv/linux/loongarch/Makefile | 10 +
.../unix/sysv/linux/loongarch/arch-syscall.h | 292 +++ .../unix/sysv/linux/loongarch/arch-syscall.h | 292 +++
.../sysv/linux/loongarch/atomic-machine.h | 196 ++ .../sysv/linux/loongarch/atomic-machine.h | 196 ++
.../unix/sysv/linux/loongarch/bits/fcntl.h | 61 + .../unix/sysv/linux/loongarch/bits/fcntl.h | 61 +
@ -132,7 +131,7 @@ Change-Id: Ia618b0101a483a2e07b8ecd114130907eb8ca5db
.../sysv/linux/loongarch/ucontext-macros.h | 32 + .../sysv/linux/loongarch/ucontext-macros.h | 32 +
.../unix/sysv/linux/loongarch/ucontext_i.sym | 31 + .../unix/sysv/linux/loongarch/ucontext_i.sym | 31 +
sysdeps/unix/sysv/linux/loongarch/vfork.S | 50 + sysdeps/unix/sysv/linux/loongarch/vfork.S | 50 +
126 files changed, 10427 insertions(+), 2 deletions(-) 125 files changed, 10359 insertions(+), 1 deletion(-)
create mode 100644 sysdeps/loongarch/Implies create mode 100644 sysdeps/loongarch/Implies
create mode 100644 sysdeps/loongarch/Makefile create mode 100644 sysdeps/loongarch/Makefile
create mode 100644 sysdeps/loongarch/__longjmp.S create mode 100644 sysdeps/loongarch/__longjmp.S
@ -273,7 +272,7 @@ index 13101496..89596a83 100644
#undef __LINUX_KERNEL_VERSION #undef __LINUX_KERNEL_VERSION
diff --git a/elf/elf.h b/elf/elf.h diff --git a/elf/elf.h b/elf/elf.h
index c5315d1b..4119f784 100644 index a64576bb..088f9764 100644
--- a/elf/elf.h --- a/elf/elf.h
+++ b/elf/elf.h +++ b/elf/elf.h
@@ -358,8 +358,9 @@ typedef struct @@ -358,8 +358,9 @@ typedef struct
@ -287,7 +286,7 @@ index c5315d1b..4119f784 100644
/* Old spellings/synonyms. */ /* Old spellings/synonyms. */
@@ -4036,6 +4037,74 @@ enum @@ -4038,6 +4039,74 @@ enum
#define R_NDS32_TLS_TPOFF 102 #define R_NDS32_TLS_TPOFF 102
#define R_NDS32_TLS_DESC 119 #define R_NDS32_TLS_DESC 119
@ -832,10 +831,10 @@ index 00000000..9fd106a3
+#endif /* dl-irel.h */ +#endif /* dl-irel.h */
diff --git a/sysdeps/loongarch/dl-machine.h b/sysdeps/loongarch/dl-machine.h diff --git a/sysdeps/loongarch/dl-machine.h b/sysdeps/loongarch/dl-machine.h
new file mode 100644 new file mode 100644
index 00000000..84f0ab81 index 00000000..b6eac3ae
--- /dev/null --- /dev/null
+++ b/sysdeps/loongarch/dl-machine.h +++ b/sysdeps/loongarch/dl-machine.h
@@ -0,0 +1,359 @@ @@ -0,0 +1,305 @@
+/* Machine-dependent ELF dynamic relocation inline functions. +/* Machine-dependent ELF dynamic relocation inline functions.
+ Copyright (C) 2021 Free Software Foundation, Inc. + Copyright (C) 2021 Free Software Foundation, Inc.
+ +
@ -883,13 +882,7 @@ index 00000000..84f0ab81
+#define ELF_MACHINE_IRELATIVE R_LARCH_IRELATIVE +#define ELF_MACHINE_IRELATIVE R_LARCH_IRELATIVE
+ +
+#define elf_machine_type_class(type) \ +#define elf_machine_type_class(type) \
+ ((ELF_RTYPE_CLASS_PLT * ((type) == ELF_MACHINE_JMP_SLOT \ + ((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))) + | (ELF_RTYPE_CLASS_COPY *((type) == R_LARCH_COPY)))
+ +
+#define ELF_MACHINE_NO_REL 1 +#define ELF_MACHINE_NO_REL 1
@ -906,78 +899,52 @@ index 00000000..84f0ab81
+ return 1; + return 1;
+} +}
+ +
+/* Runtime address of .got */ +/* Return the run-time load address of the shared object. */
+#define _GLOBAL_OFFSET_TABLE_ \ +static inline ElfW (Addr) elf_machine_load_address (void)
+ ({ \ +{
+ ElfW (Addr) * r; \ + extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
+ asm("la.pcrel %0, _GLOBAL_OFFSET_TABLE_" : "=r"(r)); \ + return (ElfW(Addr)) &__ehdr_start;
+ r; \ +}
+ })
+ +
+/* Return the link-time address of _DYNAMIC. */ +/* Return the link-time address of _DYNAMIC. */
+static inline ElfW (Addr) elf_machine_dynamic (void) +static inline ElfW (Addr) elf_machine_dynamic (void)
+{ +{
+ return _GLOBAL_OFFSET_TABLE_[0]; + extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+} + return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
+
+#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. +/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point; + The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point. */ + its return value is the user program's entry point. */
+ +
+#define RTLD_START \ +#define RTLD_START asm (\
+ asm(".text\n\ + ".text\n\
+ " _RTLD_PROLOGUE (ENTRY_POINT) "\ + " _RTLD_PROLOGUE (ENTRY_POINT) "\
+ .cfi_label .Ldummy \n\ + .cfi_label .Ldummy \n\
+ " CFI_UNDEFINED (1) " \n\ + " CFI_UNDEFINED (1) " \n\
+ or $a0, $sp, $zero \n\ + or $a0, $sp, $zero \n\
+ bl _dl_start \n\ + bl _dl_start \n\
+ # Stash user entry point in s0. \n\ + # Stash user entry point in s0. \n\
+ or $s0, $v0, $zero \n\ + or $s0, $a0, $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\ + # Load the original argument count. \n\
+ ld.d $a1, $sp, 0 \n\ + ld.d $a1, $sp, 0 \n\
+ # Subtract _dl_skip_args from it. \n\ + # Call _dl_init (struct link_map *main_map, int argc, \
+ sub.d $a1, $a1, $a0 \n\ + char **argv, char **env) \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\ + la $a0, _rtld_local \n\
+ ld.d $a0, $a0, 0 \n\ + ld.d $a0, $a0, 0 \n\
+ addi.d $a2, $sp, 8 \n\ + addi.d $a2, $sp, 8 \n\
+ slli.d $a3, $a1, 3 \n\ + slli.d $a3, $a1, 3 \n\
+ add.d $a3, $a3, $a2 \n\ + add.d $a3, $a3, $a2 \n\
+ addi.d $a3, $a3, 8 \n\ + addi.d $a3, $a3, 8 \n\
+ # Stash the stack pointer in s1.\n\
+ or $s1, $sp, $zero \n\
+ # Adjust $sp for 16-aligned \n\ + # Adjust $sp for 16-aligned \n\
+ srli.d $t0, $sp, 4 \n\ + bstrins.d $sp, $zero, 3, 0 \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\ + # Call the function to run the initializers. \n\
+ bl _dl_init \n\ + bl _dl_init \n\
+ # Restore the stack pointer for _start.\n\
+ or $sp, $s1, $zero \n\
+ # Pass our finalizer function to _start. \n\ + # Pass our finalizer function to _start. \n\
+ ld.d $sp, $sp, 24 \n\
+ la $a0, _dl_fini \n\ + la $a0, _dl_fini \n\
+ # Jump to the user entry point. \n\ + # Jump to the user entry point. \n\
+ jirl $zero, $s0, 0 \n\ + jirl $zero, $s0, 0 \n\
@ -1032,6 +999,14 @@ index 00000000..84f0ab81
+ +
+ switch (r_type) + switch (r_type)
+ { + {
+ case R_LARCH_JUMP_SLOT:
+ case __WORDSIZE == 64 ? R_LARCH_64 : R_LARCH_32:
+ *addr_field = value;
+ break;
+
+ case R_LARCH_NONE:
+ break;
+
+#ifndef RTLD_BOOTSTRAP +#ifndef RTLD_BOOTSTRAP
+ case __WORDSIZE == 64 ? R_LARCH_TLS_DTPMOD64: + case __WORDSIZE == 64 ? R_LARCH_TLS_DTPMOD64:
+ R_LARCH_TLS_DTPMOD32: + R_LARCH_TLS_DTPMOD32:
@ -1087,42 +1062,19 @@ index 00000000..84f0ab81
+ memcpy (reloc_addr, (void *) value, size); + memcpy (reloc_addr, (void *) value, size);
+ break; + break;
+ } + }
+#endif
+
+#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
+ case R_LARCH_RELATIVE: + 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; + *addr_field = map->l_addr + reloc->r_addend;
+ break; + break;
+ } + }
+#endif
+
+ case R_LARCH_JUMP_SLOT:
+ case __WORDSIZE == 64 ? R_LARCH_64:
+ R_LARCH_32:
+ *addr_field = value;
+ break;
+ +
+ case R_LARCH_IRELATIVE: + case R_LARCH_IRELATIVE:
+ value = map->l_addr + reloc->r_addend; + value = map->l_addr + reloc->r_addend;
+ if (__glibc_likely (!skip_ifunc))
+ value = ((ElfW (Addr) (*) (void)) value) (); + value = ((ElfW (Addr) (*) (void)) value) ();
+ *addr_field = value; + *addr_field = value;
+ break; + break;
+ +#endif
+ case R_LARCH_NONE:
+ break;
+ +
+ default: + default:
+ _dl_reloc_bad_type (map, r_type, 0); + _dl_reloc_bad_type (map, r_type, 0);
@ -1156,13 +1108,6 @@ index 00000000..84f0ab81
+ else + else
+ *reloc_addr = map->l_mach.plt; + *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 + else
+ _dl_reloc_bad_type (map, r_type, 1); + _dl_reloc_bad_type (map, r_type, 1);
+} +}
@ -4749,10 +4694,10 @@ index 00000000..3b17e0b7
+#endif /* tls.h */ +#endif /* tls.h */
diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure
new file mode 100644 new file mode 100644
index 00000000..118963cd index 00000000..2e3abb9e
--- /dev/null --- /dev/null
+++ b/sysdeps/loongarch/preconfigure +++ b/sysdeps/loongarch/preconfigure
@@ -0,0 +1,53 @@ @@ -0,0 +1,52 @@
+# This file is generated from configure.ac by Autoconf. DO NOT EDIT! +# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
+# Local preconfigure fragment for sysdeps/loongarch +# Local preconfigure fragment for sysdeps/loongarch
+ +
@ -4805,7 +4750,6 @@ index 00000000..118963cd
+ base_machine=loongarch + base_machine=loongarch
+ ;; + ;;
+esac +esac
+
diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S
new file mode 100644 new file mode 100644
index 00000000..00ea14b2 index 00000000..00ea14b2
@ -5083,10 +5027,10 @@ index 00000000..a990a471
+#endif /* stackinfo.h */ +#endif /* stackinfo.h */
diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S
new file mode 100644 new file mode 100644
index 00000000..9ecfb5e2 index 00000000..0deda78a
--- /dev/null --- /dev/null
+++ b/sysdeps/loongarch/start.S +++ b/sysdeps/loongarch/start.S
@@ -0,0 +1,70 @@ @@ -0,0 +1,69 @@
+/* Startup code compliant to the ELF LoongArch ABI. +/* Startup code compliant to the ELF LoongArch ABI.
+ Copyright (C) 2021 Free Software Foundation, Inc. + Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library. + This file is part of the GNU C Library.
@ -5156,7 +5100,6 @@ index 00000000..9ecfb5e2
+ la.got ra, t0, abort + la.got ra, t0, abort
+ jirl ra, ra, 0 + jirl ra, ra, 0
+END (ENTRY_POINT) +END (ENTRY_POINT)
+
diff --git a/sysdeps/loongarch/sys/asm.h b/sysdeps/loongarch/sys/asm.h diff --git a/sysdeps/loongarch/sys/asm.h b/sysdeps/loongarch/sys/asm.h
new file mode 100644 new file mode 100644
index 00000000..1133f761 index 00000000..1133f761
@ -5452,36 +5395,6 @@ index 00000000..de120d8a
+#define La_regs La_loongarch_regs +#define La_regs La_loongarch_regs
+#define La_retval La_loongarch_retval +#define La_retval La_loongarch_retval
+#define int_retval lrv_a0 +#define int_retval lrv_a0
diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index f968e4ef..711ccf7e 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -135,6 +135,16 @@ fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf,
return r;
}
+#if defined (__loongarch__)
+#if (__WORDSIZE == 32 \
+ && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) \
+ || defined STAT_HAS_TIME32 \
+ || (!defined __NR_newfstatat && !defined __NR_fstatat64)
+# define FSTATAT_USE_STATX 1
+#else
+# define FSTATAT_USE_STATX 0
+#endif
+#else
#if (__WORDSIZE == 32 \
&& (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) \
|| defined STAT_HAS_TIME32
@@ -142,7 +152,7 @@ fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf,
#else
# define FSTATAT_USE_STATX 0
#endif
-
+#endif
int
__fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf,
int flag)
diff --git a/sysdeps/unix/sysv/linux/loongarch/Implies b/sysdeps/unix/sysv/linux/loongarch/Implies diff --git a/sysdeps/unix/sysv/linux/loongarch/Implies b/sysdeps/unix/sysv/linux/loongarch/Implies
new file mode 100644 new file mode 100644
index 00000000..e52b1ac3 index 00000000..e52b1ac3
@ -5491,10 +5404,10 @@ index 00000000..e52b1ac3
+loongarch/nptl +loongarch/nptl
diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile diff --git a/sysdeps/unix/sysv/linux/loongarch/Makefile b/sysdeps/unix/sysv/linux/loongarch/Makefile
new file mode 100644 new file mode 100644
index 00000000..99ac734f index 00000000..e205ce83
--- /dev/null --- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/Makefile +++ b/sysdeps/unix/sysv/linux/loongarch/Makefile
@@ -0,0 +1,11 @@ @@ -0,0 +1,10 @@
+ifeq ($(subdir),elf) +ifeq ($(subdir),elf)
+ifeq ($(build-shared),yes) +ifeq ($(build-shared),yes)
+# This is needed for DSO loading from static binaries. +# This is needed for DSO loading from static binaries.
@ -5505,7 +5418,6 @@ index 00000000..99ac734f
+ifeq ($(subdir),stdlib) +ifeq ($(subdir),stdlib)
+gen-as-const-headers += ucontext_i.sym +gen-as-const-headers += ucontext_i.sym
+endif +endif
+
diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
new file mode 100644 new file mode 100644
index 00000000..c1ff6cb6 index 00000000..c1ff6cb6
@ -11472,5 +11384,5 @@ index 00000000..585f98ee
+weak_alias (__vfork, vfork) +weak_alias (__vfork, vfork)
+strong_alias (__vfork, __libc_vfork) +strong_alias (__vfork, __libc_vfork)
-- --
2.31.1 2.33.0

View File

@ -70,7 +70,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.34 Version: 2.34
Release: 140 Release: 141
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -306,7 +306,6 @@ Patch9018: 0002-elf-ld.so-add-testcase-for-ld.so-load-shared-object-.patch
Patch9019: 0003-elf-ld.so-use-special-mmap-for-hugepage-to-get-symbo.patch Patch9019: 0003-elf-ld.so-use-special-mmap-for-hugepage-to-get-symbo.patch
Patch9020: malloc-use-__get_nprocs-replace-__get_nprocs_sched.patch Patch9020: malloc-use-__get_nprocs-replace-__get_nprocs_sched.patch
Patch9021: x86-use-total-l3cache-for-non_temporal_threshold.patch Patch9021: x86-use-total-l3cache-for-non_temporal_threshold.patch
%ifarch loongarch64
Patch9022: login-Add-back-libutil-as-an-empty-library.patch Patch9022: login-Add-back-libutil-as-an-empty-library.patch
Patch9023: malloc-Fix-malloc-debug-for-2.35-onwards.patch Patch9023: malloc-Fix-malloc-debug-for-2.35-onwards.patch
Patch9024: LoongArch-Port.patch Patch9024: LoongArch-Port.patch
@ -321,7 +320,6 @@ Patch9032: LoongArch-Fix-ptr-mangling-demangling-and-SHMLBA.patch
Patch9033: LoongArch-Add-static-PIE-support.patch Patch9033: LoongArch-Add-static-PIE-support.patch
Patch9034: LoongArch-Fix-the-condition-to-use-PC-relative-addre.patch Patch9034: LoongArch-Fix-the-condition-to-use-PC-relative-addre.patch
Patch9035: LoongArch-Further-refine-the-condition-to-enable-sta.patch Patch9035: LoongArch-Further-refine-the-condition-to-enable-sta.patch
%endif
Patch9036: add-pthread_cond_clockwait-GLIBC_2_28.patch Patch9036: add-pthread_cond_clockwait-GLIBC_2_28.patch
Patch9037: 0001-ld.so-support-ld.so-mmap-hugetlb-hugepage-according-.patch Patch9037: 0001-ld.so-support-ld.so-mmap-hugetlb-hugepage-according-.patch
Patch9038: 0002-elf-ld.so-keep-compatible-with-the-original-policy-o.patch Patch9038: 0002-elf-ld.so-keep-compatible-with-the-original-policy-o.patch
@ -1228,7 +1226,7 @@ elf/ld.so --library-path .:elf:nptl:dlfcn \
%endif %endif
popd popd
%endif # %{run_glibc_tests} %endif
############################################################################## ##############################################################################
# Install and uninstall scripts # Install and uninstall scripts
@ -1504,6 +1502,9 @@ fi
%endif %endif
%changelog %changelog
* Mon Nov 13 2023 lixing <lixing@loongson.cn> - 2.34-141
- Fixup LoongArch Port errors
* Thu Nov 9 2023 doupengda <doupengda@loongson.cn> - 2.34-140 * Thu Nov 9 2023 doupengda <doupengda@loongson.cn> - 2.34-140
- Modify patch 9030 defined multiple times - Modify patch 9030 defined multiple times