[PATCH] glibc: add arc700 patch

Rosen Penev rosenp at gmail.com
Thu Dec 24 19:36:16 EST 2020


glibc does not officially support ARC700 so this adds the missing
pieces. I looked at uClibc-ng and a patch by Synopsis for glibc.

ran make toolchain/glibc/refresh to clean up fuzz.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 toolchain/glibc/common.mk                     |  2 +-
 ...use-of-DES-encryption-functions-in-n.patch | 87 +++++++------------
 .../glibc/patches/100-fix_cross_rpcgen.patch  |  1 +
 toolchain/glibc/patches/300-arc.patch         | 55 ++++++++++++
 4 files changed, 87 insertions(+), 58 deletions(-)
 create mode 100644 toolchain/glibc/patches/300-arc.patch

diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk
index faf749eea3..555bd19a61 100644
--- a/toolchain/glibc/common.mk
+++ b/toolchain/glibc/common.mk
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=glibc
 PKG_VERSION:=2.32
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
diff --git a/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch b/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch
index 002e7a1770..10d9f65d18 100644
--- a/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch
+++ b/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch
@@ -23,11 +23,9 @@ provides them.
  sunrpc/des_soft.c          |   2 +-
  13 files changed, 305 insertions(+), 90 deletions(-)
 
-diff --git a/conform/data/stdlib.h-data b/conform/data/stdlib.h-data
-index 6913828196..d8fcccc2fb 100644
 --- a/conform/data/stdlib.h-data
 +++ b/conform/data/stdlib.h-data
-@@ -149,6 +149,9 @@ function {unsigned short int*} seed48 (unsigned short int[3])
+@@ -149,6 +149,9 @@ function {unsigned short int*} seed48 (u
  #if !defined ISO && !defined ISO99 && !defined ISO11 && !defined POSIX && !defined XPG4 && !defined XPG42 && !defined UNIX98
  function int setenv (const char*, const char*, int)
  #endif
@@ -37,8 +35,6 @@ index 6913828196..d8fcccc2fb 100644
  #if !defined ISO && !defined ISO99 && !defined ISO11 && !defined XPG4 && !defined POSIX && !defined POSIX2008
  function {char*} setstate (char*)
  #endif
-diff --git a/conform/data/unistd.h-data b/conform/data/unistd.h-data
-index aa070528e8..ddf4f25132 100644
 --- a/conform/data/unistd.h-data
 +++ b/conform/data/unistd.h-data
 @@ -437,6 +437,9 @@ function int chroot (const char*)
@@ -61,8 +57,6 @@ index aa070528e8..ddf4f25132 100644
  function int execl (const char*, const char*, ...)
  function int execle (const char*, const char*, ...)
  function int execlp (const char*, const char*, ...)
-diff --git a/crypt/cert.c b/crypt/cert.c
-index e070ca398d..80029e9078 100644
 --- a/crypt/cert.c
 +++ b/crypt/cert.c
 @@ -10,22 +10,6 @@
@@ -102,8 +96,6 @@ index e070ca398d..80029e9078 100644
 -}
 -
 -#endif
-diff --git a/crypt/crypt-entry.c b/crypt/crypt-entry.c
-index 502b5846f0..09332c690a 100644
 --- a/crypt/crypt-entry.c
 +++ b/crypt/crypt-entry.c
 @@ -35,7 +35,6 @@
@@ -114,7 +106,7 @@ index 502b5846f0..09332c690a 100644
  
  /* Prototypes for local functions.  */
  #ifndef __GNU_LIBRARY__
-@@ -177,7 +176,17 @@ crypt (const char *key, const char *salt)
+@@ -177,7 +176,17 @@ crypt (const char *key, const char *salt
    return __crypt_r (key, salt, &_ufc_foobar);
  }
  
@@ -134,8 +126,6 @@ index 502b5846f0..09332c690a 100644
 +  return crypt (key, salt);
 +}
  #endif
-diff --git a/crypt/crypt.h b/crypt/crypt.h
-index ca8ad456cc..7d0de95018 100644
 --- a/crypt/crypt.h
 +++ b/crypt/crypt.h
 @@ -36,6 +36,14 @@ __BEGIN_DECLS
@@ -168,8 +158,6 @@ index ca8ad456cc..7d0de95018 100644
  #endif
  
  __END_DECLS
-diff --git a/crypt/crypt_util.c b/crypt/crypt_util.c
-index 4b2f0a89cb..b012cde6bd 100644
 --- a/crypt/crypt_util.c
 +++ b/crypt/crypt_util.c
 @@ -34,7 +34,6 @@
@@ -196,7 +184,7 @@ index 4b2f0a89cb..b012cde6bd 100644
  
  /*
   * This is the final
-@@ -788,7 +785,6 @@ _ufc_output_conversion_r (ufc_long v1, ufc_long v2, const char *salt,
+@@ -788,7 +785,6 @@ _ufc_output_conversion_r (ufc_long v1, u
    __data->crypt_3_buf[13] = 0;
  }
  
@@ -204,7 +192,7 @@ index 4b2f0a89cb..b012cde6bd 100644
  
  /*
   * UNIX encrypt function. Takes a bitvector
-@@ -889,14 +885,12 @@ __encrypt_r (char *__block, int __edflag,
+@@ -889,14 +885,12 @@ __encrypt_r (char *__block, int __edflag
    }
  }
  weak_alias (__encrypt_r, encrypt_r)
@@ -219,7 +207,7 @@ index 4b2f0a89cb..b012cde6bd 100644
  
  
  /*
-@@ -921,15 +915,12 @@ __setkey_r (const char *__key, struct crypt_data * __restrict __data)
+@@ -921,15 +915,12 @@ __setkey_r (const char *__key, struct cr
    _ufc_mk_keytab_r((char *) ktab, __data);
  }
  weak_alias (__setkey_r, setkey_r)
@@ -235,11 +223,9 @@ index 4b2f0a89cb..b012cde6bd 100644
  
  void
  __b64_from_24bit (char **cp, int *buflen,
-diff --git a/manual/conf.texi b/manual/conf.texi
-index f959b00bb6..51fb2f5aa1 100644
 --- a/manual/conf.texi
 +++ b/manual/conf.texi
-@@ -780,8 +780,6 @@ Inquire about the parameter corresponding to @code{_XOPEN_LEGACY}.
+@@ -780,8 +780,6 @@ Inquire about the parameter correspondin
  @item _SC_XOPEN_CRYPT
  @standards{X/Open, unistd.h}
  Inquire about the parameter corresponding to @code{_XOPEN_CRYPT}.
@@ -248,11 +234,9 @@ index f959b00bb6..51fb2f5aa1 100644
  
  @item _SC_XOPEN_ENH_I18N
  @standards{X/Open, unistd.h}
-diff --git a/manual/crypt.texi b/manual/crypt.texi
-index af23dd7847..1b151f2d74 100644
 --- a/manual/crypt.texi
 +++ b/manual/crypt.texi
-@@ -16,8 +16,19 @@ subject to them, even if you do not use the functions in this chapter
+@@ -16,8 +16,19 @@ subject to them, even if you do not use
  yourself.  The restrictions vary from place to place and are changed
  often, so we cannot give any more specific advice than this warning.
  
@@ -272,7 +256,7 @@ index af23dd7847..1b151f2d74 100644
  * Unpredictable Bytes::         Randomness for cryptographic purposes.
  @end menu
  
-@@ -190,6 +201,199 @@ unpredictable as possible; @pxref{Unpredictable Bytes}.
+@@ -190,6 +201,199 @@ unpredictable as possible; @pxref{Unpred
  @include genpass.c.texi
  @end smallexample
  
@@ -472,8 +456,6 @@ index af23dd7847..1b151f2d74 100644
  The next program demonstrates how to verify a passphrase.  It checks a
  hash hardcoded into the program, because looking up real users' hashed
  passphrases may require special privileges (@pxref{User Database}).
-diff --git a/manual/string.texi b/manual/string.texi
-index 23f516439a..5586b52dee 100644
 --- a/manual/string.texi
 +++ b/manual/string.texi
 @@ -36,8 +36,8 @@ too.
@@ -487,7 +469,7 @@ index 23f516439a..5586b52dee 100644
  * Encode Binary Data::          Encoding and Decoding of Binary Data.
  * Argz and Envz Vectors::       Null-separated string vectors.
  @end menu
-@@ -2426,73 +2426,73 @@ functionality under a different name, such as @code{explicit_memset},
+@@ -2426,73 +2426,73 @@ functionality under a different name, su
  systems it may be in @file{strings.h} instead.
  @end deftypefun
  
@@ -538,10 +520,19 @@ index 23f516439a..5586b52dee 100644
  
 - at node Obfuscating Data
 - at section Obfuscating Data
-- at cindex Rot13
 + at node Trivial Encryption
 + at section Trivial Encryption
 + at cindex encryption
++
++
++The @code{memfrob} function converts an array of data to something
++unrecognizable and back again.  It is not encryption in its usual sense
++since it is easy for someone to convert the encrypted data back to clear
++text.  The transformation is analogous to Usenet's ``Rot13'' encryption
++method for obscuring offensive jokes from sensitive eyes and such.
++Unlike Rot13, @code{memfrob} works on arbitrary binary data, not just
++text.
+ @cindex Rot13
  
 -The @code{memfrob} function reversibly obfuscates an array of binary
 -data.  This is not true encryption; the obfuscated data still bears a
@@ -549,20 +540,12 @@ index 23f516439a..5586b52dee 100644
 -undo the obfuscation.  It is analogous to the ``Rot13'' cipher used on
 -Usenet for obscuring offensive jokes, spoilers for works of fiction,
 -and so on, but it can be applied to arbitrary binary data.
- 
+-
 -Programs that need true encryption---a transformation that completely
 -obscures the original and cannot be reversed without knowledge of a
 -secret key---should use a dedicated cryptography library, such as
 - at uref{https://www.gnu.org/software/libgcrypt/,,libgcrypt}.
-+The @code{memfrob} function converts an array of data to something
-+unrecognizable and back again.  It is not encryption in its usual sense
-+since it is easy for someone to convert the encrypted data back to clear
-+text.  The transformation is analogous to Usenet's ``Rot13'' encryption
-+method for obscuring offensive jokes from sensitive eyes and such.
-+Unlike Rot13, @code{memfrob} works on arbitrary binary data, not just
-+text.
-+ at cindex Rot13
- 
+-
 -Programs that need to @emph{destroy} data should use
 - at code{explicit_bzero} (@pxref{Erasing Sensitive Data}), or possibly
 - at code{strfry} (@pxref{Shuffling Bytes}).
@@ -579,13 +562,14 @@ index 23f516439a..5586b52dee 100644
 -beginning at @var{mem}, in place.  Each byte is bitwise xor-ed with
 -the binary pattern 00101010 (hexadecimal 0x2A).  The return value is
 -always @var{mem}.
+-
+- at code{memfrob} a second time on the same data returns it to
+-its original state.
 + at code{memfrob} transforms (frobnicates) each byte of the data structure
 +at @var{mem}, which is @var{length} bytes long, by bitwise exclusive
 +oring it with binary 00101010.  It does the transformation in place and
 +its return value is always @var{mem}.
- 
-- at code{memfrob} a second time on the same data returns it to
--its original state.
++
 +Note that @code{memfrob} a second time on the same data structure
 +returns it to its original state.
 +
@@ -600,8 +584,6 @@ index 23f516439a..5586b52dee 100644
  @end deftypefun
  
  @node Encode Binary Data
-diff --git a/posix/unistd.h b/posix/unistd.h
-index 32b8161619..6fac59999f 100644
 --- a/posix/unistd.h
 +++ b/posix/unistd.h
 @@ -107,6 +107,9 @@ __BEGIN_DECLS
@@ -614,7 +596,7 @@ index 32b8161619..6fac59999f 100644
  /* The enhanced internationalization capabilities according to XPG4.2
     are present.  */
  #define	_XOPEN_ENH_I18N	1
-@@ -1129,17 +1132,25 @@ ssize_t copy_file_range (int __infd, __off64_t *__pinoff,
+@@ -1129,17 +1132,25 @@ ssize_t copy_file_range (int __infd, __o
  extern int fdatasync (int __fildes);
  #endif /* Use POSIX199309 */
  
@@ -643,11 +625,9 @@ index 32b8161619..6fac59999f 100644
  /* Swab pairs bytes in the first N bytes of the area pointed to by
     FROM and copy the result to TO.  The value of TO must not be in the
     range [FROM - N + 1, FROM - 1].  If N is odd the first byte in FROM
-diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
-index 3aa27a9d25..67e5e66f94 100644
 --- a/stdlib/stdlib.h
 +++ b/stdlib/stdlib.h
-@@ -962,6 +962,12 @@ extern int getsubopt (char **__restrict __optionp,
+@@ -962,6 +962,12 @@ extern int getsubopt (char **__restrict
  #endif
  
  
@@ -660,11 +640,9 @@ index 3aa27a9d25..67e5e66f94 100644
  /* X/Open pseudo terminal handling.  */
  
  #ifdef __USE_XOPEN2KXSI
-diff --git a/sunrpc/des_crypt.c b/sunrpc/des_crypt.c
-index 9b4bd2d5dd..a4d8b2936b 100644
 --- a/sunrpc/des_crypt.c
 +++ b/sunrpc/des_crypt.c
-@@ -86,9 +86,6 @@ common_crypt (char *key, char *buf, register unsigned len,
+@@ -86,9 +86,6 @@ common_crypt (char *key, char *buf, regi
    return desdev == DES_SW ? DESERR_NONE : DESERR_NOHWDEVICE;
  }
  
@@ -674,7 +652,7 @@ index 9b4bd2d5dd..a4d8b2936b 100644
  /*
   * CBC mode encryption
   */
-@@ -105,7 +102,7 @@ cbc_crypt (char *key, char *buf, unsigned int len, unsigned int mode,
+@@ -105,7 +102,7 @@ cbc_crypt (char *key, char *buf, unsigne
    COPY8 (dp.des_ivec, ivec);
    return err;
  }
@@ -683,14 +661,12 @@ index 9b4bd2d5dd..a4d8b2936b 100644
  
  /*
   * ECB mode encryption
-@@ -118,4 +115,4 @@ ecb_crypt (char *key, char *buf, unsigned int len, unsigned int mode)
+@@ -118,4 +115,4 @@ ecb_crypt (char *key, char *buf, unsigne
    dp.des_mode = ECB;
    return common_crypt (key, buf, len, mode, &dp);
  }
 -hidden_nolink (ecb_crypt, libc, GLIBC_2_1)
 +libc_hidden_nolink_sunrpc (ecb_crypt, GLIBC_2_1)
-diff --git a/sunrpc/des_soft.c b/sunrpc/des_soft.c
-index a87de96cc7..f884f8f21b 100644
 --- a/sunrpc/des_soft.c
 +++ b/sunrpc/des_soft.c
 @@ -71,4 +71,4 @@ des_setparity (char *p)
@@ -699,6 +675,3 @@ index a87de96cc7..f884f8f21b 100644
  }
 -hidden_nolink (des_setparity, libc, GLIBC_2_1)
 +libc_hidden_nolink_sunrpc (des_setparity, GLIBC_2_1)
--- 
-2.25.1
-
diff --git a/toolchain/glibc/patches/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/100-fix_cross_rpcgen.patch
index 6ee1e80424..9baed08139 100644
--- a/toolchain/glibc/patches/100-fix_cross_rpcgen.patch
+++ b/toolchain/glibc/patches/100-fix_cross_rpcgen.patch
@@ -33,3 +33,4 @@
 +typedef char *caddr_t;
  # define __daddr_t_defined
  #endif
+ 
diff --git a/toolchain/glibc/patches/300-arc.patch b/toolchain/glibc/patches/300-arc.patch
new file mode 100644
index 0000000000..66f7aeb3ef
--- /dev/null
+++ b/toolchain/glibc/patches/300-arc.patch
@@ -0,0 +1,55 @@
+--- a/sysdeps/arc/atomic-machine.h
++++ b/sysdeps/arc/atomic-machine.h
+@@ -64,6 +64,10 @@ typedef uintmax_t uatomic_max_t;
+   __atomic_val_bysize (__arch_compare_and_exchange_val, int,		\
+ 		       mem, new, old, __ATOMIC_ACQUIRE)
+ 
++#ifdef __ARC700__
++#define atomic_full_barrier()  ({ asm volatile ("sync":::"memory"); })
++#else
+ #define atomic_full_barrier()  ({ asm volatile ("dmb 3":::"memory"); })
++#endif
+ 
+ #endif /* _ARC_BITS_ATOMIC_H */
+--- a/sysdeps/unix/sysv/linux/arc/syscall.S
++++ b/sysdeps/unix/sysv/linux/arc/syscall.S
+@@ -24,8 +24,13 @@ ENTRY (syscall)
+ 	mov_s	r1, r2
+ 	mov_s	r2, r3
+ 	mov_s	r3, r4
++#ifdef __ARC700__
++	mov	r4, r5
++	mov	r5, r6
++#else
+ 	mov_s	r4, r5
+ 	mov_s	r5, r6
++#endif
+ 
+ 	ARC_TRAP_INSN
+ 	brhi	r0, -4096, L (call_syscall_err)
+--- a/sysdeps/unix/sysv/linux/arc/sysdep.h
++++ b/sysdeps/unix/sysv/linux/arc/sysdep.h
+@@ -128,7 +128,11 @@ L (call_syscall_err):			ASM_LINE_SEP	\
+     mov    r8, __NR_##syscall_name	ASM_LINE_SEP	\
+     ARC_TRAP_INSN			ASM_LINE_SEP
+ 
++# ifdef __ARC700__
++# define ARC_TRAP_INSN	trap0
++# else
+ # define ARC_TRAP_INSN	trap_s 0
++# endif
+ 
+ #else  /* !__ASSEMBLER__ */
+ 
+@@ -139,7 +143,11 @@ extern long int __syscall_error (long in
+ hidden_proto (__syscall_error)
+ # endif
+ 
++# ifdef __ARC700__
++# define ARC_TRAP_INSN	"trap0		\n\t"
++# else
+ # define ARC_TRAP_INSN	"trap_s 0	\n\t"
++#endif
+ 
+ # undef INTERNAL_SYSCALL_NCS
+ # define INTERNAL_SYSCALL_NCS(number, nr_args, args...)	\
-- 
2.29.2




More information about the openwrt-devel mailing list