diff options
95 files changed, 3961 insertions, 605 deletions
diff --git a/INSTALL b/INSTALL index 2f2d12c335..c8c524527b 100644 --- a/INSTALL +++ b/INSTALL @@ -15,98 +15,98 @@ Configuring and compiling the GNU C Library The GNU C Library cannot be compiled in the source directory. You must build it in a separate build directory. For example, if you have -unpacked the GNU C Library sources in ‘/src/gnu/glibc-VERSION’, create a -directory ‘/src/gnu/glibc-build’ to put the object files in. This +unpacked the GNU C Library sources in '/src/gnu/glibc-VERSION', create a +directory '/src/gnu/glibc-build' to put the object files in. This allows removing the whole build directory in case an error occurs, which is the safest way to get a fresh start and should always be done. - From your object directory, run the shell script ‘configure’ located -at the top level of the source tree. In the scenario above, you’d type + From your object directory, run the shell script 'configure' located +at the top level of the source tree. In the scenario above, you'd type $ ../glibc-VERSION/configure ARGS... - Please note that even though you’re building in a separate build + Please note that even though you're building in a separate build directory, the compilation may need to create or modify files and directories in the source directory. -‘configure’ takes many options, but the only one that is usually -mandatory is ‘--prefix’. This option tells ‘configure’ where you want -the GNU C Library installed. This defaults to ‘/usr/local’, but the +'configure' takes many options, but the only one that is usually +mandatory is '--prefix'. This option tells 'configure' where you want +the GNU C Library installed. This defaults to '/usr/local', but the normal setting to install as the standard system library is -‘--prefix=/usr’ for GNU/Linux systems and ‘--prefix=’ (an empty prefix) +'--prefix=/usr' for GNU/Linux systems and '--prefix=' (an empty prefix) for GNU/Hurd systems. - It may also be useful to pass ‘CC=COMPILER’ and ‘CFLAGS=FLAGS’ -arguments to ‘configure’. ‘CC’ selects the C compiler that will be -used, and ‘CFLAGS’ sets optimization options for the compiler. Any + It may also be useful to pass 'CC=COMPILER' and 'CFLAGS=FLAGS' +arguments to 'configure'. 'CC' selects the C compiler that will be +used, and 'CFLAGS' sets optimization options for the compiler. Any compiler options required for all compilations, such as options selecting an ABI or a processor for which to generate code, should be -included in ‘CC’. Options that may be overridden by the GNU C Library +included in 'CC'. Options that may be overridden by the GNU C Library build system for particular files, such as for optimization and -debugging, should go in ‘CFLAGS’. The default value of ‘CFLAGS’ is ‘-g --O2’, and the GNU C Library cannot be compiled without optimization, so -if ‘CFLAGS’ is specified it must enable optimization. For example: +debugging, should go in 'CFLAGS'. The default value of 'CFLAGS' is '-g +-O2', and the GNU C Library cannot be compiled without optimization, so +if 'CFLAGS' is specified it must enable optimization. For example: $ ../glibc-VERSION/configure CC="gcc -m32" CFLAGS="-O3" The following list describes all of the available options for -‘configure’: +'configure': -‘--prefix=DIRECTORY’ +'--prefix=DIRECTORY' Install machine-independent data files in subdirectories of - ‘DIRECTORY’. The default is to install in ‘/usr/local’. + 'DIRECTORY'. The default is to install in '/usr/local'. -‘--exec-prefix=DIRECTORY’ +'--exec-prefix=DIRECTORY' Install the library and other machine-dependent files in - subdirectories of ‘DIRECTORY’. The default is to the ‘--prefix’ - directory if that option is specified, or ‘/usr/local’ otherwise. + subdirectories of 'DIRECTORY'. The default is to the '--prefix' + directory if that option is specified, or '/usr/local' otherwise. -‘--with-headers=DIRECTORY’ - Look for kernel header files in DIRECTORY, not ‘/usr/include’. The - GNU C Library needs information from the kernel’s header files +'--with-headers=DIRECTORY' + Look for kernel header files in DIRECTORY, not '/usr/include'. The + GNU C Library needs information from the kernel's header files describing the interface to the kernel. The GNU C Library will - normally look in ‘/usr/include’ for them, but if you specify this + normally look in '/usr/include' for them, but if you specify this option, it will look in DIRECTORY instead. This option is primarily of use on a system where the headers in - ‘/usr/include’ come from an older version of the GNU C Library. + '/usr/include' come from an older version of the GNU C Library. Conflicts can occasionally happen in this case. You can also use this option if you want to compile the GNU C Library with a newer - set of kernel headers than the ones found in ‘/usr/include’. + set of kernel headers than the ones found in '/usr/include'. -‘--enable-kernel=VERSION’ +'--enable-kernel=VERSION' This option is currently only useful on GNU/Linux systems. The VERSION parameter should have the form X.Y.Z and describes the smallest version of the Linux kernel the generated library is expected to support. The higher the VERSION number is, the less compatibility code is added, and the faster the code gets. -‘--with-binutils=DIRECTORY’ - Use the binutils (assembler and linker) in ‘DIRECTORY’, not the +'--with-binutils=DIRECTORY' + Use the binutils (assembler and linker) in 'DIRECTORY', not the ones the C compiler would default to. You can use this option if the default binutils on your system cannot deal with all the - constructs in the GNU C Library. In that case, ‘configure’ will + constructs in the GNU C Library. In that case, 'configure' will detect the problem and suppress these constructs, so that the - library will still be usable, but functionality may be lost—for - example, you can’t build a shared libc with old binutils. + library will still be usable, but functionality may be lost--for + example, you can't build a shared libc with old binutils. -‘--with-nonshared-cflags=CFLAGS’ +'--with-nonshared-cflags=CFLAGS' Use additional compiler flags CFLAGS to build the parts of the library which are always statically linked into applications and libraries even with shared linking (that is, the object files - contained in ‘lib*_nonshared.a’ libraries). The build process will + contained in 'lib*_nonshared.a' libraries). The build process will automatically use the appropriate flags, but this option can be used to set additional flags required for building applications and libraries, to match local policy. For example, if such a policy requires that all code linked into applications must be built with source fortification, - ‘--with-nonshared-cflags=-Wp,-D_FORTIFY_SOURCE=2’ will make sure - that the objects in ‘libc_nonshared.a’ are compiled with this flag + '--with-nonshared-cflags=-Wp,-D_FORTIFY_SOURCE=2' will make sure + that the objects in 'libc_nonshared.a' are compiled with this flag (although this will not affect the generated code in this particular case and potentially change debugging information and metadata only). -‘--with-rtld-early-cflags=CFLAGS’ +'--with-rtld-early-cflags=CFLAGS' Use additional compiler flags CFLAGS to build the early startup code of the dynamic linker. These flags can be used to enable early dynamic linker diagnostics to run on CPUs which are not @@ -114,18 +114,18 @@ if ‘CFLAGS’ is specified it must enable optimization. For example: compiler flags which target a later instruction set architecture (ISA). -‘--with-timeoutfactor=NUM’ +'--with-timeoutfactor=NUM' Specify an integer NUM to scale the timeout of test programs. This - factor can be changed at run time using ‘TIMEOUTFACTOR’ environment + factor can be changed at run time using 'TIMEOUTFACTOR' environment variable. -‘--disable-shared’ - Don’t build shared libraries even if it is possible. Not all +'--disable-shared' + Don't build shared libraries even if it is possible. Not all systems support shared libraries; you need ELF support and (currently) the GNU linker. -‘--disable-default-pie’ - Don’t build glibc programs and the testsuite as position +'--disable-default-pie' + Don't build glibc programs and the testsuite as position independent executables (PIE). By default, glibc programs and tests are created as position independent executables on targets that support it. If the toolchain and architecture support it, static @@ -133,29 +133,29 @@ if ‘CFLAGS’ is specified it must enable optimization. For example: used with the GCC option, -static-pie, which is available with GCC 8 or above, to create static PIE. -‘--enable-cet’ -‘--enable-cet=permissive’ +'--enable-cet' +'--enable-cet=permissive' Enable Intel Control-flow Enforcement Technology (CET) support. - When the GNU C Library is built with ‘--enable-cet’ or - ‘--enable-cet=permissive’, the resulting library is protected with + When the GNU C Library is built with '--enable-cet' or + '--enable-cet=permissive', the resulting library is protected with indirect branch tracking (IBT) and shadow stack (SHSTK). When CET is enabled, the GNU C Library is compatible with all existing executables and shared libraries. This feature is currently supported on x86_64 and x32 with GCC 8 and binutils 2.29 or later. - With ‘--enable-cet’, it is an error to dlopen a non CET enabled + With '--enable-cet', it is an error to dlopen a non CET enabled shared library in CET enabled application. With - ‘--enable-cet=permissive’, CET is disabled when dlopening a non CET + '--enable-cet=permissive', CET is disabled when dlopening a non CET enabled shared library in CET enabled application. - NOTE: ‘--enable-cet’ is only supported on x86_64 and x32. + NOTE: '--enable-cet' is only supported on x86_64 and x32. -‘--enable-memory-tagging’ +'--enable-memory-tagging' Enable memory tagging support if the architecture supports it. When the GNU C Library is built with this option then the resulting library will be able to control the use of tagged memory when hardware support is present by use of the tunable - ‘glibc.mem.tagging’. This includes the generation of tagged memory - when using the ‘malloc’ APIs. + 'glibc.mem.tagging'. This includes the generation of tagged memory + when using the 'malloc' APIs. At present only AArch64 platforms with MTE provide this functionality, although the library will still operate (without @@ -163,115 +163,115 @@ if ‘CFLAGS’ is specified it must enable optimization. For example: The default is to disable support for memory tagging. -‘--disable-profile’ - Don’t build libraries with profiling information. You may want to - use this option if you don’t plan to do profiling. +'--disable-profile' + Don't build libraries with profiling information. You may want to + use this option if you don't plan to do profiling. -‘--enable-static-nss’ +'--enable-static-nss' Compile static versions of the NSS (Name Service Switch) libraries. This is not recommended because it defeats the purpose of NSS; a program linked statically with the NSS libraries cannot be dynamically reconfigured to use a different name database. -‘--enable-hardcoded-path-in-tests’ +'--enable-hardcoded-path-in-tests' By default, dynamic tests are linked to run with the installed C library. This option hardcodes the newly built C library path in dynamic tests so that they can be invoked directly. -‘--disable-timezone-tools’ - By default, timezone related utilities (‘zic’, ‘zdump’, and - ‘tzselect’) are installed with the GNU C Library. If you are - building these independently (e.g. by using the ‘tzcode’ package), +'--disable-timezone-tools' + By default, timezone related utilities ('zic', 'zdump', and + 'tzselect') are installed with the GNU C Library. If you are + building these independently (e.g. by using the 'tzcode' package), then this option will allow disabling the install of these. Note that you need to make sure the external tools are kept in sync with the versions that the GNU C Library expects as the data - formats may change over time. Consult the ‘timezone’ subdirectory + formats may change over time. Consult the 'timezone' subdirectory for more details. -‘--enable-stack-protector’ -‘--enable-stack-protector=strong’ -‘--enable-stack-protector=all’ +'--enable-stack-protector' +'--enable-stack-protector=strong' +'--enable-stack-protector=all' Compile the C library and all other parts of the glibc package (including the threading and math libraries, NSS modules, and - transliteration modules) using the GCC ‘-fstack-protector’, - ‘-fstack-protector-strong’ or ‘-fstack-protector-all’ options to + transliteration modules) using the GCC '-fstack-protector', + '-fstack-protector-strong' or '-fstack-protector-all' options to detect stack overruns. Only the dynamic linker and a small number of routines called directly from assembler are excluded from this protection. -‘--enable-bind-now’ +'--enable-bind-now' Disable lazy binding for installed shared objects and programs. This provides additional security hardening because it enables full RELRO and a read-only global offset table (GOT), at the cost of slightly increased program load times. -‘--enable-pt_chown’ - The file ‘pt_chown’ is a helper binary for ‘grantpt’ (*note +'--enable-pt_chown' + The file 'pt_chown' is a helper binary for 'grantpt' (*note Pseudo-Terminals: Allocation.) that is installed setuid root to fix up pseudo-terminal ownership on GNU/Hurd. It is not required on GNU/Linux, and the GNU C Library will not use the installed - ‘pt_chown’ program when configured with ‘--enable-pt_chown’. + 'pt_chown' program when configured with '--enable-pt_chown'. -‘--disable-werror’ - By default, the GNU C Library is built with ‘-Werror’. If you wish +'--disable-werror' + By default, the GNU C Library is built with '-Werror'. If you wish to build without this option (for example, if building with a newer version of GCC than this version of the GNU C Library was tested - with, so new warnings cause the build with ‘-Werror’ to fail), you - can configure with ‘--disable-werror’. + with, so new warnings cause the build with '-Werror' to fail), you + can configure with '--disable-werror'. -‘--disable-mathvec’ +'--disable-mathvec' By default for x86_64, the GNU C Library is built with the vector math library. Use this option to disable the vector math library. -‘--disable-scv’ - Disable using ‘scv’ instruction for syscalls. All syscalls will - use ‘sc’ instead, even if the kernel supports ‘scv’. PowerPC only. +'--disable-scv' + Disable using 'scv' instruction for syscalls. All syscalls will + use 'sc' instead, even if the kernel supports 'scv'. PowerPC only. -‘--build=BUILD-SYSTEM’ -‘--host=HOST-SYSTEM’ +'--build=BUILD-SYSTEM' +'--host=HOST-SYSTEM' These options are for cross-compiling. If you specify both options - and BUILD-SYSTEM is different from HOST-SYSTEM, ‘configure’ will + and BUILD-SYSTEM is different from HOST-SYSTEM, 'configure' will prepare to cross-compile the GNU C Library from BUILD-SYSTEM to be - used on HOST-SYSTEM. You’ll probably need the ‘--with-headers’ - option too, and you may have to override CONFIGURE’s selection of + used on HOST-SYSTEM. You'll probably need the '--with-headers' + option too, and you may have to override CONFIGURE's selection of the compiler and/or binutils. - If you only specify ‘--host’, ‘configure’ will prepare for a native + If you only specify '--host', 'configure' will prepare for a native compile but use what you specify instead of guessing what your system is. This is most useful to change the CPU submodel. For - example, if ‘configure’ guesses your machine as ‘i686-pc-linux-gnu’ + example, if 'configure' guesses your machine as 'i686-pc-linux-gnu' but you want to compile a library for 586es, give - ‘--host=i586-pc-linux-gnu’ or just ‘--host=i586-linux’ and add the - appropriate compiler flags (‘-mcpu=i586’ will do the trick) to - ‘CC’. + '--host=i586-pc-linux-gnu' or just '--host=i586-linux' and add the + appropriate compiler flags ('-mcpu=i586' will do the trick) to + 'CC'. - If you specify just ‘--build’, ‘configure’ will get confused. + If you specify just '--build', 'configure' will get confused. -‘--with-pkgversion=VERSION’ +'--with-pkgversion=VERSION' Specify a description, possibly including a build number or build - date, of the binaries being built, to be included in ‘--version’ + date, of the binaries being built, to be included in '--version' output from programs installed with the GNU C Library. For - example, ‘--with-pkgversion='FooBar GNU/Linux glibc build 123'’. - The default value is ‘GNU libc’. + example, '--with-pkgversion='FooBar GNU/Linux glibc build 123''. + The default value is 'GNU libc'. -‘--with-bugurl=URL’ +'--with-bugurl=URL' Specify the URL that users should visit if they wish to report a - bug, to be included in ‘--help’ output from programs installed with + bug, to be included in '--help' output from programs installed with the GNU C Library. The default value refers to the main bug-reporting information for the GNU C Library. -‘--enable-fortify-source’ -‘--enable-fortify-source=LEVEL’ - Use -D_FORTIFY_SOURCE=‘LEVEL’ to control hardening in the GNU C - Library. If not provided, ‘LEVEL’ defaults to highest possible +'--enable-fortify-source' +'--enable-fortify-source=LEVEL' + Use -D_FORTIFY_SOURCE='LEVEL' to control hardening in the GNU C + Library. If not provided, 'LEVEL' defaults to highest possible value supported by the build compiler. Default is to disable fortification. - To build the library and related programs, type ‘make’. This will -produce a lot of output, some of which may look like errors from ‘make’ -but aren’t. Look for error messages from ‘make’ containing ‘***’. + To build the library and related programs, type 'make'. This will +produce a lot of output, some of which may look like errors from 'make' +but aren't. Look for error messages from 'make' containing '***'. Those indicate that something is seriously wrong. The compilation process can take a long time, depending on the @@ -279,91 +279,91 @@ configuration and the speed of your machine. Some complex modules may take a very long time to compile, as much as several minutes on slower machines. Do not panic if the compiler appears to hang. - If you want to run a parallel make, simply pass the ‘-j’ option with -an appropriate numeric parameter to ‘make’. You need a recent GNU -‘make’ version, though. + If you want to run a parallel make, simply pass the '-j' option with +an appropriate numeric parameter to 'make'. You need a recent GNU +'make' version, though. To build and run test programs which exercise some of the library -facilities, type ‘make check’. If it does not complete successfully, do +facilities, type 'make check'. If it does not complete successfully, do not use the built library, and report a bug after verifying that the problem is not already known. *Note Reporting Bugs::, for instructions on reporting bugs. Note that some of the tests assume they are not -being run by ‘root’. We recommend you compile and test the GNU C +being run by 'root'. We recommend you compile and test the GNU C Library as an unprivileged user. Before reporting bugs make sure there is no problem with your system. The tests (and later installation) use some pre-existing files of the -system such as ‘/etc/passwd’, ‘/etc/nsswitch.conf’ and others. These +system such as '/etc/passwd', '/etc/nsswitch.conf' and others. These files must all contain correct and sensible content. - Normally, ‘make check’ will run all the tests before reporting all + Normally, 'make check' will run all the tests before reporting all problems found and exiting with error status if any problems occurred. -You can specify ‘stop-on-test-failure=y’ when running ‘make check’ to +You can specify 'stop-on-test-failure=y' when running 'make check' to make the test run stop and exit with an error status immediately when a failure occurs. - To format the ‘GNU C Library Reference Manual’ for printing, type -‘make dvi’. You need a working TeX installation to do this. The + To format the 'GNU C Library Reference Manual' for printing, type +'make dvi'. You need a working TeX installation to do this. The distribution builds the on-line formatted version of the manual, as Info files, as part of the build process. You can build them manually with -‘make info’. +'make info'. The library has a number of special-purpose configuration parameters -which you can find in ‘Makeconfig’. These can be overwritten with the -file ‘configparms’. To change them, create a ‘configparms’ in your +which you can find in 'Makeconfig'. These can be overwritten with the +file 'configparms'. To change them, create a 'configparms' in your build directory and add values as appropriate for your system. The file -is included and parsed by ‘make’ and has to follow the conventions for +is included and parsed by 'make' and has to follow the conventions for makefiles. It is easy to configure the GNU C Library for cross-compilation by -setting a few variables in ‘configparms’. Set ‘CC’ to the +setting a few variables in 'configparms'. Set 'CC' to the cross-compiler for the target you configured the library for; it is -important to use this same ‘CC’ value when running ‘configure’, like -this: ‘configure TARGET CC=TARGET-gcc’. Set ‘BUILD_CC’ to the compiler +important to use this same 'CC' value when running 'configure', like +this: 'configure TARGET CC=TARGET-gcc'. Set 'BUILD_CC' to the compiler to use for programs run on the build system as part of compiling the -library. You may need to set ‘AR’ to cross-compiling versions of ‘ar’ +library. You may need to set 'AR' to cross-compiling versions of 'ar' if the native tools are not configured to work with object files for the target you configured for. When cross-compiling the GNU C Library, it -may be tested using ‘make check -test-wrapper="SRCDIR/scripts/cross-test-ssh.sh HOSTNAME"’, where SRCDIR +may be tested using 'make check +test-wrapper="SRCDIR/scripts/cross-test-ssh.sh HOSTNAME"', where SRCDIR is the absolute directory name for the main source directory and HOSTNAME is the host name of a system that can run the newly built binaries of the GNU C Library. The source and build directories must be visible at the same locations on both the build system and HOSTNAME. -The ‘cross-test-ssh.sh’ script requires ‘flock’ from ‘util-linux’ to +The 'cross-test-ssh.sh' script requires 'flock' from 'util-linux' to work when GLIBC_TEST_ALLOW_TIME_SETTING environment variable is set. It is also possible to execute tests, which require setting the date on the target machine. Following use cases are supported: - • ‘GLIBC_TEST_ALLOW_TIME_SETTING’ is set in the environment in which + * 'GLIBC_TEST_ALLOW_TIME_SETTING' is set in the environment in which eligible tests are executed and have the privilege to run - ‘clock_settime’. In this case, nothing prevents those tests from + 'clock_settime'. In this case, nothing prevents those tests from running in parallel, so the caller shall assure that those tests are serialized or provide a proper wrapper script for them. - • The ‘cross-test-ssh.sh’ script is used and one passes the - ‘--allow-time-setting’ flag. In this case, both sets - ‘GLIBC_TEST_ALLOW_TIME_SETTING’ and serialization of test execution + * The 'cross-test-ssh.sh' script is used and one passes the + '--allow-time-setting' flag. In this case, both sets + 'GLIBC_TEST_ALLOW_TIME_SETTING' and serialization of test execution are assured automatically. - In general, when testing the GNU C Library, ‘test-wrapper’ may be set + In general, when testing the GNU C Library, 'test-wrapper' may be set to the name and arguments of any program to run newly built binaries. This program must preserve the arguments to the binary being run, its working directory and the standard input, output and error file -descriptors. If ‘TEST-WRAPPER env’ will not work to run a program with -environment variables set, then ‘test-wrapper-env’ must be set to a +descriptors. If 'TEST-WRAPPER env' will not work to run a program with +environment variables set, then 'test-wrapper-env' must be set to a program that runs a newly built program with environment variable -assignments in effect, those assignments being specified as ‘VAR=VALUE’ +assignments in effect, those assignments being specified as 'VAR=VALUE' before the name of the program to be run. If multiple assignments to the same variable are specified, the last assignment specified must take -precedence. Similarly, if ‘TEST-WRAPPER env -i’ will not work to run a +precedence. Similarly, if 'TEST-WRAPPER env -i' will not work to run a program with an environment completely empty of variables except those -directly assigned, then ‘test-wrapper-env-only’ must be set; its use has -the same syntax as ‘test-wrapper-env’, the only difference in its +directly assigned, then 'test-wrapper-env-only' must be set; its use has +the same syntax as 'test-wrapper-env', the only difference in its semantics being starting with an empty set of environment variables rather than the ambient set. - For AArch64 with SVE, when testing the GNU C Library, ‘test-wrapper’ + For AArch64 with SVE, when testing the GNU C Library, 'test-wrapper' may be set to "SRCDIR/sysdeps/unix/sysv/linux/aarch64/vltest.py VECTOR-LENGTH" to change Vector Length. @@ -371,51 +371,51 @@ Installing the C Library ======================== To install the library and its header files, and the Info files of the -manual, type ‘make install’. This will build things, if necessary, +manual, type 'make install'. This will build things, if necessary, before installing them; however, you should still compile everything first. If you are installing the GNU C Library as your primary C library, we recommend that you shut the system down to single-user mode first, and reboot afterward. This minimizes the risk of breaking things when the library changes out from underneath. - ‘make install’ will do the entire job of upgrading from a previous + 'make install' will do the entire job of upgrading from a previous installation of the GNU C Library version 2.x. There may sometimes be headers left behind from the previous installation, but those are generally harmless. If you want to avoid leaving headers behind you can do things in the following order. - You must first build the library (‘make’), optionally check it (‘make -check’), switch the include directories and then install (‘make -install’). The steps must be done in this order. Not moving the + You must first build the library ('make'), optionally check it ('make +check'), switch the include directories and then install ('make +install'). The steps must be done in this order. Not moving the directory before install will result in an unusable mixture of header files from both libraries, but configuring, building, and checking the library requires the ability to compile and run programs against the old -library. The new ‘/usr/include’, after switching the include +library. The new '/usr/include', after switching the include directories and before installing the library should contain the Linux headers, but nothing else. If you do this, you will need to restore any headers from libraries other than the GNU C Library yourself after installing the library. You can install the GNU C Library somewhere other than where you -configured it to go by setting the ‘DESTDIR’ GNU standard make variable -on the command line for ‘make install’. The value of this variable is +configured it to go by setting the 'DESTDIR' GNU standard make variable +on the command line for 'make install'. The value of this variable is prepended to all the paths for installation. This is useful when setting up a chroot environment or preparing a binary distribution. The directory should be specified with an absolute file name. Installing -with the ‘prefix’ and ‘exec_prefix’ GNU standard make variables set is +with the 'prefix' and 'exec_prefix' GNU standard make variables set is not supported. - The GNU C Library includes a daemon called ‘nscd’, which you may or -may not want to run. ‘nscd’ caches name service lookups; it can + The GNU C Library includes a daemon called 'nscd', which you may or +may not want to run. 'nscd' caches name service lookups; it can dramatically improve performance with NIS+, and may help with DNS as well. - One auxiliary program, ‘/usr/libexec/pt_chown’, is installed setuid -‘root’ if the ‘--enable-pt_chown’ configuration option is used. This -program is invoked by the ‘grantpt’ function; it sets the permissions on + One auxiliary program, '/usr/libexec/pt_chown', is installed setuid +'root' if the '--enable-pt_chown' configuration option is used. This +program is invoked by the 'grantpt' function; it sets the permissions on a pseudoterminal so it can be used by the calling process. If you are -using a Linux kernel with the ‘devpts’ filesystem enabled and mounted at -‘/dev/pts’, you don’t need this program. +using a Linux kernel with the 'devpts' filesystem enabled and mounted at +'/dev/pts', you don't need this program. After installation you should configure the timezone and install locales for your system. The time zone configuration ensures that your @@ -425,34 +425,34 @@ expectations of your language and geographic region. The GNU C Library is able to use two kinds of localization information sources, the first is a locale database named -‘locale-archive’ which is generally installed as -‘/usr/lib/locale/locale-archive’. The locale archive has the benefit of +'locale-archive' which is generally installed as +'/usr/lib/locale/locale-archive'. The locale archive has the benefit of taking up less space and being very fast to load, but only if you plan to install sixty or more locales. If you plan to install one or two locales you can instead install individual locales into their self-named -directories e.g. ‘/usr/lib/locale/en_US.utf8’. For example to install -the German locale using the character set for UTF-8 with name ‘de_DE’ -into the locale archive issue the command ‘localedef -i de_DE -f UTF-8 -de_DE’, and to install just the one locale issue the command ‘localedef ---no-archive -i de_DE -f UTF-8 de_DE’. To configure all locales that +directories e.g. '/usr/lib/locale/en_US.utf8'. For example to install +the German locale using the character set for UTF-8 with name 'de_DE' +into the locale archive issue the command 'localedef -i de_DE -f UTF-8 +de_DE', and to install just the one locale issue the command 'localedef +--no-archive -i de_DE -f UTF-8 de_DE'. To configure all locales that are supported by the GNU C Library, you can issue from your build -directory the command ‘make localedata/install-locales’ to install all -locales into the locale archive or ‘make -localedata/install-locale-files’ to install all locales as files in the +directory the command 'make localedata/install-locales' to install all +locales into the locale archive or 'make +localedata/install-locale-files' to install all locales as files in the default configured locale installation directory (derived from -‘--prefix’ or ‘--localedir’). To install into an alternative system -root use ‘DESTDIR’ e.g. ‘make localedata/install-locale-files -DESTDIR=/opt/glibc’, but note that this does not change the configured +'--prefix' or '--localedir'). To install into an alternative system +root use 'DESTDIR' e.g. 'make localedata/install-locale-files +DESTDIR=/opt/glibc', but note that this does not change the configured prefix. - To configure the locally used timezone, set the ‘TZ’ environment -variable. The script ‘tzselect’ helps you to select the right value. -As an example, for Germany, ‘tzselect’ would tell you to use -‘TZ='Europe/Berlin'’. For a system wide installation (the given paths -are for an installation with ‘--prefix=/usr’), link the timezone file -which is in ‘/usr/share/zoneinfo’ to the file ‘/etc/localtime’. For -Germany, you might execute ‘ln -s /usr/share/zoneinfo/Europe/Berlin -/etc/localtime’. + To configure the locally used timezone, set the 'TZ' environment +variable. The script 'tzselect' helps you to select the right value. +As an example, for Germany, 'tzselect' would tell you to use +'TZ='Europe/Berlin''. For a system wide installation (the given paths +are for an installation with '--prefix=/usr'), link the timezone file +which is in '/usr/share/zoneinfo' to the file '/etc/localtime'. For +Germany, you might execute 'ln -s /usr/share/zoneinfo/Europe/Berlin +/etc/localtime'. Recommended Tools for Compilation ================================= @@ -460,12 +460,12 @@ Recommended Tools for Compilation We recommend installing the following GNU tools before attempting to build the GNU C Library: - • GNU ‘make’ 4.0 or newer + * GNU 'make' 4.0 or newer - As of release time, GNU ‘make’ 4.4.1 is the newest verified to work + As of release time, GNU 'make' 4.4.1 is the newest verified to work to build the GNU C Library. - • GCC 6.2 or newer + * GCC 6.2 or newer GCC 6.2 or higher is required. In general it is recommended to use the newest version of the compiler that is known to work for @@ -474,9 +474,9 @@ build the GNU C Library: verified to work to build the GNU C Library. For PowerPC 64-bits little-endian (powerpc64le), a GCC version with - support for ‘-mno-gnu-attribute’, ‘-mabi=ieeelongdouble’, and - ‘-mabi=ibmlondouble’ is required. Likewise, the compiler must also - support passing ‘-mlong-double-128’ with the preceding options. As + support for '-mno-gnu-attribute', '-mabi=ieeelongdouble', and + '-mabi=ibmlondouble' is required. Likewise, the compiler must also + support passing '-mlong-double-128' with the preceding options. As of release, this implies GCC 7.4 and newer (excepting GCC 7.5.0, see GCC PR94200). These additional features are required for building the GNU C Library with support for IEEE long double. @@ -493,10 +493,10 @@ build the GNU C Library: been built with support for GNU indirect functions. This ensures that correct debugging information is generated for functions selected by IFUNC resolvers. This support can either be enabled by - configuring GCC with ‘--enable-gnu-indirect-function’, or by - enabling it by default by setting ‘default_gnu_indirect_function’ + configuring GCC with '--enable-gnu-indirect-function', or by + enabling it by default by setting 'default_gnu_indirect_function' variable for a particular architecture in the GCC source file - ‘gcc/config.gcc’. + 'gcc/config.gcc'. You can use whatever compiler you like to compile programs that use the GNU C Library. @@ -504,100 +504,100 @@ build the GNU C Library: Check the FAQ for any special compiler issues on particular platforms. - • GNU ‘binutils’ 2.25 or later + * GNU 'binutils' 2.25 or later - You must use GNU ‘binutils’ (as and ld) to build the GNU C Library. + You must use GNU 'binutils' (as and ld) to build the GNU C Library. No other assembler or linker has the necessary functionality at the - moment. As of release time, GNU ‘binutils’ 2.42 is the newest + moment. As of release time, GNU 'binutils' 2.42 is the newest verified to work to build the GNU C Library. - For PowerPC 64-bits little-endian (powerpc64le), ‘objcopy’ is - required to support ‘--update-section’. This option requires + For PowerPC 64-bits little-endian (powerpc64le), 'objcopy' is + required to support '--update-section'. This option requires binutils 2.26 or newer. - ARC architecture needs ‘binutils’ 2.32 or higher for TLS related + ARC architecture needs 'binutils' 2.32 or higher for TLS related fixes. - • GNU ‘texinfo’ 4.7 or later + * GNU 'texinfo' 4.7 or later To correctly translate and install the Texinfo documentation you - need this version of the ‘texinfo’ package. Earlier versions do + need this version of the 'texinfo' package. Earlier versions do not understand all the tags used in the document, and the installation mechanism for the info files is not present or works - differently. As of release time, ‘texinfo’ 7.0.3 is the newest + differently. As of release time, 'texinfo' 7.0.3 is the newest verified to work to build the GNU C Library. - • GNU ‘awk’ 3.1.2, or higher + * GNU 'awk' 3.1.2, or higher - ‘awk’ is used in several places to generate files. Some ‘gawk’ - extensions are used, including the ‘asorti’ function, which was - introduced in version 3.1.2 of ‘gawk’. As of release time, ‘gawk’ + 'awk' is used in several places to generate files. Some 'gawk' + extensions are used, including the 'asorti' function, which was + introduced in version 3.1.2 of 'gawk'. As of release time, 'gawk' version 5.2.2 is the newest verified to work to build the GNU C Library. - • GNU ‘bison’ 2.7 or later + * GNU 'bison' 2.7 or later - ‘bison’ is used to generate the ‘yacc’ parser code in the ‘intl’ - subdirectory. As of release time, ‘bison’ version 3.8.2 is the + 'bison' is used to generate the 'yacc' parser code in the 'intl' + subdirectory. As of release time, 'bison' version 3.8.2 is the newest verified to work to build the GNU C Library. - • Perl 5 + * Perl 5 Perl is not required, but if present it is used in some tests and - the ‘mtrace’ program, to build the GNU C Library manual. As of - release time ‘perl’ version 5.38.2 is the newest verified to work + the 'mtrace' program, to build the GNU C Library manual. As of + release time 'perl' version 5.38.2 is the newest verified to work to build the GNU C Library. - • GNU ‘sed’ 3.02 or newer + * GNU 'sed' 3.02 or newer - ‘Sed’ is used in several places to generate files. Most scripts - work with any version of ‘sed’. As of release time, ‘sed’ version + 'Sed' is used in several places to generate files. Most scripts + work with any version of 'sed'. As of release time, 'sed' version 4.9 is the newest verified to work to build the GNU C Library. - • Python 3.4 or later + * Python 3.4 or later Python is required to build the GNU C Library. As of release time, Python 3.11 is the newest verified to work for building and testing the GNU C Library. - • PExpect 4.0 + * PExpect 4.0 The pretty printer tests drive GDB through test programs and - compare its output to the printers’. PExpect is used to capture + compare its output to the printers'. PExpect is used to capture the output of GDB, and should be compatible with the Python version in your system. As of release time PExpect 4.8.0 is the newest verified to work to test the pretty printers. - • The Python ‘abnf’ module. + * The Python 'abnf' module. This module is optional and used to verify some ABNF grammars in the manual. Version 2.2.0 has been confirmed to work as expected. - A missing ‘abnf’ module does not reduce the test coverage of the + A missing 'abnf' module does not reduce the test coverage of the library itself. - • GDB 7.8 or later with support for Python 2.7/3.4 or later + * GDB 7.8 or later with support for Python 2.7/3.4 or later GDB itself needs to be configured with Python support in order to use the pretty printers. Notice that your system having Python - available doesn’t imply that GDB supports it, nor that your - system’s Python and GDB’s have the same version. As of release - time GNU ‘debugger’ 13.2 is the newest verified to work to test the + available doesn't imply that GDB supports it, nor that your + system's Python and GDB's have the same version. As of release + time GNU 'debugger' 13.2 is the newest verified to work to test the pretty printers. Unless Python, PExpect and GDB with Python support are present, the - printer tests will report themselves as ‘UNSUPPORTED’. Notice that + printer tests will report themselves as 'UNSUPPORTED'. Notice that some of the printer tests require the GNU C Library to be compiled with debugging symbols. -If you change any of the ‘configure.ac’ files you will also need +If you change any of the 'configure.ac' files you will also need - • GNU ‘autoconf’ 2.71 (exactly) + * GNU 'autoconf' 2.71 (exactly) and if you change any of the message translation files you will need - • GNU ‘gettext’ 0.10.36 or later + * GNU 'gettext' 0.10.36 or later - As of release time, GNU ‘gettext’ version 0.21.1 is the newest + As of release time, GNU 'gettext' version 0.21.1 is the newest version verified to work to build the GNU C Library. You may also need these packages if you upgrade your source tree using @@ -608,40 +608,40 @@ Specific advice for GNU/Linux systems If you are installing the GNU C Library on GNU/Linux systems, you need to have the header files from a 3.2 or newer kernel around for -reference. These headers must be installed using ‘make -headers_install’; the headers present in the kernel source directory are +reference. These headers must be installed using 'make +headers_install'; the headers present in the kernel source directory are not suitable for direct use by the GNU C Library. You do not need to use that kernel, just have its headers installed where the GNU C Library can access them, referred to here as INSTALL-DIRECTORY. The easiest way to do this is to unpack it in a directory such as -‘/usr/src/linux-VERSION’. In that directory, run ‘make headers_install -INSTALL_HDR_PATH=INSTALL-DIRECTORY’. Finally, configure the GNU C -Library with the option ‘--with-headers=INSTALL-DIRECTORY/include’. Use +'/usr/src/linux-VERSION'. In that directory, run 'make headers_install +INSTALL_HDR_PATH=INSTALL-DIRECTORY'. Finally, configure the GNU C +Library with the option '--with-headers=INSTALL-DIRECTORY/include'. Use the most recent kernel you can get your hands on. (If you are cross-compiling the GNU C Library, you need to specify -‘ARCH=ARCHITECTURE’ in the ‘make headers_install’ command, where +'ARCH=ARCHITECTURE' in the 'make headers_install' command, where ARCHITECTURE is the architecture name used by the Linux kernel, such as -‘x86’ or ‘powerpc’.) +'x86' or 'powerpc'.) After installing the GNU C Library, you may need to remove or rename -directories such as ‘/usr/include/linux’ and ‘/usr/include/asm’, and -replace them with copies of directories such as ‘linux’ and ‘asm’ from -‘INSTALL-DIRECTORY/include’. All directories present in -‘INSTALL-DIRECTORY/include’ should be copied, except that the GNU C -Library provides its own version of ‘/usr/include/scsi’; the files +directories such as '/usr/include/linux' and '/usr/include/asm', and +replace them with copies of directories such as 'linux' and 'asm' from +'INSTALL-DIRECTORY/include'. All directories present in +'INSTALL-DIRECTORY/include' should be copied, except that the GNU C +Library provides its own version of '/usr/include/scsi'; the files provided by the kernel should be copied without replacing those provided -by the GNU C Library. The ‘linux’, ‘asm’ and ‘asm-generic’ directories +by the GNU C Library. The 'linux', 'asm' and 'asm-generic' directories are required to compile programs using the GNU C Library; the other directories describe interfaces to the kernel but are not required if not compiling programs using those interfaces. You do not need to copy kernel headers if you did not specify an alternate kernel header source -using ‘--with-headers’. +using '--with-headers'. The Filesystem Hierarchy Standard for GNU/Linux systems expects some -components of the GNU C Library installation to be in ‘/lib’ and some in -‘/usr/lib’. This is handled automatically if you configure the GNU C -Library with ‘--prefix=/usr’. If you set some other prefix or allow it -to default to ‘/usr/local’, then all the components are installed there. +components of the GNU C Library installation to be in '/lib' and some in +'/usr/lib'. This is handled automatically if you configure the GNU C +Library with '--prefix=/usr'. If you set some other prefix or allow it +to default to '/usr/local', then all the components are installed there. As of release time, Linux version 6.1.5 is the newest stable version verified to work to build the GNU C Library. @@ -651,30 +651,30 @@ Reporting Bugs There are probably bugs in the GNU C Library. There are certainly errors and omissions in this manual. If you report them, they will get -fixed. If you don’t, no one will ever know about them and they will +fixed. If you don't, no one will ever know about them and they will remain unfixed for all eternity, if not longer. It is a good idea to verify that the problem has not already been -reported. Bugs are documented in two places: The file ‘BUGS’ describes +reported. Bugs are documented in two places: The file 'BUGS' describes a number of well known bugs and the central GNU C Library bug tracking system has a WWW interface at <https://sourceware.org/bugzilla/>. The WWW interface gives you access to open and closed reports. A closed report normally includes a patch or a hint on solving the problem. To report a bug, first you must find it. With any luck, this will be -the hard part. Once you’ve found a bug, make sure it’s really a bug. A +the hard part. Once you've found a bug, make sure it's really a bug. A good way to do this is to see if the GNU C Library behaves the same way some other C library does. If so, probably you are wrong and the libraries are right (but not necessarily). If not, one of the libraries is probably wrong. It might not be the GNU C Library. Many historical -Unix C libraries permit things that we don’t, such as closing a file +Unix C libraries permit things that we don't, such as closing a file twice. If you think you have found some way in which the GNU C Library does not conform to the ISO and POSIX standards (*note Standards and Portability::), that is definitely a bug. Report it! - Once you’re sure you’ve found a bug, try to narrow it down to the + Once you're sure you've found a bug, try to narrow it down to the smallest test case that reproduces the problem. In the case of a C library, you really only need to narrow it down to one library function call, if possible. This should not be too difficult. @@ -683,8 +683,8 @@ call, if possible. This should not be too difficult. Do this at <https://www.gnu.org/software/libc/bugs.html>. If you are not sure how a function should behave, and this manual -doesn’t tell you, that’s a bug in the manual. Report that too! If the -function’s behavior disagrees with the manual, then either the library +doesn't tell you, that's a bug in the manual. Report that too! If the +function's behavior disagrees with the manual, then either the library or the manual has a bug, so report the disagreement. If you find any errors or omissions in this manual, please report them to the bug database. If you refer to specific sections of the manual, please diff --git a/Makeconfig b/Makeconfig index e583765712..61ff1d0d9b 100644 --- a/Makeconfig +++ b/Makeconfig @@ -360,6 +360,8 @@ whole-archive = -Wl,--whole-archive # Installed name of the startup code. # The ELF convention is that the startfile is called crt1.o start-installed-name = crt1.o +# Similar to crt1.o, but without _IO_stdin_used. +start-name-2.0 = crt1-2.0.o # On systems that do not need a special startfile for statically linked # binaries, simply set it to the normal name. ifndef static-start-installed-name @@ -537,6 +539,25 @@ else # build-static endif # build-shared endif # +link +# Command for linking test programs with crt1.o from glibc 2.0. ++link-2.0-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \ + $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ + $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ + $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-name-2.0)) \ + $(+preinit) $(+prector) ++link-2.0-before-libc = -o $@ $(+link-2.0-before-inputs) \ + $(filter-out $(addprefix $(csu-objpfx),start.o \ + $(start-name-2.0))\ + $(+preinit) $(link-extra-libs) \ + $(common-objpfx)libc% $(+postinit),$^) \ + $(link-extra-libs) ++link-after-libc = $(+postctor) $(+postinit) +define +link-2.0-tests +$(CC) $(+link-2.0-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ + $(+link-after-libc) +$(call after-link,$@) +endef + # The pretty printer test programs need to be compiled without optimizations # so they won't confuse gdb. We could use either the 'GCC optimize' pragma # or the 'optimize' function attribute to achieve this; however, at least on diff --git a/Makefile b/Makefile index 7052b46df8..adf4749124 100644 --- a/Makefile +++ b/Makefile @@ -577,6 +577,13 @@ $(objpfx)lint-makefiles.out: scripts/lint-makefiles.sh $(SHELL) $< "$(PYTHON)" `pwd` > $@ ; \ $(evaluate-test) +# Link libc.a as a whole to verify that it does not contain multiple +# definitions of any symbols. +tests-special += $(objpfx)link-static-libc.out +$(objpfx)link-static-libc.out: + $(LINK.o) $(whole-archive) -r $(objpfx)libc.a -o /dev/null > $@ 2>&1; \ + $(evaluate-test) + # Print test summary for tests in $1 .sum file; # $2 is optional test identifier. # Fail if there are unexpected failures in the test results. @@ -737,7 +744,7 @@ endif INSTALL: manual/install-plain.texi manual/macros.texi \ $(common-objpfx)manual/pkgvers.texi manual/install.texi makeinfo --no-validate --plaintext --no-number-sections \ - -I$(common-objpfx)manual $< -o $@-tmp + --disable-encoding -I$(common-objpfx)manual $< -o $@-tmp $(AWK) 'NF == 0 { ++n; next } \ NF != 0 { while (n-- > 0) print ""; n = 0; print }' \ < $@-tmp > $@-tmp2 diff --git a/NEWS b/NEWS index cf6078cf20..2234021a95 100644 --- a/NEWS +++ b/NEWS @@ -177,6 +177,25 @@ found in the advisories directory of the release tarball: GLIBC-SA-2024-0003: syslog: Integer overflow in __vsyslog_internal (CVE-2023-6780) + GLIBC-SA-2024-0004: + ISO-2022-CN-EXT: fix out-of-bound writes when writing escape + sequence (CVE-2024-2961) + + GLIBC-SA-2024-0005: + nscd: Stack-based buffer overflow in netgroup cache (CVE-2024-33599) + + GLIBC-SA-2024-0006: + nscd: Null pointer crashes after notfound response + (CVE-2024-33600) + + GLIBC-SA-2024-0007: + nscd: netgroup cache may terminate daemon on memory allocation + failure (CVE-2024-33601) + + GLIBC-SA-2024-0008: + nscd: netgroup cache assumes NSS callback uses in-buffer strings + (CVE-2024-33602) + The following bugs are resolved with this release: [14522] localedata: fy_DE: LC_IDENTIFICATION data looks weird diff --git a/Rules b/Rules index c7db0a4869..9010c5d5b2 100644 --- a/Rules +++ b/Rules @@ -188,6 +188,7 @@ binaries-all = $(binaries-all-notests) $(binaries-all-tests) binaries-static-notests = $(others-static) binaries-static-tests = $(tests-static) $(xtests-static) binaries-static = $(binaries-static-notests) $(binaries-static-tests) +binaries-shared-2.0-tests = $(tests-2.0) ifeq (yesyes,$(have-fpie)$(build-shared)) binaries-pie-tests = $(tests-pie) $(xtests-pie) binaries-pie-notests = $(others-pie) @@ -215,7 +216,8 @@ binaries-malloc-hugetlb2-tests = endif binaries-pie = $(binaries-pie-tests) $(binaries-pie-notests) -binaries-shared-tests = $(filter-out $(binaries-pie) $(binaries-static), \ +binaries-shared-tests = $(filter-out $(binaries-pie) $(binaries-static) \ + $(binaries-shared-2.0-tests), \ $(binaries-all-tests)) binaries-shared-notests = $(filter-out $(binaries-pie) $(binaries-static), \ $(binaries-all-notests)) @@ -235,6 +237,15 @@ $(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \ $(+link-tests) endif +# Linking test programs with crt1.o from glibc 2.0. +ifneq "$(strip $(binaries-shared-2.0-tests))" "" +$(addprefix $(objpfx),$(binaries-shared-2.0-tests)): %: %.o \ + $(link-extra-libs-tests) \ + $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \ + $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) + $(+link-2.0-tests) +endif + ifneq "$(strip $(binaries-mcheck-tests))" "" $(addprefix $(objpfx),$(binaries-mcheck-tests)): %-mcheck: %.o \ $(link-extra-libs-tests) \ diff --git a/advisories/GLIBC-SA-2024-0005 b/advisories/GLIBC-SA-2024-0005 new file mode 100644 index 0000000000..a59596610a --- /dev/null +++ b/advisories/GLIBC-SA-2024-0005 @@ -0,0 +1,22 @@ +nscd: Stack-based buffer overflow in netgroup cache + +If the Name Service Cache Daemon's (nscd) fixed size cache is exhausted +by client requests then a subsequent client request for netgroup data +may result in a stack-based buffer overflow. This flaw was introduced +in glibc 2.15 when the cache was added to nscd. + +This vulnerability is only present in the nscd binary. + +CVE-Id: CVE-2024-33599 +Public-Date: 2024-04-23 +Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) +Fix-Commit: 69c58d5ef9f584ea198bd00f7964d364d0e6b921 (2.31-155) +Fix-Commit: a77064893bfe8a701770e2f53a4d33805bc47a5a (2.32-141) +Fix-Commit: 5c75001a96abcd50cbdb74df24c3f013188d076e (2.33-264) +Fix-Commit: 52f73e5c4e29b14e79167272297977f360ae1e97 (2.34-460) +Fix-Commit: 7a95873543ce225376faf13bb71c43dea6d24f86 (2.35-316) +Fix-Commit: caa3151ca460bdd9330adeedd68c3112d97bffe4 (2.36-165) +Fix-Commit: f75c298e747b2b8b41b1c2f551c011a52c41bfd1 (2.37-91) +Fix-Commit: 5968aebb86164034b8f8421b4abab2f837a5bdaf (2.38-72) +Fix-Commit: 1263d583d2e28afb8be53f8d6922f0842036f35d (2.39-35) +Fix-Commit: 87801a8fd06db1d654eea3e4f7626ff476a9bdaa (2.40) diff --git a/advisories/GLIBC-SA-2024-0006 b/advisories/GLIBC-SA-2024-0006 new file mode 100644 index 0000000000..d44148d3d9 --- /dev/null +++ b/advisories/GLIBC-SA-2024-0006 @@ -0,0 +1,32 @@ +nscd: Null pointer crash after notfound response + +If the Name Service Cache Daemon's (nscd) cache fails to add a not-found +netgroup response to the cache, the client request can result in a null +pointer dereference. This flaw was introduced in glibc 2.15 when the +cache was added to nscd. + +This vulnerability is only present in the nscd binary. + +CVE-Id: CVE-2024-33600 +Public-Date: 2024-04-24 +Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) +Fix-Commit: b048a482f088e53144d26a61c390bed0210f49f2 (2.40) +Fix-Commit: 7835b00dbce53c3c87bbbb1754a95fb5e58187aa (2.40) +Fix-Commit: c99f886de54446cd4447db6b44be93dabbdc2f8b (2.39-37) +Fix-Commit: 5a508e0b508c8ad53bd0d2fb48fd71b242626341 (2.39-36) +Fix-Commit: 2ae9446c1b7a3064743b4a51c0bbae668ee43e4c (2.38-74) +Fix-Commit: 541ea5172aa658c4bd5c6c6d6fd13903c3d5bb0a (2.38-73) +Fix-Commit: a8070b31043c7585c36ba68a74298c4f7af075c3 (2.37-93) +Fix-Commit: 5eea50c4402e39588de98aa1d4469a79774703d4 (2.37-92) +Fix-Commit: f205b3af56740e3b014915b1bd3b162afe3407ef (2.36-167) +Fix-Commit: c34f470a615b136170abd16142da5dd0c024f7d1 (2.36-166) +Fix-Commit: bafadc589fbe21ae330e8c2af74db9da44a17660 (2.35-318) +Fix-Commit: 4370bef52b0f3f3652c6aa13d7a9bb3ac079746d (2.35-317) +Fix-Commit: 1f94122289a9bf7dba573f5d60327aaa2b85cf2e (2.34-462) +Fix-Commit: 966d6ac9e40222b84bb21674cc4f83c8d72a5a26 (2.34-461) +Fix-Commit: e3eef1b8fbdd3a7917af466ca9c4b7477251ca79 (2.33-266) +Fix-Commit: f20a8d696b13c6261b52a6434899121f8b19d5a7 (2.33-265) +Fix-Commit: be602180146de37582a3da3a0caa4b719645de9c (2.32-143) +Fix-Commit: 394eae338199078b7961b051c191539870742d7b (2.32-142) +Fix-Commit: 8d7949183760170c61e55def723c1d8050187874 (2.31-157) +Fix-Commit: 304ce5fe466c4762b21b36c26926a4657b59b53e (2.31-156) diff --git a/advisories/GLIBC-SA-2024-0007 b/advisories/GLIBC-SA-2024-0007 new file mode 100644 index 0000000000..b6928fa27a --- /dev/null +++ b/advisories/GLIBC-SA-2024-0007 @@ -0,0 +1,28 @@ +nscd: netgroup cache may terminate daemon on memory allocation failure + +The Name Service Cache Daemon's (nscd) netgroup cache uses xmalloc or +xrealloc and these functions may terminate the process due to a memory +allocation failure resulting in a denial of service to the clients. The +flaw was introduced in glibc 2.15 when the cache was added to nscd. + +This vulnerability is only present in the nscd binary. + +Subsequent refactoring of the netgroup cache only added more uses of +xmalloc and xrealloc. Uses of xmalloc and xrealloc in other parts of +nscd only occur during startup of the daemon and so are not affected by +client requests that could trigger an out of memory followed by +termination. + +CVE-Id: CVE-2024-33601 +Public-Date: 2024-04-24 +Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) +Fix-Commit: c04a21e050d64a1193a6daab872bca2528bda44b (2.40) +Fix-Commit: a9a8d3eebb145779a18d90e3966009a1daa63cd8 (2.39-38) +Fix-Commit: 71af8ca864345d39b746d5cee84b94b430fad5db (2.38-75) +Fix-Commit: 6e106dc214d6a033a4e945d1c6cf58061f1c5f1f (2.37-94) +Fix-Commit: b6742463694b1dfdd5120b91ee21cf05d15ec2e2 (2.36-168) +Fix-Commit: 7a5864cac60e06000394128a5a2817b03542f5a3 (2.35-319) +Fix-Commit: 86f1d5f4129c373ac6fb6df5bcf38273838843cb (2.34-463) +Fix-Commit: 4d27d4b9a188786fc6a56745506cec2acfc51f83 (2.33-267) +Fix-Commit: 3ed195a8ec89da281e3c4bf887a13d281b72d8f4 (2.32-144) +Fix-Commit: bbf5a58ccb55679217f94de706164d15372fbbc0 (2.31-158) diff --git a/advisories/GLIBC-SA-2024-0008 b/advisories/GLIBC-SA-2024-0008 new file mode 100644 index 0000000000..d93e2a6f0b --- /dev/null +++ b/advisories/GLIBC-SA-2024-0008 @@ -0,0 +1,26 @@ +nscd: netgroup cache assumes NSS callback uses in-buffer strings + +The Name Service Cache Daemon's (nscd) netgroup cache can corrupt memory +when the NSS callback does not store all strings in the provided buffer. +The flaw was introduced in glibc 2.15 when the cache was added to nscd. + +This vulnerability is only present in the nscd binary. + +There is no guarantee from the NSS callback API that the returned +strings are all within the buffer. However, the netgroup cache code +assumes that the NSS callback uses in-buffer strings and if it doesn't +the buffer resizing logic could lead to potential memory corruption. + +CVE-Id: CVE-2024-33602 +Public-Date: 2024-04-24 +Vulnerable-Commit: 684ae515993269277448150a1ca70db3b94aa5bd (2.15) +Fix-Commit: c04a21e050d64a1193a6daab872bca2528bda44b (2.40) +Fix-Commit: a9a8d3eebb145779a18d90e3966009a1daa63cd8 (2.39-38) +Fix-Commit: 71af8ca864345d39b746d5cee84b94b430fad5db (2.38-75) +Fix-Commit: 6e106dc214d6a033a4e945d1c6cf58061f1c5f1f (2.37-94) +Fix-Commit: b6742463694b1dfdd5120b91ee21cf05d15ec2e2 (2.36-168) +Fix-Commit: 7a5864cac60e06000394128a5a2817b03542f5a3 (2.35-319) +Fix-Commit: 86f1d5f4129c373ac6fb6df5bcf38273838843cb (2.34-463) +Fix-Commit: 4d27d4b9a188786fc6a56745506cec2acfc51f83 (2.33-267) +Fix-Commit: 3ed195a8ec89da281e3c4bf887a13d281b72d8f4 (2.32-144) +Fix-Commit: bbf5a58ccb55679217f94de706164d15372fbbc0 (2.31-158) diff --git a/csu/Makefile b/csu/Makefile index 946fd91031..777d6720a7 100644 --- a/csu/Makefile +++ b/csu/Makefile @@ -42,6 +42,7 @@ csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o) extra-objs = \ $(csu-dummies) \ $(start-installed-name) \ + $(start-name-2.0) \ S$(start-installed-name) \ g$(start-installed-name) \ start.o \ @@ -182,6 +183,9 @@ ifndef start-installed-name-rule $(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \ $(objpfx)init.o $(objpfx)static-reloc.o $(link-relocatable) +$(objpfx)$(start-name-2.0): $(objpfx)start.o $(objpfx)abi-note.o \ + $(objpfx)static-reloc.o + $(link-relocatable) $(objpfx)r$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \ $(objpfx)init.o $(link-relocatable) diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index d3ccd2ecd4..147cc4cf23 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -32,6 +32,7 @@ #include <ldsodefs.h> #include <array_length.h> #include <dl-minimal-malloc.h> +#include <dl-symbol-redir-ifunc.h> #define TUNABLES_INTERNAL 1 #include "dl-tunables.h" @@ -118,6 +119,17 @@ do_tunable_update_val (tunable_t *cur, const tunable_val_t *valp, cur->initialized = true; } +static bool +tunable_parse_num (const char *strval, size_t len, tunable_num_t *val) +{ + char *endptr = NULL; + uint64_t numval = _dl_strtoul (strval, &endptr); + if (endptr != strval + len) + return false; + *val = (tunable_num_t) numval; + return true; +} + /* Validate range of the input value and initialize the tunable CUR if it looks good. */ static bool @@ -127,11 +139,8 @@ tunable_initialize (tunable_t *cur, const char *strval, size_t len) if (cur->type.type_code != TUNABLE_TYPE_STRING) { - char *endptr = NULL; - uint64_t numval = _dl_strtoul (strval, &endptr); - if (endptr != strval + len) + if (!tunable_parse_num (strval, len, &val.numval)) return false; - val.numval = (tunable_num_t) numval; } else val.strval = (struct tunable_str_t) { strval, len }; @@ -221,19 +230,7 @@ parse_tunables_string (const char *valstring, struct tunable_toset_t *tunables) if (tunable_is_name (cur->name, name)) { - tunables[ntunables++] = - (struct tunable_toset_t) { cur, value, p - value }; - - /* Ignore tunables if enable_secure is set */ - if (tunable_is_name ("glibc.rtld.enable_secure", name)) - { - tunable_num_t val = (tunable_num_t) _dl_strtoul (value, NULL); - if (val == 1) - { - __libc_enable_secure = 1; - return 0; - } - } + tunables[i] = (struct tunable_toset_t) { cur, value, p - value }; break; } } @@ -243,25 +240,50 @@ parse_tunables_string (const char *valstring, struct tunable_toset_t *tunables) } static void +parse_tunable_print_error (const struct tunable_toset_t *toset) +{ + _dl_error_printf ("WARNING: ld.so: invalid GLIBC_TUNABLES value `%.*s' " + "for option `%s': ignored.\n", + (int) toset->len, + toset->value, + toset->t->name); +} + +static void parse_tunables (const char *valstring) { - struct tunable_toset_t tunables[tunables_list_size]; - int ntunables = parse_tunables_string (valstring, tunables); - if (ntunables == -1) + struct tunable_toset_t tunables[tunables_list_size] = { 0 }; + if (parse_tunables_string (valstring, tunables) == -1) { _dl_error_printf ( "WARNING: ld.so: invalid GLIBC_TUNABLES `%s': ignored.\n", valstring); return; } - for (int i = 0; i < ntunables; i++) - if (!tunable_initialize (tunables[i].t, tunables[i].value, - tunables[i].len)) - _dl_error_printf ("WARNING: ld.so: invalid GLIBC_TUNABLES value `%.*s' " - "for option `%s': ignored.\n", - (int) tunables[i].len, - tunables[i].value, - tunables[i].t->name); + /* Ignore tunables if enable_secure is set */ + struct tunable_toset_t *tsec = + &tunables[TUNABLE_ENUM_NAME(glibc, rtld, enable_secure)]; + if (tsec->t != NULL) + { + tunable_num_t val; + if (!tunable_parse_num (tsec->value, tsec->len, &val)) + parse_tunable_print_error (tsec); + else if (val == 1) + { + __libc_enable_secure = 1; + return; + } + } + + for (int i = 0; i < tunables_list_size; i++) + { + if (tunables[i].t == NULL) + continue; + + if (!tunable_initialize (tunables[i].t, tunables[i].value, + tunables[i].len)) + parse_tunable_print_error (&tunables[i]); + } } /* Initialize the tunables list from the environment. For now we only use the @@ -278,6 +300,9 @@ __tunables_init (char **envp) if (__libc_enable_secure) return; + enum { tunable_num_env_alias = array_length (tunable_env_alias_list) }; + struct tunable_toset_t tunables_env_alias[tunable_num_env_alias] = { 0 }; + while ((envp = get_next_env (envp, &envname, &envval, &prev_envp)) != NULL) { /* The environment variable is allocated on the stack by the kernel, so @@ -289,29 +314,44 @@ __tunables_init (char **envp) continue; } - for (int i = 0; i < tunables_list_size; i++) + for (int i = 0; i < tunable_num_env_alias; i++) { - tunable_t *cur = &tunable_list[i]; + tunable_t *cur = &tunable_list[tunable_env_alias_list[i]]; + const char *name = cur->env_alias; - /* Skip over tunables that have either been set already or should be - skipped. */ - if (cur->initialized || cur->env_alias[0] == '\0') + if (name[0] == '\0') continue; - const char *name = cur->env_alias; - - /* We have a match. Initialize and move on to the next line. */ if (tunable_is_name (name, envname)) { size_t envvallen = 0; /* The environment variable is always null-terminated. */ for (const char *p = envval; *p != '\0'; p++, envvallen++); - tunable_initialize (cur, envval, envvallen); + tunables_env_alias[i] = + (struct tunable_toset_t) { cur, envval, envvallen }; break; } } } + + /* Check if glibc.rtld.enable_secure was set and skip over the environment + variables aliases. */ + if (__libc_enable_secure) + return; + + for (int i = 0; i < tunable_num_env_alias; i++) + { + /* Skip over tunables that have either been set or already initialized. */ + if (tunables_env_alias[i].t == NULL + || tunables_env_alias[i].t->initialized) + continue; + + if (!tunable_initialize (tunables_env_alias[i].t, + tunables_env_alias[i].value, + tunables_env_alias[i].len)) + parse_tunable_print_error (&tunables_env_alias[i]); + } } void diff --git a/elf/tst-audit18.c b/elf/tst-audit18.c index 841251dd70..cec93e269c 100644 --- a/elf/tst-audit18.c +++ b/elf/tst-audit18.c @@ -79,7 +79,7 @@ do_test (int argc, char *argv[]) setenv ("LD_AUDIT", "tst-auditmod18.so", 0); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit18", 0, sc_allow_stderr); struct diff --git a/elf/tst-audit19b.c b/elf/tst-audit19b.c index 70bfe4eadf..88d99a416b 100644 --- a/elf/tst-audit19b.c +++ b/elf/tst-audit19b.c @@ -69,7 +69,7 @@ do_test (int argc, char *argv[]) setenv ("LD_AUDIT", "tst-auditmod18b.so", 0); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit18b", 0, sc_allow_stderr); bool find_symbind = false; diff --git a/elf/tst-audit22.c b/elf/tst-audit22.c index 4e97be3be0..6aa18af948 100644 --- a/elf/tst-audit22.c +++ b/elf/tst-audit22.c @@ -83,7 +83,7 @@ do_test (int argc, char *argv[]) setenv ("LD_AUDIT", "tst-auditmod22.so", 0); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr); /* The respawned process should always print the vDSO address (otherwise it diff --git a/elf/tst-audit23.c b/elf/tst-audit23.c index 32e7c8b2a3..d2640fe8b2 100644 --- a/elf/tst-audit23.c +++ b/elf/tst-audit23.c @@ -82,7 +82,7 @@ do_test (int argc, char *argv[]) setenv ("LD_AUDIT", "tst-auditmod23.so", 0); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr); /* The expected la_objopen/la_objclose: diff --git a/elf/tst-audit25a.c b/elf/tst-audit25a.c index b209ee820f..cdd4f2ce2b 100644 --- a/elf/tst-audit25a.c +++ b/elf/tst-audit25a.c @@ -77,7 +77,7 @@ do_test (int argc, char *argv[]) { struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit25a", 0, sc_allow_stderr); @@ -102,7 +102,7 @@ do_test (int argc, char *argv[]) { setenv ("LD_BIND_NOW", "1", 0); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit25a", 0, sc_allow_stderr); diff --git a/elf/tst-audit25b.c b/elf/tst-audit25b.c index 9b8665d517..939f4d6188 100644 --- a/elf/tst-audit25b.c +++ b/elf/tst-audit25b.c @@ -76,7 +76,7 @@ do_test (int argc, char *argv[]) { struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit25a", 0, sc_allow_stderr); @@ -102,7 +102,7 @@ do_test (int argc, char *argv[]) { setenv ("LD_BIND_NOW", "1", 0); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-audit25a", 0, sc_allow_stderr); diff --git a/elf/tst-glibc-hwcaps-2-cache.c b/elf/tst-glibc-hwcaps-2-cache.c index 81ab44ff78..af91476cca 100644 --- a/elf/tst-glibc-hwcaps-2-cache.c +++ b/elf/tst-glibc-hwcaps-2-cache.c @@ -32,7 +32,7 @@ main (int argc, char **argv) /* Run ldconfig to populate the cache. */ char *command = xasprintf ("%s/ldconfig", support_install_rootsbindir); struct support_capture_subprocess result = - support_capture_subprogram (command, &((char *) { NULL })); + support_capture_subprogram (command, &((char *) { NULL }), NULL); support_capture_subprocess_check (&result, "ldconfig", 0, sc_allow_none); free (command); diff --git a/elf/tst-rtld-run-static.c b/elf/tst-rtld-run-static.c index b2650e85ff..f05c00eb7b 100644 --- a/elf/tst-rtld-run-static.c +++ b/elf/tst-rtld-run-static.c @@ -30,7 +30,7 @@ do_test (void) { char *argv[] = { (char *) "ld.so", ldconfig_path, (char *) "--help", NULL }; struct support_capture_subprocess cap - = support_capture_subprogram (support_objdir_elf_ldso, argv); + = support_capture_subprogram (support_objdir_elf_ldso, argv, NULL); support_capture_subprocess_check (&cap, "no --argv0", 0, sc_allow_stdout); puts ("info: output without --argv0:"); puts (cap.out.buffer); @@ -46,7 +46,7 @@ do_test (void) ldconfig_path, (char *) "--help", NULL }; struct support_capture_subprocess cap - = support_capture_subprogram (support_objdir_elf_ldso, argv); + = support_capture_subprogram (support_objdir_elf_ldso, argv, NULL); support_capture_subprocess_check (&cap, "with --argv0", 0, sc_allow_stdout); puts ("info: output with --argv0:"); puts (cap.out.buffer); diff --git a/elf/tst-tunables-enable_secure.c b/elf/tst-tunables-enable_secure.c index e31e1f7faa..99a065e8db 100644 --- a/elf/tst-tunables-enable_secure.c +++ b/elf/tst-tunables-enable_secure.c @@ -17,6 +17,10 @@ <https://www.gnu.org/licenses/>. */ #include <array_length.h> +/* The test uses the tunable_env_alias_list size, which is only exported for + ld.so. This will result in a copy of tunable_list and + tunable_env_alias_list, which is ununsed by the test itself. */ +#define TUNABLES_INTERNAL 1 #include <dl-tunables.h> #include <getopt.h> #include <intprops.h> @@ -34,6 +38,8 @@ static int restart; static const struct test_t { const char *env; + const char *extraenv; + bool check_multiple; int32_t expected_malloc_check; int32_t expected_enable_secure; } tests[] = @@ -41,39 +47,124 @@ static const struct test_t /* Expected tunable format. */ /* Tunables should be ignored if enable_secure is set. */ { - "glibc.malloc.check=2:glibc.rtld.enable_secure=1", + "GLIBC_TUNABLES=glibc.malloc.check=2:glibc.rtld.enable_secure=1", + NULL, + false, 0, 1, }, /* Tunables should be ignored if enable_secure is set. */ { - "glibc.rtld.enable_secure=1:glibc.malloc.check=2", + "GLIBC_TUNABLES=glibc.rtld.enable_secure=1:glibc.malloc.check=2", + NULL, + false, 0, 1, }, /* Tunables should be set if enable_secure is unset. */ { - "glibc.rtld.enable_secure=0:glibc.malloc.check=2", + "GLIBC_TUNABLES=glibc.rtld.enable_secure=0:glibc.malloc.check=2", + NULL, + false, 2, 0, }, + /* Tunables should be ignored if enable_secure is set. */ + { + "GLIBC_TUNABLES=glibc.malloc.check=2:glibc.rtld.enable_secure=1", + "MALLOC_CHECK_=2", + false, + 0, + 1, + }, + /* Same as before, but with enviroment alias prior GLIBC_TUNABLES. */ + { + "MALLOC_CHECK_=2", + "GLIBC_TUNABLES=glibc.malloc.check=2:glibc.rtld.enable_secure=1", + false, + 0, + 1, + }, + /* Tunables should be ignored if enable_secure is set. */ + { + "GLIBC_TUNABLES=glibc.rtld.enable_secure=1:glibc.malloc.check=2", + "MALLOC_CHECK_=2", + false, + 0, + 1, + }, + { + "MALLOC_CHECK_=2", + "GLIBC_TUNABLES=glibc.rtld.enable_secure=1:glibc.malloc.check=2", + false, + 0, + 1, + }, + /* Tunables should be set if enable_secure is unset. */ + { + "GLIBC_TUNABLES=glibc.rtld.enable_secure=0:glibc.malloc.check=2", + /* Tunable have precedence over the environment variable. */ + "MALLOC_CHECK_=1", + false, + 2, + 0, + }, + { + "MALLOC_CHECK_=1", + "GLIBC_TUNABLES=glibc.rtld.enable_secure=0:glibc.malloc.check=2", + /* Tunable have precedence over the environment variable. */ + false, + 2, + 0, + }, + /* Tunables should be set if enable_secure is unset. */ + { + "GLIBC_TUNABLES=glibc.rtld.enable_secure=0", + /* Tunable have precedence over the environment variable. */ + "MALLOC_CHECK_=1", + false, + 1, + 0, + }, + /* Tunables should be set if enable_secure is unset. */ + { + "GLIBC_TUNABLES=glibc.rtld.enable_secure=0", + /* Tunable have precedence over the environment variable. */ + "MALLOC_CHECK_=1", + false, + 1, + 0, + }, + /* Check with tunables environment variable alias set multiple times. */ + { + "GLIBC_TUNABLES=glibc.rtld.enable_secure=1:glibc.malloc.check=2", + "MALLOC_CHECK_=2", + true, + 0, + 1, + }, + /* Tunables should be set if enable_secure is unset. */ + { + "GLIBC_TUNABLES=glibc.rtld.enable_secure=0", + /* Tunable have precedence over the environment variable. */ + "MALLOC_CHECK_=1", + true, + 1, + 0, + }, }; static int handle_restart (int i) { if (tests[i].expected_enable_secure == 1) - { - TEST_COMPARE (1, __libc_enable_secure); - } + TEST_COMPARE (1, __libc_enable_secure); else - { - TEST_COMPARE (tests[i].expected_malloc_check, - TUNABLE_GET_FULL (glibc, malloc, check, int32_t, NULL)); - TEST_COMPARE (tests[i].expected_enable_secure, - TUNABLE_GET_FULL (glibc, rtld, enable_secure, int32_t, - NULL)); - } + TEST_COMPARE (tests[i].expected_enable_secure, + TUNABLE_GET_FULL (glibc, rtld, enable_secure, int32_t, + NULL)); + TEST_COMPARE (tests[i].expected_malloc_check, + TUNABLE_GET_FULL (glibc, malloc, check, int32_t, NULL)); return 0; } @@ -106,14 +197,31 @@ do_test (int argc, char *argv[]) spargv[i] = NULL; } + enum { tunable_num_env_alias = array_length (tunable_env_alias_list) }; + for (int i = 0; i < array_length (tests); i++) { snprintf (nteststr, sizeof nteststr, "%d", i); printf ("[%d] Spawned test for %s\n", i, tests[i].env); setenv ("GLIBC_TUNABLES", tests[i].env, 1); + + char *envp[2 + tunable_num_env_alias + 1] = + { + (char *) tests[i].env, + (char *) tests[i].extraenv, + NULL, + }; + if (tests[i].check_multiple) + { + int j; + for (j=0; j < tunable_num_env_alias; j++) + envp[j + 2] = (char *) tests[i].extraenv; + envp[j + 2] = NULL; + } + struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, envp); support_capture_subprocess_check (&result, "tst-tunables-enable_secure", 0, sc_allow_stderr); support_capture_subprocess_free (&result); diff --git a/elf/tst-tunables.c b/elf/tst-tunables.c index 095b5c81d9..4884dd09f0 100644 --- a/elf/tst-tunables.c +++ b/elf/tst-tunables.c @@ -17,6 +17,10 @@ <https://www.gnu.org/licenses/>. */ #include <array_length.h> +/* The test uses the tunable_list size, which is only exported for + ld.so. This will result in a copy of tunable_list, which is ununsed by + the test itself. */ +#define TUNABLES_INTERNAL 1 #include <dl-tunables.h> #include <getopt.h> #include <intprops.h> @@ -24,12 +28,13 @@ #include <stdlib.h> #include <support/capture_subprocess.h> #include <support/check.h> +#include <support/support.h> static int restart; #define CMDLINE_OPTIONS \ { "restart", no_argument, &restart, 1 }, -static const struct test_t +static struct test_t { const char *name; const char *value; @@ -284,6 +289,29 @@ static const struct test_t 0, 0, }, + /* Also check for repeated tunables with a count larger than the total number + of tunables. */ + { + "GLIBC_TUNABLES", + NULL, + 2, + 0, + 0, + }, + { + "GLIBC_TUNABLES", + NULL, + 1, + 0, + 0, + }, + { + "GLIBC_TUNABLES", + NULL, + 0, + 0, + 0, + }, }; static int @@ -327,6 +355,37 @@ do_test (int argc, char *argv[]) spargv[i] = NULL; } + /* Create a tunable line with the duplicate values with a total number + larger than the different number of tunables. */ + { + enum { tunables_list_size = array_length (tunable_list) }; + const char *value = ""; + for (int i = 0; i < tunables_list_size; i++) + value = xasprintf ("%sglibc.malloc.check=2%c", + value, + i == (tunables_list_size - 1) ? '\0' : ':'); + tests[33].value = value; + } + /* Same as before, but the last tunable values is differen than the + rest. */ + { + enum { tunables_list_size = array_length (tunable_list) }; + const char *value = ""; + for (int i = 0; i < tunables_list_size - 1; i++) + value = xasprintf ("%sglibc.malloc.check=2:", value); + value = xasprintf ("%sglibc.malloc.check=1", value); + tests[34].value = value; + } + /* Same as before, but with an invalid last entry. */ + { + enum { tunables_list_size = array_length (tunable_list) }; + const char *value = ""; + for (int i = 0; i < tunables_list_size - 1; i++) + value = xasprintf ("%sglibc.malloc.check=2:", value); + value = xasprintf ("%sglibc.malloc.check=1=1", value); + tests[35].value = value; + } + for (int i = 0; i < array_length (tests); i++) { snprintf (nteststr, sizeof nteststr, "%d", i); @@ -337,7 +396,7 @@ do_test (int argc, char *argv[]) tests[i].value); setenv (tests[i].name, tests[i].value, 1); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-tunables", 0, sc_allow_stderr); support_capture_subprocess_free (&result); diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h index 1616c635d5..7bdb4d0ea9 100644 --- a/hurd/hurd/fd.h +++ b/hurd/hurd/fd.h @@ -300,8 +300,6 @@ __hurd_at_flags (int *at_flags, int *flags) *flags &= ~O_NOLINK; *at_flags &= ~AT_SYMLINK_FOLLOW; - if (*at_flags & AT_NO_AUTOMOUNT) - *flags |= O_NOTRANS; *at_flags &= ~AT_NO_AUTOMOUNT; if (*at_flags != 0) diff --git a/libio/Makefile b/libio/Makefile index 27623c92a9..0c1f16ee3b 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -68,22 +68,76 @@ routines_no_fortify += \ wprintf \ # routines_no_fortify -tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ - tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 \ - tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \ - tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \ - tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \ - tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \ - tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \ - bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \ - tst-memstream1 tst-memstream2 tst-memstream3 tst-memstream4 \ - tst-wmemstream1 tst-wmemstream2 tst-wmemstream3 tst-wmemstream4 \ - tst-wmemstream5 bug-memstream1 bug-wmemstream1 \ - tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \ - tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler \ - tst-ftell-append tst-fputws tst-bz22415 tst-fgetc-after-eof \ - tst-sprintf-ub tst-sprintf-chk-ub tst-bz24051 tst-bz24153 \ - tst-wfile-sync tst-bz28828 tst-getdelim +tests = \ + bug-fopena+ \ + bug-fseek \ + bug-ftell \ + bug-memstream1 \ + bug-mmap-fflush \ + bug-rewind \ + bug-rewind2 \ + bug-ungetc \ + bug-ungetc2 \ + bug-ungetc3 \ + bug-ungetc4 \ + bug-ungetwc1 \ + bug-ungetwc2 \ + bug-wfflush \ + bug-wmemstream1 \ + bug-wsetpos \ + test-fmemopen \ + tst-atime \ + tst-bz22415 \ + tst-bz24051 \ + tst-bz24153 \ + tst-bz28828 \ + tst-eof \ + tst-ext \ + tst-ext2 \ + tst-fgetc-after-eof \ + tst-fgetwc \ + tst-fgetws \ + tst-fopenloc2 \ + tst-fputws \ + tst-freopen \ + tst-fseek \ + tst-ftell-active-handler \ + tst-ftell-append \ + tst-ftell-partial-wide \ + tst-fwrite-error \ + tst-getdelim \ + tst-memstream1 \ + tst-memstream2 \ + tst-memstream3 \ + tst-memstream4 \ + tst-mmap-eofsync \ + tst-mmap-fflushsync \ + tst-mmap-offend \ + tst-mmap-setvbuf \ + tst-mmap2-eofsync \ + tst-popen1 \ + tst-setvbuf1 \ + tst-sprintf-chk-ub \ + tst-sprintf-ub \ + tst-sscanf \ + tst-swscanf \ + tst-ungetwc1 \ + tst-ungetwc2 \ + tst-wfile-sync \ + tst-widetext \ + tst-wmemstream1 \ + tst-wmemstream2 \ + tst-wmemstream3 \ + tst-wmemstream4 \ + tst-wmemstream5 \ + tst_getwc \ + tst_putwc \ + tst_swprintf \ + tst_swscanf \ + tst_wprintf \ + tst_wprintf2 \ + tst_wscanf \ + # tests tests-internal = tst-vtables tst-vtables-interposed @@ -212,6 +266,12 @@ aux := fileops genops stdfiles stdio strops ifeq ($(build-shared),yes) generated += tst-bz24228.mtrace tst-bz24228.check aux += oldfileops oldstdfiles +tests += \ + tst-stderr-compat \ +# tests +tests-2.0 += \ + tst-stderr-compat \ +# tests-2.0 endif shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \ @@ -229,16 +289,26 @@ tests-special += $(objpfx)tst-fopenloc-cmp.out $(objpfx)tst-fopenloc-mem.out \ $(objpfx)tst-bz24228-mem.out endif -tests += tst-cleanup-default tst-cleanup-default-static +tests += \ + tst-cleanup-default \ + tst-cleanup-default-static \ + # tests tests-static += tst-cleanup-default-static tests-special += $(objpfx)tst-cleanup-default-cmp.out $(objpfx)tst-cleanup-default-static-cmp.out LDFLAGS-tst-cleanup-default = -Wl,--gc-sections LDFLAGS-tst-cleanup-default-static = -Wl,--gc-sections ifeq ($(have-gnu-retain)$(have-z-start-stop-gc),yesyes) -tests += tst-cleanup-start-stop-gc tst-cleanup-start-stop-gc-static \ - tst-cleanup-nostart-stop-gc tst-cleanup-nostart-stop-gc-static -tests-static += tst-cleanup-start-stop-gc-static tst-cleanup-nostart-stop-gc-static +tests += \ + tst-cleanup-nostart-stop-gc \ + tst-cleanup-nostart-stop-gc-static \ + tst-cleanup-start-stop-gc \ + tst-cleanup-start-stop-gc-static \ + # tests +tests-static += \ + tst-cleanup-nostart-stop-gc-static \ + tst-cleanup-start-stop-gc-static \ + # tests-static tests-special += $(objpfx)tst-cleanup-start-stop-gc-cmp.out \ $(objpfx)tst-cleanup-start-stop-gc-static-cmp.out \ $(objpfx)tst-cleanup-nostart-stop-gc-cmp.out \ diff --git a/libio/tst-stderr-compat.c b/libio/tst-stderr-compat.c new file mode 100644 index 0000000000..8221415cd4 --- /dev/null +++ b/libio/tst-stderr-compat.c @@ -0,0 +1,52 @@ +/* Test that fclose works on stderr from glibc 2.0. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <shlib-compat.h> + +#if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +# define _LIBC +# define _IO_USE_OLD_IO_FILE +# include <stdio.h> +# include <support/check.h> + +extern FILE _IO_stderr_; +compat_symbol_reference (libc, _IO_stderr_, _IO_stderr_, GLIBC_2_0); +compat_symbol_reference (libc, fclose, fclose, GLIBC_2_0); + +__attribute__ ((weak, noclone, noinline)) +void +do_fclose (FILE *fp) +{ + TEST_VERIFY_EXIT (fclose (fp) == 0); +} + +static int +do_test (void) +{ + do_fclose (&_IO_stderr_); + return 0; +} +#else +static int +do_test (void) +{ + return 0; +} +#endif + +#include <support/test-driver.c> diff --git a/localedata/Makefile b/localedata/Makefile index 6d0bac225b..14532bf07c 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -93,6 +93,7 @@ test-input := \ ln_CD.UTF-8 \ lt_LT.UTF-8 \ lv_LV.UTF-8 \ + mdf_RU.UTF-8 \ mi_NZ.UTF-8 \ ml_IN.UTF-8 \ mn_MN.UTF-8 \ @@ -358,6 +359,7 @@ LOCALES := \ ln_CD.UTF-8 \ lt_LT.UTF-8 \ lv_LV.UTF-8 \ + mdf_RU.UTF-8 \ mi_NZ.UTF-8 \ ml_IN.UTF-8 \ mn_MN.UTF-8 \ diff --git a/localedata/SUPPORTED b/localedata/SUPPORTED index a2f3132480..759895cc3a 100644 --- a/localedata/SUPPORTED +++ b/localedata/SUPPORTED @@ -318,6 +318,7 @@ lzh_TW/UTF-8 \ mag_IN/UTF-8 \ mai_IN/UTF-8 \ mai_NP/UTF-8 \ +mdf_RU/UTF-8 \ mfe_MU/UTF-8 \ mg_MG.UTF-8/UTF-8 \ mg_MG/ISO-8859-15 \ diff --git a/localedata/locales/mdf_RU b/localedata/locales/mdf_RU new file mode 100644 index 0000000000..af7bdc1f46 --- /dev/null +++ b/localedata/locales/mdf_RU @@ -0,0 +1,199 @@ +comment_char % +escape_char / + +% This file is part of the GNU C Library and contains locale data. +% The Free Software Foundation does not claim any copyright interest +% in the locale data contained in this file. The foregoing does not +% affect the license of the GNU C Library as a whole. It does not +% exempt you from the conditions of the license if your use would +% otherwise be governed by that license. + +% Moksha Language Locale for Russia +% Source: +% Contact: Pavel Malashkin +% Email: <2odissey@gmail.com> +% Language: mdf +% Territory: RU +% Revision: 0.1 +% Date: 2024-01-18 +% Application: general +% Users: general + +% +% TODO: check LC_COLLATE +% +% needed extra cyrillic chars: Ә <U+04D8>, ә <U+04D9> +% +% Note: Moksha adopted latin alphabet should gradually +% replace cyrillic alphabet + +LC_IDENTIFICATION +title "Moksha language locale for Russia" +source "Pavel Malashkin" +address "" +contact "Pavel Malashkin" +email "2odissey@gmail.com" +tel "" +fax "" +language "Moksha" +territory "Russia" +revision "0.1" +date "2024-01-18" + +category "i18n:2012";LC_IDENTIFICATION +category "i18n:2012";LC_CTYPE +category "i18n:2012";LC_COLLATE +category "i18n:2012";LC_TIME +category "i18n:2012";LC_NUMERIC +category "i18n:2012";LC_PAPER +category "i18n:2012";LC_TELEPHONE +category "i18n:2012";LC_MEASUREMENT +category "i18n:2012";LC_ADDRESS +category "i18n:2012";LC_MONETARY +category "i18n:2012";LC_MESSAGES +END LC_IDENTIFICATION + +LC_COLLATE + +% There is no collation information for Moksha in CLDR. +% +% Moksha Cyrillic alphabet +% +% А а Б б В в Г г Д д Е е Ё ё Ж ж +% З з И и Й й К к Л л М м Н н О о +% П п Р р С с Т т У у Ф ф Х х Ц ц +% Ч ч Ш ш Щ щ Ъ ъ Ы ы Ь ь Э э Ю ю +% Я я Ӑ ӑ Ӓ ӓ +% +% Note: letter Ъ ъ has been replaced with letter Ӑ ӑ (A with breeve) +% for represent the mid central vowel [ə] +% +% Note: for represent near-open front unrounded vowel [æ] +% use letter Ӓ ӓ (A with diaeresis) + +copy "iso14651_t1" + +collating-symbol <cyrillic-a-with-breeve> +collating-symbol <cyrillic-a-with-diaeresis> + +% Ӑ after Я +reorder-after <S044F> % Cyrillic Small Letter Ya (я) +<cyrillic-a-with-breeve> +<cyrillic-a-with-diaeresis> + +ӑ <cyrillic-a-with-breeve>;<BASE>;<MIN>;IGNORE +Ӑ <cyrillic-a-with-breeve>;<BASE>;<CAP>;IGNORE +ӓ <cyrillic-a-with-diaeresis>;<BASE>;<MIN>;IGNORE +Ӓ <cyrillic-a-with-diaeresis>;<BASE>;<CAP>;IGNORE + +reorder-end + +END LC_COLLATE + +LC_CTYPE +copy "ru_RU" +END LC_CTYPE + +LC_MESSAGES +yesexpr "^[+1yYдД]" +noexpr "^[-0nNаА]" +yesstr "да" % да +nostr "аш" % аш +END LC_MESSAGES + +% Use Russian monetary standards only for cyrillic locale +LC_MONETARY +copy "ru_RU" +END LC_MONETARY + +% Use Russian numeric standards +LC_NUMERIC +copy "ru_RU" +END LC_NUMERIC + +LC_TIME +% day - The full names of the week days: +% https://sourceware.org/bugzilla/show_bug.cgi?id=31530#c6 +% https://en.wiktionary.org/wiki/Appendix:Days_of_the_week +day "Недляши";/ + "Атяньжи";/ + "Шавши";/ + "Вержи";/ + "Шуваланя";/ + "Пяденця";/ + "Ёткши" +% abday - The abbreviations for the week days: +abday "Нед";/ + "Атя";/ + "Шав";/ + "Вер";/ + "Шув";/ + "Пяд";/ + "Ётк" +mon "январь";/ + "февраль";/ + "март";/ + "апрель";/ + "май";/ + "июнь";/ + "июль";/ + "август";/ + "сентябрь";/ + "октябрь";/ + "ноябрь";/ + "декабрь" +abmon "янв";/ + "фев";/ + "мар";/ + "апр";/ + "май";/ + "июн";/ + "июл";/ + "авг";/ + "сен";/ + "окт";/ + "ноя";/ + "дек" +d_t_fmt "%a %d %b %Y %T" +date_fmt "%a %d %b %Y %T %Z" +d_fmt "%d.%m.%Y" +t_fmt "%T" +am_pm "";"" +t_fmt_ampm "" +week 7;19971130;1 +first_weekday 2 +END LC_TIME + +LC_PAPER +copy "i18n" +END LC_PAPER + +LC_TELEPHONE +copy "ru_RU" +END LC_TELEPHONE + +LC_MEASUREMENT +copy "i18n" +END LC_MEASUREMENT + +LC_NAME +copy "ru_RU" +END LC_NAME + +LC_ADDRESS +% Use Russian postal format +postal_fmt "%f%N%a%N%d%N%b%N%s %h %e %r%N%z %T%N%c%N" +% https://mdf.wikipedia.org/wiki/%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F_%D0%BC%D0%B0%D1%81%D1%82%D0%BE%D1%80 : Россия мастор +country_name "Россия мастор" +country_ab2 "RU" +country_ab3 "RUS" +country_num 643 +country_car "RUS" +% https://mdf.wikipedia.org/wiki/%D0%9C%D0%BE%D0%BA%D1%88%D0%B5%D0%BD%D1%8C_%D0%BA%D1%8F%D0%BB%D1%8C : Мокшень кяль +lang_name "Мокшень кяль" +% ISO 639 language abbreviations: +% 639-1 2 letter, 639-2 3 letter terminology +lang_ab "" +lang_term "mdf" +lang_lib "mdf" +END LC_ADDRESS diff --git a/localedata/mdf_RU.UTF-8.in b/localedata/mdf_RU.UTF-8.in new file mode 100644 index 0000000000..b69da39b85 --- /dev/null +++ b/localedata/mdf_RU.UTF-8.in @@ -0,0 +1,6 @@ +я +Я +ӑ +Ӑ +ӓ +Ӓ diff --git a/math/Makefile b/math/Makefile index a9fef9e2db..435939aedb 100644 --- a/math/Makefile +++ b/math/Makefile @@ -566,6 +566,9 @@ tests += \ test-matherr \ test-matherr-2 \ # tests +tests-2.0 += \ + test-matherr-2 \ + # tests-2.0 endif # These tests use internal (unexported) GMP functions and are linked diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c index e8fe041846..5fdcf4204e 100644 --- a/nscd/netgroupcache.c +++ b/nscd/netgroupcache.c @@ -522,7 +522,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req, if (__glibc_unlikely (dataset == NULL)) { cacheable = false; - /* The alloca is safe because nscd_run_worker verfies that + /* The alloca is safe because nscd_run_worker verifies that key_len is not larger than MAXKEYLEN. */ dataset = alloca (sizeof (*dataset) + req->key_len); } @@ -680,8 +680,8 @@ readdinnetgr (struct database_dyn *db, struct hashentry *he, .key_len = he->len }; - int timeout = addinnetgrX (db, -1, &req, db->data + he->key, he->owner, - he, dh); + time_t timeout = addinnetgrX (db, -1, &req, db->data + he->key, he->owner, + he, dh); if (timeout < 0) timeout = 0; return timeout; diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index 35dac538e5..38eb9f2dd2 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -362,8 +362,9 @@ class Context(object): gcc_cfg=['--enable-obsolete']) self.add_config(arch='or1k', os_name='linux-gnu', - variant='soft', - gcc_cfg=['--with-multilib-list=mcmov']) + gcc_cfg=['--with-multilib-list=mcmov,mhard-float'], + glibcs=[{'variant': 'soft'}, + {'variant': 'hard', 'ccopts': '-mhard-float'}]) self.add_config(arch='powerpc', os_name='linux-gnu', gcc_cfg=['--disable-multilib', '--enable-secureplt'], diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk index 9f5336381e..fc3b41376f 100644 --- a/scripts/gen-tunables.awk +++ b/scripts/gen-tunables.awk @@ -156,7 +156,7 @@ END { print "# define TUNABLE_ALIAS_MAX " (max_alias_len + 1) print "# include \"dl-tunable-types.h\"" # Finally, the tunable list. - print "static tunable_t tunable_list[] attribute_relro = {" + print "static tunable_t tunable_list[] attribute_relro __attribute_used__ = {" for (tnm in types) { split (tnm, indices, SUBSEP); t = indices[1]; @@ -168,5 +168,19 @@ END { default_val[t,n,m], env_alias[t,n,m]); } print "};" + + # Map of tunable with environment variables aliases used during parsing. */ + print "\nstatic const tunable_id_t tunable_env_alias_list[] =" + printf "{\n" + for (tnm in types) { + split (tnm, indices, SUBSEP); + t = indices[1]; + n = indices[2]; + m = indices[3]; + if (env_alias[t,n,m] != "{0}") { + printf (" TUNABLE_ENUM_NAME(%s, %s, %s),\n", t, n, m); + } + } + printf "};\n" print "#endif" } diff --git a/support/capture_subprocess.h b/support/capture_subprocess.h index 1ecbdfe4fc..93b7245d2a 100644 --- a/support/capture_subprocess.h +++ b/support/capture_subprocess.h @@ -35,11 +35,12 @@ struct support_capture_subprocess struct support_capture_subprocess support_capture_subprocess (void (*callback) (void *), void *closure); -/* Issue FILE with ARGV arguments by using posix_spawn and capture standard - output, standard error, and the exit status. The out.buffer and err.buffer - are handle as support_capture_subprocess. */ +/* Issue FILE with ARGV arguments and ENVP environments by using posix_spawn + and capture standard output, standard error, and the exit status. If + ENVP is NULL the current environment variable is used. The out.buffer and + err.buffer are handle by support_capture_subprocess. */ struct support_capture_subprocess support_capture_subprogram - (const char *file, char *const argv[]); + (const char *file, char *const argv[], char *const envp[]); /* Copy the running program into a setgid binary and run it with CHILD_ID argument. If execution is successful, return the exit status of the child diff --git a/support/subprocess.h b/support/subprocess.h index 8fbb895353..8274a2b22b 100644 --- a/support/subprocess.h +++ b/support/subprocess.h @@ -33,10 +33,11 @@ struct support_subprocess struct support_subprocess support_subprocess (void (*callback) (void *), void *closure); -/* Issue FILE with ARGV arguments by using posix_spawn and return is PID, a - pipe redirected to STDOUT, and a pipe redirected to STDERR. */ +/* Issue FILE with ARGV arguments and ENVP environments by using posix_spawn + and return is PID, a pipe redirected to STDOUT, and a pipe redirected to + STDERR. If ENVP is NULL the current environment variable is used. */ struct support_subprocess support_subprogram - (const char *file, char *const argv[]); + (const char *file, char *const argv[], char *const envp[]); /* Invoke program FILE with ARGV arguments by using posix_spawn and wait for it to complete. Return program exit status. */ diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c index ffced8a89f..53847194cb 100644 --- a/support/support_capture_subprocess.c +++ b/support/support_capture_subprocess.c @@ -93,13 +93,14 @@ support_capture_subprocess (void (*callback) (void *), void *closure) } struct support_capture_subprocess -support_capture_subprogram (const char *file, char *const argv[]) +support_capture_subprogram (const char *file, char *const argv[], + char *const envp[]) { struct support_capture_subprocess result; xopen_memstream (&result.out); xopen_memstream (&result.err); - struct support_subprocess proc = support_subprogram (file, argv); + struct support_subprocess proc = support_subprogram (file, argv, envp); support_capture_poll (&result, &proc); return result; diff --git a/support/support_subprocess.c b/support/support_subprocess.c index a2fef394d4..b692a7f8b1 100644 --- a/support/support_subprocess.c +++ b/support/support_subprocess.c @@ -69,7 +69,7 @@ support_subprocess (void (*callback) (void *), void *closure) } struct support_subprocess -support_subprogram (const char *file, char *const argv[]) +support_subprogram (const char *file, char *const argv[], char *const envp[]) { struct support_subprocess result = support_subprocess_init (); @@ -84,7 +84,8 @@ support_subprogram (const char *file, char *const argv[]) xposix_spawn_file_actions_addclose (&fa, result.stdout_pipe[1]); xposix_spawn_file_actions_addclose (&fa, result.stderr_pipe[1]); - result.pid = xposix_spawn (file, &fa, NULL, argv, environ); + result.pid = xposix_spawn (file, &fa, NULL, argv, + envp == NULL ? environ : envp); xclose (result.stdout_pipe[1]); xclose (result.stderr_pipe[1]); diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c index 8145548982..756fb75d19 100644 --- a/support/tst-support_capture_subprocess.c +++ b/support/tst-support_capture_subprocess.c @@ -238,7 +238,7 @@ do_subprogram (const struct test *test) args[argc] = NULL; TEST_VERIFY (argc < argv_size); - return support_capture_subprogram (args[0], args); + return support_capture_subprogram (args[0], args, NULL); } enum test_type diff --git a/sysdeps/aarch64/cpu-features.h b/sysdeps/aarch64/cpu-features.h index 5f2da91ebb..31782b66f9 100644 --- a/sysdeps/aarch64/cpu-features.h +++ b/sysdeps/aarch64/cpu-features.h @@ -47,13 +47,6 @@ #define IS_THUNDERX2(midr) (MIDR_IMPLEMENTOR(midr) == 'C' \ && MIDR_PARTNUM(midr) == 0xaf) -#define IS_NEOVERSE_N1(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \ - && MIDR_PARTNUM(midr) == 0xd0c) -#define IS_NEOVERSE_N2(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \ - && MIDR_PARTNUM(midr) == 0xd49) -#define IS_NEOVERSE_V1(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \ - && MIDR_PARTNUM(midr) == 0xd40) - #define IS_EMAG(midr) (MIDR_IMPLEMENTOR(midr) == 'P' \ && MIDR_PARTNUM(midr) == 0x000) diff --git a/sysdeps/aarch64/multiarch/memset_generic.S b/sysdeps/aarch64/multiarch/memset_generic.S index 81748bdbce..e125a5ed85 100644 --- a/sysdeps/aarch64/multiarch/memset_generic.S +++ b/sysdeps/aarch64/multiarch/memset_generic.S @@ -33,3 +33,7 @@ #endif #include <../memset.S> + +#if IS_IN (rtld) +strong_alias (memset, __memset_generic) +#endif diff --git a/sysdeps/i386/i586/memcpy.S b/sysdeps/i386/i586/memcpy.S index 3e26f112d6..79856d498a 100644 --- a/sysdeps/i386/i586/memcpy.S +++ b/sysdeps/i386/i586/memcpy.S @@ -26,7 +26,7 @@ #define LEN SRC+4 .text -#if defined PIC && IS_IN (libc) +#if defined SHARED && IS_IN (libc) ENTRY (__memcpy_chk) movl 12(%esp), %eax cmpl %eax, 16(%esp) diff --git a/sysdeps/i386/i686/memmove.S b/sysdeps/i386/i686/memmove.S index f230359ad6..effd958120 100644 --- a/sysdeps/i386/i686/memmove.S +++ b/sysdeps/i386/i686/memmove.S @@ -29,7 +29,7 @@ #define SRC DEST+4 #define LEN SRC+4 -#if defined PIC && IS_IN (libc) +#if defined SHARED && IS_IN (libc) ENTRY_CHK (__memmove_chk) movl 12(%esp), %eax cmpl %eax, 16(%esp) diff --git a/sysdeps/i386/i686/memset.S b/sysdeps/i386/i686/memset.S index f02f5a6df7..ab06771ea0 100644 --- a/sysdeps/i386/i686/memset.S +++ b/sysdeps/i386/i686/memset.S @@ -27,7 +27,7 @@ #define LEN CHR+4 .text -#if defined PIC && IS_IN (libc) +#if defined SHARED && IS_IN (libc) ENTRY_CHK (__memset_chk) movl 12(%esp), %eax cmpl %eax, 16(%esp) diff --git a/sysdeps/or1k/fpu/fclrexcpt.c b/sysdeps/or1k/fpu/fclrexcpt.c new file mode 100644 index 0000000000..44224f9c24 --- /dev/null +++ b/sysdeps/or1k/fpu/fclrexcpt.c @@ -0,0 +1,44 @@ +/* Clear given exceptions in current floating-point environment. + OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +feclearexcept (int excepts) +{ + fpu_control_t cw; + fpu_control_t cw_new; + + /* Mask out unsupported bits/exceptions. */ + excepts &= FE_ALL_EXCEPT; + + /* Read the complete control word. */ + _FPU_GETCW (cw); + + cw_new = cw & ~excepts; + + /* Put the new data in effect. */ + if (cw != cw_new) + _FPU_SETCW (cw_new); + + /* Success. */ + return 0; +} +libm_hidden_def (feclearexcept) diff --git a/sysdeps/or1k/fpu/fegetenv.c b/sysdeps/or1k/fpu/fegetenv.c new file mode 100644 index 0000000000..70c75aa0bf --- /dev/null +++ b/sysdeps/or1k/fpu/fegetenv.c @@ -0,0 +1,32 @@ +/* Store current floating-point environment. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +__fegetenv (fenv_t *envp) +{ + _FPU_GETCW (*envp); + + /* Success. */ + return 0; +} +libm_hidden_def (__fegetenv) +weak_alias (__fegetenv, fegetenv) +libm_hidden_weak (fegetenv) diff --git a/sysdeps/or1k/fpu/fegetmode.c b/sysdeps/or1k/fpu/fegetmode.c new file mode 100644 index 0000000000..7fffd2e0b5 --- /dev/null +++ b/sysdeps/or1k/fpu/fegetmode.c @@ -0,0 +1,29 @@ +/* Store current floating-point control modes. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fegetmode (femode_t *modep) +{ + _FPU_GETCW (*modep); + + /* Success. */ + return 0; +} diff --git a/sysdeps/or1k/fpu/fegetround.c b/sysdeps/or1k/fpu/fegetround.c new file mode 100644 index 0000000000..7e993b980a --- /dev/null +++ b/sysdeps/or1k/fpu/fegetround.c @@ -0,0 +1,29 @@ +/* Return current rounding direction. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <get-rounding-mode.h> + +int +__fegetround (void) +{ + return get_rounding_mode (); +} +libm_hidden_def (__fegetround) +weak_alias (__fegetround, fegetround) +libm_hidden_weak (fegetround) diff --git a/sysdeps/or1k/fpu/feholdexcpt.c b/sysdeps/or1k/fpu/feholdexcpt.c new file mode 100644 index 0000000000..0036e41ba2 --- /dev/null +++ b/sysdeps/or1k/fpu/feholdexcpt.c @@ -0,0 +1,33 @@ +/* Store current floating-point environment and clear exceptions. + OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fenv_private.h> + +int +__feholdexcept (fenv_t *envp) +{ + libc_feholdexcept_or1k (envp); + + /* Success. */ + return 0; +} +libm_hidden_def (__feholdexcept) +weak_alias (__feholdexcept, feholdexcept) +libm_hidden_weak (feholdexcept) diff --git a/sysdeps/or1k/fpu/fenv_private.h b/sysdeps/or1k/fpu/fenv_private.h new file mode 100644 index 0000000000..4f401e7a5a --- /dev/null +++ b/sysdeps/or1k/fpu/fenv_private.h @@ -0,0 +1,199 @@ +/* Private floating point rounding and exceptions handling. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef OR1K_FENV_PRIVATE_H +#define OR1K_FENV_PRIVATE_H 1 + +#include <fenv.h> +#include <fpu_control.h> + +static __always_inline void +libc_feholdexcept_or1k (fenv_t *envp) +{ + fpu_control_t cw; + fpu_control_t cw_new; + + /* Get and store the environment. */ + _FPU_GETCW (cw); + *envp = cw; + + /* Clear the exception status flags. */ + cw_new = cw & ~FE_ALL_EXCEPT; + + if (cw != cw_new) + _FPU_SETCW (cw_new); +} + +#define libc_feholdexcept libc_feholdexcept_or1k +#define libc_feholdexceptf libc_feholdexcept_or1k +#define libc_feholdexceptl libc_feholdexcept_or1k + +static __always_inline void +libc_fesetround_or1k (int round) +{ + fpu_control_t cw; + fpu_control_t cw_new; + + _FPU_GETCW (cw); + cw_new = cw & ~_FPU_FPCSR_RM_MASK; + cw_new |= round; + if (cw != cw_new) + _FPU_SETCW (cw_new); +} + +#define libc_fesetround libc_fesetround_or1k +#define libc_fesetroundf libc_fesetround_or1k +#define libc_fesetroundl libc_fesetround_or1k + +static __always_inline void +libc_feholdexcept_setround_or1k (fenv_t *envp, int round) +{ + fpu_control_t cw; + fpu_control_t cw_new; + + /* Get and store the environment. */ + _FPU_GETCW (cw); + *envp = cw; + + /* Clear the status flags and rounding mode. */ + cw_new = cw & ~(FE_ALL_EXCEPT | _FPU_FPCSR_RM_MASK); + + /* Set rounding mode. */ + cw_new |= round; + + if (cw != cw_new) + _FPU_SETCW (cw_new); +} + +#define libc_feholdexcept_setround libc_feholdexcept_setround_or1k +#define libc_feholdexcept_setroundf libc_feholdexcept_setround_or1k +#define libc_feholdexcept_setroundl libc_feholdexcept_setround_or1k + +static __always_inline int +libc_fetestexcept_or1k (int ex) +{ + fpu_control_t cw; + + /* Get current control word. */ + _FPU_GETCW (cw); + + /* Check if any of the queried exception flags are set. */ + return cw & ex & FE_ALL_EXCEPT; +} + +#define libc_fetestexcept libc_fetestexcept_or1k +#define libc_fetestexceptf libc_fetestexcept_or1k +#define libc_fetestexceptl libc_fetestexcept_or1k + +static __always_inline void +libc_fesetenv_or1k (const fenv_t *envp) +{ + if (envp == FE_DFL_ENV) + _FPU_SETCW (_FPU_DEFAULT); + else + _FPU_SETCW (*envp); +} + +#define libc_fesetenv libc_fesetenv_or1k +#define libc_fesetenvf libc_fesetenv_or1k +#define libc_fesetenvl libc_fesetenv_or1k +#define libc_feresetround_noex libc_fesetenv_or1k +#define libc_feresetround_noexf libc_fesetenv_or1k +#define libc_feresetround_noexl libc_fesetenv_or1k + +static __always_inline int +libc_feupdateenv_test_or1k (const fenv_t *envp, int ex) +{ + fpu_control_t cw; + fpu_control_t cw_new; + int excepts; + + /* Get current control word. */ + _FPU_GETCW (cw); + + /* Merge current exception flags with the passed fenv. */ + excepts = cw & FE_ALL_EXCEPT; + cw_new = (envp == FE_DFL_ENV ? _FPU_DEFAULT : *envp) | excepts; + + if (__glibc_unlikely (cw != cw_new)) + _FPU_SETCW (cw_new); + + /* Raise the exceptions if enabled in the new FP state. */ + if (__glibc_unlikely (excepts)) + __feraiseexcept (excepts); + + return excepts & ex; +} + +#define libc_feupdateenv_test libc_feupdateenv_test_or1k +#define libc_feupdateenv_testf libc_feupdateenv_test_or1k +#define libc_feupdateenv_testl libc_feupdateenv_test_or1k + +static __always_inline void +libc_feupdateenv_or1k (const fenv_t *envp) +{ + libc_feupdateenv_test_or1k (envp, 0); +} + +#define libc_feupdateenv libc_feupdateenv_or1k +#define libc_feupdateenvf libc_feupdateenv_or1k +#define libc_feupdateenvl libc_feupdateenv_or1k + +static __always_inline void +libc_feholdsetround_or1k (fenv_t *envp, int round) +{ + fpu_control_t cw; + + _FPU_GETCW (cw); + *envp = cw; + + /* Check whether rounding modes are different. */ + round = (cw ^ round) & _FPU_FPCSR_RM_MASK; + + /* Set new rounding mode if different. */ + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (cw ^ round); +} + +#define libc_feholdsetround libc_feholdsetround_or1k +#define libc_feholdsetroundf libc_feholdsetround_or1k +#define libc_feholdsetroundl libc_feholdsetround_or1k + +static __always_inline void +libc_feresetround_or1k (fenv_t *envp) +{ + fpu_control_t cw; + int round; + + _FPU_GETCW (cw); + + /* Check whether rounding modes are different. */ + round = (*envp ^ cw) & _FPU_FPCSR_RM_MASK; + + /* Restore the rounding mode if it was changed. */ + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (cw ^ round); +} + +#define libc_feresetround libc_feresetround_or1k +#define libc_feresetroundf libc_feresetround_or1k +#define libc_feresetroundl libc_feresetround_or1k + +#include_next <fenv_private.h> + +#endif diff --git a/sysdeps/or1k/fpu/fesetenv.c b/sysdeps/or1k/fpu/fesetenv.c new file mode 100644 index 0000000000..742ca719e0 --- /dev/null +++ b/sysdeps/or1k/fpu/fesetenv.c @@ -0,0 +1,32 @@ +/* Install given floating-point environment. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fenv_private.h> + +int +__fesetenv (const fenv_t *envp) +{ + libc_fesetenv_or1k (envp); + + /* Success. */ + return 0; +} +libm_hidden_def (__fesetenv) +weak_alias (__fesetenv, fesetenv) +libm_hidden_weak (fesetenv) diff --git a/sysdeps/or1k/fpu/fesetexcept.c b/sysdeps/or1k/fpu/fesetexcept.c new file mode 100644 index 0000000000..43734eac18 --- /dev/null +++ b/sysdeps/or1k/fpu/fesetexcept.c @@ -0,0 +1,35 @@ +/* Set given exception flags. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fesetexcept (int excepts) +{ + fpu_control_t cw; + fpu_control_t cw_new; + + _FPU_GETCW (cw); + cw_new = cw | (excepts & FE_ALL_EXCEPT); + if (cw != cw_new) + _FPU_SETCW (cw_new); + + /* Success. */ + return 0; +} diff --git a/sysdeps/or1k/fpu/fesetmode.c b/sysdeps/or1k/fpu/fesetmode.c new file mode 100644 index 0000000000..d4556927ce --- /dev/null +++ b/sysdeps/or1k/fpu/fesetmode.c @@ -0,0 +1,39 @@ +/* Install given floating-point control modes. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fesetmode (const femode_t *modep) +{ + fpu_control_t cw; + fpu_control_t cw_new; + + _FPU_GETCW (cw); + cw_new = cw & ~_FPU_FPCSR_RM_MASK; + if (modep == FE_DFL_MODE) + cw_new |= (_FPU_DEFAULT & _FPU_FPCSR_RM_MASK); + else + cw_new |= (*modep & _FPU_FPCSR_RM_MASK); + if (cw != cw_new) + _FPU_SETCW (cw_new); + + /* Success. */ + return 0; +} diff --git a/sysdeps/or1k/fpu/fesetround.c b/sysdeps/or1k/fpu/fesetround.c new file mode 100644 index 0000000000..c2ada98f1b --- /dev/null +++ b/sysdeps/or1k/fpu/fesetround.c @@ -0,0 +1,39 @@ +/* Set current rounding direction. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fenv_private.h> + +int +__fesetround (int round) +{ + switch (round) + { + case FE_TONEAREST: + case FE_TOWARDZERO: + case FE_DOWNWARD: + case FE_UPWARD: + libc_fesetround_or1k (round); + return 0; + default: + return round; /* A nonzero value. */ + } +} +libm_hidden_def (__fesetround) +weak_alias (__fesetround, fesetround) +libm_hidden_weak (fesetround) diff --git a/sysdeps/or1k/fpu/feupdateenv.c b/sysdeps/or1k/fpu/feupdateenv.c new file mode 100644 index 0000000000..3355bf6596 --- /dev/null +++ b/sysdeps/or1k/fpu/feupdateenv.c @@ -0,0 +1,33 @@ +/* Install given floating-point environment and raise exceptions. + OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fenv_private.h> + +int +__feupdateenv (const fenv_t *envp) +{ + libc_feupdateenv_or1k (envp); + + /* Success. */ + return 0; +} +libm_hidden_def (__feupdateenv) +weak_alias (__feupdateenv, feupdateenv) +libm_hidden_weak (feupdateenv) diff --git a/sysdeps/or1k/fpu/fgetexcptflg.c b/sysdeps/or1k/fpu/fgetexcptflg.c new file mode 100644 index 0000000000..a954f6a2f1 --- /dev/null +++ b/sysdeps/or1k/fpu/fgetexcptflg.c @@ -0,0 +1,29 @@ +/* Store current state of exceptions. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fenv_private.h> + +int +fegetexceptflag (fexcept_t *flagp, int excepts) +{ + *flagp = libc_fetestexcept_or1k (excepts); + + /* Success. */ + return 0; +} diff --git a/sysdeps/or1k/fpu/fix-fp-int-convert-overflow.h b/sysdeps/or1k/fpu/fix-fp-int-convert-overflow.h new file mode 100644 index 0000000000..78104289c0 --- /dev/null +++ b/sysdeps/or1k/fpu/fix-fp-int-convert-overflow.h @@ -0,0 +1,38 @@ +/* Fix for conversion of floating point to integer overflow. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef FIX_FP_INT_CONVERT_OVERFLOW_H +#define FIX_FP_INT_CONVERT_OVERFLOW_H 1 + +/* The generic libgcc2.c conversions from floating point to long long + may not raise the correct exceptions on overflow (and may raise + spurious "inexact" exceptions even in non-overflow cases, see + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59412>). */ +#define FIX_FLT_LONG_CONVERT_OVERFLOW 0 +#define FIX_FLT_LLONG_CONVERT_OVERFLOW 1 + +#define FIX_DBL_LONG_CONVERT_OVERFLOW 0 +#define FIX_DBL_LLONG_CONVERT_OVERFLOW 1 + +#define FIX_LDBL_LONG_CONVERT_OVERFLOW 0 +#define FIX_LDBL_LLONG_CONVERT_OVERFLOW 0 + +#define FIX_FLT128_LONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LLONG_CONVERT_OVERFLOW 0 + +#endif /* fix-fp-int-convert-overflow.h */ diff --git a/sysdeps/or1k/fpu/fraiseexcpt.c b/sysdeps/or1k/fpu/fraiseexcpt.c new file mode 100644 index 0000000000..bbacfd50bc --- /dev/null +++ b/sysdeps/or1k/fpu/fraiseexcpt.c @@ -0,0 +1,67 @@ +/* Raise given exceptions. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> +#include <float.h> +#include <math.h> + +int +__feraiseexcept (int excepts) +{ + if (excepts == 0) + return 0; + + /* Raise exceptions represented by EXPECTS. */ + + if (excepts & FE_INEXACT) + { + float d = 1.0, x = 3.0; + __asm__ volatile ("lf.div.s %0, %0, %1" : "+r" (d) : "r" (x)); + } + + if (excepts & FE_UNDERFLOW) + { + float d = FLT_MIN; + __asm__ volatile ("lf.mul.s %0, %0, %0" : "+r" (d)); + } + + if (excepts & FE_OVERFLOW) + { + float d = FLT_MAX; + __asm__ volatile ("lf.mul.s %0, %0, %0" : "+r" (d) : "r" (d)); + } + + if (excepts & FE_DIVBYZERO) + { + float d = 1.0, x = 0.0; + __asm__ volatile ("lf.div.s %0, %0, %1" : "+r" (d) : "r" (x)); + } + + if (excepts & FE_INVALID) + { + float d = HUGE_VAL, x = 0.0; + __asm__ volatile ("lf.mul.s %0, %1, %0" : "+r" (d) : "r" (x)); + } + + /* Success. */ + return 0; +} +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/or1k/fpu/fsetexcptflg.c b/sysdeps/or1k/fpu/fsetexcptflg.c new file mode 100644 index 0000000000..c327e4c5d1 --- /dev/null +++ b/sysdeps/or1k/fpu/fsetexcptflg.c @@ -0,0 +1,43 @@ +/* Set floating-point environment exception handling. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fesetexceptflag (const fexcept_t *flagp, int excepts) +{ + fpu_control_t cw; + fpu_control_t cw_new; + + /* Get the current exceptions. */ + _FPU_GETCW (cw); + + /* Make sure the flags we want restored are legal. */ + excepts &= FE_ALL_EXCEPT; + + /* Now set selected bits from flagp. Note that we ignore all non-flag + bits from *flagp, so they don't matter. */ + cw_new = (cw & ~excepts) | (*flagp & excepts); + + if (cw != cw_new) + _FPU_SETCW (cw_new); + + /* Success. */ + return 0; +} diff --git a/sysdeps/or1k/fpu/ftestexcept.c b/sysdeps/or1k/fpu/ftestexcept.c new file mode 100644 index 0000000000..59f06afa22 --- /dev/null +++ b/sysdeps/or1k/fpu/ftestexcept.c @@ -0,0 +1,27 @@ +/* Test exception in current environment. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fenv_private.h> + +int +fetestexcept (int excepts) +{ + return libc_fetestexcept_or1k (excepts); +} +libm_hidden_def (fetestexcept) diff --git a/sysdeps/or1k/fpu/get-rounding-mode.h b/sysdeps/or1k/fpu/get-rounding-mode.h new file mode 100644 index 0000000000..a66d553be8 --- /dev/null +++ b/sysdeps/or1k/fpu/get-rounding-mode.h @@ -0,0 +1,38 @@ +/* Determine floating-point rounding mode within libc. OpenRISC version. + + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _OR1K_GET_ROUNDING_MODE_H +#define _OR1K_GET_ROUNDING_MODE_H 1 + +#include <fenv.h> +#include <fpu_control.h> + +/* Return the floating-point rounding mode. */ + +static inline int +get_rounding_mode (void) +{ + fpu_control_t cw; + + _FPU_GETCW (cw); + return cw & _FPU_FPCSR_RM_MASK; +} + +#endif /* get-rounding-mode.h */ diff --git a/sysdeps/or1k/fpu/libm-test-ulps b/sysdeps/or1k/fpu/libm-test-ulps new file mode 100644 index 0000000000..948ec01cdc --- /dev/null +++ b/sysdeps/or1k/fpu/libm-test-ulps @@ -0,0 +1,1115 @@ +# Begin of automatic generation + +# Maximal error of functions: +Function: "acos": +double: 1 +float: 1 + +Function: "acos_downward": +double: 1 +float: 1 + +Function: "acos_towardzero": +double: 1 +float: 1 + +Function: "acos_upward": +double: 1 +float: 1 + +Function: "acosh": +double: 2 +float: 2 + +Function: "acosh_downward": +double: 2 +float: 2 + +Function: "acosh_towardzero": +double: 2 +float: 2 + +Function: "acosh_upward": +double: 2 +float: 2 + +Function: "asin": +double: 1 +float: 1 + +Function: "asin_downward": +double: 1 +float: 1 + +Function: "asin_towardzero": +double: 1 +float: 1 + +Function: "asin_upward": +double: 2 +float: 1 + +Function: "asinh": +double: 2 +float: 2 + +Function: "asinh_downward": +double: 3 +float: 3 + +Function: "asinh_towardzero": +double: 2 +float: 2 + +Function: "asinh_upward": +double: 3 +float: 3 + +Function: "atan": +double: 1 +float: 1 + +Function: "atan2": +float: 2 + +Function: "atan2_downward": +double: 5 +float: 2 + +Function: "atan2_towardzero": +double: 5 +float: 2 + +Function: "atan2_upward": +double: 8 +float: 2 + +Function: "atan_downward": +double: 1 +float: 2 + +Function: "atan_towardzero": +double: 1 +float: 1 + +Function: "atan_upward": +double: 1 +float: 2 + +Function: "atanh": +double: 2 +float: 2 + +Function: "atanh_downward": +double: 3 +float: 3 + +Function: "atanh_towardzero": +double: 2 +float: 2 + +Function: "atanh_upward": +double: 3 +float: 3 + +Function: "cabs": +double: 1 + +Function: "cabs_downward": +double: 1 + +Function: "cabs_towardzero": +double: 1 + +Function: "cabs_upward": +double: 1 + +Function: Real part of "cacos": +double: 1 +float: 2 + +Function: Imaginary part of "cacos": +double: 2 +float: 2 + +Function: Real part of "cacos_downward": +double: 3 +float: 2 + +Function: Imaginary part of "cacos_downward": +double: 5 +float: 3 + +Function: Real part of "cacos_towardzero": +double: 3 +float: 2 + +Function: Imaginary part of "cacos_towardzero": +double: 4 +float: 2 + +Function: Real part of "cacos_upward": +double: 2 +float: 2 + +Function: Imaginary part of "cacos_upward": +double: 5 +float: 7 + +Function: Real part of "cacosh": +double: 2 +float: 2 + +Function: Imaginary part of "cacosh": +double: 1 +float: 2 + +Function: Real part of "cacosh_downward": +double: 4 +float: 2 + +Function: Imaginary part of "cacosh_downward": +double: 3 +float: 3 + +Function: Real part of "cacosh_towardzero": +double: 4 +float: 2 + +Function: Imaginary part of "cacosh_towardzero": +double: 3 +float: 2 + +Function: Real part of "cacosh_upward": +double: 4 +float: 3 + +Function: Imaginary part of "cacosh_upward": +double: 3 +float: 2 + +Function: "carg": +float: 1 + +Function: "carg_downward": +double: 5 +float: 2 + +Function: "carg_towardzero": +double: 5 +float: 2 + +Function: "carg_upward": +double: 8 +float: 2 + +Function: Real part of "casin": +double: 1 +float: 1 + +Function: Imaginary part of "casin": +double: 2 +float: 2 + +Function: Real part of "casin_downward": +double: 3 +float: 2 + +Function: Imaginary part of "casin_downward": +double: 5 +float: 3 + +Function: Real part of "casin_towardzero": +double: 3 +float: 1 + +Function: Imaginary part of "casin_towardzero": +double: 4 +float: 2 + +Function: Real part of "casin_upward": +double: 3 +float: 2 + +Function: Imaginary part of "casin_upward": +double: 5 +float: 7 + +Function: Real part of "casinh": +double: 2 +float: 2 + +Function: Imaginary part of "casinh": +double: 1 +float: 1 + +Function: Real part of "casinh_downward": +double: 5 +float: 3 + +Function: Imaginary part of "casinh_downward": +double: 3 +float: 2 + +Function: Real part of "casinh_towardzero": +double: 4 +float: 2 + +Function: Imaginary part of "casinh_towardzero": +double: 3 +float: 1 + +Function: Real part of "casinh_upward": +double: 5 +float: 7 + +Function: Imaginary part of "casinh_upward": +double: 3 +float: 2 + +Function: Real part of "catan": +double: 1 +float: 1 + +Function: Imaginary part of "catan": +double: 1 +float: 1 + +Function: Real part of "catan_downward": +double: 1 +float: 2 + +Function: Imaginary part of "catan_downward": +double: 2 +float: 2 + +Function: Real part of "catan_towardzero": +double: 1 +float: 2 + +Function: Imaginary part of "catan_towardzero": +double: 2 +float: 2 + +Function: Real part of "catan_upward": +double: 2 +float: 1 + +Function: Imaginary part of "catan_upward": +double: 2 +float: 2 + +Function: Real part of "catanh": +double: 1 +float: 1 + +Function: Imaginary part of "catanh": +double: 1 +float: 1 + +Function: Real part of "catanh_downward": +double: 2 +float: 2 + +Function: Imaginary part of "catanh_downward": +double: 1 +float: 2 + +Function: Real part of "catanh_towardzero": +double: 2 +float: 2 + +Function: Imaginary part of "catanh_towardzero": +double: 1 +float: 2 + +Function: Real part of "catanh_upward": +double: 4 +float: 4 + +Function: Imaginary part of "catanh_upward": +double: 2 +float: 1 + +Function: "cbrt": +double: 4 +float: 1 + +Function: "cbrt_downward": +double: 4 +float: 1 + +Function: "cbrt_towardzero": +double: 3 +float: 1 + +Function: "cbrt_upward": +double: 5 +float: 1 + +Function: Real part of "ccos": +double: 1 +float: 1 + +Function: Imaginary part of "ccos": +double: 1 +float: 1 + +Function: Real part of "ccos_downward": +double: 3 +float: 1 + +Function: Imaginary part of "ccos_downward": +double: 3 +float: 3 + +Function: Real part of "ccos_towardzero": +double: 3 +float: 2 + +Function: Imaginary part of "ccos_towardzero": +double: 3 +float: 3 + +Function: Real part of "ccos_upward": +double: 1 +float: 2 + +Function: Imaginary part of "ccos_upward": +double: 2 +float: 2 + +Function: Real part of "ccosh": +double: 2 +float: 1 + +Function: Imaginary part of "ccosh": +double: 1 +float: 1 + +Function: Real part of "ccosh_downward": +double: 3 +float: 2 + +Function: Imaginary part of "ccosh_downward": +double: 3 +float: 3 + +Function: Real part of "ccosh_towardzero": +double: 3 +float: 3 + +Function: Imaginary part of "ccosh_towardzero": +double: 3 +float: 3 + +Function: Real part of "ccosh_upward": +double: 1 +float: 2 + +Function: Imaginary part of "ccosh_upward": +double: 2 +float: 2 + +Function: Real part of "cexp": +double: 2 +float: 1 + +Function: Imaginary part of "cexp": +double: 1 +float: 2 + +Function: Real part of "cexp_downward": +double: 4 +float: 2 + +Function: Imaginary part of "cexp_downward": +double: 3 +float: 3 + +Function: Real part of "cexp_towardzero": +double: 4 +float: 2 + +Function: Imaginary part of "cexp_towardzero": +double: 3 +float: 3 + +Function: Real part of "cexp_upward": +double: 2 +float: 2 + +Function: Imaginary part of "cexp_upward": +double: 3 +float: 2 + +Function: Real part of "clog": +double: 3 +float: 3 + +Function: Imaginary part of "clog": +double: 1 +float: 1 + +Function: Real part of "clog10": +double: 3 +float: 4 + +Function: Imaginary part of "clog10": +double: 2 +float: 2 + +Function: Real part of "clog10_downward": +double: 7 +float: 5 + +Function: Imaginary part of "clog10_downward": +double: 8 +float: 4 + +Function: Real part of "clog10_towardzero": +double: 5 +float: 5 + +Function: Imaginary part of "clog10_towardzero": +double: 8 +float: 4 + +Function: Real part of "clog10_upward": +double: 6 +float: 5 + +Function: Imaginary part of "clog10_upward": +double: 5 +float: 4 + +Function: Real part of "clog_downward": +double: 4 +float: 3 + +Function: Imaginary part of "clog_downward": +double: 5 +float: 2 + +Function: Real part of "clog_towardzero": +double: 8 +float: 4 + +Function: Imaginary part of "clog_towardzero": +double: 5 +float: 3 + +Function: Real part of "clog_upward": +double: 8 +float: 3 + +Function: Imaginary part of "clog_upward": +double: 8 +float: 2 + +Function: "cos": +double: 1 +float: 1 + +Function: "cos_downward": +double: 1 +float: 1 + +Function: "cos_towardzero": +double: 4 +float: 1 + +Function: "cos_upward": +double: 4 +float: 1 + +Function: "cosh": +double: 2 +float: 2 + +Function: "cosh_downward": +double: 3 +float: 1 + +Function: "cosh_towardzero": +double: 3 +float: 1 + +Function: "cosh_upward": +double: 2 +float: 2 + +Function: Real part of "cpow": +double: 2 +float: 5 + +Function: Imaginary part of "cpow": +float: 2 + +Function: Real part of "cpow_downward": +double: 5 +float: 8 + +Function: Imaginary part of "cpow_downward": +double: 2 +float: 2 + +Function: Real part of "cpow_towardzero": +double: 5 +float: 8 + +Function: Imaginary part of "cpow_towardzero": +double: 2 +float: 2 + +Function: Real part of "cpow_upward": +double: 4 +float: 1 + +Function: Imaginary part of "cpow_upward": +double: 2 +float: 2 + +Function: Real part of "csin": +double: 1 +float: 1 + +Function: Real part of "csin_downward": +double: 3 +float: 3 + +Function: Imaginary part of "csin_downward": +double: 3 +float: 1 + +Function: Real part of "csin_towardzero": +double: 3 +float: 3 + +Function: Imaginary part of "csin_towardzero": +double: 3 +float: 1 + +Function: Real part of "csin_upward": +double: 2 +float: 2 + +Function: Imaginary part of "csin_upward": +double: 1 +float: 2 + +Function: Real part of "csinh": +float: 1 + +Function: Imaginary part of "csinh": +double: 1 +float: 1 + +Function: Real part of "csinh_downward": +double: 3 +float: 1 + +Function: Imaginary part of "csinh_downward": +double: 3 +float: 3 + +Function: Real part of "csinh_towardzero": +double: 3 +float: 2 + +Function: Imaginary part of "csinh_towardzero": +double: 3 +float: 3 + +Function: Real part of "csinh_upward": +double: 1 +float: 2 + +Function: Imaginary part of "csinh_upward": +double: 2 +float: 2 + +Function: Real part of "csqrt": +double: 2 +float: 2 + +Function: Imaginary part of "csqrt": +double: 2 +float: 2 + +Function: Real part of "csqrt_downward": +double: 5 +float: 4 + +Function: Imaginary part of "csqrt_downward": +double: 4 +float: 3 + +Function: Real part of "csqrt_towardzero": +double: 4 +float: 3 + +Function: Imaginary part of "csqrt_towardzero": +double: 4 +float: 3 + +Function: Real part of "csqrt_upward": +double: 5 +float: 4 + +Function: Imaginary part of "csqrt_upward": +double: 3 +float: 3 + +Function: Real part of "ctan": +double: 1 +float: 1 + +Function: Imaginary part of "ctan": +double: 2 +float: 2 + +Function: Real part of "ctan_downward": +double: 6 +float: 5 + +Function: Imaginary part of "ctan_downward": +double: 3 +float: 2 + +Function: Real part of "ctan_towardzero": +double: 5 +float: 3 + +Function: Imaginary part of "ctan_towardzero": +double: 3 +float: 2 + +Function: Real part of "ctan_upward": +double: 2 +float: 4 + +Function: Imaginary part of "ctan_upward": +double: 2 +float: 1 + +Function: Real part of "ctanh": +double: 2 +float: 2 + +Function: Imaginary part of "ctanh": +double: 2 +float: 2 + +Function: Real part of "ctanh_downward": +double: 3 +float: 2 + +Function: Imaginary part of "ctanh_downward": +double: 6 +float: 5 + +Function: Real part of "ctanh_towardzero": +double: 3 +float: 2 + +Function: Imaginary part of "ctanh_towardzero": +double: 5 +float: 3 + +Function: Real part of "ctanh_upward": +double: 2 +float: 2 + +Function: Imaginary part of "ctanh_upward": +double: 2 +float: 3 + +Function: "erf": +double: 1 +float: 1 + +Function: "erf_downward": +double: 1 +float: 1 + +Function: "erf_towardzero": +double: 1 +float: 1 + +Function: "erf_upward": +double: 1 +float: 1 + +Function: "erfc": +double: 5 +float: 3 + +Function: "erfc_downward": +double: 5 +float: 6 + +Function: "erfc_towardzero": +double: 3 +float: 4 + +Function: "erfc_upward": +double: 5 +float: 6 + +Function: "exp": +double: 1 +float: 1 + +Function: "exp10": +double: 2 +float: 1 + +Function: "exp10_downward": +double: 3 +float: 1 + +Function: "exp10_towardzero": +double: 3 +float: 1 + +Function: "exp10_upward": +double: 2 +float: 1 + +Function: "exp2": +double: 1 + +Function: "exp2_downward": +double: 1 + +Function: "exp2_towardzero": +double: 1 + +Function: "exp2_upward": +double: 1 +float: 1 + +Function: "exp_downward": +double: 1 +float: 1 + +Function: "exp_towardzero": +double: 1 +float: 1 + +Function: "exp_upward": +double: 1 +float: 1 + +Function: "expm1": +double: 1 +float: 1 + +Function: "expm1_downward": +double: 1 +float: 1 + +Function: "expm1_towardzero": +double: 1 +float: 2 + +Function: "expm1_upward": +double: 1 +float: 1 + +Function: "gamma": +double: 4 +float: 7 + +Function: "gamma_downward": +double: 7 +float: 7 + +Function: "gamma_towardzero": +double: 7 +float: 7 + +Function: "gamma_upward": +double: 5 +float: 6 + +Function: "hypot": +double: 1 +float: 1 + +Function: "hypot_downward": +double: 1 + +Function: "hypot_towardzero": +double: 1 + +Function: "hypot_upward": +double: 1 + +Function: "j0": +double: 2 +float: 9 + +Function: "j0_downward": +double: 5 +float: 9 + +Function: "j0_towardzero": +double: 6 +float: 9 + +Function: "j0_upward": +double: 9 +float: 9 + +Function: "j1": +double: 4 +float: 9 + +Function: "j1_downward": +double: 5 +float: 8 + +Function: "j1_towardzero": +double: 4 +float: 8 + +Function: "j1_upward": +double: 9 +float: 9 + +Function: "jn": +double: 4 +float: 4 + +Function: "jn_downward": +double: 7 +float: 9 + +Function: "jn_towardzero": +double: 7 +float: 9 + +Function: "jn_upward": +double: 7 +float: 9 + +Function: "lgamma": +double: 4 +float: 7 + +Function: "lgamma_downward": +double: 7 +float: 7 + +Function: "lgamma_towardzero": +double: 7 +float: 7 + +Function: "lgamma_upward": +double: 5 +float: 6 + +Function: "log10": +double: 2 +float: 2 + +Function: "log10_downward": +double: 2 +float: 3 + +Function: "log10_towardzero": +double: 2 +float: 1 + +Function: "log10_upward": +double: 2 +float: 2 + +Function: "log1p": +double: 1 +float: 1 + +Function: "log1p_downward": +double: 2 +float: 2 + +Function: "log1p_towardzero": +double: 2 +float: 2 + +Function: "log1p_upward": +double: 2 +float: 2 + +Function: "log2": +float: 1 + +Function: "log2_downward": +double: 1 + +Function: "log2_towardzero": +double: 1 + +Function: "log2_upward": +double: 1 + +Function: "pow": +double: 1 + +Function: "pow_downward": +double: 1 +float: 1 + +Function: "pow_towardzero": +double: 1 +float: 1 + +Function: "pow_upward": +double: 1 +float: 1 + +Function: "sin": +double: 1 +float: 1 + +Function: "sin_downward": +double: 4 +float: 1 + +Function: "sin_towardzero": +double: 3 +float: 1 + +Function: "sin_upward": +double: 7 +float: 1 + +Function: "sincos": +double: 1 + +Function: "sincos_downward": +double: 1 +float: 1 + +Function: "sincos_towardzero": +double: 4 +float: 1 + +Function: "sincos_upward": +double: 1 +float: 1 + +Function: "sinh": +double: 2 +float: 2 + +Function: "sinh_downward": +double: 3 +float: 3 + +Function: "sinh_towardzero": +double: 3 +float: 2 + +Function: "sinh_upward": +double: 3 +float: 3 + +Function: "tan": +float: 1 + +Function: "tan_downward": +double: 1 +float: 2 + +Function: "tan_towardzero": +double: 1 +float: 1 + +Function: "tan_upward": +double: 1 +float: 1 + +Function: "tanh": +double: 2 +float: 2 + +Function: "tanh_downward": +double: 3 +float: 3 + +Function: "tanh_towardzero": +double: 2 +float: 2 + +Function: "tanh_upward": +double: 3 +float: 3 + +Function: "tgamma": +double: 9 +float: 8 + +Function: "tgamma_downward": +double: 9 +float: 9 + +Function: "tgamma_towardzero": +double: 9 +float: 8 + +Function: "tgamma_upward": +double: 9 +float: 8 + +Function: "y0": +double: 3 +float: 9 + +Function: "y0_downward": +double: 3 +float: 9 + +Function: "y0_towardzero": +double: 4 +float: 9 + +Function: "y0_upward": +double: 3 +float: 9 + +Function: "y1": +double: 3 +float: 9 + +Function: "y1_downward": +double: 6 +float: 9 + +Function: "y1_towardzero": +double: 3 +float: 9 + +Function: "y1_upward": +double: 7 +float: 9 + +Function: "yn": +double: 3 +float: 3 + +Function: "yn_downward": +double: 6 +float: 8 + +Function: "yn_towardzero": +double: 8 +float: 8 + +Function: "yn_upward": +double: 8 +float: 8 + +# end of automatic generation diff --git a/sysdeps/or1k/fpu/libm-test-ulps-name b/sysdeps/or1k/fpu/libm-test-ulps-name new file mode 100644 index 0000000000..7f72f7a873 --- /dev/null +++ b/sysdeps/or1k/fpu/libm-test-ulps-name @@ -0,0 +1 @@ +OpenRISC hard-float diff --git a/sysdeps/or1k/fpu_control.h b/sysdeps/or1k/fpu_control.h new file mode 100644 index 0000000000..f89364a31e --- /dev/null +++ b/sysdeps/or1k/fpu_control.h @@ -0,0 +1,89 @@ +/* FPU control word bits. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _FPU_CONTROL_H +#define _FPU_CONTROL_H + +#ifndef __or1k_hard_float__ + +# define _FPU_RESERVED 0xffffffff +# define _FPU_DEFAULT 0x00000000 +# define _FPU_GETCW(cw) (cw) = 0 +# define _FPU_SETCW(cw) (void) (cw) + +#else /* __or1k_hard_float__ */ + +/* Layout of FPCSR: + + The bits of the FPCSR are defined as follows, this should help + explain how the masks below have come to be. + + +-----------+----------------------------+-----+----+ + | 32 - 12 | 11 10 9 8 7 6 5 4 3 | 2-1 | 0 | + +-----------+----------------------------+-----+----+ + | Reserved | DZ IN IV IX Z QN SN UN OV | RM | EE | + +-----------+----------------------------+-----+----+ + + Exception flags: + + DZ - divide by zero flag. + IN - infinite flag. + IV - invalid flag. + IX - inexact flag. + Z - zero flag. + QN - qnan flag. + SN - snan flag. + UN - underflow flag. + OV - overflow flag. + + Rounding modes: + + The FPCSR bits 2-1 labeled above as RM specify the rounding mode. + + 00 - round to nearest + 01 - round to zero + 10 - round to positive infinity + 11 - round to negative infinity + + Enabling exceptions: + + EE - set to enable FPU exceptions. + + */ + +# define _FPU_RESERVED 0xfffff000 +/* Default: rounding to nearest with exceptions disabled. */ +# define _FPU_DEFAULT 0 +/* IEEE: Same as above with exceptions enabled. */ +# define _FPU_IEEE (_FPU_DEFAULT | 1) + +# define _FPU_FPCSR_RM_MASK (0x3 << 1) + +/* Macros for accessing the hardware control word. */ +# define _FPU_GETCW(cw) __asm__ volatile ("l.mfspr %0,r0,20" : "=r" (cw)) +# define _FPU_SETCW(cw) __asm__ volatile ("l.mtspr r0,%0,20" : : "r" (cw)) + +#endif /* __or1k_hard_float__ */ + +/* Type of the control word. */ +typedef unsigned int fpu_control_t; + +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; + +#endif /* fpu_control.h */ diff --git a/sysdeps/or1k/libm-test-ulps-name b/sysdeps/or1k/libm-test-ulps-name deleted file mode 100644 index 0af6591fd9..0000000000 --- a/sysdeps/or1k/libm-test-ulps-name +++ /dev/null @@ -1 +0,0 @@ -OpenRISC diff --git a/sysdeps/or1k/math-tests-snan-payload.h b/sysdeps/or1k/math-tests-snan-payload.h new file mode 100644 index 0000000000..62467a371c --- /dev/null +++ b/sysdeps/or1k/math-tests-snan-payload.h @@ -0,0 +1,26 @@ +/* Configuration for math tests: sNaN payloads. OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef OR1K_MATH_TESTS_SNAN_PAYLOAD_H +#define OR1K_MATH_TESTS_SNAN_PAYLOAD_H 1 + +/* OpenRISC floating-point instructions do not preserve NaN + payloads. */ +#define SNAN_TESTS_PRESERVE_PAYLOAD 0 + +#endif /* math-tests-snan-payload.h */ diff --git a/sysdeps/or1k/math-tests-trap.h b/sysdeps/or1k/math-tests-trap.h new file mode 100644 index 0000000000..a95b42d66d --- /dev/null +++ b/sysdeps/or1k/math-tests-trap.h @@ -0,0 +1,27 @@ +/* Configuration for math tests: support for enabling exception traps. + OpenRISC version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef OR1K_MATH_TESTS_TRAP_H +#define OR1K_MATH_TESTS_TRAP_H 1 + +#include <fenv.h> + +#define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) ((EXCEPT) == 0) + +#endif /* math-tests-trap.h */ diff --git a/sysdeps/or1k/libm-test-ulps b/sysdeps/or1k/nofpu/libm-test-ulps index 785bae70d0..785bae70d0 100644 --- a/sysdeps/or1k/libm-test-ulps +++ b/sysdeps/or1k/nofpu/libm-test-ulps diff --git a/sysdeps/or1k/nofpu/libm-test-ulps-name b/sysdeps/or1k/nofpu/libm-test-ulps-name new file mode 100644 index 0000000000..76c66a0e53 --- /dev/null +++ b/sysdeps/or1k/nofpu/libm-test-ulps-name @@ -0,0 +1 @@ +OpenRISC soft-float diff --git a/sysdeps/or1k/sfp-machine.h b/sysdeps/or1k/sfp-machine.h index d17fd37730..70aa421ef0 100644 --- a/sysdeps/or1k/sfp-machine.h +++ b/sysdeps/or1k/sfp-machine.h @@ -90,4 +90,21 @@ #define FP_ROUNDMODE (_fpcsr & FP_RND_MASK) +#ifdef __or1k_hard_float__ +#define FP_INIT_ROUNDMODE \ +do { \ + __asm__ volatile ("l.mfspr %0,r0,20" : "=r" (_fpcsr)); \ +} while (0) + +#define FP_HANDLE_EXCEPTIONS \ +do { \ + if (__builtin_expect (_fex, 0)) \ + { \ + _fpcsr &= ~FP_EX_ALL; \ + _fpcsr |= _fex; \ + __asm__ volatile ("l.mtspr r0,%0,20" : : "r" (_fpcsr)); \ + } \ +} while (0) +#endif /* __or1k_hard_float__ */ + #define _FP_TININESS_AFTER_ROUNDING 0 diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h index f9167056a8..0a06e4486b 100644 --- a/sysdeps/powerpc/fpu/fenv_libc.h +++ b/sysdeps/powerpc/fpu/fenv_libc.h @@ -182,19 +182,13 @@ __fesetround_inline (int round) return 0; } -/* Same as __fesetround_inline, however without runtime check to use DFP - mtfsfi syntax (as relax_fenv_state) or if round value is valid. */ +/* Same as __fesetround_inline, and it also disable the floating-point + inexact execption (bit 60 - XE, assuming NI is 0). It does not check + if ROUND is a valid value. */ static inline void -__fesetround_inline_nocheck (const int round) +__fesetround_inline_disable_inexact (const int round) { -#ifdef _ARCH_PWR9 - __fe_mffscrn (round); -#else - if (__glibc_likely (GLRO(dl_hwcap2) & PPC_FEATURE2_ARCH_3_00)) - __fe_mffscrn (round); - else - asm volatile ("mtfsfi 7,%0" : : "n" (round)); -#endif + asm volatile ("mtfsfi 7,%0" : : "n" (round)); } #define FPSCR_MASK(bit) (1 << (31 - (bit))) diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h index b68833640f..6996519c61 100644 --- a/sysdeps/powerpc/fpu/round_to_integer.h +++ b/sysdeps/powerpc/fpu/round_to_integer.h @@ -42,14 +42,14 @@ set_fenv_mode (enum round_mode mode) switch (mode) { case CEIL: - __fesetround_inline_nocheck (FE_UPWARD); + __fesetround_inline_disable_inexact (FE_UPWARD); break; case FLOOR: - __fesetround_inline_nocheck (FE_DOWNWARD); + __fesetround_inline_disable_inexact (FE_DOWNWARD); break; case TRUNC: case ROUND: - __fesetround_inline_nocheck (FE_TOWARDZERO); + __fesetround_inline_disable_inexact (FE_TOWARDZERO); break; case NEARBYINT: /* Disable FE_INEXACT exception */ diff --git a/sysdeps/powerpc/powerpc64/le/power10/strncmp.S b/sysdeps/powerpc/powerpc64/le/power10/strncmp.S new file mode 100644 index 0000000000..d4ba76acae --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/power10/strncmp.S @@ -0,0 +1,271 @@ +/* Optimized strncmp implementation for PowerPC64/POWER10. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +/* Implements the function + + int [r3] strncmp (const char *s1 [r3], const char *s2 [r4], size_t [r5] n) + + The implementation uses unaligned doubleword access to avoid specialized + code paths depending of data alignment for first 32 bytes and uses + vectorised loops after that. */ + +#ifndef STRNCMP +# define STRNCMP strncmp +#endif + +/* TODO: Change this to actual instructions when minimum binutils is upgraded + to 2.27. Macros are defined below for these newer instructions in order + to maintain compatibility. */ + +#define LXVP(xtp,dq,ra) \ + .long(((6)<<(32-6)) \ + | ((((xtp)-32)>>1)<<(32-10)) \ + | ((1)<<(32-11)) \ + | ((ra)<<(32-16)) \ + | dq) + +#define COMPARE_16(vreg1,vreg2,offset) \ + lxv vreg1+32,offset(r3); \ + lxv vreg2+32,offset(r4); \ + vcmpnezb. v7,vreg1,vreg2; \ + bne cr6,L(different); \ + cmpldi cr7,r5,16; \ + ble cr7,L(ret0); \ + addi r5,r5,-16; + +#define COMPARE_32(vreg1,vreg2,offset,label1,label2) \ + LXVP(vreg1+32,offset,r3); \ + LXVP(vreg2+32,offset,r4); \ + vcmpnezb. v7,vreg1+1,vreg2+1; \ + bne cr6,L(label1); \ + vcmpnezb. v7,vreg1,vreg2; \ + bne cr6,L(label2); \ + cmpldi cr7,r5,32; \ + ble cr7,L(ret0); \ + addi r5,r5,-32; + +#define TAIL_FIRST_16B(vreg1,vreg2) \ + vctzlsbb r6,v7; \ + cmpld cr7,r5,r6; \ + ble cr7,L(ret0); \ + vextubrx r5,r6,vreg1; \ + vextubrx r4,r6,vreg2; \ + subf r3,r4,r5; \ + blr; + +#define TAIL_SECOND_16B(vreg1,vreg2) \ + vctzlsbb r6,v7; \ + addi r0,r6,16; \ + cmpld cr7,r5,r0; \ + ble cr7,L(ret0); \ + vextubrx r5,r6,vreg1; \ + vextubrx r4,r6,vreg2; \ + subf r3,r4,r5; \ + blr; + +#define CHECK_N_BYTES(reg1,reg2,len_reg) \ + sldi r6,len_reg,56; \ + lxvl 32+v4,reg1,r6; \ + lxvl 32+v5,reg2,r6; \ + add reg1,reg1,len_reg; \ + add reg2,reg2,len_reg; \ + vcmpnezb v7,v4,v5; \ + vctzlsbb r6,v7; \ + cmpld cr7,r6,len_reg; \ + blt cr7,L(different); \ + cmpld cr7,r5,len_reg; \ + ble cr7,L(ret0); \ + sub r5,r5,len_reg; \ + + /* TODO: change this to .machine power10 when the minimum required + binutils allows it. */ + .machine power9 +ENTRY_TOCLESS (STRNCMP, 4) + /* Check if size is 0. */ + cmpdi cr0,r5,0 + beq cr0,L(ret0) + andi. r7,r3,4095 + andi. r8,r4,4095 + cmpldi cr0,r7,4096-16 + cmpldi cr1,r8,4096-16 + bgt cr0,L(crosses) + bgt cr1,L(crosses) + COMPARE_16(v4,v5,0) + addi r3,r3,16 + addi r4,r4,16 + +L(crosses): + andi. r7,r3,15 + subfic r7,r7,16 /* r7(nalign1) = 16 - (str1 & 15). */ + andi. r9,r4,15 + subfic r8,r9,16 /* r8(nalign2) = 16 - (str2 & 15). */ + cmpld cr7,r7,r8 + beq cr7,L(same_aligned) + blt cr7,L(nalign1_min) + + /* nalign2 is minimum and s2 pointer is aligned. */ + CHECK_N_BYTES(r3,r4,r8) + /* Are we on the 64B hunk which crosses a page? */ + andi. r10,r3,63 /* Determine offset into 64B hunk. */ + andi. r8,r3,15 /* The offset into the 16B hunk. */ + neg r7,r3 + andi. r9,r7,15 /* Number of bytes after a 16B cross. */ + rlwinm. r7,r7,26,0x3F /* ((r4-4096))>>6&63. */ + beq L(compare_64_pagecross) + mtctr r7 + b L(compare_64B_unaligned) + + /* nalign1 is minimum and s1 pointer is aligned. */ +L(nalign1_min): + CHECK_N_BYTES(r3,r4,r7) + /* Are we on the 64B hunk which crosses a page? */ + andi. r10,r4,63 /* Determine offset into 64B hunk. */ + andi. r8,r4,15 /* The offset into the 16B hunk. */ + neg r7,r4 + andi. r9,r7,15 /* Number of bytes after a 16B cross. */ + rlwinm. r7,r7,26,0x3F /* ((r4-4096))>>6&63. */ + beq L(compare_64_pagecross) + mtctr r7 + + .p2align 5 +L(compare_64B_unaligned): + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + COMPARE_16(v4,v5,32) + COMPARE_16(v4,v5,48) + addi r3,r3,64 + addi r4,r4,64 + bdnz L(compare_64B_unaligned) + + /* Cross the page boundary of s2, carefully. Only for first + iteration we have to get the count of 64B blocks to be checked. + From second iteration and beyond, loop counter is always 63. */ +L(compare_64_pagecross): + li r11, 63 + mtctr r11 + cmpldi r10,16 + ble L(cross_4) + cmpldi r10,32 + ble L(cross_3) + cmpldi r10,48 + ble L(cross_2) +L(cross_1): + CHECK_N_BYTES(r3,r4,r9) + CHECK_N_BYTES(r3,r4,r8) + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + COMPARE_16(v4,v5,32) + addi r3,r3,48 + addi r4,r4,48 + b L(compare_64B_unaligned) +L(cross_2): + COMPARE_16(v4,v5,0) + addi r3,r3,16 + addi r4,r4,16 + CHECK_N_BYTES(r3,r4,r9) + CHECK_N_BYTES(r3,r4,r8) + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + addi r3,r3,32 + addi r4,r4,32 + b L(compare_64B_unaligned) +L(cross_3): + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + addi r3,r3,32 + addi r4,r4,32 + CHECK_N_BYTES(r3,r4,r9) + CHECK_N_BYTES(r3,r4,r8) + COMPARE_16(v4,v5,0) + addi r3,r3,16 + addi r4,r4,16 + b L(compare_64B_unaligned) +L(cross_4): + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + COMPARE_16(v4,v5,32) + addi r3,r3,48 + addi r4,r4,48 + CHECK_N_BYTES(r3,r4,r9) + CHECK_N_BYTES(r3,r4,r8) + b L(compare_64B_unaligned) + +L(same_aligned): + CHECK_N_BYTES(r3,r4,r7) + /* Align s1 to 32B and adjust s2 address. + Use lxvp only if both s1 and s2 are 32B aligned. */ + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + COMPARE_16(v4,v5,32) + COMPARE_16(v4,v5,48) + addi r3,r3,64 + addi r4,r4,64 + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + addi r5,r5,32 + + clrldi r6,r3,59 + subfic r7,r6,32 + add r3,r3,r7 + add r4,r4,r7 + subf r5,r7,r5 + andi. r7,r4,0x1F + beq cr0,L(32B_aligned_loop) + + .p2align 5 +L(16B_aligned_loop): + COMPARE_16(v4,v5,0) + COMPARE_16(v4,v5,16) + COMPARE_16(v4,v5,32) + COMPARE_16(v4,v5,48) + addi r3,r3,64 + addi r4,r4,64 + b L(16B_aligned_loop) + + /* Calculate and return the difference. */ +L(different): + TAIL_FIRST_16B(v4,v5) + + .p2align 5 +L(32B_aligned_loop): + COMPARE_32(v14,v16,0,tail1,tail2) + COMPARE_32(v18,v20,32,tail3,tail4) + COMPARE_32(v22,v24,64,tail5,tail6) + COMPARE_32(v26,v28,96,tail7,tail8) + addi r3,r3,128 + addi r4,r4,128 + b L(32B_aligned_loop) + +L(tail1): TAIL_FIRST_16B(v15,v17) +L(tail2): TAIL_SECOND_16B(v14,v16) +L(tail3): TAIL_FIRST_16B(v19,v21) +L(tail4): TAIL_SECOND_16B(v18,v20) +L(tail5): TAIL_FIRST_16B(v23,v25) +L(tail6): TAIL_SECOND_16B(v22,v24) +L(tail7): TAIL_FIRST_16B(v27,v29) +L(tail8): TAIL_SECOND_16B(v26,v28) + + .p2align 5 +L(ret0): + li r3,0 + blr + +END(STRNCMP) +libc_hidden_builtin_def(strncmp) diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile index a38ff46448..b847c19049 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile @@ -34,7 +34,7 @@ ifneq (,$(filter %le,$(config-machine))) sysdep_routines += memchr-power10 memcmp-power10 memcpy-power10 \ memmove-power10 memset-power10 rawmemchr-power9 \ rawmemchr-power10 strcmp-power9 strcmp-power10 \ - strncmp-power9 strcpy-power9 stpcpy-power9 \ + strncmp-power9 strncmp-power10 strcpy-power9 stpcpy-power9 \ strlen-power9 strncpy-power9 stpncpy-power9 strlen-power10 endif CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c index 30fd89e109..2bb47d3527 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c @@ -164,6 +164,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, /* Support sysdeps/powerpc/powerpc64/multiarch/strncmp.c. */ IFUNC_IMPL (i, name, strncmp, #ifdef __LITTLE_ENDIAN__ + IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_3_1 + && hwcap & PPC_FEATURE_HAS_VSX, + __strncmp_power10) IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_3_00 && hwcap & PPC_FEATURE_HAS_ALTIVEC, __strncmp_power9) diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power10.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power10.S new file mode 100644 index 0000000000..d7026c12e2 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power10.S @@ -0,0 +1,25 @@ +/* Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#if defined __LITTLE_ENDIAN__ && IS_IN (libc) +#define STRNCMP __strncmp_power10 + +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(name) + +#include <sysdeps/powerpc/powerpc64/le/power10/strncmp.S> +#endif diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c index 6178f4a432..a5ed67f766 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c +++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c @@ -29,6 +29,7 @@ extern __typeof (strncmp) __strncmp_ppc attribute_hidden; extern __typeof (strncmp) __strncmp_power8 attribute_hidden; # ifdef __LITTLE_ENDIAN__ extern __typeof (strncmp) __strncmp_power9 attribute_hidden; +extern __typeof (strncmp) __strncmp_power10 attribute_hidden; # endif # undef strncmp @@ -36,6 +37,9 @@ extern __typeof (strncmp) __strncmp_power9 attribute_hidden; ifunc symbol properly. */ libc_ifunc_redirected (__redirect_strncmp, strncmp, # ifdef __LITTLE_ENDIAN__ + (hwcap2 & PPC_FEATURE2_ARCH_3_1 + && hwcap & PPC_FEATURE_HAS_VSX) + ? __strncmp_power10 : (hwcap2 & PPC_FEATURE2_ARCH_3_00 && hwcap & PPC_FEATURE_HAS_ALTIVEC) ? __strncmp_power9 : diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index f9efb50764..04ea56559e 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -282,6 +282,10 @@ tests += \ tst-vfork2x \ # tests +tests-2.0 += \ + tst-pthread_kill-exited + # tests-2.0 + tests-time64 += \ tst-abstime-time64 \ tst-cnd-timedwait-time64 \ diff --git a/sysdeps/sparc/sparc64/rtld-memset.c b/sysdeps/sparc/sparc64/rtld-memset.c index 55f3835790..a19202a620 100644 --- a/sysdeps/sparc/sparc64/rtld-memset.c +++ b/sysdeps/sparc/sparc64/rtld-memset.c @@ -1 +1,4 @@ #include <string/memset.c> +#if IS_IN(rtld) +strong_alias (memset, __memset_ultra1) +#endif diff --git a/sysdeps/unix/sysv/linux/or1k/Versions b/sysdeps/unix/sysv/linux/or1k/Versions new file mode 100644 index 0000000000..c1299de116 --- /dev/null +++ b/sysdeps/unix/sysv/linux/or1k/Versions @@ -0,0 +1,14 @@ +libc { + GLIBC_2.35 { + getcontext; + setcontext; + swapcontext; + makecontext; + } + GLIBC_2.40 { + getcontext; + setcontext; + swapcontext; + makecontext; + } +} diff --git a/sysdeps/unix/sysv/linux/or1k/getcontext-common.S b/sysdeps/unix/sysv/linux/or1k/getcontext-common.S new file mode 100644 index 0000000000..9187749615 --- /dev/null +++ b/sysdeps/unix/sysv/linux/or1k/getcontext-common.S @@ -0,0 +1,88 @@ +/* Save current context. OpenRISC common version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +/* This common getcontext template helps define different + implementations using control macros. Before including + this file in another file define the following: + + __CONTEXT_FUNC_NAME + __CONTEXT_ENABLE_FPCSR + __CONTEXT_SIGMASK_OFFSET + */ + +/* int getcontext (ucontext_t *ucp) + + Returns 0 on success -1 and errno on failure. + */ + .text +ENTRY(__CONTEXT_FUNC_NAME) + /* Store r1, the stack pointer. */ + l.sw (UCONTEXT_MCONTEXT + 1*4)(r3), r1 + /* Store r2, the frame pointer. */ + l.sw (UCONTEXT_MCONTEXT + 2*4)(r3), r2 + /* Store r9, the link register. */ + l.sw (UCONTEXT_MCONTEXT + 9*4)(r3), r9 + /* Store r9 to reg[11] too, as we need two links for makecontext. */ + l.sw (UCONTEXT_MCONTEXT + 11*4)(r3), r9 + /* Store r10, the TLS register. */ + l.sw (UCONTEXT_MCONTEXT + 10*4)(r3), r10 + /* Store r14-r30 even, callee saved registers. */ + l.sw (UCONTEXT_MCONTEXT + 14*4)(r3), r14 + l.sw (UCONTEXT_MCONTEXT + 16*4)(r3), r16 + l.sw (UCONTEXT_MCONTEXT + 18*4)(r3), r18 + l.sw (UCONTEXT_MCONTEXT + 20*4)(r3), r20 + l.sw (UCONTEXT_MCONTEXT + 22*4)(r3), r22 + l.sw (UCONTEXT_MCONTEXT + 24*4)(r3), r24 + l.sw (UCONTEXT_MCONTEXT + 26*4)(r3), r26 + l.sw (UCONTEXT_MCONTEXT + 28*4)(r3), r28 + l.sw (UCONTEXT_MCONTEXT + 30*4)(r3), r30 + +#ifdef __CONTEXT_ENABLE_FPCSR +# ifdef __or1k_hard_float__ + /* Store the floating point state. */ + l.mfspr r4, r0, 20 + l.sw (MCONTEXT_FPCSR)(r3), r4 +# else + /* Store zero to indicate default rounding as per softfloat. */ + l.sw (MCONTEXT_FPCSR)(r3), r0 +# endif /* __or1k_hard_float__ */ +#endif /* __CONTEXT_ENABLE_FPCSR */ + + /* Get signal mask. */ + /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */ + l.ori r6, r0, _NSIG8 + l.addi r5, r3, __CONTEXT_SIGMASK_OFFSET + l.ori r4, r0, 0 + l.ori r3, r0, SIG_BLOCK + l.ori r11, r0, SYS_ify (rt_sigprocmask) + /* Do the syscall. */ + l.sys 1 + l.nop + + /* if -4096 < ret < 0 holds, it's an error */ + l.sfgeui r11, 0xf001 + l.bf 1f + l.nop + + l.jr r9 + l.ori r11, r0, 0 + +1: l.j __syscall_error + l.ori r3, r11, 0 + +END(__CONTEXT_FUNC_NAME) diff --git a/sysdeps/unix/sysv/linux/or1k/getcontext.S b/sysdeps/unix/sysv/linux/or1k/getcontext.S index a25b377bda..da69e6999c 100644 --- a/sysdeps/unix/sysv/linux/or1k/getcontext.S +++ b/sysdeps/unix/sysv/linux/or1k/getcontext.S @@ -17,56 +17,35 @@ <https://www.gnu.org/licenses/>. */ #include <sysdep.h> +#include <shlib-compat.h> #include "ucontext_i.h" -/* int getcontext (ucontext_t *ucp) +#define __CONTEXT_FUNC_NAME __getcontext +#define __CONTEXT_ENABLE_FPCSR 1 +#define __CONTEXT_SIGMASK_OFFSET UCONTEXT_SIGMASK - Returns 0 on success -1 and errno on failure. - */ - .text -ENTRY(__getcontext) - /* Store r1, the stack pointer. */ - l.sw (UCONTEXT_MCONTEXT + 1*4)(r3), r1 - /* Store r2, the frame pointer. */ - l.sw (UCONTEXT_MCONTEXT + 2*4)(r3), r2 - /* Store r9, the link register. */ - l.sw (UCONTEXT_MCONTEXT + 9*4)(r3), r9 - /* Store r9 to reg[11] too, as we need two links for makecontext. */ - l.sw (UCONTEXT_MCONTEXT + 11*4)(r3), r9 - /* Store r10, the TLS register. */ - l.sw (UCONTEXT_MCONTEXT + 10*4)(r3), r10 - /* Store r14-r30 even, callee saved registers. */ - l.sw (UCONTEXT_MCONTEXT + 14*4)(r3), r14 - l.sw (UCONTEXT_MCONTEXT + 16*4)(r3), r16 - l.sw (UCONTEXT_MCONTEXT + 18*4)(r3), r18 - l.sw (UCONTEXT_MCONTEXT + 20*4)(r3), r20 - l.sw (UCONTEXT_MCONTEXT + 22*4)(r3), r22 - l.sw (UCONTEXT_MCONTEXT + 24*4)(r3), r24 - l.sw (UCONTEXT_MCONTEXT + 26*4)(r3), r26 - l.sw (UCONTEXT_MCONTEXT + 28*4)(r3), r28 - l.sw (UCONTEXT_MCONTEXT + 30*4)(r3), r30 +#include "getcontext-common.S" - /* Get signal mask. */ - /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */ - l.ori r6, r0, _NSIG8 - l.addi r5, r3, UCONTEXT_SIGMASK - l.ori r4, r0, 0 - l.ori r3, r0, SIG_BLOCK - l.ori r11, r0, SYS_ify (rt_sigprocmask) - /* Do the syscall. */ - l.sys 1 - l.nop +versioned_symbol (libc, __getcontext, getcontext, GLIBC_2_40) - /* if -4096 < ret < 0 holds, it's an error */ - l.sfgeui r11, 0xf001 - l.bf 1f - l.nop +#if SHLIB_COMPAT (libc, GLIBC_2_35, GLIBC_2_40) - l.jr r9 - l.ori r11, r0, 0 +/* Define a compat version of getcontext for glibc's before the fpcsr + field was added to mcontext_t. The offset sigmask changed with this + introduction, the change was done because glibc's definition of + ucontext_t was initially defined incompatible with the Linux + definition of ucontext_t. We keep the compatability definition to + allow getcontext, setcontext and swapcontext to work in older + binaries. */ -1: l.j __syscall_error - l.ori r3, r11, 0 +# undef __CONTEXT_FUNC_NAME +# undef __CONTEXT_ENABLE_FPCSR +# undef __CONTEXT_SIGMASK_OFFSET +# define __CONTEXT_FUNC_NAME __getcontext_nofpcsr +# define __CONTEXT_SIGMASK_OFFSET (UCONTEXT_SIGMASK - 4) -END(__getcontext) -weak_alias(__getcontext, getcontext) +# include "getcontext-common.S" + +compat_symbol (libc, __getcontext_nofpcsr, getcontext, GLIBC_2_35) + +#endif diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist index c40c843aaf..959e59e7e7 100644 --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist @@ -2255,3 +2255,7 @@ GLIBC_2.39 stdc_trailing_zeros_ui F GLIBC_2.39 stdc_trailing_zeros_ul F GLIBC_2.39 stdc_trailing_zeros_ull F GLIBC_2.39 stdc_trailing_zeros_us F +GLIBC_2.40 getcontext F +GLIBC_2.40 makecontext F +GLIBC_2.40 setcontext F +GLIBC_2.40 swapcontext F diff --git a/sysdeps/unix/sysv/linux/or1k/makecontext.c b/sysdeps/unix/sysv/linux/or1k/makecontext.c index fa6626e7de..7e131bae41 100644 --- a/sysdeps/unix/sysv/linux/or1k/makecontext.c +++ b/sysdeps/unix/sysv/linux/or1k/makecontext.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <shlib-compat.h> #include <sysdep.h> #include <stdarg.h> #include <stdint.h> @@ -36,12 +37,11 @@ r1 : stack pointer r2 : frame pointer, set to NULL */ -void -__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) +static void +do_makecontext (ucontext_t *ucp, void (*startcontext) (void), + void (*func) (void), int argc, va_list ap) { - extern void __startcontext (void); unsigned long int *sp; - va_list ap; int i; sp = (unsigned long int *) @@ -55,8 +55,8 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) /* Keep uc_link in r14. */ ucp->uc_mcontext.__gprs[14] = (uintptr_t) ucp->uc_link; - /* Return address points to function __startcontext. */ - ucp->uc_mcontext.__gprs[9] = (uintptr_t) &__startcontext; + /* Return address points to function startcontext. */ + ucp->uc_mcontext.__gprs[9] = (uintptr_t) startcontext; /* Frame pointer is null. */ ucp->uc_mcontext.__gprs[2] = (uintptr_t) 0; /* Restart in user-space starting at 'func'. */ @@ -64,14 +64,47 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) /* Set stack pointer. */ ucp->uc_mcontext.__gprs[1] = (uintptr_t) sp; - va_start (ap, argc); for (i = 0; i < argc; ++i) if (i < 6) ucp->uc_mcontext.__gprs[i + 3] = va_arg (ap, unsigned long int); else sp[i - 6] = va_arg (ap, unsigned long int); +} +void +__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) +{ + extern void __startcontext (void); + va_list ap; + + va_start (ap, argc); + do_makecontext (ucp, &__startcontext, func, argc, ap); va_end (ap); } -weak_alias (__makecontext, makecontext) +versioned_symbol (libc, __makecontext, makecontext, GLIBC_2_40); + +#if SHLIB_COMPAT (libc, GLIBC_2_35, GLIBC_2_40) + +/* Define a compat version of makecontext for glibc's before the fpcsr + field was added to mcontext_t. The offset sigmask changed with this + introduction, the change was done because glibc's definition of + ucontext_t was initially defined incompatible with the Linux + definition of ucontext_t. We keep the compatability definition to + allow getcontext, setcontext and swapcontext to work in older + binaries. */ + +void +__makecontext_nofpcsr (ucontext_t *ucp, void (*func) (void), int argc, ...) +{ + extern void __startcontext_nofpcsr (void); + va_list ap; + + va_start (ap, argc); + do_makecontext (ucp, &__startcontext_nofpcsr, func, argc, ap); + va_end (ap); +} + +compat_symbol (libc, __makecontext_nofpcsr, makecontext, GLIBC_2_35); + +#endif diff --git a/sysdeps/unix/sysv/linux/or1k/setcontext-common.S b/sysdeps/unix/sysv/linux/or1k/setcontext-common.S new file mode 100644 index 0000000000..8a4f147513 --- /dev/null +++ b/sysdeps/unix/sysv/linux/or1k/setcontext-common.S @@ -0,0 +1,120 @@ +/* Set current context. OpenRISC common version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +/* This common setcontext and startcontext template helps define + different implementations using control macros. Before including + this file in another file define the following: + + __CONTEXT_FUNC_NAME + __CONTEXT_ENABLE_FPCSR + __CONTEXT_SIGMASK_OFFSET + __STARTCONTEXT_FUNC_NAME + */ + +/* int setcontext (const ucontext_t *ucp) */ + .text +ENTRY(__CONTEXT_FUNC_NAME) + l.ori r30, r3, 0 + + /* Restore signal mask. */ + /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */ + l.ori r6, r0, _NSIG8 + l.ori r5, r0, 0 + l.addi r4, r3, __CONTEXT_SIGMASK_OFFSET + l.ori r3, r0, SIG_SETMASK + l.ori r11, r0, SYS_ify (rt_sigprocmask) + /* Do the syscall. */ + l.sys 1 + l.nop + + /* if -4096 < ret < 0 holds, it's an error */ + l.sfgeui r11, 0xf001 + l.bf 1f + l.nop +#ifdef __CONTEXT_ENABLE_FPCSR +# ifdef __or1k_hard_float__ + /* Restore the floating point state. */ + l.lwz r28, (MCONTEXT_FPCSR)(r30) + l.mtspr r0, r28, 20 +# endif /* __or1k_hard_float__ */ +#endif /* __CONTEXT_ENABLE_FPCSR */ + /* Restore argument registers, for the makecontext case. */ + l.lwz r3, (UCONTEXT_MCONTEXT + 3*4)(r30) + l.lwz r4, (UCONTEXT_MCONTEXT + 4*4)(r30) + l.lwz r5, (UCONTEXT_MCONTEXT + 5*4)(r30) + l.lwz r6, (UCONTEXT_MCONTEXT + 6*4)(r30) + l.lwz r7, (UCONTEXT_MCONTEXT + 7*4)(r30) + l.lwz r8, (UCONTEXT_MCONTEXT + 8*4)(r30) + + /* Restore registers stored in getcontext. */ + l.lwz r1, (UCONTEXT_MCONTEXT + 1*4)(r30) + l.lwz r2, (UCONTEXT_MCONTEXT + 2*4)(r30) + l.lwz r9, (UCONTEXT_MCONTEXT + 9*4)(r30) + l.lwz r10, (UCONTEXT_MCONTEXT + 10*4)(r30) + l.lwz r11, (UCONTEXT_MCONTEXT + 11*4)(r30) + /* Restore r14-r30 even, callee saved registers. */ + l.lwz r14, (UCONTEXT_MCONTEXT + 14*4)(r30) + l.lwz r16, (UCONTEXT_MCONTEXT + 16*4)(r30) + l.lwz r18, (UCONTEXT_MCONTEXT + 18*4)(r30) + l.lwz r20, (UCONTEXT_MCONTEXT + 20*4)(r30) + l.lwz r22, (UCONTEXT_MCONTEXT + 22*4)(r30) + l.lwz r24, (UCONTEXT_MCONTEXT + 24*4)(r30) + l.lwz r26, (UCONTEXT_MCONTEXT + 26*4)(r30) + l.lwz r28, (UCONTEXT_MCONTEXT + 28*4)(r30) + l.lwz r30, (UCONTEXT_MCONTEXT + 30*4)(r30) + + l.jr r11 + l.ori r11, r0, 0 + +1: l.j __syscall_error + l.ori r3, r11, 0 + +END (__CONTEXT_FUNC_NAME) + + /* We add a NOP here because when the unwinder is looking for the + enclosing function of the link register (r9) address FDE lookup will + use '$r9 - 1' finding setcontext which is wrong. This is because in + makecontext we have set r9 to the start of &__startcontext. + + If this NOP did not exist the unwinder would repeatedly find + __setcontext's FDE in an infinite loop. Modifying/deleting the below + __startcontext's FDE has no help on this. */ + l.nop + +ENTRY(__STARTCONTEXT_FUNC_NAME) + + l.ori r3, r14, 0 + l.sfeq r3, r0 + /* If uc_link is not 0 resume there, otherwise exit. */ + l.bnf __CONTEXT_FUNC_NAME + l.nop + +#ifdef SHARED + /* Obtain a pointer to .got in r16 */ + l.jal 0x8 + l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4) + l.ori r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0) + l.add r16, r16, r9 + l.lwz r16, got(exit)(r16) + l.jr r16 +#else + l.j exit +#endif + l.nop + +END(__STARTCONTEXT_FUNC_NAME) diff --git a/sysdeps/unix/sysv/linux/or1k/setcontext.S b/sysdeps/unix/sysv/linux/or1k/setcontext.S index d28a0ac0aa..a49a5c51c3 100644 --- a/sysdeps/unix/sysv/linux/or1k/setcontext.S +++ b/sysdeps/unix/sysv/linux/or1k/setcontext.S @@ -16,93 +16,39 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <shlib-compat.h> #include <sysdep.h> #include "ucontext_i.h" -/* int setcontext (const ucontext_t *ucp) */ - .text -ENTRY(__setcontext) - l.ori r30, r3, 0 +#define __CONTEXT_FUNC_NAME __setcontext +#define __CONTEXT_ENABLE_FPCSR 1 +#define __CONTEXT_SIGMASK_OFFSET UCONTEXT_SIGMASK +#define __STARTCONTEXT_FUNC_NAME __startcontext - /* Restore signal mask. */ - /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */ - l.ori r6, r0, _NSIG8 - l.ori r5, r0, 0 - l.addi r4, r3, UCONTEXT_SIGMASK - l.ori r3, r0, SIG_SETMASK - l.ori r11, r0, SYS_ify (rt_sigprocmask) - /* Do the syscall. */ - l.sys 1 - l.nop +#include "setcontext-common.S" - /* if -4096 < ret < 0 holds, it's an error */ - l.sfgeui r11, 0xf001 - l.bf 1f - l.nop +versioned_symbol (libc, __setcontext, setcontext, GLIBC_2_40) - /* Restore argument registers, for the makecontext case. */ - l.lwz r3, (UCONTEXT_MCONTEXT + 3*4)(r30) - l.lwz r4, (UCONTEXT_MCONTEXT + 4*4)(r30) - l.lwz r5, (UCONTEXT_MCONTEXT + 5*4)(r30) - l.lwz r6, (UCONTEXT_MCONTEXT + 6*4)(r30) - l.lwz r7, (UCONTEXT_MCONTEXT + 7*4)(r30) - l.lwz r8, (UCONTEXT_MCONTEXT + 8*4)(r30) +#if SHLIB_COMPAT (libc, GLIBC_2_35, GLIBC_2_40) - /* Restore registers stored in getcontext. */ - l.lwz r1, (UCONTEXT_MCONTEXT + 1*4)(r30) - l.lwz r2, (UCONTEXT_MCONTEXT + 2*4)(r30) - l.lwz r9, (UCONTEXT_MCONTEXT + 9*4)(r30) - l.lwz r10, (UCONTEXT_MCONTEXT + 10*4)(r30) - l.lwz r11, (UCONTEXT_MCONTEXT + 11*4)(r30) - /* Restore r14-r30 even, callee saved registers. */ - l.lwz r14, (UCONTEXT_MCONTEXT + 14*4)(r30) - l.lwz r16, (UCONTEXT_MCONTEXT + 16*4)(r30) - l.lwz r18, (UCONTEXT_MCONTEXT + 18*4)(r30) - l.lwz r20, (UCONTEXT_MCONTEXT + 20*4)(r30) - l.lwz r22, (UCONTEXT_MCONTEXT + 22*4)(r30) - l.lwz r24, (UCONTEXT_MCONTEXT + 24*4)(r30) - l.lwz r26, (UCONTEXT_MCONTEXT + 26*4)(r30) - l.lwz r28, (UCONTEXT_MCONTEXT + 28*4)(r30) - l.lwz r30, (UCONTEXT_MCONTEXT + 30*4)(r30) +/* Define a compat version of setcontext for glibc's before the fpcsr + field was added to mcontext_t. The offset sigmask changed with this + introduction, the change was done because glibc's definition of + ucontext_t was initially defined incompatible with the Linux + definition of ucontext_t. We keep the compatability definition to + allow getcontext, setcontext and swapcontext to work in older + binaries. */ - l.jr r11 - l.ori r11, r0, 0 +# undef __CONTEXT_FUNC_NAME +# undef __CONTEXT_ENABLE_FPCSR +# undef __CONTEXT_SIGMASK_OFFSET +# undef __STARTCONTEXT_FUNC_NAME +# define __CONTEXT_FUNC_NAME __setcontext_nofpcsr +# define __CONTEXT_SIGMASK_OFFSET (UCONTEXT_SIGMASK - 4) +# define __STARTCONTEXT_FUNC_NAME __startcontext_nofpcsr -1: l.j __syscall_error - l.ori r3, r11, 0 +# include "setcontext-common.S" -END (__setcontext) -weak_alias (__setcontext, setcontext) +compat_symbol (libc, __setcontext_nofpcsr, setcontext, GLIBC_2_35) - /* We add a NOP here because when the unwinder is looking for the - enclosing function of the link register (r9) address FDE lookup will - use '$r9 - 1' finding setcontext which is wrong. This is because in - makecontext we have set r9 to the start of &__startcontext. - - If this NOP did not exist the unwinder would repeatedly find - __setcontext's FDE in an infinite loop. Modifying/deleting the below - __startcontext's FDE has no help on this. */ - l.nop - -ENTRY(__startcontext) - - l.ori r3, r14, 0 - l.sfeq r3, r0 - /* If uc_link is not 0 resume there, otherwise exit. */ - l.bnf __setcontext - l.nop - -#ifdef SHARED - /* Obtain a pointer to .got in r16 */ - l.jal 0x8 - l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4) - l.ori r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0) - l.add r16, r16, r9 - l.lwz r16, got(exit)(r16) - l.jr r16 -#else - l.j exit #endif - l.nop - -END(__startcontext) diff --git a/sysdeps/unix/sysv/linux/or1k/swapcontext-common.S b/sysdeps/unix/sysv/linux/or1k/swapcontext-common.S new file mode 100644 index 0000000000..b7e2d4c820 --- /dev/null +++ b/sysdeps/unix/sysv/linux/or1k/swapcontext-common.S @@ -0,0 +1,139 @@ +/* Swap two contexts. OpenRISC version. + Copyright (C) 2022-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +/* This common swapcontext template helps define different + implementations using control macros. Before including this file + in another file define the following: + + __CONTEXT_FUNC_NAME + __CONTEXT_ENABLE_FPCSR + __CONTEXT_SIGMASK_OFFSET + */ + +/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */ + .text +ENTRY(__CONTEXT_FUNC_NAME) + + /* Same as getcontext. */ + /* Store r1, the stack pointer. */ + l.sw (UCONTEXT_MCONTEXT + 1*4)(r3), r1 + /* Store r2, the frame pointer. */ + l.sw (UCONTEXT_MCONTEXT + 2*4)(r3), r2 + /* Store r9, the link register. */ + l.sw (UCONTEXT_MCONTEXT + 9*4)(r3), r9 + /* Store r9 to reg[11] too, as we need two links for makecontext. */ + l.sw (UCONTEXT_MCONTEXT + 11*4)(r3), r9 + /* Store r10, the TLS register. */ + l.sw (UCONTEXT_MCONTEXT + 10*4)(r3), r10 + /* Store r14-r30 even, callee saved registers. */ + l.sw (UCONTEXT_MCONTEXT + 14*4)(r3), r14 + l.sw (UCONTEXT_MCONTEXT + 16*4)(r3), r16 + l.sw (UCONTEXT_MCONTEXT + 18*4)(r3), r18 + l.sw (UCONTEXT_MCONTEXT + 20*4)(r3), r20 + l.sw (UCONTEXT_MCONTEXT + 22*4)(r3), r22 + l.sw (UCONTEXT_MCONTEXT + 24*4)(r3), r24 + l.sw (UCONTEXT_MCONTEXT + 26*4)(r3), r26 + l.sw (UCONTEXT_MCONTEXT + 28*4)(r3), r28 + l.sw (UCONTEXT_MCONTEXT + 30*4)(r3), r30 + +#ifdef __CONTEXT_ENABLE_FPCSR +# ifdef __or1k_hard_float__ + /* Store the floating point state. */ + l.mfspr r6, r0, 20 + l.sw (MCONTEXT_FPCSR)(r3), r6 +# else + /* Store zero to indicate default rounding as per softfloat. */ + l.sw (MCONTEXT_FPCSR)(r3), r0 +# endif /* __or1k_hard_float__ */ +#endif /* __CONTEXT_ENABLE_FPCSR */ + /* Store ucp to non-argument syscall preserved register. */ + l.ori r30, r4, 0 + + /* Get signal mask. */ + /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */ + l.ori r6, r0, _NSIG8 + l.addi r5, r3, __CONTEXT_SIGMASK_OFFSET + l.ori r4, r0, 0 + l.ori r3, r0, SIG_BLOCK + l.ori r11, r0, SYS_ify (rt_sigprocmask) + /* Do the syscall. */ + l.sys 1 + l.nop + + /* if -4096 < ret < 0 holds, it's an error */ + l.sfgeui r11, 0xf001 + l.bf 1f + l.nop + + /* Same as setcontext. */ + + /* Restore signal mask. */ + /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */ + l.ori r6, r0, _NSIG8 + l.ori r5, r0, 0 + l.addi r4, r30, __CONTEXT_SIGMASK_OFFSET + l.ori r3, r0, SIG_SETMASK + l.ori r11, r0, SYS_ify (rt_sigprocmask) + /* Do the syscall. */ + l.sys 1 + l.nop + + /* if -4096 < ret < 0 holds, it's an error */ + l.sfgeui r11, 0xf001 + l.bf 1f + l.nop + +#ifdef __CONTEXT_ENABLE_FPCSR +# ifdef __or1k_hard_float__ + /* Restore the floating point state. */ + l.lwz r28, (MCONTEXT_FPCSR)(r30) + l.mtspr r0, r28, 20 +# endif /* __or1k_hard_float__ */ +#endif /* __CONTEXT_ENABLE_FPCSR */ + + /* Restore argument registers, for the makecontext case. */ + l.lwz r3, (UCONTEXT_MCONTEXT + 3*4)(r30) + l.lwz r4, (UCONTEXT_MCONTEXT + 4*4)(r30) + l.lwz r5, (UCONTEXT_MCONTEXT + 5*4)(r30) + l.lwz r6, (UCONTEXT_MCONTEXT + 6*4)(r30) + l.lwz r7, (UCONTEXT_MCONTEXT + 7*4)(r30) + l.lwz r8, (UCONTEXT_MCONTEXT + 8*4)(r30) + + /* Restore registers stored in getcontext. */ + l.lwz r1, (UCONTEXT_MCONTEXT + 1*4)(r30) + l.lwz r2, (UCONTEXT_MCONTEXT + 2*4)(r30) + l.lwz r9, (UCONTEXT_MCONTEXT + 9*4)(r30) + l.lwz r10, (UCONTEXT_MCONTEXT + 10*4)(r30) + l.lwz r11, (UCONTEXT_MCONTEXT + 11*4)(r30) + l.lwz r14, (UCONTEXT_MCONTEXT + 14*4)(r30) + l.lwz r16, (UCONTEXT_MCONTEXT + 16*4)(r30) + l.lwz r18, (UCONTEXT_MCONTEXT + 18*4)(r30) + l.lwz r20, (UCONTEXT_MCONTEXT + 20*4)(r30) + l.lwz r22, (UCONTEXT_MCONTEXT + 22*4)(r30) + l.lwz r24, (UCONTEXT_MCONTEXT + 24*4)(r30) + l.lwz r26, (UCONTEXT_MCONTEXT + 26*4)(r30) + l.lwz r28, (UCONTEXT_MCONTEXT + 28*4)(r30) + l.lwz r30, (UCONTEXT_MCONTEXT + 30*4)(r30) + + l.jr r11 + l.ori r11, r0, 0 + +1: l.j __syscall_error + l.ori r3, r11, 0 + +END (__CONTEXT_FUNC_NAME) diff --git a/sysdeps/unix/sysv/linux/or1k/swapcontext.S b/sysdeps/unix/sysv/linux/or1k/swapcontext.S index d09651a5b2..861c1e26ba 100644 --- a/sysdeps/unix/sysv/linux/or1k/swapcontext.S +++ b/sysdeps/unix/sysv/linux/or1k/swapcontext.S @@ -16,101 +16,36 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <shlib-compat.h> #include <sysdep.h> #include "ucontext_i.h" -/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */ - .text -ENTRY(__swapcontext) +#define __CONTEXT_FUNC_NAME __swapcontext +#define __CONTEXT_ENABLE_FPCSR 1 +#define __CONTEXT_SIGMASK_OFFSET UCONTEXT_SIGMASK - /* Same as getcontext. */ - /* Store r1, the stack pointer. */ - l.sw (UCONTEXT_MCONTEXT + 1*4)(r3), r1 - /* Store r2, the frame pointer. */ - l.sw (UCONTEXT_MCONTEXT + 2*4)(r3), r2 - /* Store r9, the link register. */ - l.sw (UCONTEXT_MCONTEXT + 9*4)(r3), r9 - /* Store r9 to reg[11] too, as we need two links for makecontext. */ - l.sw (UCONTEXT_MCONTEXT + 11*4)(r3), r9 - /* Store r10, the TLS register. */ - l.sw (UCONTEXT_MCONTEXT + 10*4)(r3), r10 - /* Store r14-r30 even, callee saved registers. */ - l.sw (UCONTEXT_MCONTEXT + 14*4)(r3), r14 - l.sw (UCONTEXT_MCONTEXT + 16*4)(r3), r16 - l.sw (UCONTEXT_MCONTEXT + 18*4)(r3), r18 - l.sw (UCONTEXT_MCONTEXT + 20*4)(r3), r20 - l.sw (UCONTEXT_MCONTEXT + 22*4)(r3), r22 - l.sw (UCONTEXT_MCONTEXT + 24*4)(r3), r24 - l.sw (UCONTEXT_MCONTEXT + 26*4)(r3), r26 - l.sw (UCONTEXT_MCONTEXT + 28*4)(r3), r28 - l.sw (UCONTEXT_MCONTEXT + 30*4)(r3), r30 +#include "swapcontext-common.S" - /* Store ucp to non-argument syscall preserved register. */ - l.ori r30, r4, 0 +versioned_symbol (libc, __swapcontext, swapcontext, GLIBC_2_40) - /* Get signal mask. */ - /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */ - l.ori r6, r0, _NSIG8 - l.addi r5, r3, UCONTEXT_SIGMASK - l.ori r4, r0, 0 - l.ori r3, r0, SIG_BLOCK - l.ori r11, r0, SYS_ify (rt_sigprocmask) - /* Do the syscall. */ - l.sys 1 - l.nop +#if SHLIB_COMPAT (libc, GLIBC_2_35, GLIBC_2_40) - /* if -4096 < ret < 0 holds, it's an error */ - l.sfgeui r11, 0xf001 - l.bf 1f - l.nop +/* Define a compat version of swapcontext for glibc's before the fpcsr + field was added to mcontext_t. The offset sigmask changed with this + introduction, the change was done because glibc's definition of + ucontext_t was initially defined incompatible with the Linux + definition of ucontext_t. We keep the compatability definition to + allow getcontext, setcontext and swapcontext to work in older + binaries. */ - /* Same as setcontext. */ +# undef __CONTEXT_FUNC_NAME +# undef __CONTEXT_ENABLE_FPCSR +# undef __CONTEXT_SIGMASK_OFFSET +# define __CONTEXT_FUNC_NAME __swapcontext_nofpcsr +# define __CONTEXT_SIGMASK_OFFSET (UCONTEXT_SIGMASK - 4) - /* Restore signal mask. */ - /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */ - l.ori r6, r0, _NSIG8 - l.ori r5, r0, 0 - l.addi r4, r30, UCONTEXT_SIGMASK - l.ori r3, r0, SIG_SETMASK - l.ori r11, r0, SYS_ify (rt_sigprocmask) - /* Do the syscall. */ - l.sys 1 - l.nop +# include "swapcontext-common.S" - /* if -4096 < ret < 0 holds, it's an error */ - l.sfgeui r11, 0xf001 - l.bf 1f - l.nop +compat_symbol (libc, __swapcontext_nofpcsr, swapcontext, GLIBC_2_35) - /* Restore argument registers, for the makecontext case. */ - l.lwz r3, (UCONTEXT_MCONTEXT + 3*4)(r30) - l.lwz r4, (UCONTEXT_MCONTEXT + 4*4)(r30) - l.lwz r5, (UCONTEXT_MCONTEXT + 5*4)(r30) - l.lwz r6, (UCONTEXT_MCONTEXT + 6*4)(r30) - l.lwz r7, (UCONTEXT_MCONTEXT + 7*4)(r30) - l.lwz r8, (UCONTEXT_MCONTEXT + 8*4)(r30) - - /* Restore registers stored in getcontext. */ - l.lwz r1, (UCONTEXT_MCONTEXT + 1*4)(r30) - l.lwz r2, (UCONTEXT_MCONTEXT + 2*4)(r30) - l.lwz r9, (UCONTEXT_MCONTEXT + 9*4)(r30) - l.lwz r10, (UCONTEXT_MCONTEXT + 10*4)(r30) - l.lwz r11, (UCONTEXT_MCONTEXT + 11*4)(r30) - l.lwz r14, (UCONTEXT_MCONTEXT + 14*4)(r30) - l.lwz r16, (UCONTEXT_MCONTEXT + 16*4)(r30) - l.lwz r18, (UCONTEXT_MCONTEXT + 18*4)(r30) - l.lwz r20, (UCONTEXT_MCONTEXT + 20*4)(r30) - l.lwz r22, (UCONTEXT_MCONTEXT + 22*4)(r30) - l.lwz r24, (UCONTEXT_MCONTEXT + 24*4)(r30) - l.lwz r26, (UCONTEXT_MCONTEXT + 26*4)(r30) - l.lwz r28, (UCONTEXT_MCONTEXT + 28*4)(r30) - l.lwz r30, (UCONTEXT_MCONTEXT + 30*4)(r30) - - l.jr r11 - l.ori r11, r0, 0 - -1: l.j __syscall_error - l.ori r3, r11, 0 - -END (__swapcontext) -weak_alias (__swapcontext, swapcontext) +#endif diff --git a/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h index b17e919154..1b428592ee 100644 --- a/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h +++ b/sysdeps/unix/sysv/linux/or1k/sys/ucontext.h @@ -38,6 +38,7 @@ typedef struct unsigned long int __gprs[__NGREG]; unsigned long int __pc; unsigned long int __sr; + unsigned long int __fpcsr; } mcontext_t; /* Userlevel context. */ diff --git a/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym index a8d4db080f..45cd72527d 100644 --- a/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym +++ b/sysdeps/unix/sysv/linux/or1k/ucontext_i.sym @@ -13,6 +13,7 @@ _NSIG8 (_NSIG / 8) -- Offsets of the fields in the ucontext_t structure. #define ucontext(member) offsetof (ucontext_t, member) #define stack(member) ucontext (uc_stack.member) +#define mcontext(member) ucontext (uc_mcontext.member) UCONTEXT_LINK ucontext (uc_link) UCONTEXT_STACK ucontext (uc_stack) @@ -23,4 +24,6 @@ STACK_SP stack (ss_sp) STACK_SIZE stack (ss_size) STACK_FLAGS stack (ss_flags) +MCONTEXT_FPCSR mcontext (__fpcsr) + UCONTEXT_SIZE sizeof (ucontext_t) diff --git a/sysdeps/unix/sysv/linux/timespec_get.c b/sysdeps/unix/sysv/linux/timespec_get.c index c6e5e66289..778d1e3354 100644 --- a/sysdeps/unix/sysv/linux/timespec_get.c +++ b/sysdeps/unix/sysv/linux/timespec_get.c @@ -5,7 +5,7 @@ The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2.1 of the License. + version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/sysdeps/unix/sysv/linux/timespec_getres.c b/sysdeps/unix/sysv/linux/timespec_getres.c index 5acebe2a2c..2eef9e512c 100644 --- a/sysdeps/unix/sysv/linux/timespec_getres.c +++ b/sysdeps/unix/sysv/linux/timespec_getres.c @@ -5,7 +5,7 @@ The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2.1 of the License. + version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/sysdeps/x86/dl-get-cpu-features.c b/sysdeps/x86/dl-get-cpu-features.c index 4d6c5c59a6..579d02d638 100644 --- a/sysdeps/x86/dl-get-cpu-features.c +++ b/sysdeps/x86/dl-get-cpu-features.c @@ -64,6 +64,11 @@ Fatal glibc error: CPU does not support x86-64-v%d\n", 4); # endif /* ISA level 4 */ # endif /* ISA level 3 */ # endif /* ISA level 2 */ +# ifdef GCCMACRO__APX_F__ + if (!CPU_FEATURE_USABLE_P (cpu_features, APX_F)) + _dl_fatal_printf ("\ +Fatal glibc error: CPU does not support APX\n"); +# endif # endif /* IS_IN (rtld) */ } } diff --git a/sysdeps/x86/tst-hwcap-tunables.c b/sysdeps/x86/tst-hwcap-tunables.c index f6a65b88de..8589a9fd66 100644 --- a/sysdeps/x86/tst-hwcap-tunables.c +++ b/sysdeps/x86/tst-hwcap-tunables.c @@ -133,7 +133,7 @@ do_test (int argc, char *argv[]) setenv ("GLIBC_TUNABLES", tunable, 1); struct support_capture_subprocess result - = support_capture_subprogram (spargv[0], spargv); + = support_capture_subprogram (spargv[0], spargv, NULL); support_capture_subprocess_check (&result, "tst-tunables", 0, sc_allow_stderr); support_capture_subprocess_free (&result); diff --git a/sysdeps/x86_64/multiarch/wcsncat-evex.S b/sysdeps/x86_64/multiarch/wcsncat-evex.S index 392215950a..10bfb0a531 100644 --- a/sysdeps/x86_64/multiarch/wcsncat-evex.S +++ b/sysdeps/x86_64/multiarch/wcsncat-evex.S @@ -1,9 +1,9 @@ -#ifndef WCSCAT -# define WCSCAT __wcsncat_evex +#ifndef WCSNCAT +# define WCSNCAT __wcsncat_evex #endif #define USE_AS_WCSCPY #define USE_AS_STRCAT -#define STRNCAT WCSCAT +#define STRNCAT WCSNCAT #include "strncat-evex.S" diff --git a/time/timespec_get.c b/time/timespec_get.c index b031e42ca2..26a044bca6 100644 --- a/time/timespec_get.c +++ b/time/timespec_get.c @@ -4,7 +4,7 @@ The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2.1 of the License. + version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/time/timespec_getres.c b/time/timespec_getres.c index edb397507c..2e18b8bcac 100644 --- a/time/timespec_getres.c +++ b/time/timespec_getres.c @@ -5,7 +5,7 @@ The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2.1 of the License. + version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |