Go to file
Zack Weinberg 329ea513b4 Avoid cancellable I/O primitives in ld.so.
Neither the <dlfcn.h> entry points, nor lazy symbol resolution, nor
initial shared library load-up, are cancellation points, so ld.so
should exclusively use I/O primitives that are not cancellable.  We
currently achieve this by having the cancellation hooks compile as
no-ops when IS_IN(rtld); this patch changes to using exclusively
_nocancel primitives in the source code instead, which makes the
intent clearer and significantly reduces the amount of code compiled
under IS_IN(rtld) as well as IS_IN(libc) -- in particular,
elf/Makefile no longer thinks we require a copy of unwind.c in
rtld-libc.a.  (The older mechanism is preserved as a backstop.)

The bulk of the change is splitting up the files that define the
_nocancel I/O functions, so they don't also define the variants that
*are* cancellation points; after which, the existing logic for picking
out the bits of libc that need to be recompiled as part of ld.so Just
Works.  I did this for all of the _nocancel functions, not just the
ones used by ld.so, for consistency.

fcntl was a little tricky because it's only a cancellation point for
certain opcodes (F_SETLKW(64), which can block), and the existing
__fcntl_nocancel wasn't applying the FCNTL_ADJUST_CMD hook, which
strikes me as asking for trouble, especially as the only nontrivial
definition of FCNTL_ADJUST_CMD (for powerpc64) changes F_*LK* opcodes.
To fix this, fcntl_common moves to fcntl_nocancel.c along with
__fcntl_nocancel, and changes its name to the extern (but hidden)
symbol __fcntl_nocancel_adjusted, so that regular fcntl can continue
calling it.  __fcntl_nocancel now applies FCNTL_ADJUST_CMD; so that
both both fcntl.c and fcntl_nocancel.c can see it, the only nontrivial
definition moves from sysdeps/u/s/l/powerpc/powerpc64/fcntl.c to
.../powerpc64/sysdep.h and becomes entirely a macro, instead of a macro
that calls an inline function.

The nptl version of libpthread also changes a little, because its
"compat-routines" formerly included files that defined all the
_nocancel functions it uses; instead of continuing to duplicate them,
I exported the relevant ones from libc.so as GLIBC_PRIVATE.  Since the
Linux fcntl.c calls a function defined by fcntl_nocancel.c, it can no
longer be used from libpthread.so; instead, introduce a custom
forwarder, pt-fcntl.c, and export __libc_fcntl from libc.so as
GLIBC_PRIVATE.  The nios2-linux ABI doesn't include a copy of vfork()
in libpthread, and it was handling that by manipulating
libpthread-routines in .../linux/nios2/Makefile; it is cleaner to do
what other such ports do, and have a pt-vfork.S that defines no symbols.

Right now, it appears that Hurd does not implement _nocancel I/O, so
sysdeps/generic/not-cancel.h will forward everything back to the
regular functions.  This changed the names of some of the functions
that sysdeps/mach/hurd/dl-sysdep.c needs to interpose.

	* elf/dl-load.c, elf/dl-misc.c, elf/dl-profile.c, elf/rtld.c
	* sysdeps/unix/sysv/linux/dl-sysdep.c
	Include not-cancel.h.  Use __close_nocancel instead of __close,
	__open64_nocancel instead of __open, __read_nocancel instead of
	__libc_read, and __write_nocancel instead of __libc_write.

	* csu/check_fds.c (check_one_fd)
	* sysdeps/posix/fdopendir.c (__fdopendir)
	* sysdeps/posix/opendir.c (__alloc_dir): Use __fcntl_nocancel
        instead of __fcntl and/or __libc_fcntl.

	* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np)
	* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np)
        * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system):
	Use __open64_nocancel instead of __open_nocancel.

	* sysdeps/unix/sysv/linux/not-cancel.h: Move all of the
	hidden_proto declarations to the end and issue them if either
	IS_IN(libc) or IS_IN(rtld).
	* sysdeps/unix/sysv/linux/Makefile [subdir=io] (sysdep_routines):
	Add close_nocancel, fcntl_nocancel, nanosleep_nocancel,
	open_nocancel, open64_nocancel, openat_nocancel, pause_nocancel,
	read_nocancel, waitpid_nocancel, write_nocancel.

        * io/Versions [GLIBC_PRIVATE]: Add __libc_fcntl,
        __fcntl_nocancel, __open64_nocancel, __write_nocancel.
        * posix/Versions: Add __nanosleep_nocancel, __pause_nocancel.

        * nptl/pt-fcntl.c: New file.
        * nptl/Makefile (pthread-compat-wrappers): Remove fcntl.
        (libpthread-routines): Add pt-fcntl.
        * include/fcntl.h (__fcntl_nocancel_adjusted): New function.
        (__libc_fcntl): Remove attribute_hidden.
	* sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Call
	__fcntl_nocancel_adjusted, not fcntl_common.
        (__fcntl_nocancel): Move to new file fcntl_nocancel.c.
	(fcntl_common): Rename to __fcntl_nocancel_adjusted; also move
	to fcntl_nocancel.c.
	* sysdeps/unix/sysv/linux/fcntl_nocancel.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h:
	Define FCNTL_ADJUST_CMD here, as a self-contained macro.

	* sysdeps/unix/sysv/linux/close.c: Move __close_nocancel to...
	* sysdeps/unix/sysv/linux/close_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/nanosleep.c: Move __nanosleep_nocancel to...
	* sysdeps/unix/sysv/linux/nanosleep_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/open.c: Move __open_nocancel to...
	* sysdeps/unix/sysv/linux/open_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/open64.c: Move __open64_nocancel to...
	* sysdeps/unix/sysv/linux/open64_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/openat.c: Move __openat_nocancel to...
	* sysdeps/unix/sysv/linux/openat_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/openat64.c: Move __openat64_nocancel to...
	* sysdeps/unix/sysv/linux/openat64_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/pause.c: Move __pause_nocancel to...
	* sysdeps/unix/sysv/linux/pause_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/read.c: Move __read_nocancel to...
	* sysdeps/unix/sysv/linux/read_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/waitpid.c: Move __waitpid_nocancel to...
	* sysdeps/unix/sysv/linux/waitpid_nocancel.c: ...this new file.
	* sysdeps/unix/sysv/linux/write.c: Move __write_nocancel to...
	* sysdeps/unix/sysv/linux/write_nocancel.c: ...this new file.

        * sysdeps/unix/sysv/linux/nios2/Makefile: Don't override
        libpthread-routines.
        * sysdeps/unix/sysv/linux/nios2/pt-vfork.S: New file which
        defines nothing.

        * sysdeps/mach/hurd/dl-sysdep.c: Define __read instead of
        __libc_read, and __write instead of __libc_write.  Define
        __open64 in addition to __open.
2018-06-12 09:53:04 -04:00
ChangeLog.old Add missing reference to bug 21654 2017-10-07 13:14:36 +02:00
argp Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
assert Fix uninitialized variable in assert_perror (bug 22761) 2018-02-05 11:06:15 +01:00
benchtests benchtests: Catch exceptions in input arguments 2018-06-01 16:32:43 -05:00
bits hurd: Fix shmid_ds's shm_segsz field type 2018-06-02 21:52:43 +02:00
catgets intl/tst-gettext: fix failure with newest msgfmt 2018-02-18 18:16:05 +01:00
conform hurd xfails: Add missing bug references 2018-04-20 17:14:13 +02:00
crypt crypt: Fix badsalttest test (Bug 22765) 2018-02-01 00:02:49 -08:00
csu Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
ctype Use libc_hidden_* for tolower, toupper (bug 15105). 2018-02-23 13:54:53 +00:00
debug libio: Avoid _allocate_buffer, _free_buffer function pointers [BZ #23236] 2018-06-01 10:41:03 +02:00
dirent Consolidate alphasort{64} and versionsort{64} implementation 2018-04-23 17:35:16 -03:00
dlfcn Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
elf Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
gmon Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gnulib Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
grp Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gshadow Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
hesiod Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
htl hurd: Avoid local PLT in libpthread 2018-04-03 02:56:35 +02:00
hurd hurd: Silence warning 2018-04-04 02:06:16 +02:00
iconv Fix s390 -Os iconv build. 2018-03-05 21:46:55 +00:00
iconvdata Add aliases to recognize normalized charset names (bug 19527) 2018-04-16 17:30:56 +02:00
include Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
inet Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247] 2018-05-23 15:27:24 +02:00
intl intl/tst-gettext: fix failure with newest msgfmt 2018-02-18 18:16:05 +01:00
io Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
libio libio: Avoid _allocate_buffer, _free_buffer function pointers [BZ #23236] 2018-06-01 10:41:03 +02:00
locale Fix two more -Os strcoll / wcscoll build failures. 2018-02-27 16:55:42 +00:00
localedata gd_GB, hsb_DE, wa_BE: Add alternative month names (bug 23140). 2018-06-12 01:33:55 +02:00
login Update copyright dates not handled by scripts/update-copyrights. 2018-01-01 00:41:16 +00:00
mach hurd: Add missing symbols 2018-04-04 02:17:49 +02:00
malloc malloc: harden removal from unsorted list 2018-03-14 16:25:57 -04:00
manual Add narrowing divide functions. 2018-05-17 00:40:52 +00:00
math Fix ldbl-96 fma (Inf, Inf, finite) (bug 23272). 2018-06-11 16:33:42 +00:00
mathvec Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
misc Implement allocate_once for atomic initialization with allocation 2018-05-23 15:27:01 +02:00
nis libnsl: Turn remaining symbols into compat symbols [BZ #22701] 2018-01-29 17:42:30 +01:00
nptl Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
nptl_db nptl_db: Remove stale `match_pid' parameter from `iterate_thread_list' 2018-03-01 16:10:05 +00:00
nscd Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247] 2018-05-23 15:27:24 +02:00
nss Fix multiple definitions of __nss_*_database (bug 22918) 2018-03-03 17:44:24 +01:00
po Update translations from the Translation Project 2018-03-12 13:24:46 +00:00
posix Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
pwd Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
resolv Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247] 2018-05-23 15:27:24 +02:00
resource resource/tst-getrlimit.c: Add copyright header 2018-01-05 20:34:10 +01:00
rt hurd: Add hurd thread library 2018-04-02 01:44:14 +02:00
scripts Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
setjmp x86: Use pad in pthread_unwind_buf to preserve shadow stack register 2018-05-02 06:17:41 -07:00
shadow Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
signal Add tst-sigaction.c to test BZ #23069 2018-04-26 22:21:13 +02:00
socket Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
soft-fp Make powerpc-nofpu __sqrtsf2, __sqrtdf2 compat symbols (bug 18473). 2018-06-01 17:25:12 +00:00
stdio-common Remove miscellaneous debris from libio. 2018-02-21 14:39:54 -05:00
stdlib stdlib: Additional tests need generated locale dependencies 2018-05-29 10:34:53 +02:00
streams Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
string Add a test case for [BZ #23196] 2018-05-23 04:00:11 -07:00
sunrpc sunrpc: Remove stray exports without --enable-obsolete-rpc [BZ #23166] 2018-05-11 15:36:50 +02:00
support support: Add wrappers for pthread_barrierattr_t 2018-05-29 15:37:00 +02:00
sysdeps Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
sysvipc Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
termios Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
time Fix year 2039 bug for localtime with 64-bit time_t (bug 22639). 2018-05-18 11:57:15 +00:00
timezone Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
wcsmbs math: Merge strtod_nan_*.h into math-type-macros-*.h 2018-05-16 06:03:08 +02:00
wctype Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
.gitattributes Assume __NR_openat is always defined 2016-03-23 23:35:08 +01:00
.gitignore Add *.pyc to .gitignore 2015-05-18 15:26:26 +05:30
COPYING
COPYING.LIB
ChangeLog Avoid cancellable I/O primitives in ld.so. 2018-06-12 09:53:04 -04:00
INSTALL Document use of CC and CFLAGS in more detail (bug 20980, bug 21234). 2018-02-15 23:48:47 +00:00
LICENSES Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247] 2018-05-23 15:27:24 +02:00
MAINTAINERS Add MAINTAINERS 2017-05-11 13:38:30 -04:00
Makeconfig Add support for sqrt asm redirects 2018-03-15 19:21:35 +00:00
Makefile Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
Makefile.in New make target to only build benchmark binaries 2016-04-20 10:23:28 +05:30
Makerules Define GEN_AS_CONST_HEADERS when generating header files [BZ #22792] 2018-02-23 11:29:39 -08:00
NEWS gd_GB, hsb_DE, wa_BE: Add alternative month names (bug 23140). 2018-06-12 01:33:55 +02:00
README Remove tilegx port. 2018-04-27 19:11:24 +00:00
Rules Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
abi-tags Remove the bulk of the NaCl port. 2017-05-20 08:09:10 -04:00
aclocal.m4 LIBC_SLIBDIR_RTLDDIR: substitute arguments in single quotes 2018-01-25 17:20:28 +01:00
config.h.in Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247] 2018-05-23 15:27:24 +02:00
config.make.in Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614] 2017-12-18 12:24:38 -08:00
configure Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614] 2017-12-18 12:24:38 -08:00
configure.ac Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614] 2017-12-18 12:24:38 -08:00
extra-lib.mk Rename cppflags-iterator.mk to libof-iterator.mk, remove extra-modules.mk. 2017-05-09 07:06:29 -04:00
gen-locales.mk Improve gen-locales.mk and gen-locale.sh to make test files with @ options work 2018-02-27 17:01:57 +01:00
libc-abis
libof-iterator.mk Rename cppflags-iterator.mk to libof-iterator.mk, remove extra-modules.mk. 2017-05-09 07:06:29 -04:00
o-iterator.mk
shlib-versions Extend NSS test suite 2017-07-17 15:52:44 -04:00
test-skeleton.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
version.h Open master branch for glibc 2.28 development 2018-02-01 17:18:19 +00:00

README

This directory contains the sources of the GNU C Library.
See the file "version.h" for what release version you have.

The GNU C Library is the standard system C library for all GNU systems,
and is an important part of what makes up a GNU system.  It provides the
system API for all programs written in C and C-compatible languages such
as C++ and Objective C; the runtime facilities of other programming
languages use the C library to access the underlying operating system.

In GNU/Linux systems, the C library works with the Linux kernel to
implement the operating system behavior seen by user applications.
In GNU/Hurd systems, it works with a microkernel and Hurd servers.

The GNU C Library implements much of the POSIX.1 functionality in the
GNU/Hurd system, using configurations i[4567]86-*-gnu.

When working with Linux kernels, this version of the GNU C Library
requires Linux kernel version 3.2 or later.

Also note that the shared version of the libgcc_s library must be
installed for the pthread library to work correctly.

The GNU C Library supports these configurations for using Linux kernels:

	aarch64*-*-linux-gnu
	alpha*-*-linux-gnu
	arm-*-linux-gnueabi
	hppa-*-linux-gnu
	i[4567]86-*-linux-gnu
	x86_64-*-linux-gnu	Can build either x86_64 or x32
	ia64-*-linux-gnu
	m68k-*-linux-gnu
	microblaze*-*-linux-gnu
	mips-*-linux-gnu
	mips64-*-linux-gnu
	powerpc-*-linux-gnu	Hardware or software floating point, BE only.
	powerpc64*-*-linux-gnu	Big-endian and little-endian.
	s390-*-linux-gnu
	s390x-*-linux-gnu
	riscv64-*-linux-gnu
	sh[34]-*-linux-gnu
	sparc*-*-linux-gnu
	sparc64*-*-linux-gnu

If you are interested in doing a port, please contact the glibc
maintainers; see http://www.gnu.org/software/libc/ for more
information.

See the file INSTALL to find out how to configure, build, and install
the GNU C Library.  You might also consider reading the WWW pages for
the C library at http://www.gnu.org/software/libc/.

The GNU C Library is (almost) completely documented by the Texinfo manual
found in the `manual/' subdirectory.  The manual is still being updated
and contains some known errors and omissions; we regret that we do not
have the resources to work on the manual as much as we would like.  For
corrections to the manual, please file a bug in the `manual' component,
following the bug-reporting instructions below.  Please be sure to check
the manual in the current development sources to see if your problem has
already been corrected.

Please see http://www.gnu.org/software/libc/bugs.html for bug reporting
information.  We are now using the Bugzilla system to track all bug reports.
This web page gives detailed information on how to report bugs properly.

The GNU C Library is free software.  See the file COPYING.LIB for copying
conditions, and LICENSES for notices about a few contributions that require
these additional notices to be distributed.  License copyright years may be
listed using range notation, e.g., 1996-2015, indicating that every year in
the range, inclusive, is a copyrightable year that would otherwise be listed
individually.