| Commit message (Expand) | Author | Age | Files | Lines |
| * | add getauxval function•••in a sense this implementation is incomplete since it doesn't provide
the HWCAP_* macros for use with AT_HWCAP, which is perhaps the most
important intended usage case for getauxval. they will be added at a
later time.
| Rich Felker | 2014-04-07 | 1 | -0/+12 |
| * | fix failure of printf %g to strip trailing zeros in some cases•••the code to strip trailing zeros was only looking in the last slot for
up to 9 zeros, assuming that the rounding code had already removed
fully-zero slots from the end. however, this ignored cases where the
rounding code did not run at all, which occur when the value being
printed is exactly representable in the requested precision.
the simplest solution is to move the code that strips trailing zero
slots to run unconditionally, immediately after rounding, rather than
as the last step of rounding.
| Rich Felker | 2014-04-07 | 1 | -1/+1 |
| * | fix carry into uninitialized slots during printf floating point rounding•••in cases where rounding caused a carry, the slot into which the carry
was taking place was unconditionally treated as valid, despite the
possibility that it could be a new slot prior to the beginning of the
existing non-rounded number. in theory this could lead to unbounded
runaway carry, but in order for that to happen, the whole
uninitialized buffer would need to have been pre-filled with 32-bit
integer values greater than or equal to 999999999.
patch based on proposed fix by Morten Welinder, who also discovered
and reported the bug.
| Rich Felker | 2014-04-07 | 1 | -1/+1 |
| * | remove some cruft from libc/tls init code | Rich Felker | 2014-04-07 | 2 | -3/+0 |
| * | remove cruft left behind when lazy thread pointer init was removed•••the function itself was static, but the weak alias provided an
externally visible reference and thus prevented the dead code from
being omitted from the output. so this change actually reduces bloat
in mandatory static-linked code.
| Rich Felker | 2014-04-04 | 1 | -8/+0 |
| * | add __sigsetjmp ABI-compat alias for sigsetjmp | Rich Felker | 2014-04-02 | 9 | -1/+28 |
| * | remove struct elem entirely from hsearch.c•••There are two changes here, both of which make sense to be done in a
single patch:
- Remove hash from struct elem and compute it at runtime wherever
necessary.
- Eliminate struct elem and use ENTRY directly.
As a result we cut down on the memory usage as each element in the
hash table now contains only an ENTRY not an ENTRY + size_t for the
hash. The downside is that the hash needs to be computed at runtime.
| sin | 2014-04-02 | 1 | -29/+22 |
| * | implement hcreate_r, hdestroy_r and hsearch_r•••the size and alignment of struct hsearch_data are matched to the glibc
definition for binary compatibility. the members of the structure do
not match, which should not be a problem as long as applications
correctly treat the structure as opaque.
unlike the glibc implementation, this version of hcreate_r does not
require the caller to zero-fill the structure before use.
| sin | 2014-04-02 | 1 | -30/+73 |
| * | avoid malloc failure for small requests when brk can't be extended•••this issue mainly affects PIE binaries and execution of programs via
direct invocation of the dynamic linker binary: depending on kernel
behavior, in these cases the initial brk may be placed at at location
where it cannot be extended, due to conflicting adjacent maps.
when brk fails, mmap is used instead to expand the heap. in order to
avoid expensive bookkeeping for managing fragmentation by merging
these new heap regions, the minimum size for new heap regions
increases exponentially in the number of regions. this limits the
number of regions, and thereby the number of fixed fragmentation
points, to a quantity which is logarithmic with respect to the size of
virtual address space and thus negligible. the exponential growth is
tuned so as to avoid expanding the heap by more than approximately 50%
of its current total size.
| Rich Felker | 2014-04-02 | 1 | -1/+23 |
| * | remove lazy ssp initialization•••now that thread pointer is initialized always, ssp canary
initialization can be done unconditionally. this simplifies
the ldso as it does not try to detect ssp usage, and the
init function itself as it is always called exactly once.
this also merges ssp init path for shared and static linking.
| Timo Teräs | 2014-03-25 | 3 | -28/+5 |
| * | if dynamic linker's relro mprotect call fails, include reason in message | Rich Felker | 2014-03-25 | 1 | -1/+1 |
| * | cosmetic improvements in dynamic linker cleanup•••consistent use of braces in if/else structure, line length.
| Rich Felker | 2014-03-25 | 1 | -5/+5 |
| * | clean up internal dynamic linker functions enumerating phdrs•••record phentsize in struct dso, so the phdrs can be easily
enumerated via it. simplify all functions enumerating phdrs
to require only struct dso. also merge find_map_range and
find_dso to kernel_mapped_dso function that does both tasks
during single phdr enumeration.
| Timo Teräs | 2014-03-25 | 1 | -28/+23 |
| * | implement PT_GNU_RELRO support | Timo Teräs | 2014-03-25 | 1 | -15/+37 |
| * | fix pointer type mismatch and misplacement of const | Rich Felker | 2014-03-24 | 1 | -2/+2 |
| * | fix confstr return value•••per the specification, the terminating null byte is counted.
| Timo Teräs | 2014-03-24 | 1 | -1/+1 |
| * | always initialize thread pointer at program start•••this is the first step in an overhaul aimed at greatly simplifying and
optimizing everything dealing with thread-local state.
previously, the thread pointer was initialized lazily on first access,
or at program startup if stack protector was in use, or at certain
random places where inconsistent state could be reached if it were not
initialized early. while believed to be fully correct, the logic was
fragile and non-obvious.
in the first phase of the thread pointer overhaul, support is retained
(and in some cases improved) for systems/situation where loading the
thread pointer fails, e.g. old kernels.
some notes on specific changes:
- the confusing use of libc.main_thread as an indicator that the
thread pointer is initialized is eliminated in favor of an explicit
has_thread_pointer predicate.
- sigaction no longer needs to ensure that the thread pointer is
initialized before installing a signal handler (this was needed to
prevent a situation where the signal handler caused the thread
pointer to be initialized and the subsequent sigreturn cleared it
again) but it still needs to ensure that implementation-internal
thread-related signals are not blocked.
- pthread tsd initialization for the main thread is deferred in a new
manner to minimize bloat in the static-linked __init_tp code.
- pthread_setcancelstate no longer needs special handling for the
situation before the thread pointer is initialized. it simply fails
on systems that cannot support a thread pointer, which are
non-conforming anyway.
- pthread_cleanup_push/pop now check for missing thread pointer and
nop themselves out in this case, so stdio no longer needs to avoid
the cancellable path when the thread pointer is not available.
a number of cases remain where certain interfaces may crash if the
system does not support a thread pointer. at this point, these should
be limited to pthread interfaces, and the number of such cases should
be fewer than before.
| Rich Felker | 2014-03-24 | 14 | -98/+118 |
| * | reduce static linking overhead from TLS support by inlining mmap syscall•••the external mmap function is heavy because it has to handle error
reporting that the kernel cannot do, and has to do some locking for
arcane race-condition-avoidance purposes. for allocating initial TLS,
we do not need any of that; the raw syscall suffices.
on i386, this change shaves off 13% of the size of .text for the empty
program.
| Rich Felker | 2014-03-23 | 1 | -1/+9 |
| * | include header that declares __syscall_ret where it's defined•••in general, we aim to always include the header that's declaring a
function before defining it so that the compiler can check that
prototypes match.
additionally, the internal syscall.h declares __syscall_ret with a
visibility attribute to improve code generation for shared libc (to
prevent gratuitous GOT-register loads). this declaration should be
visible at the point where __syscall_ret is defined, too, or the
inconsistency could theoretically lead to problems at link-time.
| Rich Felker | 2014-03-23 | 1 | -0/+1 |
| * | fix mips sigsetjmp asm to match fixed jmp_buf size•••this was missed in the previous commit.
| Rich Felker | 2014-03-18 | 1 | -1/+1 |
| * | use syscall_arg_t for arguments in public syscall() function•••on x32, this change allows programs which use syscall() with pointers
or 64-bit values as arguments to work correctly, i.e. without
truncation or incorrect sign extension. on all other supported archs,
syscall_arg_t is defined as long, so this change is a no-op.
| Rich Felker | 2014-03-18 | 1 | -7/+7 |
| * | fix negated error codes from ptsname_r•••the incorrect error codes also made their way into errno when
__ptsname_r was called by plain ptsname, which reports errors via
errno rather than a return value.
| Rich Felker | 2014-03-17 | 1 | -1/+1 |
| * | semctl: fix UB causing crashes on powerpc•••it's UB to fetch variadic args when none are passed, and this caused
real crashes on ppc due to its calling convention, which defines that
for variadic functions aggregate types be passed as pointers.
the assignment caused that pointer to get dereferenced, resulting in
a crash.
| rofl0r | 2014-03-13 | 1 | -4/+8 |
| * | fix incorrect rounding in printf floating point corner cases•••the printf floating point formatting code contains an optimization to
avoid computing digits that will be thrown away by rounding at the
specified (or default) precision. while it was correctly retaining all
places up to the last decimal place to be printed, it was not
retaining enough precision to see the next nonzero decimal place in
all cases. this could cause incorrect rounding down in round-to-even
(default) rounding mode, for example, when printing 0.5+DBL_EPSILON
with "%.0f".
in the fix, LDBL_MANT_DIG/3 is a lazy (non-sharp) upper bound on the
number of zeros between any two nonzero decimal digits.
| Rich Felker | 2014-03-09 | 1 | -2/+2 |
| * | fix buffer overflow in printf formatting of denormals with low bit set•••empirically the overflow was an off-by-one, and it did not seem to be
overwriting meaningful data. rather than simply increasing the buffer
size by one, however, I have attempted to make the size obviously
correct in terms of bounds on the number of iterations for the loops
that fill the buffer. this still results in no more than a negligible
size increase of the buffer on the stack (6-7 32-bit slots) and is a
"safer" fix unless/until somebody wants to do the proof that a smaller
buffer would suffice.
| Rich Felker | 2014-03-09 | 1 | -1/+2 |
| * | in fcntl, use unsigned long instead of long for variadic argument type•••neither is correct; different commands take different argument types,
and some take no arguments at all. I have a much larger overhaul of
fcntl prepared to address this, but it's not appropriate to commit
during freeze.
the immediate problem being addressed affects forward-compatibility on
x32: if new commands are added and they take pointers, but the
libc-level fcntl function is not aware of them, using long would
sign-extend the pointer to 64 bits and give the kernel an invalid
pointer. on the kernel side, the argument to fcntl is always treated
as unsigned long, so no harm is done by treating possibly-signed
integer arguments as unsigned. for every command that takes an integer
argument except for F_SETOWN, large integer arguments and negative
arguments are handled identically anyway. in the case of F_SETOWN, the
kernel is responsible for converting the argument which it received as
unsigned long to int, so the sign of negative arguments is recovered.
the other problem that will be addressed later is that the type passed
to va_arg does not match the type in the caller of fcntl. an advanced
compiler doing cross-translation-unit analysis could potentially see
this mismatch and issue warnings or otherwise make trouble.
on i386, this patch was confirmed not to alter the code generated by
gcc 4.7.3. in principle the generated code should not be affected on
any arch except x32.
| Rich Felker | 2014-03-07 | 1 | -2/+2 |
| * | x32: fix sysinfo()•••the kernel uses long longs in the struct, but the documentation
says they're long. so we need to fixup the mismatch between the
userspace and kernelspace structs.
since the struct offers a mem_unit member, we can avoid truncation
by adjusting that value.
| rofl0r | 2014-03-06 | 1 | -0/+5 |
| * | fix strerror on mips: one error code is out of the 8-bit table range•••if we ever encounter other targets where error codes don't fit in the
8-bit range, the table should probably just be bumped to 16-bit, but
for now I don't want to increase the table size on all archs just
because of a bug in the mips abi.
| Rich Felker | 2014-03-05 | 1 | -1/+7 |
| * | add nofpu subarchs to the sh arch, and properly detect compiler's fpu config | Rich Felker | 2014-02-27 | 8 | -0/+49 |
| * | rename superh port to "sh" for consistency•••linux, gcc, etc. all use "sh" as the name for the superh arch. there
was already some inconsistency internally in musl: the dynamic linker
was searching for "ld-musl-sh.path" as its path file despite its own
name being "ld-musl-superh.so.1". there was some sentiment in both
directions as to how to resolve the inconsistency, but overall "sh"
was favored.
| Rich Felker | 2014-02-27 | 13 | -0/+0 |
| * | fix readdir not to set ENOENT when directory is removed while reading•••per POSIX, ENOENT is reserved for invalid stream position; it is an
optional error and would only happen if the application performs
invalid seeks on the underlying file descriptor. however, linux's
getdents syscall also returns ENOENT if the directory was removed
between the time it was opened and the time of the read. we need to
catch this case and remap it to simple end-of-file condition (null
pointer return value like an error, but no change to errno). this
issue reportedly affects GNU make in certain corner cases.
rather than backing up and restoring errno, I've just changed the
syscall to be made in a way that doesn't affect errno (via an inline
syscall rather than a call to the __getdents function). the latter
still exists for the purpose of providing the public getdents alias
which sets errno.
| Rich Felker | 2014-02-25 | 1 | -2/+7 |
| * | add missing sub files for mipsel-sf to use softfloat code•••the build system has no automatic way to know this code applies to
both big (default) and little endian variants, so explicit .sub files
are needed.
| Rich Felker | 2014-02-24 | 3 | -0/+3 |
| * | mips: add mips-sf subarch support (soft-float)•••Userspace emulated floating-point (gcc -msoft-float) is not compatible
with the default mips abi (assumes an FPU or in kernel emulation of it).
Soft vs hard float abi should not be mixed, __mips_soft_float is checked
in musl's configure script and there is no runtime check. The -sf subarch
does not save/restore floating-point registers in setjmp/longjmp and only
provides dummy fenv implementation.
| Szabolcs Nagy | 2014-02-24 | 5 | -0/+53 |
| * | superh port | Bobby Bingham | 2014-02-23 | 13 | -0/+374 |
| * | mostly-cosmetic fixups to x32 port merge | Rich Felker | 2014-02-23 | 3 | -11/+11 |
| * | x32 port (diff against vanilla x86_64) | rofl0r | 2014-02-23 | 26 | -114/+120 |
| * | import vanilla x86_64 code as x32 | rofl0r | 2014-02-23 | 43 | -0/+675 |
| * | use syscall_arg_t type for syscall prototypes in pthread code | rofl0r | 2014-02-22 | 2 | -3/+8 |
| * | internal/syscall.h: add syscall_arg_t macro•••some 32-on-64 archs require that the actual syscall args be long long.
in that case syscall_arch.h can define syscall_arg_t to whatever it needs
and syscall.h picks it up.
all other archs just use long as usual.
| rofl0r | 2014-02-22 | 1 | -6/+11 |
| * | internal/syscall.h: use a macro for the syscall args casts•••this allows syscall_arch.h to define the macro __scc if special
casting is needed, as is the case for x32, where the actual syscall
arguments are 64bit, but, in case of pointers, would get sign-extended
and thus become invalid.
| rofl0r | 2014-02-22 | 1 | -13/+17 |
| * | add fallback emulation for accept4 on old kernels•••the other atomic FD_CLOEXEC interfaces (dup3, pipe2, socket) already
had such emulation in place. the justification for doing the emulation
here is the same as for the other functions: it allows applications to
simply use accept4 rather than having to have their own fallback code
for ENOSYS/EINVAL (which one you get is arch-specific!) and there is
no reasonable way an application could benefit from knowing the
operation is emulated/non-atomic since there is no workaround at the
application level for non-atomicity (that is the whole reason these
interfaces were added).
| Rich Felker | 2014-02-21 | 1 | -1/+12 |
| * | add ipv6 and icmpv6 to getprotoent-family functions•••based on patch by orc.
| Rich Felker | 2014-02-13 | 1 | -1/+3 |
| * | fix typo in table for getprotoent that caused out-of-bound reads•••this was unlikely to lead to any crash or dangerous behavior, but
caused adjacent string constants to be treated as part of the
protocols table, possibly returning nonsensical results for unknown
protocol names/numbers or when getprotoent was called in a loop to
enumerate all protocols.
| Rich Felker | 2014-02-13 | 1 | -1/+1 |
| * | make posix_spawn accept null pid pointer arguments•••this is a requirement in the specification that was overlooked.
| Rich Felker | 2014-02-12 | 1 | -1/+1 |
| * | clone: make clone a wrapper around __clone•••The architecture-specific assembly versions of clone did not set errno on
failure, which is inconsistent with glibc. __clone still returns the error
via its return value, and clone is now a wrapper that sets errno as needed.
The public clone has also been moved to src/linux, as it's not directly
related to the pthreads API.
__clone is called by pthread_create, which does not report errors via
errno. Though not strictly necessary, it's nice to avoid clobbering errno
here.
| Bobby Bingham | 2014-02-09 | 6 | -18/+22 |
| * | fix fesetenv(FE_DFL_ENV) on x86_64 (see previous commit) | Szabolcs Nagy | 2014-02-09 | 1 | -1/+1 |
| * | fix fesetenv(FE_DFL_ENV) on i386•••the default fenv was not set up properly, in particular the
tag word that indicates the contents of the x87 registers was
set to 0 (used) instead of 0xffff (empty)
this could cause random crashes after setting the default fenv
because it corrupted the fpu stack and then any float computation
gives NaN result breaking the program logic (usually after a
float to integer conversion).
| Szabolcs Nagy | 2014-02-09 | 1 | -1/+1 |
| * | in fdopen, avoid setting O_APPEND flag if it's already set•••this saves a syscall in the case where the underlying open already
took place with O_APPEND, which is common because fopen with append
modes sets O_APPEND at the time of open before passing the file
descriptor to __fdopen.
| Rich Felker | 2014-02-07 | 1 | -1/+2 |
| * | fix ftello result for append streams with unflushed output•••when there is unflushed output, ftello (and ftell) compute the logical
stream position as the underlying file descriptor's offset plus an
adjustment for the amount of buffered data. however, this can give the
wrong result for append-mode streams where the unflushed writes should
adjust the logical position to be at the end of the file, as if a seek
to end-of-file takes place before the write.
the solution turns out to be a simple trick: when ftello (indirectly)
calls lseek to determine the current file offset, use SEEK_END instead
of SEEK_CUR if the stream is append-mode and there's unwritten
buffered data.
the ISO C rules regarding switching between reading and writing for a
stream opened in an update mode, along with the POSIX rules regarding
switching "active handles", conveniently leave undefined the
hypothetical usage cases where this fix might lead to observably
incorrect offsets.
the bug being fixed was discovered via the test case for glibc issue
| Rich Felker | 2014-02-07 | 3 | -1/+5 |
| * | add legacy functions setkey() and encrypt() | Timo Teräs | 2014-02-05 | 2 | -6/+66 |