H.J. Lu [Wed, 14 Oct 2015 22:21:55 +0000 (15:21 -0700)]
Mark internal unistd functions hidden in ld.so
Since internal unistd functions are only used internally in ld.so and
libc.so, they can be made hidden. Some functions can't be hidden in
ld.so on Hurd since they will be preempted by the ones in libc.so after
bootstrap.
[BZ #19122]
* include/unistd.h [IS_IN (rtld)]: Include <dl-unistd.h>.
* sysdeps/generic/dl-unistd.h: New file.
* sysdeps/mach/hurd/dl-unistd.h: Likewise.
H.J. Lu [Wed, 14 Oct 2015 22:14:15 +0000 (15:14 -0700)]
Mark ld.so internal mmap functions hidden in ld.so
Since ld.so internal mmap functions are only used internally in ld.so,
they can be made hidden. Don't hide __mmap on Hurd, since __mmap in
ld.so will be preempted by the one in libc.so after bootstrap.
[BZ #19122]
* include/sys/mman.h [IS_IN (rtld)]: Include <dl-mman.h>.
* sysdeps/generic/dl-mman.h: New file.
* sysdeps/mach/hurd/dl-mman.h: Likewise.
Joseph Myers [Tue, 20 Oct 2015 11:54:09 +0000 (11:54 +0000)]
Convert 113 more function definitions to prototype style (files with assertions).
This mostly automatically-generated patch converts 113 function
definitions in glibc from old-style K&R to prototype-style. Following
my other recent such patches, this one deals with the case of function
definitions in files that either contain assertions or where grep
suggested they might contain assertions - and thus where it isn't
possible to use a simple object code comparison as a sanity check on
the correctness of the patch, because line numbers are changed.
A few such automatically-generated changes needed to be supplemented
by manual changes for the result to compile. openat64 had a prototype
declaration with "..." but an old-style definition in
sysdeps/unix/sysv/linux/dl-openat64.c, and "..." needed adding to the
generated prototype in the definition (I've filed
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68024> for diagnosing
such cases in GCC; the old state was undefined behavior not requiring
a diagnostic, but one seems a good idea). In addition, as Florian has
noted regparm attribute mismatches between declaration and definition
are only diagnosed for prototype definitions, and five functions
needed internal_function added to their definitions (in the case of
__pthread_mutex_cond_lock, via the macro definition of
__pthread_mutex_lock) to compile on i386.
After this patch is in, remaining old-style definitions are probably
most readily fixed manually before we can turn on
-Wold-style-definition for all builds.
Joseph Myers [Tue, 20 Oct 2015 11:52:27 +0000 (11:52 +0000)]
Convert 29 more function definitions to prototype style (multiple parameters in one K&R parameter declaration).
This automatically-generated patch converts 29 function definitions in
glibc (including one in an example in the manual) from old-style K&R
to prototype-style. Following my other recent such patches, this one
deals with the case of function definitions where one K&R parameter
declaration declares multiple parameters, as in:
void
foo (a, b)
int a, *b;
{
}
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
Joseph Myers [Tue, 20 Oct 2015 11:51:03 +0000 (11:51 +0000)]
Convert 24 more function definitions to prototype style (array parameters).
This automatically-generated patch converts 24 function definitions in
glibc from old-style K&R to prototype-style. Following my other
recent such patches, this one deals with the case of functions with
array parameters.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
Joseph Myers [Mon, 19 Oct 2015 22:34:20 +0000 (22:34 +0000)]
Remove gnu_unique_object configure test.
There is a configure test for assembler support for the
gnu_unique_object symbol type. This support was added in binutils
2.20, so is present in all versions supported for building glibc.
Thus, I think the configure test can be removed; this patch does so.
Now, there is a caveat that the gas NEWS entry refers to this as a
feature for GNU/Linux targets. But the condition is use of
ELFOSABI_GNU or ELFOSABI_NONE. ELFOSABI_GNU covers Hurd as well as
GNU/Linux (as was the case with the older ELFOSABI_LINUX name), and
ELFOSABI_NONE means this is effectively OS-independent. Furthermore,
I think a correct binutils port for any glibc target ought to support
this feature for use with glibc; glibc supports this as an
OS-independent feature (the configure test is only about glibc
testcases).
Tested for x86_64 (testsuite, and that installed shared libraries are
unchanged by the patch).
Joseph Myers [Mon, 19 Oct 2015 21:24:50 +0000 (21:24 +0000)]
Do not use -Wno-strict-prototypes.
Two glibc makefiles use -Wno-strict-prototypes. I don't know if this
was needed before my recent conversion of many function definitions to
prototype style, but it's not needed now; this patch removes it.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
* posix/Makefile (CFLAGS-regex.c): Remove variable.
* resolv/Makefile (+cflags): Do not use -Wno-strict-prototypes.
Joseph Myers [Mon, 19 Oct 2015 21:23:47 +0000 (21:23 +0000)]
Convert 69 more function definitions to prototype style (line wrap cases).
This automatically-generated patch converts 69 function definitions in
glibc from old-style K&R to prototype-style.
This patch, covering both sysdeps and non-sysdeps files, deals with
cases where the prototype needed to be wrapped over more than one
line. Otherwise, exclusions and caveats are as for
<https://sourceware.org/ml/libc-alpha/2015-10/msg00594.html> and
<https://sourceware.org/ml/libc-alpha/2015-10/msg00599.html>.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
Mike Frysinger [Mon, 19 Oct 2015 17:07:28 +0000 (13:07 -0400)]
use -fstack-protector-strong when available
With gcc-4.9, a new -fstack-protector-strong flag is available that is
between -fstack-protector (pretty weak) and -fstack-protector-all (pretty
strong) that provides good trade-offs between overhead but still providing
good coverage. Update the places in glibc that use ssp to use this flag
when it's available.
This also kills off the indirection of hardcoding the flag name in the
Makefiles and adding it based on a have-ssp boolean. Instead, the build
always expands the $(stack-protector) variable to the best ssp setting.
This makes the build logic a bit simpler and allows people to easily set
to a diff flag like:
make stack-protector=-fstack-protector-all
The previous code used to evaluate the preprocessor token is_lock_free to
a variable before starting a transaction. This behavior can cause an
error if another thread got the lock (without using a transaction)
between the evaluation of the token and the beginning of the transaction.
This bug can be triggered with the following order of events:
1. The lock accessed by is_lock_free is free.
2. Thread T1 evaluates is_lock_free and stores into register R1 that the
lock is free.
3. Thread T2 acquires the same lock used in is_lock_free.
4. T1 begins the transaction, creating a memory barrier where is_lock_free
is false, but R1 is true.
5. T1 reads R1 and doesn't abort the transaction.
6. T1 calls ELIDE_UNLOCK, which reads false from is_lock_free and decides
to unlock a lock acquired by T2, leading to undefined behavior.
This patch delays the evaluation of is_lock_free to inside a transaction
by moving this part of the code to the macro ELIDE_LOCK.
[BZ #18743]
* sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
code to...
(ELIDE_LOCK): ...here.
(__get_new_count): New function with part of the code from
__elide_lock that updates the value of adapt_count after a
transaction abort.
(__elided_trylock): Moved this code to...
(ELIDE_TRYLOCK): ...here.
Geoffrey Thomas [Mon, 19 Oct 2015 14:03:28 +0000 (19:33 +0530)]
pt_chown: Clear any signal mask inherited from the parent process.
If grantpt() is called from a thread that is masking signals (for
instance, from a program using signalfd or using a dedicated
signal-handling thread), then that mask will get inherited to pt_chown.
This means that signals like SIGINT will not interrup pt_chown, so if it
hangs (e.g., because getgrnam("tty") hangs on a remote name service),
Ctrl-C will terminate the parent process but leave pt_chown around. Since
it's setuid, it's hard to kill any other way.
It is safe for pt_chown to unmask all signals, because grantpt() can be
(and usually is) called from an unprivileged process with all signals
unmasked.
Joseph Myers [Mon, 19 Oct 2015 12:06:00 +0000 (12:06 +0000)]
Remove .weak, .weakext configure tests.
There are configure tests for assembler .weak support, and, as a
fallback, for .weakext support.
.weakext appears to be an ECOFF thing (although a few ELF targets
support it as well). .weak has been supported by the GNU assembler
for ELF targets since version 2.2, so given the requirement for ELF
the configure tests are obsolete; this patch removes them.
Tested for x86_64 (testsuite, and that installed shared libraries are
unchanged by the patch).
Joseph Myers [Mon, 19 Oct 2015 12:04:33 +0000 (12:04 +0000)]
Convert 231 sysdeps function definitions to prototype style.
This mostly automatically-generated patch converts 231 sysdeps
function definitions in glibc from old-style K&R to prototype-style.
For __aio_sigqueue and __gai_sigqueue I had to add internal_function
to the definitions as noted by Florian in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00595.html> to keep
the functions compiling on x86 after conversion to prototype
definitions. Otherwise, the patch is automatically generated with all
the same exclusions and caveats as in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00594.html> except
that it's a patch for sysdeps files.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch). Also tested for arm,
mips64 and powerpc32 that installed stripped shared libraries are
unchanged by the patch.
Egmont Koblinger [Tue, 13 Oct 2015 18:48:55 +0000 (20:48 +0200)]
hu_HU: change time separator to colon [BZ #18918]
The previous (11th) version of the Hungarian spelling rules (released
in 1984) said that the separator had to be a dot, e.g. 10.35 meaning
10 o'clock 35 minutes. glibc correctly implements this.
The brand new (12th) version, in effect since September 1, 2015 adopts
to the common use of colon (especially in the digital world) and
allows to use either separator, without even expressing a preference.
For computer systems, using colons is way more typical and probably
easier to recognize. Dot is typically used in printed materials.
It also avoids an almost ambiguous situation where a space makes a
difference, e.g. "10.15-ig" means "until 10 o'clock 15 minutes"
whereas "10. 15-ig" means "until 15th of October". So I believe using
the colon as the separator is not only more frequent in the computer
world, but is also easier and quicker to recognize for the brain that
it's about hour:minute rather than month and day. And luckily it's now
equally correct according to the official rules.
In both editions it's the very last (299th and 300th, respectively) rule.
Microsoft also uses and recommends a colon since at least May 2011:
http://download.microsoft.com/download/e/6/1/e61266b2-d8b4-4fe0-a553-f01dc3976675/hun-hun-StyleGuide.pdf
The time format is different in common language and in the language of
IT. In common texts we usually do not abbreviate, so the full forms are
used: “7 óra 10 perckor csörgött a telefon”. However, the short format,
consisting of numerals only, can also be used. In this case a period
must be used between the two numbers and there must not be a space
between them: “találkozzunk 10.45-kor”.
However, in software mostly the short format is used, and the numbers
are separated by a colon. An obvious example is the clock in the bottom
right corner of your screen, thus 18:31.
Joseph Myers [Fri, 16 Oct 2015 21:28:03 +0000 (21:28 +0000)]
Add more tests for ceil, floor, round, trunc.
This patch adds more tests for ceil, floor, round and trunc, with a
particular focus on verifying they don't raise spurious "inexact"
exceptions for integer arguments (a C99 / C11 requirement, as opposed
to the general principle that they shouldn't raise "inexact" for any
arguments at all which is a TS 18661-1 requirement).
Tested for x86_64 and x86.
* math/libm-test.inc (ceil_test_data): Add more tests and more
expectations for "inexact".
(floor_test_data): Add more tests.
(round_test_data): Likewise.
(trunc_test_data): Likewise.
Joseph Myers [Fri, 16 Oct 2015 20:21:49 +0000 (20:21 +0000)]
Convert 703 function definitions to prototype style.
This automatically-generated patch converts 703 function definitions
in glibc from old-style K&R to prototype-style.
This conversion is deliberately simplistic, excluding any tricky cases
as even a patch covering only simple cases is still very large.
Currently excluded are: sysdeps files (to improve test coverage for
the initial patch); files containing assertions (to avoid line number
changes so that generated libraries can be compared); any cases where
the generated function declaration would involve lines over 79
characters and so need to be wrapped; any cases with array parameters
or other cases where parameter declarators don't end with the
parameter name; any other cases that my script didn't parse.
I didn't try to make the ChangeLog generation indicate when function
definitions are conditional; it just lists the functions changed
without regard to that.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
Joseph Myers [Thu, 15 Oct 2015 23:59:54 +0000 (23:59 +0000)]
Remove NPTL configure errors based on top-level configure tests.
sysdeps/nptl/configure.ac has code to give errors if certain tests in
the top-level configure failed. However, all those failure conditions
also produce errors in the top-level configure, so the errors in the
NPTL configure are completely redundant; this patch removes them.
(As suggested in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00510.html>, I think
the top-level tests in question can be completely removed as
unnecessary given the version tests. But even without that there is
clearly no point in duplicating code that gives an error if the test
fails.)
Tested for x86_64 (testsuite, and that installed shared libraries are
unchanged by the patch).
* sysdeps/nptl/configure.ac: Do not give errors based on the
results of top-level configure tests.
* sysdeps/nptl/configure: Regenerated.
Joseph Myers [Thu, 15 Oct 2015 22:35:13 +0000 (22:35 +0000)]
Remove -fexceptions configure test.
There is a configure test for -fexceptions. This option was added in
GCC 2.8, so the test is obsolete - and indeed plenty of code is using
-fexceptions directly. This patch removes the configure test and
makes all uses of $(exceptions) use -fexceptions directly.
Tested for x86_64 and x86 (testsuite, and that installed shared
libraries are unchanged by the patch).
Joseph Myers [Thu, 15 Oct 2015 22:29:06 +0000 (22:29 +0000)]
Do not leave files behind in /tmp from testing.
I noticed that glibc testsuite runs left several files behind in /tmp
(or TMPDIR, if different). The problem was testcases that generate a
template for mkstemp / mkstemp64, ending with XXXXXX, then pass that
template to add_temp_file before calling mkstemp / mkstemp64, meaning
that the template ending with XXXXXX is stored in the list of
temporary files to delete (add_temp_file uses strdup so that the
original string doesn't need to stay live), not the actual filename as
determined by mkstemp / mkstemp64. This patch fixes those tests to
call add_temp_file later.
Tested for x86_64 (that the files are no longer left behind by a
testsuite run and the modified tests still pass).
* io/test-lfs.c (do_prepare): Do not call add_temp_file until
after mkstemp64.
* login/tst-utmp.c (do_prepare): Likewise.
* rt/tst-aio.c (do_prepare): Likewise.
* rt/tst-aio64.c (do_prepare): Likewise.
Paul Murphy [Thu, 3 Sep 2015 18:40:11 +0000 (13:40 -0500)]
nptl: Add adapt_count parameter to lll_unlock_elision
Adding this parameter will give architectures more freedom in
how they choose to update this variable. This change has no
effect on architectures which choose not to use it.
* nptl/pthread_mutex_unlock.c(lll_unlock_elision):
Add elision adapt_count parameter to list of arguments.
* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
(lll_unlock_elision): Update with new parameter list
* sysdeps/unix/sysv/linux/s390/lowlevellock.h
(lll_unlock_elision): Likewise
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
(lll_unlock_elision): Likewise
H.J. Lu [Thu, 15 Oct 2015 21:13:37 +0000 (14:13 -0700)]
Mark _dl_catch_error hidden
Since _dl_catch_error is only used internally in ld.so, it should be
declared in sysdeps/generic/ldsodefs.h, not include/dlfcn.h and it can
be made hidden.
[BZ #19122]
* include/dlfcn.h (_dl_catch_error): Moved to ...
* sysdeps/generic/ldsodefs.h (_dl_catch_error): Add
attribute_hidden.
Joseph Myers [Thu, 15 Oct 2015 20:28:27 +0000 (20:28 +0000)]
Remove assembler -mtune=i686 configure test.
There is a configure test for assembler support for -mtune=i686. This
option was added in binutils 2.18 so the test is obsolete; this patch
removes it.
Tested for x86 (testsuite, and that installed shared libraries are
unchanged by the patch).
Joseph Myers [Thu, 15 Oct 2015 19:47:55 +0000 (19:47 +0000)]
Remove .previous, .popsection configure tests.
There is a configure test for the assembler .previous directive, and,
as a fallback, for .popsection.
glibc now only supports ELF. For ELF, the GNU assembler has supported
.previous since version 2.2 (support added by
Mon Jul 19 15:21:20 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
* config/obj-elf.c (obj_elf_previous): New function.
(previous_section, previous_subsection): New vars.
(obj_elf_section): Save current place in case DWARF code wants us
to pop back to it. Handle unquoted section name as well as quoted
section name. Don't crash on invalid strings.
(obj_pseudo_table): Handle new pseudos "previous", "2byte", and
"4byte".
). Thus this configure test is obsolete, and this patch removes it
(and with it the fallback .popsection test).
Tested for x86_64 and x86 (testsuite, and that installed shared
libraries are unchanged by the patch).
Joseph Myers [Thu, 15 Oct 2015 19:31:46 +0000 (19:31 +0000)]
Remove stddef.h configure test.
There is a configure test "for libc-friendly stddef.h", which sets a
makefile variable stddef.h that appears to be nowhere used. It
appears the uses of this variable were removed by:
Tue Feb 21 00:10:50 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* Makefile (headers): Remove $(stddef.h).
* Makeconfig (stddef.h): Variable removed; now require gcc version
>= 2.2.
* stddef.h: File removed.
(having been added by
Wed May 26 14:44:19 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
* configure.in (autoconf checks): Add new check for a
libc-friendly stddef.h.
so the test was of use for less than two years, before being obsolete
for over 20 years). This patch removes the test.
Tested for x86_64 and x86 (testsuite, and that installed shared
libraries are unchanged by the patch).
Florian Weimer [Thu, 15 Oct 2015 14:37:48 +0000 (16:37 +0200)]
vfscanf: Use struct scratch_buffer instead of extend_alloca
A custom character buffer is added in this commit, in the form of
struct char_buffer. The char_buffer_add function replaces the
ADDW macro (which has grown with each successive security fix).
The char_buffer_add slow path is moved out-of-line, reducing
code size.
* stdio-common/vfscanf.c (MEMCPY): Remove macro.
(struct char_buffer): New type.
(char_buffer_start, char_buffer_size, char_buffer_error)
(char_buffer_rewind, char_buffer_add): New functions.
(ADDW): Remove macro, replaced by the char_buffer_add function.
(_IO_vfscanf_internal): Rewrite using struct char_buffer instead
of extend_alloca. Make control flow more explicit.
H.J. Lu [Thu, 15 Oct 2015 13:26:38 +0000 (06:26 -0700)]
Remove i386/epoll_pwait.S
Only i386 implements epoll_pwait in assembly code withot cancellation
support. All other architectures implement epoll_pwait in epoll_pwait.c
with
int epoll_pwait (int epfd, struct epoll_event *events,
int maxevents, int timeout,
const sigset_t *set)
{
return SYSCALL_CANCEL (epoll_pwait, epfd, events, maxevents,
timeout, set, _NSIG / 8);
}
Although there is no test for epoll_pwait in glibc, since SYSCALL_CANCEL
works on i386 and epoll_pwait.c works for other architectures, it is
safe to assume that epoll_pwait.c with SYSCALL_CANCEL also works on
i386.
H.J. Lu [Thu, 15 Oct 2015 12:23:42 +0000 (05:23 -0700)]
Optimize i386 syscall inlining for GCC 5
Since GCC 5 and above can properly spill %ebx when needed, we can inline
syscalls with 6 arguments if GCC 5 or above is used to compile glibc.
This patch rewrites INTERNAL_SYSCALL macros and skips __libc_do_syscall
for GCC 5.
For sysdeps/unix/sysv/linux/i386/brk.c, with -O2 -march=i686
-mtune=generic, GCC 5.2 now generates:
H.J. Lu [Thu, 15 Oct 2015 11:33:15 +0000 (04:33 -0700)]
i386: Remove syscall assembly codes with 6 arguments
This patch removes i386 assembly implementation for mmap, mmap64,
semtimeop now that i386 have 6 argument syscall support from C code
and GCC 5 can inline syscalls with 6 arguments. We also compile mmap.c,
mmap64.c and semtimedop.c with -fomit-frame-pointer since %ebp may be
used to pass the 6th argument to syscall.
Fo sysdeps/unix/sysv/linux/i386/mmap.c, with -O2 -march=i686
-mtune=generic, GCC 5.2 now generates:
Florian Weimer [Thu, 15 Oct 2015 07:23:07 +0000 (09:23 +0200)]
Always enable pointer guard [BZ #18928]
Honoring the LD_POINTER_GUARD environment variable in AT_SECURE mode
has security implications. This commit enables pointer guard
unconditionally, and the environment variable is now ignored.
[BZ #18928]
* sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
_dl_pointer_guard member.
* elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
initializer.
(security_init): Always set up pointer guard.
(process_envvars): Do not process LD_POINTER_GUARD.
The powerpc32 implementation of lround and lroundf can produce
spurious exceptions from adding 0.5 then converting to integer. This
includes "inexact" from the conversion to integer (not allowed for
integer arguments to these functions), and, for larger integer
arguments, "inexact", and "overflow" when rounding upward, from the
addition. In addition, "inexact" is not allowed together with
"invalid" and so inexact addition must be avoided when the integer
will be out of range of 32-bit long, whether or not the argument is an
integer.
This patch fixes these problems. As in the powerpc64 llround
implementation, a check is added for too-large arguments; in the
powerpc64 case that means arguments at least 2^52 in magnitude (so
that 0.5 cannot be added exactly), while in this case it means
arguments for which the result would overflow "long". In those cases
a suitable overflowing value is used for the integer conversion
without adding 0.5, while for smaller arguments it's tested whether
the argument is an integer (by adding and subtracting 2^52 to the
absolute value and comparing with the original absolute value) to
avoid adding 0.5 to integers and generating spurious "inexact".
This code is not used when the power5+ sysdeps directories are used,
as there's a separate power5+ version of these functions..
Tested for powerpc. This gets test-float (for a default powerpc32
hard-float build without any --with-cpu) back to the point where it
should pass once powerpc ulps are regenerated; test-double still needs
another problem with exceptions fixed to get back to that point (and I
haven't looked lately at what default powerpc64 results are like).
[BZ #19134]
* sysdeps/powerpc/powerpc32/fpu/s_lround.S (.LC1): New object.
(.LC2): Likewise.
(.LC3): Likewise.
(__lround): Do not add 0.5 to integer or out-of-range arguments.
Szabolcs Nagy [Wed, 14 Oct 2015 15:58:41 +0000 (16:58 +0100)]
[BZ #19129][ARM] Fix _dl_tlsdesc_resolve_hold to save r0
_dl_tlsdesc_resolve_hold calls into a C function that clobbers r0,
but it assumes the original argument is still in r0 after the call.
This can cause crash in case of concurrent TLS access when TLSDESC
is in use (-mtls-dialect=gnu2).
Run into this while fixing BZ 18572.
Both r0 and r1 are saved/restored so the stack remains 8 byte aligned.
[BZ #19129]
* sysdeps/arm/dl-tlsdesc.S (_dl_tlsdesc_resolve_hold): Save and restore
r0 and r1.
H.J. Lu [Wed, 14 Oct 2015 12:59:50 +0000 (05:59 -0700)]
Support PLT and GOT references in local PIC check
Linker in binutils 2.26 and newer generate GOT references instead
PLT references when -z now is passed to linker. We need to extend
scripts/localplt.awk to allow PLT or GOT references.
[BZ #19007]
* scripts/localplt.awk: Also allow GOT references.
* sysdeps/unix/sysv/linux/i386/localplt.data: Mark
_Unwind_Find_FDE, calloc, memalign, realloc and __libc_memalign
with "+ REL R_386_GLOB_DAT".
* sysdeps/x86_64/localplt.data: Mark calloc, memalign, realloc
and __libc_memalign with "+ RELA R_X86_64_GLOB_DAT".
H.J. Lu [Wed, 14 Oct 2015 10:45:32 +0000 (03:45 -0700)]
Use INTERNAL_SYSCALL and INLINE_SYSCALL_ERROR_RETURN_VALUE
This patch uses INTERNAL_SYSCALL and INLINE_SYSCALL_ERROR_RETURN_VALUE
to avoid reading and writing errno directly so that we don't need to
call __x86.get_pc_thunk.reg to load PC into reg in case there is an
error.
The powerpc32 implementations of llroundf and llround produce spurious
and missing exceptions (some arising from such exceptions from
conversions to long long, some present even when fctidz is used).
This patch fixes those problems in a similar way to the llrint /
llrintf fixes. The spurious exceptions in the fctidz case for large
arguments arise from a converted value that saturated as LLONG_MAX
being converted back to float or double (the conversion back being
inexact, but "inexact" must not be raised together with "invalid"),
and from the subtraction x - xrf also being inexact for sufficiently
large arguments (whether the saturation was to LLONG_MAX or
LLONG_MIN); those are fixed by returning early if the argument is
large enough that no rounding is needed.
This code is not used for --with-cpu=power4 builds (I suspect the code
used in that case may also produce spurious "inexact" exceptions, but
that's something to investigate later).
Tested for powerpc.
[BZ #19125]
* sysdeps/powerpc/powerpc32/fpu/s_llround.c: Include <limits.h>,
<math_private.h> and <stdint.h>.
(__llround): Avoid conversions to and from long long int, and
subtractions, where those might raise spurious exceptions.
* sysdeps/powerpc/powerpc32/fpu/s_llroundf.c: Include
<math_private.h> and <stdint.h>.
(__llroundf): Avoid conversions to and from long long int, and
subtractions, where those might raise spurious exceptions.
H.J. Lu [Tue, 13 Oct 2015 18:58:53 +0000 (11:58 -0700)]
Add INLINE_SYSCALL_ERROR_RETURN_VALUE
For ia32 PIC, the first thing of many syscalls does is to call
__x86.get_pc_thunk.reg to load PC into reg in case there is an error,
which is required for setting errno. In most cases, there are no
errors. But we still call __x86.get_pc_thunk.reg. This patch adds
INLINE_SYSCALL_ERROR_RETURN_VALUE so that i386 can optimize setting
errno by branching to the internal __syscall_error without PLT.
With i386 INLINE_SYSCALL_ERROR_RETURN_VALUE and i386 syscall inlining
optimization for GCC 5, for sysdeps/unix/sysv/linux/fchmodat.c with
-O2 -march=i686 -mtune=generic, GCC 5.2 now generates:
<fchmodat>:
0: push %ebx
1: mov 0x14(%esp),%eax
5: mov 0x8(%esp),%ebx
9: mov 0xc(%esp),%ecx
d: mov 0x10(%esp),%edx
11: test $0xfffffeff,%eax
16: jne 38 <fchmodat+0x38>
18: test $0x1,%ah
1b: jne 48 <fchmodat+0x48>
1d: mov $0x132,%eax
22: call *%gs:0x10
29: cmp $0xfffff000,%eax
2e: ja 58 <fchmodat+0x58>
30: pop %ebx
31: ret
32: lea 0x0(%esi),%esi
38: pop %ebx
39: mov $0xffffffea,%eax
3e: jmp 3f <fchmodat+0x3f> 3f: R_386_PC32 __syscall_error
43: nop
44: lea 0x0(%esi,%eiz,1),%esi
48: pop %ebx
49: mov $0xffffffa1,%eax
4e: jmp 4f <fchmodat+0x4f> 4f: R_386_PC32 __syscall_error
53: nop
54: lea 0x0(%esi,%eiz,1),%esi
58: pop %ebx
59: jmp 5a <fchmodat+0x5a> 5a: R_386_PC32 __syscall_error
H.J. Lu [Tue, 13 Oct 2015 17:29:45 +0000 (10:29 -0700)]
Support x86-64 assmebler without AVX512
When x86-64 assmebler doesn't support AVX512, we should make
_dl_runtime_resolve_avx512/_dl_runtime_profile_avx512 as aliases of
_dl_runtime_resolve_avx/_dl_runtime_profile_avx. Tested on x86-64
using GCC 5.2 with binutils 20151008 and GCC 4.8 with binutils 20130219.
There are no differences in ld.so with binutils 20151008. There are no
unexpected failures with binutils 20130219 and 20151008.
[BZ #19124]
* sysdeps/x86_64/dl-trampoline.S [!HAVE_AVX512_ASM_SUPPORT]
(_dl_runtime_resolve_avx512): Make it a hidden alias of
_dl_runtime_resolve_avx.
(_dl_runtime_profile_avx512): Make it a hidden alias of
_dl_runtime_profile_avx.
Joseph Myers [Tue, 13 Oct 2015 16:53:09 +0000 (16:53 +0000)]
Move powerpc llround implementations to powerpc32 directory.
sysdeps/powerpc/fpu/ has versions of llround and llroundf that are
actually used only for powerpc32 because
sysdeps/powerpc/powerpc64/fpu/ has its own versions of those
functions. This patch moves them into sysdeps/powerpc/powerpc32/fpu
to reflect where they are actually used (in preparation for fixing
other problems with those functions).
Tested for powerpc that installed stripped shared libraries are
unchanged by this patch.
* sysdeps/powerpc/fpu/s_llround.c: Move to ....
* sysdeps/powerpc/powerpc32/fpu/s_llround.c: ...here.
* sysdeps/powerpc/fpu/s_llroundf.c: Move to ....
* sysdeps/powerpc/powerpc32/fpu/s_llroundf.c: ...here.
Joseph Myers [Tue, 13 Oct 2015 00:52:54 +0000 (00:52 +0000)]
Fix powerpc32 llrint, llrintf bad exceptions (bug 16422).
The versions of llrint and llrintf for older powerpc32 processors
convert the results of __rint / __rintf to long long int, resulting in
spurious exceptions from such casts in certain cases. This patch
makes glibc work around the problems with the libgcc conversions when
the compiler used to build glibc doesn't use the fctidz instruction
for them.
Tested for powerpc.
[BZ #16422]
* sysdeps/powerpc/powerpc32/fpu/configure.ac (libc_cv_ppc_fctidz):
New configure test.
* sysdeps/powerpc/powerpc32/fpu/configure: Regenerated.
* config.h.in [_LIBC] (HAVE_PPC_FCTIDZ): New macro.
* sysdeps/powerpc/powerpc32/fpu/s_llrint.c: Include <limits.h>,
<math_private.h> and <stdint.h>.
(__llrint): Avoid conversions to long long int where those might
raise spurious exceptions.
* sysdeps/powerpc/powerpc32/fpu/s_llrintf.c: Include
<math_private.h> and <stdint.h>.
(__llrintf): Avoid conversions to long long int where those might
raise spurious exceptions.
Samuel Thibault [Sat, 10 Oct 2015 14:21:41 +0000 (16:21 +0200)]
Make _hurd_raise_signal return errors
* hurd/hurd-raise.c (_hurd_raise_signal): Set errno to error returned
by __msg_sig_post.
* hurd/hurd/signal.h (_hurd_raise_signal): Add int return type.
Phil Blundell [Fri, 9 Oct 2015 22:39:36 +0000 (23:39 +0100)]
ChangeLog: Fix incorrect email address
For reasons that are slightly unclear, the ChangeLog entry added in 67ac0f74a4a5021f77566fdbe4cda5880eba8ba4 contained a mangled version
of my email address. Replace that with the correct one.
Joseph Myers [Fri, 9 Oct 2015 22:23:39 +0000 (22:23 +0000)]
Fix llrint, llround missing exceptions for ARM (bug 15470).
Similar to the recent fix for MIPS, ARM is also missing correct
exceptions on overflow from llrint and llround functions because casts
from floating-point types to long long do not result in correct
exceptions on overflow. This patch enables the fix for this for ARM.
Tested for ARM.
[BZ #15470]
* sysdeps/arm/fix-fp-int-convert-overflow.h: New file.
For 32-bit MIPS and some other systems, various of the lrint, llrint,
lround, llround functions can be missing exceptions on overflow
because casts do not (in current GCC) result in the proper
exceptions. In the MIPS case there are two problems here: MIPS I code
generation uses an assembler macro that doesn't raise exceptions,
while the libgcc conversions of floating-point values to long long
also do not raise "invalid" on all overflow cases (and can raise
spurious "inexact").
This patch adds support in the generic code (only the functions for
which this problem has actually been seen) for forcing the "invalid"
exception in the problem cases, and enables that support for the
affected MIPS cases.
Tested for MIPS; also tested for x86_64 and x86 that installed
stripped shared libraries are unchanged by this patch.
[BZ #16399]
* sysdeps/generic/fix-fp-int-convert-overflow.h: New file.
* sysdeps/ieee754/dbl-64/s_llrint.c: Include <fenv.h>, <limits.h>
and <fix-fp-int-convert-overflow.h>.
(__llrint) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/ieee754/dbl-64/s_llround.c: Include <fenv.h>, <limits.h>
and <fix-fp-int-convert-overflow.h>.
(__llround) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/ieee754/dbl-64/s_lrint.c: Include
<fix-fp-int-convert-overflow.h>.
(__lrint) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/ieee754/dbl-64/s_lround.c: Include
<fix-fp-int-convert-overflow.h>.
(__lround) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/ieee754/flt-32/s_llrintf.c: Include <fenv.h>, <limits.h>
and <fix-fp-int-convert-overflow.h>.
(__llrintf) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/ieee754/flt-32/s_llroundf.c: Include <fenv.h>,
<limits.h> and <fix-fp-int-convert-overflow.h>.
(__llroundf) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/ieee754/flt-32/s_lrintf.c: Include <fenv.h>, <limits.h>
and <fix-fp-int-convert-overflow.h>.
(__lrintf) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/ieee754/flt-32/s_lroundf.c: Include <fenv.h>, <limits.h>
and <fix-fp-int-convert-overflow.h>.
(__lroundf) [FE_INVALID]: Force FE_INVALID exception as needed if
FIX_DBL_LLONG_CONVERT_OVERFLOW.
* sysdeps/mips/mips32/fpu/fix-fp-int-convert-overflow.h: New file.
Carlos O'Donell [Fri, 9 Oct 2015 20:35:53 +0000 (16:35 -0400)]
Fix typo in bug-strcoll2 (Bug 18589)
Fix the copyright year and remove contributed by in the
bug-strcoll2 test. In addition add the correct dependency
on $(gen-locales) to ensure all the test locales are generated.
H.J. Lu [Fri, 9 Oct 2015 18:33:30 +0000 (11:33 -0700)]
Update lrint/lrintf/lrintl for x32
The x86_64 versions of lrint/lrintf/ lrintl are aliases for the long
long versions which isn't correct for x32, where exceptions must respect
overflow for 32-bit long. Separate versions of the long functions for
x32 that convert to 32-bit long and raise the right exceptions for that
conversion, while keeping the aliases in the non-x32 case.
Tested on x86_64 and x32. There are no code changes in libm.so on
x86_64.
* sysdeps/x86_64/fpu/s_llrint.S (__lrint): Add alias only if
__ILP32__ isn't defined.
(lrint): Likewise.
* sysdeps/x86_64/fpu/s_llrintf.S (__lrintf): Likewise.
(lrintf): Likewise.
* sysdeps/x86_64/fpu/s_llrintl.S (__lrintl): Likewise.
(lrintl): Likewise.
* sysdeps/x86_64/x32/fpu/s_lrint.S: New file.
* sysdeps/x86_64/x32/fpu/s_lrintf.S: Likewise.
* sysdeps/x86_64/x32/fpu/s_lrintl.S: Likewise.
Joseph Myers [Fri, 9 Oct 2015 00:32:14 +0000 (00:32 +0000)]
Fix dbl-64 lrint for 64-bit long (bug 19095).
The dbl-64 implementation of lrint produces incorrect results for some
arguments with 64-bit long because a 32-bit (unsigned) low part of the
mantissa is shifted left, losing high bits in the process. This patch
fixes this by casting to long int before shifting, as in lround (as
this case only applies for 64-bit long, there are no issues with
sign-extension).
Tested for mips64 (n64).
[BZ #19095]
* sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Cast low part of
mantissa to long int before shifting left.
Joseph Myers [Thu, 8 Oct 2015 22:17:45 +0000 (22:17 +0000)]
Fix lrint, llrint missing exceptions close to overflow threshold (bug 19094).
The dbl-64, ldbl-96 and ldbl-128 implementations of lrint and llrint
fail to produce "invalid" exceptions in cases where the rounded result
overflows the target type, but truncating the floating-point argument
to the next integer towards zero does not overflow it (so in
particular casts do not produce such exceptions). (This issue cannot
arise for float, or for double with 64-bit target type, or for ldbl-96
with 64-bit target type and negative arguments, because of
insufficient precision in the floating-point type for arguments with
the relevant property to exist. It also obviously cannot arise in
FE_TOWARDZERO mode.)
This patch fixes these problems by inserting checks for the special
cases that can occur in each implementation, and explicitly raising
FE_INVALID (and avoiding the cast if it might raise spurious
FE_INEXACT, while raising FE_INEXACT explicitly in the cases where it
is needed; unlike lround and llround, FE_INEXACT is required, not
optional, for these functions for a within-range inexact result).
The fixes are conditional on FE_INVALID or FE_INEXACT being defined.
If any future architecture supports one but not both of those
exceptions, the code will fail to compile and need fixing to handle
that case (this seemed better than conditioning on both macros being
defined, resulting in code that would compile but quietly miss
exceptions on such a system).
Tested for x86_64, x86 and mips64. Tested the ldbl-96 changes (only
relevant for ia64, it appears) on x86_64 by removing the x86_64
versions of lrintl / llrintl.
[BZ #19094]
* sysdeps/ieee754/dbl-64/s_lrint.c: Include <fenv.h> and
<limits.h>.
(__lrint) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
when result overflows but exception would not result from cast.
* sysdeps/ieee754/ldbl-128/s_llrintl.c: Include <fenv.h> and
<limits.h>.
(__llrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
when result overflows but exception would not result from cast.
* sysdeps/ieee754/ldbl-128/s_lrintl.c: Include <fenv.h> and
<limits.h>.
(__lrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
when result overflows but exception would not result from cast.
* sysdeps/ieee754/ldbl-96/s_llrintl.c: Include <fenv.h> and
<limits.h>.
(__llrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
when result overflows but exception would not result from cast.
* sysdeps/ieee754/ldbl-96/s_lrintl.c: Include <fenv.h> and
<limits.h>.
(__lrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
when result overflows but exception would not result from cast.
* math/libm-test.inc (lrint_test_data): Add more tests.
(llrint_test_data): Likewise.
The optimization introduced in commit f13c2a8dff2329c6692a80176262ceaaf8a6f74e, causes regressions in
sorting for languages that have digraphs that change sort order, like
cs_CZ which sorts ch between h and i.
My analysis shows the fast-forwarding optimization in STRCOLL advances
through a digraph while possibly stopping in the middle which results
in a subsequent skipping of the digraph and incorrect sorting. The
optimization is incorrect as implemented and because of that I'm
removing it for 2.23, and I will also commit this fix for 2.22 where
it was originally introduced.
This patch reverts the optimization, introduces a new bug-strcoll2.c
regression test that tests both cs_CZ.UTF-8 and da_DK.ISO-8859-1 and
ensures they sort one digraph each correctly. The optimization can't be
applied without regressing this test.
Checked on x86_64, bug-strcoll2.c fails without this patch and passes
after. This will also get a fix on 2.22 which has the same bug.
Joseph Myers [Thu, 8 Oct 2015 17:24:49 +0000 (17:24 +0000)]
Correct "inexact" expectations in lround, llround tests.
I noticed that some of my recently added tests of lround and llround
wrongly expected the "inexact" exception to be absent for certain
within-range non-integer arguments. (It's unspecified whether this
exception is present or not for within-range non-integer arguments; it
mustn't be present for integer arguments and out-of-range arguments.)
This patch corrects those expectations.
Tested for x86_64 and x86.
* math/libm-test.inc (lround_test_data): Do not expect the absence
of "inexact" for some tests with non-integer arguments.
(llround_test_data): Likewise.
Carlos O'Donell [Thu, 8 Oct 2015 02:21:36 +0000 (22:21 -0400)]
malloc: Consistently apply trim_threshold to all heaps (Bug 17195)
In the per-thread arenas we apply trim_threshold-based checks
to the extra space between the pad and the top_area. This isn't
quite accurate and instead we should be harmonizing with the way
in which trim_treshold is applied everywhere else like sysrtim
and _int_free. The trimming check should be based on the size of
the top chunk and only the size of the top chunk. The following
patch harmonizes the trimming and make it consistent for the main
arena and thread arenas.
In the old code a large padding request might have meant that
trimming was not triggered. Now trimming is considered first based
on the chunk, then the pad is subtracted, and the remainder trimmed.
This is how all the other trimmings operate. I didn't measure the
performance difference of this change because it corrects what I
consider to be a behavioural anomaly. We'll need some profile driven
optimization to make this code better, and even there Ondrej and
others have better ideas on how to speedup malloc.
Tested on x86_64 with no regressions. Already reviewed by Siddhesh
Poyarekar and Mel Gorman here and discussed here:
https://sourceware.org/ml/libc-alpha/2015-05/msg00002.html