aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-01-07Remove dbl-64/wordsize-64 (part 2)Wilco Dijkstra
Remove the wordsize-64 implementations by merging them into the main dbl-64 directory. The second patch just moves all wordsize-64 files and removes a few wordsize-64 uses in comments and Implies files. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-01-07Remove dbl-64/wordsize-64Wilco Dijkstra
Remove the wordsize-64 implementations by merging them into the main dbl-64 directory. The first patch adds special cases needed for 32-bit targets (FIX_INT_FP_CONVERT_ZERO and FIX_DBL_LONG_CONVERT_OVERFLOW) to the wordsize-64 versions. This has no effect on 64-bit targets since they don't define these macros. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-01-06Add SEGV_MTEAERR and SEGV_MTESERR from Linux 5.10.Joseph Myers
Linux 5.10 adds constants SEGV_MTEAERR and SEGV_MTESERR to asm-generic/siginfo.h. Add these to glibc's bits/siginfo-consts.h. Tested for x86_64.
2021-01-05support: Add support_small_thread_stack_sizeAdhemerval Zanella
It returns the minimum stack size large enough to cover most internal glibc stack usage.
2021-01-05stdlib: Sync canonicalize with gnulib [BZ #10635] [BZ #26592] [BZ #26341] ↵Adhemerval Zanella
[BZ #24970] It sync with gnulib version ae9fb3d66. The testcase for BZ#23741 (stdlib/test-bz22786.c) is adjusted to check also for ENOMEM. The patch fixes multiple realpath issues: - Portability fixes for errno clobbering on free (BZ#10635). The function does not call free directly anymore, although it might be done through scratch_buffer_free. The free errno clobbering is being tracked by BZ#17924. - Pointer arithmetic overflows in realpath (BZ#26592). - Realpath cyclically call __alloca(path_max) to consume too much stack space (BZ#26341). - Realpath mishandles EOVERFLOW; stat not needed anyway (BZ#24970). The check is done through faccessat now. Checked on x86_64-linux-gnu and i686-linux-gnu.
2021-01-05malloc: Add scratch_buffer_dupfreeAdhemerval Zanella
It returns a copy of the buffer up to a defined size. It will be used on realpath sync with gnulib.
2021-01-05Import filename.h from gnulibAdhemerval Zanella
And use to simplify stdlib/canonicalize.c implementation.
2021-01-05Import idx.h from gnulibAdhemerval Zanella
And use to simplify stdlib/canonicalize.c implementation.
2021-01-05alpha: Provide wait4 for static library [BZ #27150]Adhemerval Zanella
This ia regression from 09153638cfef91, versioned_symbol acts as weak_alias for !SHARED but it is undefined to avoid non versioned alias from the generic implementation. Checked with a build for alpha-linux-gnu.
2021-01-05aarch64: push the set of rules before falling into slow pathShuo Wang
It is supposed to save the rules for the instructions before falling into slow path. Tested in glibc-2.28 before fixing: Thread 2 "xxxxxxx" hit Breakpoint 1, _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 149 stp x1, x2, [sp, #-32]! Missing separate debuginfos, use: dnf debuginfo-install libgcc-7.3.0-20190804.h24.aarch64 (gdb) ni _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150 150 stp x3, x4, [sp, #16] (gdb) _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 157 mrs x4, tpidr_el0 (gdb) 158 ldr PTR_REG (1), [x0,#TLSDESC_ARG] (gdb) 159 ldr PTR_REG (0), [x4,#TCBHEAD_DTV] (gdb) 160 ldr PTR_REG (3), [x1,#TLSDESC_GEN_COUNT] (gdb) 161 ldr PTR_REG (2), [x0,#DTV_COUNTER] (gdb) 162 cmp PTR_REG (3), PTR_REG (2) (gdb) 163 b.hi 2f (gdb) 165 ldp PTR_REG (2), PTR_REG (3), [x1,#TLSDESC_MODID] (gdb) 166 add PTR_REG (0), PTR_REG (0), PTR_REG (2), lsl #(PTR_LOG_SIZE + 1) (gdb) 167 ldr PTR_REG (0), [x0] /* Load val member of DTV entry. */ (gdb) 168 cmp PTR_REG (0), #TLS_DTV_UNALLOCATED (gdb) 169 b.eq 2f (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:169 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=4294967295) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 (gdb) ni _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:184 184 stp x29, x30, [sp,#-16*NSAVEXREGPAIRS]! (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:184 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=4294967295) at /home/test/test_function.c:30 #2 0x0000000000000000 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) Co-authored-by: liqingqing <liqingqing3@huawei.com>
2021-01-04nptl: Fix comment typo in pthread_cond_wait.cJangwoong Kim
2021-01-04x86: Check IFUNC definition in unrelocated executable [BZ #20019]H.J. Lu
Calling an IFUNC function defined in unrelocated executable also leads to segfault. Issue a fatal error message when calling IFUNC function defined in the unrelocated executable from a shared library.
2021-01-04hurd: Fix mmap(!MAP_FIXED) on bogus addressSamuel Thibault
In the !MAP_FIXED case, when a bogus address is given mmap should pick up a valide address rather than returning EINVAL: Posix only talks about EINVAL for the MAP_FIXED case. This fixes long-running ghc processes.
2021-01-04x86-64: Avoid rep movsb with short distance [BZ #27130]H.J. Lu
When copying with "rep movsb", if the distance between source and destination is N*4GB + [1..63] with N >= 0, performance may be very slow. This patch updates memmove-vec-unaligned-erms.S for AVX and AVX512 versions with the distance in RCX: cmpl $63, %ecx // Don't use "rep movsb" if ECX <= 63 jbe L(Don't use rep movsb") Use "rep movsb" Benchtests data with bench-memcpy, bench-memcpy-large, bench-memcpy-random and bench-memcpy-walk on Skylake, Ice Lake and Tiger Lake show that its performance impact is within noise range as "rep movsb" is only used for data size >= 4KB.
2021-01-04aarch64: fix stack missing after sp is updatedShuo Wang
After sp is updated, the CFA offset should be set before next instruction. Tested in glibc-2.28: Thread 2 "xxxxxxx" hit Breakpoint 1, _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 149 stp x1, x2, [sp, #-32]! Missing separate debuginfos, use: dnf debuginfo-install libgcc-7.3.0-20190804.h24.aarch64 (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 (gdb) ni _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150 150 stp x3, x4, [sp, #16] (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000000000 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) ni _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 157 mrs x4, tpidr_el0 (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 Signed-off-by: liqingqing <liqingqing3@huawei.com> Signed-off-by: Shuo Wang <wangshuo47@huawei.com>
2021-01-04nptl: Remove set*id, set*gid files which are not builtFlorian Weimer
2021-01-04Drop nan-pseudo-number.h usage from testsSiddhesh Poyarekar
Make the tests use TEST_COND_intel96 to decide on whether to build the unnormal tests instead of the macro in nan-pseudo-number.h and then drop the header inclusion. This unbreaks test runs on all architectures that do not have ldbl-96. Also drop the HANDLE_PSEUDO_NUMBERS macro since it is not used anywhere.
2021-01-04posix: Sync fnmatch with gnulibAdhemerval Zanella
It sync with gnulib commit 43ee1a6bf. Checked on x86_64-linux-gnu.
2021-01-04Sync flexmember.h with gnulibAdhemerval Zanella
It sync with gnulib commit 43ee1a6bf.
2021-01-04Sync intprops.h with gnulibAdhemerval Zanella
It sync with gnulib commit 43ee1a6bf. Checked on x86_64-linux-gnu.
2021-01-04posix: Sync glob code with gnulibAdhemerval Zanella
It sync with gnulib commit 43ee1a6bf and fixes and use-after-free bug (gnulib commit 717766da8926e36). Checked on x86_64-linux-gnu.
2021-01-04posix: Sync regex code with gnulibAdhemerval Zanella
It sync with gnulib commit 43ee1a6bf. The main change is 9682f18e9. (which does not have a meaniful description). Checked on x86_64-linux-gnu.
2021-01-04Move generic nan-pseudo-number.h to ldbl-96Siddhesh Poyarekar
The concept of pseudo number formats only exists in the realm of the 96 bit long double format.
2021-01-02Sync FDL from https://www.gnu.org/licenses/fdl-1.3.texiPaul Eggert
2021-01-02Sync move-if-change from GnulibPaul Eggert
This alters move-if-change so that its --version option outputs the correct copyright date automatically. One less thing to update by hand.
2021-01-02Update automatically-generated copyright datesPaul Eggert
These were updated simply by running "make" to regen the files.
2021-01-02Update copyright dates not handled by scripts/update-copyrights.Paul Eggert
I've updated copyright dates in glibc for 2021. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. As well as the usual annual updates, mainly dates in --version output (minus csu/version.c which previously had to be handled manually but is now successfully updated by update-copyrights), there is a small change to the copyright notice in NEWS which should let NEWS get updated automatically next year. Please remember to include 2021 in the dates for any new files added in future (which means updating any existing uncommitted patches you have that add new files to use the new copyright dates in them).
2021-01-02Update copyright dates with scripts/update-copyrightsPaul Eggert
I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
2020-12-31aarch64: use PTR_ARG and SIZE_ARG instead of DELOUSESzabolcs Nagy
DELOUSE was added to asm code to make them compatible with non-LP64 ABIs, but it is an unfortunate name and the code was not compatible with ABIs where pointer and size_t are different. Glibc currently only supports the LP64 ABI so these macros are not really needed or tested, but for now the name is changed to be more meaningful instead of removing them completely. Some DELOUSE macros were dropped: clone, strlen and strnlen used it unnecessarily. The out of tree ILP32 patches are currently not maintained and will likely need a rework to rebase them on top of the time64 changes.
2020-12-31nonstring: Enable __FORTIFY_LEVEL=3Siddhesh Poyarekar
Use __builtin_dynamic_object_size in the remaining functions that don't have compiler builtins as is the case for string functions.
2020-12-31string: Enable __FORTIFY_LEVEL=3Siddhesh Poyarekar
This change enhances fortified string functions to use __builtin_dynamic_object_size under _FORTIFY_SOURCE=3 whenever the compiler supports it.
2020-12-31Introduce _FORTIFY_SOURCE=3Siddhesh Poyarekar
Introduce a new _FORTIFY_SOURCE level of 3 to enable additional fortifications that may have a noticeable performance impact, allowing more fortification coverage at the cost of some performance. With llvm 9.0 or later, this will replace the use of __builtin_object_size with __builtin_dynamic_object_size. __builtin_dynamic_object_size ----------------------------- __builtin_dynamic_object_size is an LLVM builtin that is similar to __builtin_object_size. In addition to what __builtin_object_size does, i.e. replace the builtin call with a constant object size, __builtin_dynamic_object_size will replace the call site with an expression that evaluates to the object size, thus expanding its applicability. In practice, __builtin_dynamic_object_size evaluates these expressions through malloc/calloc calls that it can associate with the object being evaluated. A simple motivating example is below; -D_FORTIFY_SOURCE=2 would miss this and emit memcpy, but -D_FORTIFY_SOURCE=3 with the help of __builtin_dynamic_object_size is able to emit __memcpy_chk with the allocation size expression passed into the function: void *copy_obj (const void *src, size_t alloc, size_t copysize) { void *obj = malloc (alloc); memcpy (obj, src, copysize); return obj; } Limitations ----------- If the object was allocated elsewhere that the compiler cannot see, or if it was allocated in the function with a function that the compiler does not recognize as an allocator then __builtin_dynamic_object_size also returns -1. Further, the expression used to compute object size may be non-trivial and may potentially incur a noticeable performance impact. These fortifications are hence enabled at a new _FORTIFY_SOURCE level to allow developers to make a choice on the tradeoff according to their environment.
2020-12-31Warn on unsupported fortification levelsSiddhesh Poyarekar
Make the _FORTIFY_SOURCE macro soup in features.h warn about unsupported fortification levels. For example, it will warn about _FORTIFY_SOURCE=3 and over with an indication of which level has been selected. Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
2020-12-30powerpc: Use scv instruction on clone when availableMatheus Castanho
clone already uses r31 to temporarily save input arguments before doing the syscall, so we use a different register to read from the TCB. We can also avoid allocating another stack frame, which is not needed since we can simply extend the usage of the red zone. Tested-by: Lucas A. M. Magalhães <lamm@linux.ibm.com> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2020-12-30powerpc: Runtime selection between sc and scv for syscallsMatheus Castanho
Linux kernel v5.9 added support for system calls using the scv instruction for POWER9 and later. The new codepath provides better performance (see below) if compared to using sc. For the foreseeable future, both sc and scv mechanisms will co-exist, so this patch enables glibc to do a runtime check and use scv when it is available. Before issuing the system call to the kernel, we check hwcap2 in the TCB for PPC_FEATURE2_SCV to see if scv is supported by the kernel. If not, we fallback to sc and keep the old behavior. The kernel implements a different error return convention for scv, so when returning from a system call we need to handle the return value differently depending on the instruction we used to enter the kernel. For syscalls implemented in ASM, entry and exit are implemented by different macros (PSEUDO and PSEUDO_RET, resp.), which may be used in sequence (e.g. for templated syscalls) or with other instructions in between (e.g. clone). To avoid accessing the TCB a second time on PSEUDO_RET to check which instruction we used, the value read from hwcap2 is cached on a non-volatile register. This is not needed when using INTERNAL_SYSCALL macro, since entry and exit are bundled into the same inline asm directive. The dynamic loader may issue syscalls before the TCB has been setup so it always uses sc with no extra checks. For the static case, there is no compile-time way to determine if we are inside startup code, so we also check the value of the thread pointer before effectively accessing the TCB. For such situations in which the availability of scv cannot be determined, sc is always used. Support for scv in syscalls implemented in their own ASM file (clone and vfork) will be added later. For now simply use sc as before. Average performance over 1M calls for each syscall "type": - stat: C wrapper calling INTERNAL_SYSCALL - getpid: templated ASM syscall - syscall: call to gettid using syscall function Standard: stat : 1.573445 us / ~3619 cycles getpid : 0.164986 us / ~379 cycles syscall : 0.162743 us / ~374 cycles With scv: stat : 1.537049 us / ~3535 cycles <~ -84 cycles / -2.32% getpid : 0.109923 us / ~253 cycles <~ -126 cycles / -33.25% syscall : 0.116410 us / ~268 cycles <~ -106 cycles / -28.34% Tested on powerpc, powerpc64, powerpc64le (with and without scv) Tested-by: Lucas A. M. Magalhães <lamm@linux.ibm.com> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2020-12-30malloc: preserve errno on mcheck hooks [BZ #17924]Adhemerval Zanella
Similar to the fix 69fda43b8d, save and restore errno for the hook functions used for MALLOC_CHECK_=3. It fixes the malloc/tst-free-errno-mcheck regression. Checked on x86_64-linux-gnu.
2020-12-30x86 long double: Add tests for pseudo normal numbersSiddhesh Poyarekar
Add some tests for fpclassify, isnan, isinf and issignaling. Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-30x86 long double: Consider pseudo numbers as signalingSiddhesh Poyarekar
Add support to treat pseudo-numbers specially and implement x86 version to consider all of them as signaling. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-29io: Remove xmknod{at} implementationsAdhemerval Zanella
With xmknod wrapper functions removed (589260cef8), the mknod functions are now properly exported, and version is done using symbols versioning instead of the extra _MKNOD_* argument. It also allows us to consolidate Linux and Hurd mknod implementation. Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-12-29io: Remove xstat implementationsAdhemerval Zanella
With xstat wrapper functions removed (8ed005daf0), the stat functions are now properly exported, and version is done using symbols versioning instead of the extra _STAT_* argument. Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-12-29free: preserve errno [BZ#17924]Paul Eggert
In the next release of POSIX, free must preserve errno <https://www.austingroupbugs.net/view.php?id=385>. Modify __libc_free to save and restore errno, so that any internal munmap etc. syscalls do not disturb the caller's errno. Add a test malloc/tst-free-errno.c (almost all by Bruno Haible), and document that free preserves errno. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-29hurd: Accept including hurd/version.hSamuel Thibault
We need it to get the RPC API version.
2020-12-28hurd: Add WSTOPPED/WCONTINUED/WEXITED/WNOWAIT support [BZ #23091]Samuel Thibault
The new __proc_waitid RPC now expects WEXITED to be passed, allowing to properly implement waitid, and thus define the missing W* macros (according to FreeBSD values).
2020-12-28support: Make support_process_state_wait wait lessSamuel Thibault
Tests such as posix/tst-waitid.c make heavy use of support_process_state_wait, and thus on non-Linux where it falls back to sleeping, a 2s sleep makes such test time out, while 1s remains fine enough.
2020-12-26hurd: set sigaction for signal preemptors in arch-independent fileSamuel Thibault
Instead of having the arch-specific trampoline setup code detect whether preemption happened or not, we'd rather pass it the sigaction. In the future, this may also allow to change sa_flags from post_signal().
2020-12-26hurd: Fix spawni SPAWN_XFLAGS_TRY_SHELL with empty argvSamuel Thibault
When argv is empty, we need to add the original script to be run on the shell command line.
2020-12-26hurd: Try shell in posix_spawn* only in compat modeSamuel Thibault
Reported by Bruno Haible <bruno@clisp.org>
2020-12-24Remove _ISOMAC check from <cpu-features.h>H.J. Lu
Remove _ISOMAC check from <cpu-features.h> since it isn't an installer header file.
2020-12-24x86: Remove the duplicated CPU_FEATURE_CPU_PH.J. Lu
CPU_FEATURE_CPU_P is defined in sysdeps/x86/sys/platform/x86.h. Remove the duplicated CPU_FEATURE_CPU_P in sysdeps/x86/include/cpu-features.h.
2020-12-24Partially revert 681900d29683722b1cb0a8e565a0585846ec5a61Siddhesh Poyarekar
Do not attempt to fix the significand top bit in long double input received in printf. The code should never reach here because isnan should now detect unnormals as NaN. This is already a NOP for glibc since it uses the gcc __builtin_isnan, which detects unnormals as NaN. Reviewed-by: Florian Weimer <fweimer@redhat.com>