about summary refs log tree commit diff
path: root/sysdeps/mach
Commit message (Collapse)AuthorAgeFilesLines
* hurd: Export _hurd_libc_proc_initSamuel Thibault2021-04-121-0/+1
| | | | | hurd's libdiskfs needs to be able to call _hurd_init + _hurd_libc_proc_init for bootstrap initialization.
* Move __isnanf128 to libc.soSiddhesh Poyarekar2021-03-302-1/+2
| | | | | | | | All of the isnan functions are in libc.so due to printf_fp, so move __isnanf128 there too for consistency. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@ascii.art.br> Reviewed-by: Florian Weimer <fweimer@redhat.com>
* hurd: handle EINTR during critical sectionsSamuel Thibault2021-03-2322-2/+102
| | | | | | | | | During critical sections, signal handling is deferred and thus RPCs return EINTR, even if SA_RESTART is set. We thus have to restart the whole critical section in that case. This also adds HURD_CRITICAL_UNLOCK in the cases where one wants to break the section in the middle.
* signal: Add __libc_sigactionAdhemerval Zanella2021-03-181-7/+5
| | | | | | | | The generic implementation basically handle the system agnostic logic (filtering out the invalid signals) while the __libc_sigaction is the function with implements the system and architecture bits. Checked on x86_64-linux-gnu and i686-linux-gnu.
* posix: Consolidate register-atforkAdhemerval Zanella2021-03-121-11/+4
| | | | | | | | | | | | | Both htl and nptl uses a different data structure to implement atfork handlers. The nptl one was refactored by 27761a1042d to use a dynarray which simplifies the code. This patch moves the nptl one to be the generic implementation and replace Hurd linked one. Different than previous NPTL, Hurd also uses a global lock, so performance should be similar. Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for i686-gnu.
* Implement <unwind-link.h> for dynamically loading the libgcc_s unwinderFlorian Weimer2021-03-011-0/+3
| | | | | | | | | | This will be used to consolidate the libgcc_s access for backtrace and pthread_cancel. Unlike the existing backtrace implementations, it provides some hardening based on pointer mangling. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Reduce the statically linked startup code [BZ #23323]Florian Weimer2021-02-251-0/+1
| | | | | | | | | | | | | | | | | | | It turns out the startup code in csu/elf-init.c has a perfect pair of ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, "return-to-csu: A New Method to Bypass 64-bit Linux ASLR"). These functions are not needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY are already processed by the dynamic linker. However, the dynamic linker skipped the main program for some reason. For maximum backwards compatibility, this is not changed, and instead, the main map is consulted from __libc_start_main if the init function argument is a NULL pointer. For statically linked binaries, the old approach based on linker symbols is still used because there is nothing else available. A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because new binaries running on an old libc would not run their ELF constructors, leading to difficult-to-debug issues.
* hurd: Fix fstatfs build failureAdhemerval Zanella2021-02-111-1/+1
| | | | | | | It was added by 1bfbaf7130 where it added a libc_hidden_proto for __fstatfs but it didn't update the Hurd version as well. Checked with a build for i686-gnu.
* hurd TIOCFLUSH: fix fixing argumentSamuel Thibault2021-02-011-2/+2
| | | | The argument actually used inside send_rpc is argptr, not arg.
* hurd TIOCFLUSH: Cope BSD 4.1 semanticSamuel Thibault2021-02-011-0/+4
| | | | | | BSD 4.1 did not have an argument for TIOCFLUSH, BSD 4.2 added it. There are still a lot of applications out there that pass a NULL argument to TIOCFLUSH, so we should rather cope with it.
* Revert "linux: Move {f}xstat{at} to compat symbols" for static buildAdhemerval Zanella2021-01-218-12/+9
| | | | | | | | | | | | | | This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 for static library. This avoids the need to rebuild the world for the case where libstdc++ (and potentially other libraries) are linked to a old glibc. To avoid requering to provide xstat symbols for newer ABIs (such as riscv32) a new LIB_COMPAT macro is added. It is similar to SHLIB_COMPAT but also works for static case (thus evaluating similar to SHLIB_COMPAT for both shared and static case). Checked with a check-abi on all affected ABIs. I also check if the static library does contains the xstat symbols.
* <sys/platform/x86.h>: Remove the C preprocessor magicH.J. Lu2021-01-212-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In <sys/platform/x86.h>, define CPU features as enum instead of using the C preprocessor magic to make it easier to wrap this functionality in other languages. Move the C preprocessor magic to internal header for better GCC codegen when more than one features are checked in a single expression as in x86-64 dl-hwcaps-subdirs.c. 1. Rename COMMON_CPUID_INDEX_XXX to CPUID_INDEX_XXX. 2. Move CPUID_INDEX_MAX to sysdeps/x86/include/cpu-features.h. 3. Remove struct cpu_features and __x86_get_cpu_features from <sys/platform/x86.h>. 4. Add __x86_get_cpuid_feature_leaf to <sys/platform/x86.h> and put it in libc. 5. Make __get_cpu_features() private to glibc. 6. Replace __x86_get_cpu_features(N) with __get_cpu_features(). 7. Add _dl_x86_get_cpu_features to GLIBC_PRIVATE. 8. Use a single enum index for each CPU feature detection. 9. Pass the CPUID feature leaf to __x86_get_cpuid_feature_leaf. 10. Return zero struct cpuid_feature for the older glibc binary with a smaller CPUID_INDEX_MAX [BZ #27104]. 11. Inside glibc, use the C preprocessor magic so that cpu_features data can be loaded just once leading to more compact code for glibc. 256 bits are used for each CPUID leaf. Some leaves only contain a few features. We can add exceptions to such leaves. But it will increase code sizes and it is harder to provide backward/forward compatibilities when new features are added to such leaves in the future. When new leaves are added, _rtld_global_ro offsets will change which leads to race condition during in-place updates. We may avoid in-place updates by 1. Rename the old glibc. 2. Install the new glibc. 3. Remove the old glibc. NB: A function, __x86_get_cpuid_feature_leaf , is used to avoid the copy relocation issue with IFUNC resolver as shown in IFUNC resolver tests.
* Hurd: Add rtld-strncpy-c.cH.J. Lu2021-01-191-0/+1
| | | | | All IFUNC functions which are used in ld.so must have a rtld version if the IFUNC version isn't safe to use in ld.so.
* hurd: Fix mmap(!MAP_FIXED) on bogus addressSamuel Thibault2021-01-041-3/+6
| | | | | | | | 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.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-02383-383/+383
| | | | | | | | | | | | | | | | 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
* io: Remove xmknod{at} implementationsAdhemerval Zanella2020-12-292-31/+1
| | | | | | | | | | 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>
* io: Remove xstat implementationsAdhemerval Zanella2020-12-291-1/+3
| | | | | | | | 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>
* hurd: Add WSTOPPED/WCONTINUED/WEXITED/WNOWAIT support [BZ #23091]Samuel Thibault2020-12-281-10/+30
| | | | | | 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).
* hurd: set sigaction for signal preemptors in arch-independent fileSamuel Thibault2020-12-261-15/+2
| | | | | | 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().
* hurd: Fix spawni SPAWN_XFLAGS_TRY_SHELL with empty argvSamuel Thibault2020-12-261-1/+5
| | | | | When argv is empty, we need to add the original script to be run on the shell command line.
* hurd: Try shell in posix_spawn* only in compat modeSamuel Thibault2020-12-261-1/+1
| | | | Reported by Bruno Haible <bruno@clisp.org>
* hurd: Make trampoline fill siginfo ss_sp from sc_uespSamuel Thibault2020-12-211-1/+1
| | | | Mach actually rather fills the uesp field, not esp.
* hurd: implement SA_SIGINFO signal handlers.Jeremie Koenig2020-12-216-62/+198
| | | | | | | SA_SIGINFO is actually just another way of expressing what we were already passing over with struct sigcontext. This just introduces the SIGINFO interface and fixes the posix values when that interface is requested by the application.
* hurd: Note when the vm_map kernel bug was fixedSamuel Thibault2020-12-201-1/+1
| | | | | dl-sysdep has been wanting to use high bits in the vm_map mask for decades, but that was only implemented lately.
* Replace __libc_multiple_libcs with __libc_initial flagFlorian Weimer2020-12-162-6/+6
| | | | | | | | | | | | | | Change sbrk to fail for !__libc_initial (in the generic implementation). As a result, sbrk is (relatively) safe to use for the __libc_initial case (from the main libc). It is therefore no longer necessary to avoid using it in that case (or updating the brk cache), and the __libc_initial flag does not need to be updated as part of dlmopen or static dlopen. As before, direct brk system calls on Linux may lead to memory corruption. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* htl: Get sem_open/sem_close/sem_unlink support [BZ #25524]Samuel Thibault2020-12-161-7/+0
| | | | | This just moves the existing nptl implementation to reuse as it is in htl.
* htl: Add pshared semaphore supportSamuel Thibault2020-12-161-1/+0
| | | | | | The implementation is extremely similar to the nptl implementation, but with slight differences in the futex interface. This fixes some of BZ 25521.
* hurd: Add __libc_open and __libc_closeSamuel Thibault2020-12-161-0/+1
| | | | Needed by libpthread for sem_open and sem_close
* hurd: make lll_* take a variable instead of a ptrSamuel Thibault2020-12-169-26/+26
| | | | | To be coherent with other ports, let's make lll_* take a variable, and rename those that keep taking a ptr into __lll_*.
* hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZERSamuel Thibault2020-12-161-4/+4
| | | | To get coherent with other ports.
* nss: Implement <nss_database.h>Florian Weimer2020-12-041-0/+8
| | | | | | | | | | | This code manages the mappings of the available databases in NSS (i.e. passwd, hosts, netgroup, etc) with the actions that should be taken to do a query on those databases. This is the main API between query functions scattered throughout glibc and the underlying code (actions, modules, etc). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* hurd: Enable using ifuncSamuel Thibault2020-11-162-6/+0
| | | | Bugs have been fixed in binutils/gcc/glibc.
* Add {,sysdep-}ld-library-path make variableSamuel Thibault2020-11-161-0/+2
| | | | | | | | On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some more paths, here mach/ and hurd/.
* hurd: let _dl_argv and __libc_stack_end be relroSamuel Thibault2020-11-151-7/+0
| | | | libpthread does not switch stacks.
* hurd: Remove some remnants of cthreadsSamuel Thibault2020-11-156-8/+10
| | | | | Libc has actually been using mach's lock-internal.h mutex for a long time already.
* hurd: Drop CLOCK_MONOTONIC change which slipped inSamuel Thibault2020-11-141-1/+0
|
* hurd: make ptsname fail with ENOTTY on non-master-ptySamuel Thibault2020-11-141-0/+8
|
* mach: Add missing assert.h includeSamuel Thibault2020-11-141-0/+2
|
* hurd: break relocation loop between libc.so and lib{mach,hurd}user.soSamuel Thibault2020-11-141-0/+12
| | | | | | | | | | | | | See https://sourceware.org/pipermail/libc-alpha/2020-November/119575.html lib{mach,hurd}user.so gets relocated before libc.so, but its references to strpcpy and memcpy would need an ifunc decision, which e.g. on x86 relies on cpu_features, but libc.so's _rtld_global_ro is not relocated yet. We can however just make lib{mach,hurd}user.so only call non-ifunc functions, which can be relocated before libc.so is relocated.
* Remove tls.h inclusion from internal errno.hAdhemerval Zanella2020-11-132-0/+2
| | | | | | | | | | | | The tls.h inclusion is not really required and limits possible definition on more arch specific headers. This is a cleanup to allow inline functions on sysdep.h, more specifically on i386 and ia64 which requires to access some tls definitions its own. No semantic changes expected, checked with a build against all affected ABIs.
* hurd: Make sure signals get startedSamuel Thibault2020-11-131-3/+3
| | | | | | Now that _hurd_libc_proc_init is idempotent, we can always call it, independently of the __libc_multiple_libcs test which may not match whether signals should be started or not.
* hurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbolsSamuel Thibault2020-11-1125-188/+510
| | | | | | We do not actually need them, so we can move their implementations into the standard {,f,l}stat{,at} variants and only keep compatibility wrappers.
* hurd: Notify the proc server later during initializationSamuel Thibault2020-11-111-0/+3
| | | | | | Notifying the proc server is an involved task, and unleashes various signal handling etc. so we have to do this after e.g. ifunc relocations are completed.
* htl: Initialize laterSamuel Thibault2020-11-116-116/+29
| | | | | | | | Since htl does not actually need a stack switch, we can initialize it like nptl is, avoiding all sorts of startup issues with ifunc. More precisely, htl defines __pthread_initialize_minimal instead of the elder _cthread_init_routine. We can then drop the stack switching dances.
* hurd: keep only required PLTs in ld.soSamuel Thibault2020-11-114-17/+5
| | | | | | | | | | | | | | | | | | | | | We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so. See Roland's comment in https://sourceware.org/bugzilla/show_bug.cgi?id=15605 "in the Hurd it's crucial that calls like __mmap be the libc ones instead of the rtld-local ones after the bootstrap phase, when the dynamic linker is being used for dlopen and the like." We used to just avoid all hidden use in the rtld ; this commit switches to keeping only those that should use PLT calls, i.e. essentially those defined in sysdeps/mach/hurd/dl-sysdep.c: __assert_fail __assert_perror_fail __*stat64 _exit This fixes a few startup issues, notably the call to __tunable_get_val that is made before PLTs are set up.
* hurd: Add missing startup callsSamuel Thibault2020-11-111-0/+16
| | | | | | DL_SYSDEP_INIT and DL_PLATFORM_INIT were not getting called, leading to missing x86 platform tuning, now mandatory with 0f09154c6400 ("x86: Initialize CPU info via IFUNC relocation [BZ 26203]")
* hurd: Correct 'ethenet' spellingJonny Grant2020-10-311-1/+1
| | | | Signed-off-by: Jonny Grant <jg@jguk.org>
* hurd: support clock_gettime(CLOCK_PROCESS/THREAD_CPUTIME_ID)Samuel Thibault2020-10-111-14/+74
| | | | | * sysdeps/mach/clock_gettime.c (__clock_gettime): Add support for CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID.
* linux: Move xmknod{at} to compat symbolsAdhemerval Zanella2020-10-092-6/+23
| | | | | | | | | | | It also decouple mknod{at} from xmknod{at}. The riscv32 ABI was added on 2.33, so it is safe to remove the old __xmknot{at} symbols and just provide the newer mknod{at} ones. Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Remove mknod wrapper functions, move them to symbolsAdhemerval Zanella2020-10-091-0/+2
| | | | | | | | | | | | | | | | | | | This patch removes the mknod and mknodat static wrapper and add the symbols on the libc with the expected names. Both the prototypes of the internal symbol linked by the static wrappers and the inline redirectors are also removed from the installed sys/stat.h header file. The wrapper implementation license LGPL exception is also removed since it is no longer statically linked to binaries. Internally the _STAT_VER* definitions are moved to the arch-specific xstatver.h file. Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>