Skip to content

Commit 59817b9

Browse files
committed
Upstream merge
2 parents cbde42f + 54b7564 commit 59817b9

File tree

907 files changed

+10274
-5418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

907 files changed

+10274
-5418
lines changed

COPYRIGHT

-6
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ in jurisdictions that may not recognize the public domain.
126126
The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
127127
Valentin Ochs and is licensed under an MIT-style license.
128128

129-
The BSD PRNG implementation (src/prng/random.c) and XSI search API
130-
(src/search/*.c) functions are Copyright © 2011 Szabolcs Nagy and
131-
licensed under following terms: "Permission to use, copy, modify,
132-
and/or distribute this code for any purpose with or without fee is
133-
hereby granted. There is no warranty."
134-
135129
The x86_64 port was written by Nicholas J. Kain and is licensed under
136130
the standard MIT terms.
137131

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ CFLAGS_AUTO = -Os -pipe
4646
CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
4747

4848
CFLAGS_ALL = $(CFLAGS_C99FSE)
49-
CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
49+
CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/include -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
5050
CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
5151

5252
LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.19
1+
1.1.22

WHATSNEW

+170
Original file line numberDiff line numberDiff line change
@@ -1907,3 +1907,173 @@ bugs fixed:
19071907
arch-specfic bugs fixed:
19081908
- x32 unistd.h wrongly reported LP64 instead of ILP32
19091909
- aarch64 signal.h had wrong type for ucontext_t uc_link member
1910+
1911+
1912+
1.1.20 release notes
1913+
1914+
new features:
1915+
- m68k port
1916+
- replacement of malloc is now allowed/supported
1917+
- setvbuf now accepts caller-provided buffers for stdio streams
1918+
- getrandom syscall wrapper, getentropy function
1919+
- mlock2 syscall wrapper
1920+
- memfd_create syscall wrapper
1921+
- explicit_bzero function
1922+
- header-level support for new linux features through 4.17
1923+
- wcsftime now supports padding specifier extensions
1924+
- dynamic linker's reclaim_gaps now works on fdpic archs
1925+
- getaddrinfo now honors AI_ADDRCONFIG
1926+
- pthread_attr_init now honors pthread_setattr_default_np defaults
1927+
1928+
hardening:
1929+
- prevent bypass of guarantee that suids start with fd 0/1/2 open
1930+
- dlopen now rejects libraries with initial-exec refs to dynamic TLS
1931+
1932+
compatibility:
1933+
- elf.h: new flags, aux vector entry types, etc.
1934+
- minor namespace issues in several headers
1935+
- intNN_t types used in bitfields now safe against -funsigned-bitfields
1936+
- complex arc trig/hyperbolic functions were badly broken
1937+
- nice function returned wrong value
1938+
- stdio locks no longer depend on read-after-free not faulting
1939+
- avoid excessive stack usage in getcwd
1940+
- inet_ntop no longer compresses single zeros in IPv6 (RFC 5952)
1941+
- resolver routability probe for sorting results works on no-IPv6 systems
1942+
- added missing ST_RELATIME definition to statvfs.h
1943+
- uchar.h now works with old C++ profiles
1944+
- added missing and arch-specific commands to ptrace.h
1945+
- musl-gcc wrapper now works with default-pie host toolchains
1946+
1947+
bugs fixed:
1948+
- getopt wrongly treating colons in optstring as valid option chars
1949+
- nl_langinfo_l(CODESET, loc) reported wrong locale's value
1950+
- out-of-tree build produced broken crt files with stack protector enabled
1951+
- fmaf produced wrong result for some corner cases
1952+
- out of bounds write for zero length buffer passed to gethostname
1953+
- getopt_long_only wrongly prefix-matched long-options over short ones
1954+
- pthread_kill wrongly returned ESRCH for exited by valid pthread_t's
1955+
- iconv buffer overflow converting to legacy JIS-based encodings
1956+
- iconv conversion to "UTF-32" (no explicit endianness) failed (regression)
1957+
- iconv mishandled big5-hkscs characters that map to two unicode chars
1958+
- dynamic linker didn't map/clear bss for libraries with single LOAD segment
1959+
- resolver wrongly duplicated trailing dot from query into canonical name
1960+
- some futex waits omitted timeout arg to syscall, thereby spun on EFAULT
1961+
- dladdr mishandled addresses not matching symbols
1962+
- alignment of dirent structures from readdir was broken (regression)
1963+
- strftime %z output wrong sign for offsets <1 hour west of UTC
1964+
- limits.h, pathconf erroneously defined SYMLINK_MAX
1965+
- FP_ILOGB0 and FP_ILOGBNAN definitions were not valid for use in #if
1966+
- getopt failed to update optarg and optind correctly on missing argument
1967+
- EMULTIHOP error lacked strerror text
1968+
- mktime malfunctioned with tm_isdst>0 but no-DST POSIX-format time zone
1969+
- async thread self-cancellation produced a deadlock condition
1970+
- pthread_barrierattr_setpshared failed to produce EINVAL for bad argument
1971+
- fileno failed to produce EBADF for non-fd-associated FILEs
1972+
- fmemopen's w+ mode failed to truncate buffer at open
1973+
- open_[w]memstream did not bind stream orientation at open time
1974+
- system wrongly returned 0x7f00 instead of -1 on error
1975+
- wide printf functions ignored field width for %c formats
1976+
- fprintf failed to set stream orientation for unbuffered stream or no output
1977+
- psignal, psiginfo, and perror wrongly set stream orientation for stderr
1978+
- psignal, psiginfo potentially clobbered errno on success
1979+
1980+
arch-specfic bugs fixed:
1981+
- on arm/aarch64/sh, local-exec TLS layout mismatched ABI with large align
1982+
- on arm/microblaze/sh, struct ipc_perm mismatched (buggy) kernel ABI
1983+
- SO_PEERSEC definition was wrong on mips
1984+
- on mips, return from start function passed to clone crashed (runaway exec)
1985+
- printf %a precision specifier malfunctioned except on ld80 archs
1986+
- async thread cancellation crashed on powerpc64 and sh-fdpic
1987+
1988+
1989+
1.1.21 release notes
1990+
1991+
new features:
1992+
- setting default thread stack size via PT_GNU_STACK program header
1993+
- arm vfork implementation
1994+
- arm tlsdesc/gnu2 tls dialect support
1995+
- name_to_handle_at and name_to_handle_at syscall wrappers
1996+
- header-level support for new linux features through 4.18
1997+
1998+
optimizations:
1999+
- glob rewrite with much better performance and stack usage properties
2000+
- single-threaded and already-locked fast paths for getc/putc variants
2001+
- single-instruction fma implementations for arm, s390x, powerpc, & x86_64
2002+
- single-instruction fabs and sqrt implementations for powerpc
2003+
- size and performance from making all internal-only functions/data hidden
2004+
- made &errno and pthread_self results cachable again (attribute((const)))
2005+
- significant speedup in strtod with short inputs
2006+
- new tsearch AVL tree implementation, smaller and faster
2007+
- special-cased nop calls to wmemmove
2008+
- fixed erroneously suboptimal skip conditions in strstr and memmem
2009+
2010+
hardening:
2011+
- default thread stack guard size increased from 4k to 8k
2012+
2013+
compatibility:
2014+
- default thread stack size increased from 80k to 128k
2015+
- building for arm as thumb2 with clang internal assembler now works
2016+
- aio threads could overflow stack on kernels that break MINSIGSTKSZ ABI
2017+
- aio threads no longer call malloc (problematic with malloc replacement)
2018+
- pthread_sigmask/sigprocmask now ignore an invalid how when not changing mask
2019+
2020+
bugs fixed:
2021+
- soft deadlock regression in stdio FILE locks with >2 threads contending
2022+
- deadlock and buffered data loss race in fclose
2023+
- race condition leading to possible crash in dcngettext plural forms
2024+
- glob failed to see past searchable-but-unreadable path components
2025+
- getdelim wrongly realloc'd buffer that was already exactly right size
2026+
- getdelim failed to set stream orientation on early error
2027+
- ttyname[_r] reported wrong error when given bad fd
2028+
- pthread_key_delete left old tsd values exposed if slot was reused
2029+
- freeaddrinfo failed to support freeing sublists
2030+
- access to optopt was broken by copy relocations
2031+
- memccpy returned wrong result if first byte past buffer end matched
2032+
- wordexp read past end of input string ending in backslash
2033+
- sem_wait and sem_timedwait were wrongly not interruptible by signals
2034+
- getspnam[_r] wrongly treated not-found as an error
2035+
2036+
arch-specfic bugs fixed:
2037+
- soft deadlocks (missing futex wake) on powerpc locking
2038+
- dlsym returned wrong address for thread-local symbols on ppc/mips/m68k
2039+
2040+
2041+
1.1.22 release notes
2042+
2043+
new features:
2044+
- priority-inheritance mutexes
2045+
- membarrier syscall, pre-registration to use it, fallback emulation
2046+
- header-level support for new linux features in 4.19, 4.20, 5.0
2047+
2048+
major internal changes:
2049+
- complete, async-safe view of all existent threads as global list
2050+
- robust __synccall based on new thread list
2051+
- new dynamic TLS is installed synchronously at dlopen
2052+
- TLSDESC resolver functions no longer make bad ABI assumptions to call C
2053+
- resolved shared library dependencies are now recorded
2054+
2055+
compatibility & conformance:
2056+
- dependency-order shared library constructor execution
2057+
- sigaltstack no longer rejects SS_AUTODISARM, future flags
2058+
- FILE is now a complete (dummy) type in pre-C11 feature profiles
2059+
- setvbuf reports failure on invalid arguments
2060+
- TSVTX is exposed unconditionally in tar.h
2061+
- multithreaded set*id() no longer depends on /proc
2062+
- key slot reuse after pthread_key_delete no longer depends on /proc
2063+
2064+
bugs fixed:
2065+
- failures in multithreaded set*id() with concurrent thread creation/exit
2066+
- interposed free was called from invalid/inconsistent contexts
2067+
- freeaddrinfo performed invalid free of some partial results lists
2068+
- dlsym dependency order search had false negatives and false positives
2069+
- dn_skipname gave wrong results for labels with 8-bit content
2070+
- dcngettext clobbered errno, often breaking printing of error messages
2071+
- sscanf read past end of buffer under certain conditions (1.1.21 regression)
2072+
- pthread_key_create spuriously failed under race condition (1.1.21 regression)
2073+
- fdopendir wrongly succeeded with O_PATH file descriptors
2074+
- gets behaved incorrectly in presence of null bytes
2075+
- namespace violations in c11 tsd and mutex function dependencies
2076+
- incorrect prototype for makecontext (unimplemented)
2077+
2078+
arch-specfic bugs fixed:
2079+
- s390x had wrong values for POSIX_FADV_DONTNEED/_NOREUSE

arch/aarch64/bits/hwcap.h

+9
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@
2121
#define HWCAP_ASIMDDP (1 << 20)
2222
#define HWCAP_SHA512 (1 << 21)
2323
#define HWCAP_SVE (1 << 22)
24+
#define HWCAP_ASIMDFHM (1 << 23)
25+
#define HWCAP_DIT (1 << 24)
26+
#define HWCAP_USCAT (1 << 25)
27+
#define HWCAP_ILRCPC (1 << 26)
28+
#define HWCAP_FLAGM (1 << 27)
29+
#define HWCAP_SSBS (1 << 28)
30+
#define HWCAP_SB (1 << 29)
31+
#define HWCAP_PACA (1 << 30)
32+
#define HWCAP_PACG (1UL << 31)

arch/aarch64/bits/syscall.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,7 @@
274274
#define __NR_pkey_alloc 289
275275
#define __NR_pkey_free 290
276276
#define __NR_statx 291
277+
#define __NR_io_pgetevents 292
278+
#define __NR_rseq 293
279+
#define __NR_kexec_file_load 294
277280

arch/aarch64/fp_arch.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#define fp_barrierf fp_barrierf
2+
static inline float fp_barrierf(float x)
3+
{
4+
__asm__ __volatile__ ("" : "+w"(x));
5+
return x;
6+
}
7+
8+
#define fp_barrier fp_barrier
9+
static inline double fp_barrier(double x)
10+
{
11+
__asm__ __volatile__ ("" : "+w"(x));
12+
return x;
13+
}
14+
15+
#define fp_force_evalf fp_force_evalf
16+
static inline void fp_force_evalf(float x)
17+
{
18+
__asm__ __volatile__ ("" : "+w"(x));
19+
}
20+
21+
#define fp_force_eval fp_force_eval
22+
static inline void fp_force_eval(double x)
23+
{
24+
__asm__ __volatile__ ("" : "+w"(x));
25+
}

arch/aarch64/pthread_arch.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
static inline struct pthread *__pthread_self()
22
{
33
char *self;
4-
__asm__ __volatile__ ("mrs %0,tpidr_el0" : "=r"(self));
5-
return (void*)(self + 16 - sizeof(struct pthread));
4+
__asm__ ("mrs %0,tpidr_el0" : "=r"(self));
5+
return (void*)(self - sizeof(struct pthread));
66
}
77

88
#define TLS_ABOVE_TP
9-
#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) - 16)
9+
#define GAP_ABOVE_TP 16
10+
#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
1011

1112
#define MC_PC pc

arch/aarch64/reloc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define NO_LEGACY_INITFINI
1212

13-
#define TPOFF_K 16
13+
#define TPOFF_K 0
1414

1515
#define REL_SYMBOLIC R_AARCH64_ABS64
1616
#define REL_GOT R_AARCH64_GLOB_DAT

arch/arm/atomic_arch.h

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
#include "libc.h"
2+
13
#if __ARM_ARCH_4__ || __ARM_ARCH_4T__ || __ARM_ARCH == 4
24
#define BLX "mov lr,pc\n\tbx"
35
#else
46
#define BLX "blx"
57
#endif
68

7-
extern uintptr_t __attribute__((__visibility__("hidden")))
8-
__a_cas_ptr, __a_barrier_ptr;
9+
extern hidden uintptr_t __a_cas_ptr, __a_barrier_ptr;
910

10-
#if ((__ARM_ARCH_6__ || __ARM_ARCH_6K__ || __ARM_ARCH_6ZK__) && !__thumb__) \
11-
|| __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
11+
#if ((__ARM_ARCH_6__ || __ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \
12+
|| __ARM_ARCH_6T2__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
1213

1314
#define a_ll a_ll
1415
static inline int a_ll(volatile int *p)
@@ -91,4 +92,16 @@ static inline int a_clz_32(uint32_t x)
9192
return x;
9293
}
9394

95+
#if __ARM_ARCH_6T2__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
96+
97+
#define a_ctz_32 a_ctz_32
98+
static inline int a_ctz_32(uint32_t x)
99+
{
100+
uint32_t xr;
101+
__asm__ ("rbit %0, %1" : "=r"(xr) : "r"(x));
102+
return a_clz_32(xr);
103+
}
104+
105+
#endif
106+
94107
#endif

arch/arm/bits/ptrace.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#define PTRACE_GETWMMXREGS 18
2+
#define PTRACE_SETWMMXREGS 19
3+
#define PTRACE_GET_THREAD_AREA 22
4+
#define PTRACE_SET_SYSCALL 23
5+
#define PTRACE_GETCRUNCHREGS 25
6+
#define PTRACE_SETCRUNCHREGS 26
7+
#define PTRACE_GETVFPREGS 27
8+
#define PTRACE_SETVFPREGS 28
9+
#define PTRACE_GETHBPREGS 29
10+
#define PTRACE_SETHBPREGS 30
11+
#define PTRACE_GETFDPIC 31
12+
#define PTRACE_GETFDPIC_EXEC 0
13+
#define PTRACE_GETFDPIC_INTERP 1
14+
15+
#define PT_GETWMMXREGS PTRACE_GETWMMXREGS
16+
#define PT_SETWMMXREGS PTRACE_SETWMMXREGS
17+
#define PT_GET_THREAD_AREA PTRACE_GET_THREAD_AREA
18+
#define PT_SET_SYSCALL PTRACE_SET_SYSCALL
19+
#define PT_GETCRUNCHREGS PTRACE_GETCRUNCHREGS
20+
#define PT_SETCRUNCHREGS PTRACE_SETCRUNCHREGS
21+
#define PT_GETVFPREGS PTRACE_GETVFPREGS
22+
#define PT_SETVFPREGS PTRACE_SETVFPREGS
23+
#define PT_GETHBPREGS PTRACE_GETHBPREGS
24+
#define PT_SETHBPREGS PTRACE_SETHBPREGS
25+
#define PT_GETFDPIC PTRACE_GETFDPIC

arch/arm/bits/syscall.h.in

+2
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@
353353
#define __NR_pkey_alloc 395
354354
#define __NR_pkey_free 396
355355
#define __NR_statx 397
356+
#define __NR_rseq 398
357+
#define __NR_io_pgetevents 399
356358

357359
#define __ARM_NR_breakpoint 0x0f0001
358360
#define __ARM_NR_cacheflush 0x0f0002

arch/arm/pthread_arch.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#if ((__ARM_ARCH_6K__ || __ARM_ARCH_6ZK__) && !__thumb__) \
1+
#if ((__ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \
22
|| __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
33

44
static inline pthread_t __pthread_self()
55
{
66
char *p;
7-
__asm__ __volatile__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(p) );
8-
return (void *)(p+8-sizeof(struct pthread));
7+
__asm__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(p) );
8+
return (void *)(p-sizeof(struct pthread));
99
}
1010

1111
#else
@@ -18,15 +18,16 @@ static inline pthread_t __pthread_self()
1818

1919
static inline pthread_t __pthread_self()
2020
{
21-
extern uintptr_t __attribute__((__visibility__("hidden"))) __a_gettp_ptr;
21+
extern hidden uintptr_t __a_gettp_ptr;
2222
register uintptr_t p __asm__("r0");
23-
__asm__ __volatile__ ( BLX " %1" : "=r"(p) : "r"(__a_gettp_ptr) : "cc", "lr" );
24-
return (void *)(p+8-sizeof(struct pthread));
23+
__asm__ ( BLX " %1" : "=r"(p) : "r"(__a_gettp_ptr) : "cc", "lr" );
24+
return (void *)(p-sizeof(struct pthread));
2525
}
2626

2727
#endif
2828

2929
#define TLS_ABOVE_TP
30-
#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) - 8)
30+
#define GAP_ABOVE_TP 8
31+
#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
3132

3233
#define MC_PC arm_pc

arch/arm/reloc.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#define NO_LEGACY_INITFINI
1818

19-
#define TPOFF_K 8
19+
#define TPOFF_K 0
2020

2121
#define REL_SYMBOLIC R_ARM_ABS32
2222
#define REL_GOT R_ARM_GLOB_DAT
@@ -26,7 +26,9 @@
2626
#define REL_DTPMOD R_ARM_TLS_DTPMOD32
2727
#define REL_DTPOFF R_ARM_TLS_DTPOFF32
2828
#define REL_TPOFF R_ARM_TLS_TPOFF32
29-
//#define REL_TLSDESC R_ARM_TLS_DESC
29+
#define REL_TLSDESC R_ARM_TLS_DESC
30+
31+
#define TLSDESC_BACKWARDS
3032

3133
#define CRTJMP(pc,sp) __asm__ __volatile__( \
3234
"mov sp,%1 ; bx %0" : : "r"(pc), "r"(sp) : "memory" )

0 commit comments

Comments
 (0)