Commit Graph

1207 Commits

Author SHA1 Message Date
Samuel Thibault 08e92e2443 Revert "hurd: Avoid PLTs for longjmp & siglongjmp"
This reverts commit e5f9508a32.
2018-04-05 09:38:58 +02:00
Samuel Thibault c120981d72 hurd: Avoid PLT for dirfd
* include/dirent.h (dirfd): Add hidden proto.
	* dirent/dirfd.c (dirfd): Add hidden def.
	* sysdeps/mach/hurd/dirfd.c (dirfd): Add hidden def.
	* sysdeps/posix/dirfd.c (dirfd): Add hidden def.
2018-04-05 01:52:29 +02:00
Samuel Thibault e5f9508a32 hurd: Avoid PLTs for longjmp & siglongjmp
* include/setjmp.h (longjmp, siglongjmp): Add hidden protos.
	* setjmp/longjmp.c (longjmp, siglongjmp): Add hidden defs.
	* sysdeps/s390/longjmp.c (longjmp, siglongjmp): Add hidden defs.
2018-04-04 23:19:18 +00:00
Samuel Thibault 5e17a480f8 Revert parts of "hurd: Avoid more libc.so local PLTs"
This reverts parts of commit 82dbf555a4.
2018-04-03 23:06:00 +02:00
Samuel Thibault 82dbf555a4 hurd: Avoid more libc.so local PLTs
* hurd/catch-signal.c (__hurd_catch_signal): Call __libc_siglongjmp
	instead if siglongjmp.
	(hurd_safe_memmove): Call __libc_longjmp instead of longjmp.
	* hurd/hurdfault.c (faulted): Call __libc_longjmp instead of longjmp.
	* include/setjmp.h (__libc_siglongjmp, __libc_longjmp): New hidden
	prototypes.
	* libio/iolibio.h (_IO_puts): New hidden prototype.
	* libio/ioputs.c (_IO_puts): New hidden def.
	* setjmp/longjmp.c (__libc_longjmp, __libc_siglongjmp): New hidden
	defs.
	* sysdeps/mach/hurd/sigwait.c (__sigwait): Call __libc_longjmp instead
	of longjmp.
2018-04-03 00:36:33 +00:00
Samuel Thibault fa97d2ab5b hurd: Fix accessing errno from rtld
Letting rtld access errno through TLS can not work at early stages since
TLS will not be initialized yet.  When a private errno is not possible,
we thus have no other way than going through __errno_location.

	* include/errno.h [IS_IN(rtld) && !RTLD_PRIVATE_ERRNO]: Do not use the
	TLS declaration of errno.
2018-03-25 00:48:01 +01:00
Wilco Dijkstra 1294b1892e Add support for sqrt asm redirects
This patch series cleans up the many uses of  __ieee754_sqrt(f/l) in GLIBC.
The goal is to enable GCC to do the inlining, and if this fails call the
__ieee754_sqrt function.  This is done by internally declaring sqrt with asm
redirects.  The compat symbols and sqrt wrappers need to disable the redirect.
The redirect is also disabled if there are already redirects defined when
using -ffinite-math-only.

All math functions (but not math tests, non-library code and libnldbl) are
built with -fno-math-errno which means GCC will typically inline sqrt as a
single instruction.  This means targets are no longer forced to add a special
inline for sqrt.

	* include/math.h (sqrt): Declare with asm redirect.
	(sqrtf): Likewise.
	(sqrtl): Likewise.
	(sqrtf128): Likewise.
	* Makeconfig: Add -fno-math-errno for libc/libm, but build testsuite,
	nonlib and libnldbl with -fmath-errno.
	* math/w_sqrt_compat.c: Define NO_MATH_REDIRECT.
	* math/w_sqrt_template.c: Likewise.
	* math/w_sqrtf_compat.c: Likewise.
	* math/w_sqrtl_compat.c: Likewise.
	* sysdeps/i386/fpu/w_sqrt.c: Likewise.
	* sysdeps/i386/fpu/w_sqrt_compat.c: Likewise.
	* sysdeps/generic/math-type-macros-float128.h: Remove math.h and
	complex.h.
2018-03-15 19:21:35 +00:00
H.J. Lu 6253bacdc0 Remove hidden __libc_longjmp
Since __libc_longjmp is a private interface for cancellation implementation
in libpthread, there is no need to provide hidden __libc_longjmp in libc.

Tested with build-many-glibcs.py.

	* include/setjmp.h (__libc_longjmp): Remove libc_hidden_proto.
	* setjmp/longjmp.c (__libc_longjmp): Remove libc_hidden_def.
	* sysdeps/s390/longjmp.c (__libc_longjmp): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/longjmp.S (__libc_longjmp):
	Likewise.
2018-03-10 09:27:20 -08:00
Adhemerval Zanella 5226a81f55 Define _DIRENT_MATCHES_DIRENT64 regardless
This patch defines _DIRENT_MATCHES_DIRENT64 to either 0 or 1 and adjust its
usage from checking its definition to its value.

Checked on a build for major Linux abis.

	* bits/dirent.h (__INO_T_MATCHES_INO64_T): Define regardless whether
	__INO_T_MATCHES_INO64_T is defined.
	* sysdeps/unix/sysv/linux/bits/dirent.h: Likewise.
	* dirent/alphasort.c: Check _DIRENT_MATCHES_DIRENT64 value instead
	of definition.
	* dirent/alphasort64.c: Likewise.
	* dirent/scandir.c: Likewise.
	* dirent/scandir64-tail.c: Likewise.
	* dirent/scandir64.c: Likewise.
	* dirent/scandirat.c: Likewise.
	* dirent/scandirat64.c: Likewise.
	* dirent/versionsort.c: Likewise.
	* dirent/versionsort64.c: Likewise.
	* include/dirent.h: Likewise.
2018-03-05 18:10:04 -03:00
Joseph Myers 000f290ff1 Use libc_hidden_* for strtoumax (bug 15105).
On sparc, localplt test failures appear when building with -Os because
of a call to strtoumax from
sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c, and strtoumax
is not inlined when building with -Os.  This patch fixes those
failures by using libc_hidden_proto and libc_hidden_def for strtoumax.

Tested with build-many-glibcs.py for
sparc64-linux-gnu-disable-multi-arch, sparc64-linux-gnu,
sparcv9-linux-gnu-disable-multi-arch, sparcv9-linux-gnu that this
fixes that test failure with -Os.

	[BZ #15105]
	* sysdeps/wordsize-32/strtoumax.c (strtoumax): Use
	libc_hidden_def.
	* sysdeps/wordsize-64/strtoumax.c (strtoumax): Likewise.
	* include/inttypes.h: New file.
2018-02-28 14:16:21 +00:00
Joseph Myers 20602c72fa Use libc_hidden_* for atoi (bug 15105).
Continuing the fixes for localplt test failures with -Os arising from
functions not being inlined in that case, this patch fixes such
failures for atoi by using libc_hidden_proto and libc_hidden_def.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os, and that the testsuite continues to pass without
-Os).

	[BZ #15105]
	* stdlib/atoi.c (atoi): Use libc_hidden_def.
	* include/stdlib.h [!_ISOMAC] (atoi): Use libc_hidden_proto.
2018-02-26 18:17:47 +00:00
Joseph Myers 54412d2061 Use libc_hidden_* for tolower, toupper (bug 15105).
Continuing the fixes for localplt test failures with -Os arising from
functions not being inlined in that case, this patch fixes such
failures for tolower and toupper by using libc_hidden_proto and
libc_hidden_def.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os, and that the testsuite continues to pass without
-Os).

2018-02-22  Joseph Myers  <joseph@codesourcery.com>

	[BZ #15105]
	* ctype/ctype.c (tolower): Use libc_hidden_def.
	(toupper): Likewise.
	* include/ctype.h [!_ISOMAC] (tolower): Use libc_hidden_proto.
	[!_ISOMAC] (toupper): Likewise.
2018-02-23 13:54:53 +00:00
Zack Weinberg 9964a14579 Mechanically remove _IO_ name aliases for types and constants.
This patch mechanically removes all remaining uses, and the
definitions, of the following libio name aliases:

 name                         replaced with
 ----                         -------------
 _IO_FILE                     FILE
 _IO_fpos_t                   __fpos_t
 _IO_fpos64_t                 __fpos64_t
 _IO_size_t                   size_t
 _IO_ssize_t                  ssize_t or __ssize_t
 _IO_off_t                    off_t
 _IO_off64_t                  off64_t
 _IO_pid_t                    pid_t
 _IO_uid_t                    uid_t
 _IO_wint_t                   wint_t
 _IO_va_list                  va_list or __gnuc_va_list
 _IO_BUFSIZ                   BUFSIZ
 _IO_cookie_io_functions_t    cookie_io_functions_t
 __io_read_fn                 cookie_read_function_t
 __io_write_fn                cookie_write_function_t
 __io_seek_fn                 cookie_seek_function_t
 __io_close_fn                cookie_close_function_t

I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because
the definitions of fpos_t and fpos64_t depend on the largefile mode.
I used __ssize_t and __gnuc_va_list in a handful of headers where
namespace cleanliness might be relevant even though they're
internal-use-only.  In all other cases, I used the public-namespace
name.

There are a tiny handful of places where I left a use of 'struct _IO_FILE'
alone, because it was being used together with 'struct _IO_FILE_plus'
or 'struct _IO_FILE_complete' in the same arithmetic expression.

Because this patch was almost entirely done with search and replace, I
may have introduced indentation botches.  I did proofread the diff,
but I may have missed something.

The ChangeLog below calls out all of the places where this was not a
pure search-and-replace change.

Installed stripped libraries and executables are unchanged by this patch,
except that some assertions in vfscanf.c change line numbers.

	* libio/libio.h (_IO_FILE): Delete; all uses changed to FILE.
	(_IO_fpos_t): Delete; all uses changed to __fpos_t.
	(_IO_fpos64_t): Delete; all uses changed to __fpos64_t.
	(_IO_size_t): Delete; all uses changed to size_t.
	(_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t.
	(_IO_off_t): Delete; all uses changed to off_t.
	(_IO_off64_t): Delete; all uses changed to off64_t.
	(_IO_pid_t): Delete; all uses changed to pid_t.
	(_IO_uid_t): Delete; all uses changed to uid_t.
	(_IO_wint_t): Delete; all uses changed to wint_t.
	(_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list.
	(_IO_BUFSIZ): Delete; all uses changed to BUFSIZ.
	(_IO_cookie_io_functions_t): Delete; all uses changed to
	cookie_io_functions_t.
	(__io_read_fn): Delete; all uses changed to cookie_read_function_t.
	(__io_write_fn): Delete; all uses changed to cookie_write_function_t.
	(__io_seek_fn): Delete; all uses changed to cookie_seek_function_t.
	(__io_close_fn): Delete: all uses changed to cookie_close_function_t.

	* libio/iofopncook.c: Remove unnecessary forward declarations.
	* libio/iolibio.h: Correct outdated commentary.
	* malloc/malloc.c (__malloc_stats): Remove unnecessary casts.
	* stdio-common/fxprintf.c (__fxprintf_nocancel):
	Remove unnecessary casts.
	* stdio-common/getline.c: Use _IO_getdelim directly.
	Don't redefine ssize_t.
	* stdio-common/printf_fp.c, stdio_common/printf_fphex.c
	* stdio-common/printf_size.c: Don't redefine size_t or FILE.
	Remove outdated comments.
	* stdio-common/vfscanf.c: Don't redefine va_list.
2018-02-21 14:11:05 -05:00
Joseph Myers 039c721a30 Fix -Os putc_unlocked, fputc_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for putc_unlocked and fputc_unlocked.

libc_hidden_* are used for both functions, while namespace issues are
addressed by making putc_unlocked a weak alias of hidden
__putc_unlocked, which is called in the one place where namespace
issues arise (and defined as an inline function in include/stdio.h).

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  This completes fixing the -Os
linknamespace failures (at least for x86_64); localplt failures remain
after this patch.

2018-02-19  Joseph Myers  <joseph@codesourcery.com>

	[BZ #15105]
	[BZ #19463]
	* libio/fputc_u.c (fputc_unlocked): Use libc_hidden_def.
	* libio/putc_u.c (putc_unlocked): Rename to __putc_unlocked and
	define as weak alias of __putc_unlocked.  Use libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (fputc_unlocked): Use
	libc_hidden_proto.
	[!_ISOMAC] (putc_unlocked): Likewise.
	[!_ISOMAC] (__putc_unlocked): Declare as hidden function, and
	define inline if [__USE_EXTERN_INLINES].
	* misc/syslog.c (__vsyslog_chk): Call __putc_unlocked instead of
	putc_unlocked.
2018-02-21 18:02:24 +00:00
Joseph Myers 30ac923dbe Fix -Os getc_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for getc_unlocked.

__getc_unlocked already exists; this patch makes it explicitly hidden,
calls it where needed for namespace reasons, adds an inline function
for it when inline functions are used and adds libc_hidden_proto /
libc_hidden_weak for getc_unlocked.

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/getc_u.c (getc_unlocked): Use libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (__getc_unlocked): Use
	attribute_hidden, and define inline if [__USE_EXTERN_INLINES].
	[!_ISOMAC] (getc_unlocked): Use libc_hidden_proto.
	* misc/getttyent.c (__getttyent): Call __getc_unlocked instead of
	getc_unlocked.
	* time/tzfile.c (__tzfile_read): Likewise.
2018-02-21 18:01:11 +00:00
Rical Jasan 862b45026f manual: Update _DEFAULT_SOURCE. [BZ #22862]
The description of the interplay between feature test macros and
compiler options in the description of _DEFAULT_SOURCE is a little
confusing, and dated, so clarify the situation, and don't assume a
specific value for _DEFAULT_SOURCE.

Also, _DEFAULT_SOURCE is supposed to be defined if none of the C/POSIX
feature test macros are defined, but the condition was lacking a test
for _ISOC11_SOURCE, so that is also addressed.

	[BZ #22862]
	* include/features.h: Add _ISOC11_SOURCE to test for whether
	to define _DEFAULT_SOURCE.
	* manual/creature.texi (_DEFAULT_SOURCE): Improve
	documentation.
2018-02-21 02:38:42 -08:00
Florian Weimer 52a01100ad elf: Remove ad-hoc restrictions on dlopen callers [BZ #22787]
This looks like a post-exploitation hardening measure: If an attacker is
able to redirect execution flow, they could use that to load a DSO which
contains additional code (or perhaps make the stack executable).

However, the checks are not in the correct place to be effective: If
they are performed before the critical operation, an attacker with
sufficient control over execution flow could simply jump directly to
the code which performs the operation, bypassing the check.  The check
would have to be executed unconditionally after the operation and
terminate the process in case a caller violation was detected.

Furthermore, in _dl_check_caller, there was a fallback reading global
writable data (GL(dl_rtld_map).l_map_start and
GL(dl_rtld_map).l_text_end), which could conceivably be targeted by an
attacker to disable the check, too.

Other critical functions (such as system) remain completely
unprotected, so the value of these additional checks does not appear
that large.  Therefore this commit removes this functionality.
2018-02-21 10:37:22 +01:00
Joseph Myers ec481ad81b Fix -Os ferror_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for ferror_unlocked.

The usual approach is followed of adding __ferror_unlocked (inlined
when ferror_unlocked is), making calls use it when required for
namespace reasons (only one such call), and using libc_hidden_proto /
libc_hidden_weak for the ferror_unlocked weak alias when only localplt
but not namespace issues are involved.

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/ferror_u.c (ferror_unlocked): Rename to __ferror_unlocked
	and define as weak alias of __ferror_unlocked.  Use
	libc_hidden_weak.
	* include/stdio.h [!_ISOMAC] (ferror_unlocked): Use
	libc_hidden_proto.
	[!_ISOMAC] (__ferror_unlocked) New declaration, and inline
	function if [__USE_EXTERN_INLINES].
	* time/getdate.c (__getdate_r): Call __ferror_unlocked instead of
	ferror_unlocked.
2018-02-19 17:32:34 +00:00
Joseph Myers 055ac2a7ee Use libc_hidden_* for argz_next, __argz_next (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for argz_next and __argz_next.  This is a
simple case of functions that are inlined for -O2 but not for -Os;
this patch adds libc_hidden_proto / libc_hidden_def for them to avoid
localplt failures even when not inlined.

Tested for x86_64 (both that it removes these particular localplt
failures for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).

	[BZ #15105]
	* include/argz.h (argz_next): Use libc_hidden_proto.
	(__argz_next): Likewise.
	* string-argz-next.c (__argz_next): Use libc_hidden_def.
	(argz_next): Use libc_hidden_weak.
2018-02-15 21:00:02 +00:00
Joseph Myers e4452a2d19 Use libc_hidden_* for __cmsg_nxthdr (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for __cmsg_nxthdr.  This is a simple case of a
function that is inlined for -O2 but not for -Os; this patch adds
libc_hidden_proto / libc_hidden_def for it to avoid a localplt failure
even when it is not inlined.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).

	[BZ #15105]
	* include/sys/socket.h [!_ISOMAC] (__cmsg_nxthdr): Use
	libc_hidden_proto.
	* sysdeps/unix/sysv/linux/cmsg_nxthdr.c (__cmsg_nxthdr): Use
	libc_hidden_def.
2018-02-15 20:59:12 +00:00
Joseph Myers 499b315324 Use libc_hidden_* for fputs (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for fputs.  fputs calls normally get redirected
to _IO_fputs by a macro in include/stdio.h (and _IO_fputs in turn uses
libc_hidden_proto), but GCC can convert an fprintf call with a
constant string argument into an fputs call, which of course is then
unaffected by the macro redirection.  (I don't know why this issue
only appears with -Os.)

This patch duly adds a use of libc_hidden_proto for fputs.  I see no
obvious reason why the fputs macro redirection is needed at all, but
this patch does not change it.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).

	[BZ #15105]
	* include/stdio.h [!_ISOMAC && IS_IN (libc)] (fputs): Use
	libc_hidden_proto.
	* libio/iofputs.c (fputs): Use libc_hidden_weak.
2018-02-15 20:58:16 +00:00
Joseph Myers 7fc03cf320 Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for feof_unlocked.

The usual approach is followed of adding __feof_unlocked (inlined when
feof_unlocked is), making calls use it when required for namespace
reasons, and using libc_hidden_proto / libc_hidden_weak for the
feof_unlocked weak alias when only localplt but not namespace issues
are involved.  In the case of getaddrinfo.c, use of __feof_unlocked
needs to be conditional since that code is also used in nscd (where
__feof_unlocked is not available).

Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved).  Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.

	[BZ #15105]
	[BZ #19463]
	* libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and
	define as weak alias of __feof_unlocked.  Use libc_hidden_weak.
	* include/stdio.h (feof_unlocked): Use libc_hidden_proto.
	(__feof_unlocked): New declaration, and inline function if
	[__USE_EXTERN_INLINES].
	* iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked
	instead of feof_unlocked.
	* intl/localealias.c [_LIBC] (FEOF): Likewise.
	* nss/nsswitch.c (nss_parse_file): Likewise.
	* sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area):
	Likewise.
	* time/getdate.c (__getdate_r): Likewise.
	* sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked):
	Define as macro to call __feof_unlocked.
2018-02-15 20:57:15 +00:00
Joseph Myers 63716ab270 Add build infrastructure for narrowing libm functions.
TS 18661-1 defines libm functions that carry out an operation (+ - * /
sqrt fma) on their arguments and return a result rounded to a
(usually) narrower type, as if the original result were computed to
infinite precision and then rounded directly to the result type
without any intermediate rounding to the argument type.  For example,
fadd, faddl and daddl for addition.  These are the last remaining TS
18661-1 functions left to be added to glibc.  TS 18661-3 extends this
to corresponding functions for _FloatN and _FloatNx types.

As functions parametrized by two rather than one varying
floating-point types, these functions require infrastructure in glibc
that was not required for previous libm functions.  This patch
provides such infrastructure - excluding test support, and actual
function implementations, which will be in subsequent patches.

Declaring the functions uses a header bits/mathcalls-narrow.h, which
is included many times, for each relevant pair of types.  This will
end up containing macro calls of the form

__MATHCALL_NARROW (__MATHCALL_NAME (add), __MATHCALL_REDIR_NAME (add), 2);

for each family of narrowing functions.  (The structure of this macro
call, with the calls to __MATHCALL_NAME and __MATHCALL_REDIR_NAME
there rather than in the definition of __MATHCALL_NARROW, arises from
the names such as "add" *not* themselves being reserved identifiers -
meaning it's necessary to avoid any indirection that would result in a
user-defined "add" macro being expanded.)  Whereas for existing
functions declaring long double functions is disabled if _LIBC in the
case where they alias double functions, to facilitate defining the
long double functions as aliases of the double ones, there is no such
logic for the narrowing functions in this patch.  Rather, the files
defining such functions are expected to use #define to hide the
original declarations of the alias names, to avoid errors about
defining aliases with incompatible types.

math/Makefile support is added for building the functions (listed in
libm-narrow-fns, currently empty) for all relevant pairs of types.  An
internal header math-narrow.h is added for macros shared between
multiple function implementations - currently a ROUND_TO_ODD macro to
facilitate writing functions using the round-to-odd implementation
approach, and alias macros to create all the required function
aliases.  libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128
are added for use when required (only for x86_64).  float128_private.h
support is added for ldbl-128 narrowing functions to be used for
_Float128.

Certain things are specifically omitted from this patch and the
immediate followups.  tgmath.h support is deferred; there remain
unresolved questions about how the type-generic macros for these
functions are supposed to work, especially in the case of arguments of
integer type.  The math.h / bits/mathcalls-narrow.h logic, and the
logic for determining what functions / aliases to define, will need
some adjustments to support the sqrt and fma functions, where
e.g. f32xsqrtf64 can just be an alias for sqrt rather than a separate
function.  TS 18661-1 defines FP_FAST_* macros but no support is
included for defining them (they won't in general be true without
architecture-specific optimized function versions).

For each of the function groups (add sub mul div sqrt fma) there are
always six functions present (e.g. fadd, faddl, daddl, f32addf64,
f32addf32x, f32xaddf64).  When _Float64x and _Float128 are supported,
there are seven more (e.g. f32addf64x, f32addf128, f64addf64x,
f64addf128, f32xaddf64x, f32xaddf128, f64xaddf128).  In addition, in
the ldbl-opt case there are function names such as __nldbl_daddl (an
alias for f32xaddf64, which is not a reserved name in TS 18661-1, only
in TS 18661-3), for calls to daddl to be mapped to in the
-mlong-double-64 case.  (Calls to faddl just get mapped to fadd, and
for sqrt and fma there won't be __nldbl_* functions because dsqrtl and
dfmal can just be mapped to sqrt and fma with -mlong-double-64.)

While there are six or thirteen functions present in each group (plus
__nldbl_* names only as an ABI, not an API), not all are distinct;
they fall in various groups of aliases.  There are two distinct
versions built if long double has the same format as double; four if
they have distinct formats but there is no _Float64x or _Float128
support; five if long double has binary128 format; seven when
_Float128 is distinct from long double.

Architecture-specific optimized versions are possible, but not
included in my patches.  For example, IA64 generally supports
narrowing the result of most floating-point instructions; Power ISA
2.07 (POWER8) supports double values as arguments to float
instructions, with the results narrowed as expected; Power ISA 3
(POWER9) supports round-to-odd for float128 instructions, so meaning
that approach can be used without needing to set and restore the
rounding mode and test "inexact".  I intend to leave any such
optimized versions to the architecture maintainers.  Generally in such
cases it would also make sense for calls to these functions to be
expanded inline (given -fno-math-errno); I put a suggestion for TS
18661-1 built-in functions at <https://gcc.gnu.org/wiki/SummerOfCode>.

Tested for x86_64 (this patch in isolation, as well as testing for
various configurations in conjunction with further patches).

	* math/bits/mathcalls-narrow.h: New file.
	* include/bits/mathcalls-narrow.h: Likewise.
	* math/math-narrow.h: Likewise.
	* math/math.h (__MATHCALL_NARROW_ARGS_1): New macro.
	(__MATHCALL_NARROW_ARGS_2): Likewise.
	(__MATHCALL_NARROW_ARGS_3): Likewise.
	(__MATHCALL_NARROW_NORMAL): Likewise.
	(__MATHCALL_NARROW_REDIR): Likewise.
	(__MATHCALL_NARROW): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)]: Repeatedly include
	<bits/mathcalls-narrow.h> with _Mret_, _Marg_ and __MATHCALL_NAME
	defined.
	[__GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
	* math/Makefile (headers): Add bits/mathcalls-narrow.h.
	(libm-narrow-fns): New variable.
	(libm-narrow-types-basic): Likewise.
	(libm-narrow-types-ldouble-yes): Likewise.
	(libm-narrow-types-float128-yes): Likewise.
	(libm-narrow-types-float128-alias-yes): Likewise.
	(libm-narrow-types): Likewise.
	(libm-routines): Add narrowing functions.
	* sysdeps/i386/fpu/fenv_private.h [__x86_64__]
	(libc_feholdexcept_setroundf128): New macro.
	[__x86_64__] (libc_feupdateenv_testf128): Likewise.
	* sysdeps/ieee754/float128/float128_private.h: Include
	<math/math-narrow.h>.
	[libc_feholdexcept_setroundf128] (libc_feholdexcept_setroundl):
	Undefine and redefine.
	[libc_feupdateenv_testf128] (libc_feupdateenv_testl): Likewise.
	(libm_alias_float_ldouble): Undefine and redefine.
	(libm_alias_double_ldouble): Likewise.
2018-02-09 21:18:52 +00:00
Zack Weinberg 63fb8f9aa9 Post-cleanup 2: minimize _G_config.h.
Nearly everything in _G_config.h is either junk or more appropriately
defined elsewhere:

 * _G_fpos_t, _G_fpos64_t, and _G_BUFSIZ are already completely unused.
 * All remaining uses of _G_va_list have been changed to __gnuc_va_list.
 * The definition of _G_HAVE_ST_BLKSIZE/_IO_HAVE_ST_BLKSIZE has
   been inlined into its sole use.
 * The complete definition of _G_iconv_t has been moved to libio.h and
   renamed _IO_iconv_t (all actual users used that name).
 * _G_IO_IO_FILE_VERSION is vestigial; some code cares whether
   _IO_stdin_used exists, but nothing looks at its value.  I've
   preserved the value as a hardwired constant in csu/init.c.
   This means csu/init.c no longer needs to include anything.
 * Many of the headers included by _G_config.h were already being
   included directly by either either libio.h or stdio.h; the
   remaining ones were moved to libio.h.
 * _G_HAVE_MREMAP is still relevant, because mremap genuinely is a
   Linux extension; it's not in POSIX and as far as I can tell it's
   not available on the Hurd either.  I also preserved _G_HAVE_MMAP,
   since it's conceivable someone would want to port glibc to a
   MMU-less, mmap-less environment in the future.  Both are now always
   defined to 1/0 as is the current convention, instead of the older
   1/undef convention.  These are the only symbols still defined in
   _G_config.h.
 * The actual inclusion of _G_config.h moves from libio.h to libioP.h,
   as this is where a potential override of _G_HAVE_MMAP happens.
 * The #ifdef logic in libioP.h controlling _IO_JUMPS_OFFSET has been
   simplified.

After this patch, the only surviving _G_ symbols are the struct tag
names _G_fpos_t and _G_fpos64_t, which are preserved for the sake of
C++ mangled names in applications, and _G_HAVE_MMAP and _G_HAVE_MREMAP,
which do not seem worth renaming.

Installed stripped libraries are unchanged by this patch.

	* bits/_G_config.h: Move back to sysdeps/generic/_G_config.h.
	Delete all contents except for definitions of _G_HAVE_MMAP and
	_G_HAVE_MREMAP.  Add commentary explaining those two symbols.
	* sysdeps/unix/sysv/linux/bits/_G_config.h: Move back to
	sysdeps/unix/sysv/linux/_G_config.h.  Make same content
	change as above.

	* libio/libio.h: Don't include bits/_G_config.h here.
	Include stddef.h with __need_wchar_t defined.  Include
	bits/types/__mbstate_t.h, bits/types/wint_t.h, and gconv.h.
	Define _IO_iconv_t here, directly.
	Don't define _IO_HAVE_ST_BLKSIZE.
	* libio/libioP.h: Include _G_config.h here.  Move include of
	shlib-compat.h up with rest of includes.  Simplify conditionals
	controlling definition of _IO_JUMPS_OFFSET.

	* csu/init.c: Remove always-true #if around entire file.
	Don't include stdio.h.  Set _IO_stdin_used to hardwired
	constant 0x20001, and update commentary.
	* include/stdio.h, sysdeps/ieee754/ldbl-opt/nldbl-compat.h:
	Replace all uses of _G_va_list with __gnuc_va_list.
	* libio/filedoalloc.c: Use #if defined _STATBUF_ST_BLKSIZE
	instead of #if _IO_HAVE_ST_BLKSIZE.
	* libio/fileops.c: Test _G_HAVE_MREMAP with #if, not #ifdef.
	* libio/iofdopen.c, libio/iofopen.c: Test _G_HAVE_MMAP with #if,
	not #ifdef.
2018-02-07 10:10:32 -05:00
Zack Weinberg 6c6c962a20 Post-cleanup 1: move libio.h back out of bits/.
We can't go very far with libio cleanups as long as we still have
_IO_MTSAFE_IO, and I am not tackling that in this patch series,
but we can at least make the maze of stdio-related headers a
little less complicated.

In this patch, libio.h moves back out of bits/ into the top level of
the libio subdirectory, and is merged with libio/bits/libio-ldbl.h
(which also used to be installed) and include/libio.h.  Since almost
no files include libio.h directly, this is quite straightforward.

libio.h is now always used with _LIBC defined, so all of the _LIBC ||
_GLIBCPP_USE_WCHAR_T conditionals are unnecessary.  Similarly, the
ifdef nest surrounding the definition of _IO_fwide_maybe_incompatible
can collapse down to a single SHLIB_COMPAT check.  I also took the
opportunity to add some checks for configuration botches to libio.h.

Installed stripped libraries are unchanged by this patch.

        * libio/bits/libio.h: Move back to libio/libio.h and adjust
        multiple-include guard to match.
        Merge contents of libio/bits/libio-ldbl.h and include/libio.h
        into this file.
        Remove preprocessor conditionals that are always true and/or
        redundant to other preprocessor conditionals in the same nest.
        Include shlib-compat.h unconditionally.
        Error out if _LIBC is not defined, or if _ISOMAC is defined,
        or if _IO_MTSAFE_IO is defined but _IO_lock_t_defined is not
        defined after including stdio.h.
        Use __BEGIN_DECLS/__END_DECLS.

        * libio/bits/libio-ldbl.h, include/bits/libio.h: Delete file.
        * include/stdio.h, libio/iolibio.h, libio/libioP.h: Include
        libio.h as <libio/libio.h> rather than as <bits/libio.h>.
2018-02-07 10:09:47 -05:00
Zack Weinberg a4fea3f2c3 Don't install libio.h or _G_config.h.
We shipped 2.27 with libio.h and _G_config.h still installed but
issuing warnings when used.  Let's stop installing them early in 2.28
so that we have plenty of time to think of another plan if there are
problems.

The public stdio.h had a genuine dependency on libio.h for the
complete definitions of FILE and cookie_io_functions_t, and a genuine
dependency on _G_config.h for the complete definitions of fpos_t and
fpos64_t; these are moved to single-type headers.
bits/types/struct_FILE.h also provides a handful of accessor and
bitflags macros so that code is not duplicated between bits/stdio.h
and libio.h.  All the other _IO_ and _G_ names used by the public
stdio.h can be replaced with either public names or __-names.

In order to minimize the risk of breaking our own compatibility code,
bits/types/struct_FILE.h preserves the _IO_USE_OLD_IO_FILE mechanism
exactly as it was in libio.h, but you have to define _LIBC to use it,
or it'll error out.  Similarly, _IO_lock_t_defined is preserved
exactly, but will error out if used without defining _LIBC.

Internally, include/stdio.h continues to include libio.h, and libio.h
scrupulously provides every _IO_* and _G_* name that it always did,
perhaps now defined in terms of the public names.  This is how this
patch avoids touching dozens of files throughout glibc and becoming
entangled with the _IO_MTSAFE_IO mess.  The remaining patches in this
series eliminate most of the _G_ names.

Tested on x86_64-linux; in addition to the test suite, I installed the
library in a sysroot and verified that a simple program that uses
stdio.h could be compiled against the installed library, and I also
verified that installed stripped libraries are unchanged.

	* libio/bits/types/__fpos_t.h, libio/bits/types/__fpos64_t.h:
	New single-type headers split from _G_config.h.
	* libio/bits/types/cookie_io_functions_t.h
	* libio/bits/types/struct_FILE.h
	New single-type headers split from libio.h.

	* libio/Makefile: Install the above new headers.  Don't install
	libio.h, _G_config.h, bits/libio.h, bits/_G_config.h, or
	bits/libio-ldbl.h.
	* libio/_G_config.h, libio/libio.h: Delete file.

	* libio/bits/libio.h: Remove improper-inclusion guard.
	Include stdio.h and don't repeat anything that it does.
	Define _IO_fpos_t as __fpos_t, _IO_fpos64_t as __fpos64_t,
	_IO_BUFSIZ as BUFSIZ, _IO_va_list as __gnuc_va_list,
	__io_read_fn as cookie_read_function_t,
	__io_write_fn as cookie_write_function_t,
	__io_seek_fn as cookie_seek_function_t,
	__io_close_fn as cookie_close_function_t,
	and _IO_cookie_io_functions_t as cookie_io_functions_t.
	Define _STDIO_USES_IOSTREAM, __HAVE_COLUMN, and _IO_file_flags
	here, in the "compatibility defines" section.  Remove an #if 0
	block.  Use the "body" macros from bits/types/struct_FILE.h to
	define _IO_getc_unlocked, _IO_putc_unlocked, _IO_feof_unlocked,
	and _IO_ferror_unlocked.
	Move prototypes of __uflow and __overflow...

	* libio/stdio.h: ...here.  Don't include bits/libio.h.
	Don't define _STDIO_USES_IOSTREAM.  Get __gnuc_va_list
	directly from stdarg.h.  Include bits/types/__fpos_t.h,
	bits/types/__fpos64_t.h, bits/types/struct_FILE.h,
	and, when __USE_GNU, bits/types/cookie_io_functions_t.h.
	Use __gnuc_va_list, not _G_va_list; __fpos_t, not _G_fpos_t;
	__fpos64_t, not _G_fpos64_t; FILE, not struct _IO_FILE;
	cookie_io_functions_t, not _IO_cookie_io_functions_t;
	__ssize_t, not _IO_ssize_t.  Unconditionally define
	BUFSIZ as 8192 and EOF as (-1).

	* libio/bits/stdio.h: Add multiple-include guard.  Use the "body"
	macros from bits/types/struct_FILE.h instead of _IO_* macros
	from libio.h; use __gnuc_va_list instead of va_list and __ssize_t
	instead of _IO_ssize_t.
	* libio/bits/stdio2.h: Similarly.

	* libio/iolibio.h: Add multiple-include guard.
	Include bits/libio.h after stdio.h.
	* libio/libioP.h: Add multiple-include guard.
	Include stdio.h and bits/libio.h before iolibio.h.

        * include/bits/types/__fpos_t.h, include/bits/types/__fpos64_t.h
	* include/bits/types/cookie_io_functions_t.h
	* include/bits/types/struct_FILE.h: New wrappers.

	* bits/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h:
        Get definitions of _G_fpos_t and _G_fpos64_t from
        bits/types/__fpos_t.h and bits/types/__fpos64_t.h
        respectively.  Remove improper-inclusion guards.

        * conform/data/stdio.h-data: Update expectations of va_list.
	* scripts/check-installed-headers.sh: Remove special case for
        libio.h and _G_config.h.
2018-02-07 10:07:31 -05:00
Joseph Myers 8b4a118222 Fix -Os gnu_dev_* linknamespace, localplt issues (bug 15105, bug 19463).
Building with -Os produces linknamespace and localplt failures for,
among other functions, gnu_dev_major, gnu_dev_minor and
gnu_dev_makedev.

The issue is that those functions are not inlined when building with
-Os.  While one could force them to be inlined in that case, it seems
more natural to fix this issue similarly to other namespace issues.
Thus, this patch makes gnu_dev_* into weak aliases for hidden symbols
__gnu_dev_*; __gnu_dev_* are then defined as inlines in the internal
include/sys/sysmacros.h, and uses of gnu_dev_* (often via the macros
major, minor and makedev) for which there are namespace issues are
changed to use __gnu_dev_*; where there are no namespace issues, use
of libc_hidden_proto serves to avoid unnecessary local PLT entry use.

Tested for x86_64, (a) without -Os, to verify the testsuite continues
to pass without problems and that the functions called under their new
names continue to be inlined as expected in that case; (b) with -Os,
to verify that the linknamespace and localplt failures in question go
away (but because of other such failures present, neither of the
relevant bugs can yet be closed).

	[BZ #15105]
	[BZ #19463]
	* include/sys/sysmacros.h [!_ISOMAC]
	(__SYSMACROS_NEED_IMPLEMENTATION): Define macro.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC]
	(_SYS_SYSMACROS_H_WRAPPER): Likewise.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (gnu_dev_major): Use
	libc_hidden_proto.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (gnu_dev_minor): Likewise.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (gnu_dev_makedev):
	Likewise.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__SYSMACROS_DECL_TEMPL):
	Undefine and redefine to add use __gnu_dev_ prefix.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__SYSMACROS_IMPL_TEMPL):
	Likewise.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__gnu_dev_major): Declare
	and define as hidden inline function.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__gnu_dev_minor):
	Likewise.
	[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__gnu_dev_makedev):
	Likewise.
	* misc/makedev.c (OUT_OF_LINE_IMPL_TEMPL): Use __gnu_dev_ prefix.
	(gnu_dev_major): Use weak_alias and libc_hidden_weak.
	(gnu_dev_minor): Likewise.
	(gnu_dev_makedev): Likewise.
	* csu/check_fds.c (check_one_fd): Use __gnu_dev_makedev instead of
	makedev.
	* posix/wordexp.c (exec_comm_child): Likewise.
	* sysdeps/mach/hurd/xmknodat.c (__xmknodat): Use __gnu_dev_minor
	instead of minor and __gnu_dev_major instead of major.
	* sysdeps/unix/sysv/linux/device-nrs.h (DEV_TTY_P): Use
	__gnu_dev_major instead of major.
	* sysdeps/unix/sysv/linux/pathconf.c (distinguish_extX): Use
	__gnu_dev_major instead of gnu_dev_major and __gnu_dev_minor
	instead of gnu_dev_minor.
	* sysdeps/unix/sysv/linux/ptsname.c (MASTER_P): Likewise.
	(SLAVE_P): Likewise.
	(__ptsname_internal): Use __gnu_dev_minor instead of minor.
	* sysdeps/unix/sysv/linux/ttyname.h (is_pty): Use __gnu_dev_major
	instead of major.
2018-02-07 14:57:31 +00:00
Joseph Myers b1c347e2cd Move fenv.h override inline functions to generic math_private.h.
The tile version of math_private.h defines some inline functions for
fenv.h functions, to optimize away internal calls to these functions
that do nothing given no support for floating-point exceptions and
rounding modes.  (Some functions may have error cases for invalid
arguments, but those aren't applicable to the internal calls from
within glibc.)  Other configurations lacking support for exceptions
and rounding modes lack such inline functions.  This patch moves them
to the generic math_private.h, appropriately conditioned, so that all
such configurations can benefit from the.

include/fenv.h is made to check whether there are any non-default
rounding modes; that needs to be done there, rather than later,
because get-rounding-mode.h defines values for otherwise unsupported
FE_* rounding modes.  It also gives an error for FE_TONEAREST
undefined, a case that already did not work for building the glibc
testsuite; the convention has by now been established that all
architectures need to provide a version of bits/fenv.h that at least
defines FE_TONEAREST.

Tested with build-many-glibcs.py.  As expected, installed stripped
shared libraries are unchanged for tile and for architectures
supporting exceptions and rounding modes, but changed for non-tile
architectures not supporting exceptions and rounding modes that
previously lacked this optimization (e.g. Nios II libm.so is about 1kB
smaller).

The optimization is not in fact complete (does not cover feholdexcept
/ __feholdexcept, so a few calls to those remain unnecessarily within
libm even after this patch), but that can be dealt with separately.

	* include/fenv.h [!_ISOMAC && !FE_TONEAREST]: Give #error.
	[!_ISOMAC] (FE_HAVE_ROUNDING_MODES): New macro.
	* sysdeps/generic/math_private.h
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fegetenv): New
	inline function.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fegetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fesetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fesetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (feupdateenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__feupdateenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES] (fegetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (__fegetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (fesetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (__fesetround): Likewise.
	* sysdeps/tile/math_private.h (fegetenv): Remove inline function.
	(__fegetenv): Likewise.
	(fesetenv): Likewise.
	(__fesetenv): Likewise.
	(feupdateenv): Likewise.
	(__feupdateenv): Likewise.
	(fegetround): Likewise.
	(__fegetround): Likewise.
	(fesetround): Likewise.
	(__fesetround): Likewise.
2018-02-01 20:54:44 +00:00
Dmitry V. Levin 23158b08a0 Update for 2.27 release 2018-02-01 16:17:18 +00:00
Florian Weimer cdd14619a7 libnsl: Turn remaining symbols into compat symbols [BZ #22701] 2018-01-29 17:42:30 +01:00
Samuel Thibault 09085ede12 hurd: Implement faccessat without AT_EACCESS flag
* hurd/hurd/fd.h: Include <fcntl.h>
(__hurd_at_flags): New function.
* hurd/lookup-at.c (__file_name_lookup_at): Replace flag computation
with call to __hurd_at_flags.
* include/unistd.h (__faccessat, __faccessat_noerrno): Add declaration.
* sysdeps/mach/hurd/access.c (access_common): Move implementation to
__faccessat
(hurd_fail_seterrno, hurd_fail_noerrno): Move to sysdeps/mach/hurd/faccessat.c.
(__access_noerrno): Use __faccessat_common instead of access_common.
(__access): Likewise.
* sysdeps/mach/hurd/euidaccess.c (__euidaccess): Replace implementation
with a call to __faccessat.
* sysdeps/mach/hurd/faccessat.c (faccessat): Rename into...
(__faccessat_common): ... this. Move implementation of __access into it when
AT_FLAGS does not contain AT_EACCESS. Make it call __hurd_at_flags, add
reauthenticate_cwdir_at helper to implement AT mechanism.
(__faccessat_noerrno): New function, just calls __faccessat_common.
(__faccessat): New function, just calls __faccessat_common.
(faccessat): Define weak alias.
2018-01-10 02:03:28 +01:00
Florian Weimer 82eef55f8f elf: Support dlvsym within libc.so
This commit adds a new _dl_open_hook entry for dlvsym and implements the
function using the existing dl_lookup_symbol_x function supplied by the
dynamic loader.

A new hook variable, _dl_open_hook2, is introduced, which should make
this change suitable for backporting: For old statically linked
binaries, __libc_dlvsym will always return NULL.
2018-01-04 18:46:24 +01:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Zack Weinberg 48a8f83281 Deprecate external use of libio.h and _G_config.h.
libio.h was originally the header for a set of supported GNU
extensions, but they have not been maintained as such in many years,
they are now standing in the way of improvements to stdio, and we
don't think there are any remaining external users.  _G_config.h was
never intended for public use, but predates the bits convention.
Move both of these headers into the bits directory and provide stubs
at top level which issue deprecation warnings.

The contents of (bits/)libio.h and (bits/)_G_config.h are still
exposed to external software via stdio.h; changing that requires more
complex surgery than I have time to attempt right now.

	* libio/libio.h, libio/_G_config.h: New stub headers which issue a
	deprecation warning and then include <bits/libio.h>, <bits/_G_config.h>
	respectively.
	* libio/libio.h: Rename the original version of this file to
	libio/bits/libio.h.  Error out if not included by stdio.h or the
	stub libio.h.
	* include/libio.h: Move to include/bits.  Forward to libio/bits/libio.h.
	* sysdeps/generic/_G_config.h: Move to top-level bits/.  Error out
	if not included by bits/libio.h or the stub _G_config.h.
	* sysdeps/unix/sysv/linux/_G_config.h: Move to
	sysdeps/unix/sysv/linux/bits.  Error out if not included by
	bits/libio.h or the stub _G_config.h.
	* libio/stdio.h: Include bits/libio.h, not libio.h.
	* libio/Makefile: Install bits/libio.h and bits/_G_config.h as
	well as libio.h and _G_config.h.

	* csu/init.c, libio/fmemopen.c, libio/iolibio.h, libio/oldfmemopen.c
	* libio/strfile.h, stdio-common/vfscanf.c
	* sysdeps/pthread/flockfile.c, sysdeps/pthread/funlockfile.c
	Include stdio.h, not _G_config.h nor libio.h.
	* libio/iofgetpos.c: Also rename fgetpos64 out of the way.
	* libio/iofsetpos.c: Also rename fsetpos64 out of the way.

	* scripts/check-installed-headers.sh: Skip libio.h and _G_config.h.
2017-12-24 09:03:28 -08:00
H.J. Lu 8d81ce0c6d Properly compute offsets of note descriptor and next note [BZ #22370]
A note header has 3 4-bytes fields, followed by note name and note
descriptor.  According to gABI, in a note entry, the note name field,
not note name size, is padded for the note descriptor.  And the note
descriptor field, not note descriptor size, is padded for the next
note entry.  Notes are aligned to 4 bytes in 32-bit objects and 8 bytes
in 64-bit objects.

For all GNU notes, the name is "GNU" which is 4 bytes.  They have the
same format in the first 16 bytes in both 32-bit and 64-bit objects.
They differ by note descriptor size and note type.  So far, .note.ABI-tag
and .note.gnu.build-id notes are always aligned to 4 bytes.  The exsting
codes compute the note size by aligning the note name size and note
descriptor size to 4 bytes.  It happens to produce the same value as
the actual note size by luck since the name size is 4 and offset of the
note descriptor is 16.  But it will produce the wrong size when note
alignment is 8 bytes in 64-bit objects.

This patch defines ELF_NOTE_DESC_OFFSET and ELF_NOTE_NEXT_OFFSET to
properly compute offsets of note descriptor and next note.  It uses
alignment of PT_NOTE segment to support both 4-byte and 8-byte note
alignments in 64-bit objects.  To handle PT_NOTE segments with
incorrect alignment, which may lead to an infinite loop, if segment
alignment is less than 4, we treate alignment as 4 bytes since some
note segments have 0 or 1 byte alignment.

	[BZ #22370]
	* elf/dl-hwcaps.c (ROUND): Removed.
	(_dl_important_hwcaps): Replace ROUND with ELF_NOTE_DESC_OFFSET
	and ELF_NOTE_NEXT_OFFSET.
	* elf/dl-load.c (ROUND): Removed.
	(open_verify): Replace ROUND with ELF_NOTE_NEXT_OFFSET.
	* elf/readelflib.c (ROUND): Removed.
	(process_elf_file): Replace ROUND with ELF_NOTE_NEXT_OFFSET.
	* include/elf.h [!_ISOMAC]: Include <libc-pointer-arith.h>.
	[!_ISOMAC] (ELF_NOTE_DESC_OFFSET): New.
	[!_ISOMAC] (ELF_NOTE_NEXT_OFFSET): Likewise.
2017-11-28 09:57:00 -08:00
Florian Weimer 67f36c7922 nss: Export nscd hash function as __nss_hash [BZ #22459] 2017-11-23 14:08:11 +01:00
Joseph Myers 754034c429 Obsolete p_secstodate.
This patch, relative to a tree with
<https://sourceware.org/ml/libc-alpha/2017-11/msg00797.html> (pending
review) applied, obsoletes p_secstodate, making the underlying
function __p_secstodate into a compat symbol not available for new
binaries or ports.  The calls in ns_print.c (part of incomplete
handling of TKEY) are changed to use %lu to print times instead of
trying to pretty-print the times any more.

Tested for x86_64.

	* resolv/res_debug.c (p_secstodate): Condition definition on
	[SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_27)].  Define
	directly as __p_secstodate, and as a compat symbol.  Do not use
	libresolv_hidden_def.
	* resolv/resolv.h (p_secstodate): Remove macro and function
	declaration.
	* resolv/ns_print.c (ns_sprintrrf): Print times with %lu, not
	using p_secstodate.
	* include/resolv.h (__p_secstodate): Do not use
	libresolv_hidden_proto.
	* resolv/Makefile (tests): Move tst-p_secstodate to ....
	(tests-internal): ... here.
	* resolv/tst-p_secstodate.c: Include <shlib-compat.h>.  Condition
	all contents on [TEST_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_27)]
	and declare and use __p_secstodate and use compat_symbol_reference
	in that case.
	[!TEST_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_27)] (do_test): Add
	implementation returning 77.
2017-11-22 22:21:10 +00:00
Stefan Liebler 80eb52e3a9 Remove attribute_hidden for wchar ifunc symbols.
On s390 (31bit) various debug/tst-*chk* testcases are failing as the tests
are ending with a segmentation fault.

One test is e.g. calling wcsnrtombs in debug/tst-chk1.c:1549.
The function wcsnrtombs itself calls __wcsnlen. This function is called via
PLT! The PLT-stub itself loads the address from GOT (r12 is assumed to be
the GOT-pointer). In this case the loaded address is zero and the following
branch leads to the segmentation fault.

Due to the attribute_hidden in commit 44af8a32c3
"Mark internal wchar functions with attribute_hidden [BZ #18822]"
for e.g. the __wcsnlen function, r12 is not loaded with the GOT-pointer
in wcsnrtombs.

On s390x (64bit), this __wcsnlen call is also using the PLT-stub. But it is
not failing as the GOT-pointer is setup with larl-instruction by the PLT-stub
itself.
Note: On s390x/s390, __wcsnlen is an IFUNC symbol.

On x86_64, __wcsnlen is also an IFUNC symbol and is called via PLT, too.

Further IFUNC symbols on s390 which were marked as hidden by the mentioned
commit are: __wcscat, __wcsncpy, __wcpncpy, __wcschrnul.

This patch removes the attribute_hidden in wchar.h.
Then the compiler setups e.g. r12 on s390 in order to call __wcsnlen via PLT.

ChangeLog:

	* include/wchar.h (__wcsnlen, __wcscat, __wcsncpy, __wcpncpy,
	__wcschrnul): Remove attribute_hidden.
2017-11-21 08:43:23 +01:00
H.J. Lu 4a306ef1c8 ld.so: Add architecture specific fields
To support Intel Control-flow Enforcement Technology (CET) run-time
control:

1. An architecture specific field in the writable ld.so namespace is
needed to indicate if CET features are enabled at run-time.
2. An architecture specific field in struct link_map is needed if
CET features are enabled in an ELF module.

This patch adds dl-procruntime.c to the writable ld.so namespace and
link_map.h to struct link_map.

Tested with build-many-glibcs.py.

	* elf/dl-support.c: Include <dl-procruntime.c>.
	* include/link.h: Include <link_map.h>.
	* sysdeps/generic/dl-procruntime.c: New file.
	* sysdeps/generic/link_map.h: Likewise.
	* sysdeps/generic/ldsodefs.h: Include <dl-procruntime.c> in
	the writable ld.so namespace.
2017-11-13 08:02:52 -08:00
H.J. Lu 8cb5295d3f Add jmp_buf-macros.h
Verify that sizes, alignments and field offsets of jmp_buf as well as
sigjmp_buf are unchanged regardless how struct __jmp_buf_tag is defined.
Since jmp_buf is target specific, jmp_buf-macros.h is added for each
Linux target.  A new target must provides its own jmp_buf-macros.h.

TODO: Hurd needs to provide a jmp_buf-macros.h.

Tested with build-many-glibcs.py.

	* include/setjmp.h [!_ISOMAC]: Include <stddef.h> and
	<jmp_buf-macros.h>.
	[!_ISOMAC] (STR_HELPER): New.
	[!_ISOMAC] (STR): Likewise.
	[!_ISOMAC] (TEST_SIZE): Likewise.
	[!_ISOMAC] (TEST_ALIGN): Likewise.
	[!_ISOMAC] (TEST_OFFSET): Likewise.
	[!_ISOMAC] Add _Static_assert to check sizes, alignments and
	field offsets of jmp_buf as well as sigjmp_buf.
	* sysdeps/unix/sysv/linux/aarch64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/jmp_buf-macros.h: Likewise.
2017-11-09 05:10:03 -08:00
Joseph Myers 3683b423a4 Handle more _FloatN, _FloatNx types in include/float.h.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch adds support in include/float.h.  This header
defines macros for _Float128 properties when using compilers before
GCC 7 that lack those macros in <float.h>.  For testing _Float32 /
_Float64 / _Float32x / _Float64x functions with older compilers, such
macros need to be defined for those types as well; for the older
compilers, those types will always be typedefs for another type, so
the definitions can be in terms of the macros for that other type.

Tested for x86_64.

	* include/float.h
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MANT_DIG): New macro.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_TRUE_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MANT_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_TRUE_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MANT_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_TRUE_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MANT_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_TRUE_MIN): Likewise.
2017-11-07 23:49:04 +00:00
Florian Weimer c94a5688fb <array_length.h>: New array_length and array_end macros 2017-11-02 12:45:20 +01:00
Joseph Myers eda162dd8a Remove _Mlong_double_ etc. macros.
math.h has a macro _Mlong_double_ for the type to use when declaring
long double functions, and similar macros for other types.
math/Makefile uses -D_Mlong_double_=double in the case of long double
having the same ABI as double.

This originates with:

Mon Jul  8 13:37:40 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>

        * math/math.h (_Mfloat_, _Mlong_double_): New macros, defined iff not
        already defined to float, long double.  Use those macros for _Mdouble_
        defns when including mathcalls.h.
        * math/Makefile [$(long-double-fcts) != yes] (CPPFLAGS): Append
        -D_Mlong_double_=double.

However, math.h stopped declaring long double functions in the case of
long double having the same ABI as double (and thus probably stopped
actually needing the Makefile definition of _Mlong_double_) with:

1998-11-05  Ulrich Drepper  <drepper@cygnus.com>

        * math/math.h: Unconditionally include bits/mathdef.h.  Declare
        long double functions only if __NO_LONG_DOUBLE_MATH is not
        defined.
        * sysdeps/generic/bits/mathdef.h: Define only if __USE_ISOC9X.
        Define __NO_LONG_DOUBLE_MATH.
        * sysdeps/m68k/fpu/bits/mathdef.h: Define only if __USE_ISOC9X.
        * sysdeps/i386/fpu/bits/mathdef.h: Likewise.

The declarations were since restored for compiling user code, but
remain absent when _LIBC is defined, which is sufficient to avoid
problems declaring function aliases of incompatible types.  Thus the
indirection through the _Mlong_double_ macro is not needed (probably
since that 1998 patch), and this patch removes _Mlong_double_ and
associated macros for other types, leaving only the macro _Mdouble_
which is actually used as the type for which a given inclusion of
<bits/mathcalls.h> should declared functions.

Tested for x86_64, and tested with build-many-glibcs.py that installed
stripped shared libraries are unchanged by this patch.

	* math/math.h [!_Mfloat_] (_Mfloat_): Do not define.
	[!_Mlong_double_] (_Mlong_double_): Likewise.
	[!_Mfloat16_] (_Mfloat16_): Likewise.
	[!_Mfloat32_] (_Mfloat32_): Likewise.
	[!_Mfloat64_] (_Mfloat64_): Likewise.
	[!_Mfloat128_] (_Mfloat128_): Likewise.
	[!_Mfloat32x_] (_Mfloat32x_): Likewise.
	[!_Mfloat64x_] (_Mfloat64x_): Likewise.
	[!_Mfloat128x_] (_Mfloat128x_): Likewise.
	(_Mdouble_): Define without indirection through those macros.
	* math/complex.h [!_Mfloat_] (_Mfloat_): Do not define.
	[!_Mfloat128_] (_Mfloat128_): Likewise.
	[_Mlong_double_] (_Mlong_double_): Likewise.
	(_Mdouble_): Define without indirection through those macros.
	* math/Makefile [$(long-double-fcts) != yes] (math-CPPFLAGS): Do
	not add -D_Mlong_double_=double.
	* include/math.h [_ISOMAC] (_Mlong_double_): Do not undefine.
	* math/test-signgam-finite-c99.c (_Mlong_double_): Likewise.
2017-10-30 20:58:51 +00:00
H.J. Lu a122dbfb2e Replace "if if " with "if " in comments
* include/alloc_buffer.h: Replace "if if " with "if " in
	comments.
	* sysdeps/mips/memcpy.S: Likkewise.
	* sysdeps/mips/memset.S: Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_sincosf16_core_avx512.S:
	Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_sincosf4_core_sse4.S:
	Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_sincosf8_core_avx2.S:
	Likewise.
2017-10-25 08:05:51 -07:00
Joseph Myers 13c92696d2 Use __f128 to define FLT128_* constants in include/float.h for old GCC.
When using compilers before GCC 7, include/float.h provides fallback
definitions of FLT128_* constants.  These definitions use 'Q' constant
suffixes, which works for configurations with _Float128 ABI-distinct
from long double, but not where it has the same ABI as long double.
This patch changes the definitions to use the __f128 macro from
<bits/floatn.h>, so allowing them to work in the non-distinct
_Float128 case (where they are used in building glibc tests, not for
building glibc itself) as well.

Tested (a) with build-many-glibcs.py with GCC 6 (installed stripped
shared libraries unchanged by the patch); (b) with
build-many-glibcs.py with GCC 6 together with the main patch to enable
float128 aliases; (c) for x86_64 with both GCC 6 and GCC 7.

	* include/float.h [!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 &&
	__GLIBC_USE (IEC_60559_TYPES_EXT)] (FLT128_MAX): Define using
	__f128.
	[!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (FLT128_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (FLT128_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (FLT128_TRUE_MIN): Likewise.
2017-10-17 20:16:01 +00:00
Carlos O'Donell 3480ddc40b shlib-compat: Update documentation of the compat_symbol_reference macro 2017-10-16 20:43:28 +02:00
Jonathan Wakely d6c064e914 Ensure C99 and C11 interfaces are available for C++ [BZ #21326]
This patch ensures that the C99 and C11 features required by C++ are
defined according to the value of the __cplusplus macro, and not just
because G++ always defines _GNU_SOURCE.  This will allow G++ to stop
defining _GNU_SOURCE some day, without causing the C99 and C11
interfaces to disappear for C++ programs.

	[BZ #21326]
	* include/features.h [__cplusplus >= 201103] (__USE_ISOC99): Define.
	[__cplusplus >= 201703] (__USE_ISOCXX17, __USE_ISOC11): Define.
	* math/Makefile (test-math-cxx11): New test.
	* math/test-math-cxx11.cc: New file.
2017-10-09 16:18:11 +02:00
H.J. Lu ee417882e0 Don't use hidden visibility in libc.a with PIE on i386
On i386, when multi-arch is enabled, all external functions must be
called via PIC PLT in PIE, which requires setting up EBX register,
since they may be IFUNC functions.

	* config.h.in (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New.
	* include/libc-symbols.h (__hidden_proto_hiddenattr): Add check
	for PIC and NO_HIDDEN_EXTERN_FUNC_IN_PIE.
	* sysdeps/i386/configure.ac (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New
	AC_DEFINE if multi-arch is enabled.
	* sysdeps/i386/configure: Regenerated.
2017-10-04 17:18:42 -07:00
Samuel Thibault 3d1870fa33 Introduce NO_RTLD_HIDDEN, make hurd use it instead of NO_HIDDEN
On the Hurd, the rtld needs to see its own dumb versions of a few functions
(defined in sysdeps/mach/hurd/dl-sysdep.c) overridden by libc's versions once
loaded. rtld should thus not have hidden attribute for these.  To achieve this,
the Hurd port used to just define NO_HIDDEN, which disables it completely. For
now, this changes that to disabling it for all rtld functions, for simplicity.

See Roland's comment on https://sourceware.org/bugzilla/show_bug.cgi?id=15605#c5

The ld.so numbers remain at

  8 .rel.plt      000000c8  00000c24  00000c24  00000c24  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .plt          000001a0  00000cf0  00000cf0  00000cf0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 10 .plt.got      00000010  00000e90  00000e90  00000e90  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 18 .got.plt      00000070  0002d000  0002d000  0002c000  2**2
                  CONTENTS, ALLOC, LOAD, DATA

which is about 3 times as much as on Linux.

The libc.so numbers get divided by 3 (the remainings are mostly RPC stub calls)

	* include/libc-symbols.h [NO_RTLD_HIDDEN] (rtld_hidden_proto,
	rtld_hidden_tls_proto, rtld_hidden_def, rtld_hidden_weak,
	rtld_hidden_rtld_hidden_ver, data_def, rtld_hidden_data_weak,
	rtld_hidden_data_ver): Define to empty.
	* include/assert.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__assert_fail,
	__assert_perror_fail): Likewise.
	* include/dirent.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(__rewinddir): Likewise.
	* include/libc-internal.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(__profile_frequency): Likewise.
	* include/setjmp.h (__sigsetjmp): Likewise.
	* include/signal.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__sigaction,
	__libc_sigaction): Likewise.
	* include/stdlib.h [NO_RTLD_HIDDEN] (unsetenv, __strtoul_internal): Do
	not set hidden attribute.
	* include/string.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__stpcpy, __strdup,
	__strerror_t, __strsep_g, memchr, memcmp, memcpy, memmove, memset,
	rawmemchr, stpcpy, strchr, strcmp, strlen, strnlen, strsep): Likewise.
	* include/sys/stat.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__fxstat,
	__fxstat64, __lxstat, __lxstat64, __xstat, __xstat64,
	__fxstatat64): Likewise.
	* include/sys/utsname.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(__uname): Likewise.
	* include/sysdeps/generic/_itoa.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(_itoa_upper_digits, _itoa_lower_digits): Likewise.
	* sysdeps/mach/hurd/configure.ac (NO_HIDDEN): Do not set.
	(NO_RTLD_HIDDEN): Set.
	* sysdeps/mach/hurd/configure: Refresh.
	* config.h.in: Refresh.
2017-10-03 01:33:38 +02:00
H.J. Lu c0769f7031 Hide internal __glob64 function [BZ #18822]
Hide internal __glob64 function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/glob.h (__glob64): Add libc_hidden_proto.
	* sysdeps/unix/sysv/linux/glob64.c (__glob64): Add
	libc_hidden_def.
2017-10-01 18:02:10 -07:00