about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* use hidden visibility rather than protected for syscall internalsRich Felker2014-04-121-1/+1
| | | | | | | | | | | | | | | the use of visibility at all is purely an optimization to avoid the need for the caller to load the GOT register or similar to prepare for a call via the PLT. there is no reason for these symbols to be externally visible, so hidden works just as well as protected, and using protected visibility is undesirable due to toolchain bugs and the lack of testing it receives. in particular, GCC's microblaze target is known to generate symbolic relocations in the GOT for functions with protected visibility. this in turn results in a dynamic linker which crashes under any nontrivial usage that requires making a syscall before symbolic relocations are processed.
* math: fix aliasing violation in long double wrappersSzabolcs Nagy2014-04-112-2/+10
| | | | | | | | | modfl and sincosl were passing long double* instead of double* to the wrapped double precision functions (on archs where long double and double have the same size). This is fixed now by using temporaries (this is not optimized to a single branch so the generated code is a bit bigger). Found by Morten Welinder.
* fix search past the end of haystack in memmemTimo Teräs2014-04-091-0/+1
| | | | | | | | to optimize the search, memchr is used to find the first occurrence of the first character of the needle in the haystack before switching to a search for the full needle. however, the number of characters skipped by this first step were not subtracted from the haystack length, causing memmem to search past the end of the haystack.
* fix printf rounding with %g for some corner case midpointsRich Felker2014-04-071-1/+1
| | | | | | | | | | the subsequent rounding code assumes the end pointer (z) accurately reflects the end of significance in the decimal expansion, but for certain large integers, spurious trailing zero slots were left behind when applying the binary exponent. issue reported by Morten Welinder; the analysis of the cause was performed by nsz, who also proposed this change.
* fix arm atomic asm register constraintRich Felker2014-04-071-1/+1
| | | | | | the "m" constraint could give a memory reference with an offset that's not compatible with ldrex/strex, so the arm-specific "Q" constraint is needed instead.
* use inline atomics and thread pointer on arm models supporting themRich Felker2014-04-072-1/+36
| | | | | | | | | | | | | | | | | | | | this is perhaps not the optimal implementation; a_cas still compiles to nested loops due to the different interface contracts of the kuser helper cas function (whose contract this patch implements) and the a_cas function (whose contract mimics the x86 cmpxchg). fixing this may be possible, but it's more complicated and thus deferred until a later time. aside from improving performance and code size, this patch also provides a means of producing binaries which can run on hardened kernels where the kuser helpers have been disabled. however, at present this requires producing binaries for armv6k or later, which will not run on older cpus. a real solution to the problem of kernels that omit the kuser helpers would be runtime detection, so that universal binaries which run on all arm cpu models can also be compatible with all kernel hardening profiles. robust detection however is a much harder problem, and will be addressed at a later time.
* add getauxval functionRich Felker2014-04-072-0/+28
| | | | | | | 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.
* fix failure of printf %g to strip trailing zeros in some casesRich Felker2014-04-071-1/+1
| | | | | | | | | | | | 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.
* fix carry into uninitialized slots during printf floating point roundingRich Felker2014-04-071-1/+1
| | | | | | | | | | | | | 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.
* remove some cruft from libc/tls init codeRich Felker2014-04-072-3/+0
|
* remove cruft left behind when lazy thread pointer init was removedRich Felker2014-04-041-8/+0
| | | | | | | 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.
* add __sigsetjmp ABI-compat alias for sigsetjmpRich Felker2014-04-029-1/+28
|
* remove struct elem entirely from hsearch.csin2014-04-021-29/+22
| | | | | | | | | | | | | 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.
* implement hcreate_r, hdestroy_r and hsearch_rsin2014-04-022-30/+85
| | | | | | | | | | 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.
* avoid malloc failure for small requests when brk can't be extendedRich Felker2014-04-021-1/+23
| | | | | | | | | | | | | | | | | 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.
* fix microblaze syscall register clobbersRich Felker2014-04-021-7/+7
| | | | | | | | | the kernel entry point for syscalls on microblaze nominally saves and restores all registers, and testing on qemu always worked since qemu behaves this way too. however, the real kernel treats r3:r4 as a potential 64-bit return value from the syscall function, and copies both over top of the saved registers before returning to userspace. thus, we need to treat r4 as always-clobbered.
* remove lazy ssp initializationTimo Teräs2014-03-253-28/+5
| | | | | | | | 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.
* if dynamic linker's relro mprotect call fails, include reason in messageRich Felker2014-03-251-1/+1
|
* cosmetic improvements in dynamic linker cleanupRich Felker2014-03-251-5/+5
| | | | consistent use of braces in if/else structure, line length.
* clean up internal dynamic linker functions enumerating phdrsTimo Teräs2014-03-251-28/+23
| | | | | | | | 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.
* implement PT_GNU_RELRO supportTimo Teräs2014-03-251-15/+37
|
* fix pointer type mismatch and misplacement of constRich Felker2014-03-241-2/+2
|
* fix confstr return valueTimo Teräs2014-03-241-1/+1
| | | | per the specification, the terminating null byte is counted.
* always initialize thread pointer at program startRich Felker2014-03-2414-98/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* reduce static linking overhead from TLS support by inlining mmap syscallRich Felker2014-03-231-1/+9
| | | | | | | | | | 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.
* include header that declares __syscall_ret where it's definedRich Felker2014-03-231-0/+1
| | | | | | | | | | | | 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.
* release 1.0.0 v1.0.0Rich Felker2014-03-202-1/+43
|
* remove claim of XSI coverage from READMERich Felker2014-03-201-2/+1
| | | | | | in addition to the dbm functions (which we don't intent to implement anyway), fmtmsg is still missing too. rather than adding exceptions I think it's best just to avoid making the claim.
* update README in preparation for releaseRich Felker2014-03-201-59/+21
| | | | | reduces the amount of news-like content on progress and development direction and focuses on the present.
* update INSTALL file with new information and better adviceRich Felker2014-03-201-109/+114
| | | | | | | | the text covering an ill-advised procedure for 'bootstrapping' a new musl-based system in-place is removed. new information on targets and compilers is added. formatting improved. the remaining text is adjusted to cover both usage with musl-gcc on a non-musl-based system and upgrading a musl-based system or toolchain.
* update COPYRIGHT file with additional contributor informationRich Felker2014-03-201-22/+54
|
* configure: check for __ILP32__ if arch is x86_64rofl0r2014-03-191-0/+4
| | | | | otherwise a multilib compiler used with -mx32 will not be detected properly.
* fix signal.h breakage from moving stack_t to arch-specific bitsRich Felker2014-03-189-48/+50
| | | | | | in the previous changes, I missed the fact that both the prototype of the sigaltstack function and the definition of ucontext_t depend on stack_t.
* fix mips stack_tRich Felker2014-03-181-1/+1
| | | | like almost everything on mips, this is gratuitously different.
* move signal.h definition of stack_t to arch-specific bitsRich Felker2014-03-189-6/+48
| | | | | it's different at least on mips. mips version will be fixed in a separate commit to show the change.
* fix mips sigsetjmp asm to match fixed jmp_buf sizeRich Felker2014-03-181-1/+1
| | | | this was missed in the previous commit.
* fix typo in filename used in sh portRich Felker2014-03-181-0/+0
|
* fix size of mips jmp_bufRich Felker2014-03-181-1/+1
| | | | | | | | | | | the excess space was unused and unintentional. this change does not affect the ABI between applications and libc. while it does theoretically affect linkage between third-party translation units using jmp_buf as part of a structure, we've already changed jmp_buf at least once on all archs, and problems were never observed, likely because such usage would be very unusual. in any case it's best to get things right now rather than making changes sometime during the 1.0.x series or later.
* remove useless and incorrect uc_regspace member from mips ucontext_tRich Felker2014-03-181-1/+0
| | | | | | this seems to have been copied erroneously from the arm version of the file. it's fairly harmless but it's a mistake and better to fix now than later.
* use syscall_arg_t for arguments in public syscall() functionRich Felker2014-03-181-7/+7
| | | | | | | 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.
* make configure accept alternate gcc tuples for x32Rich Felker2014-03-171-1/+1
| | | | | | | | the previous pattern required "x32" to be used as the second field of the gcc tuple, which is usually reserved for vendor use and not appropriate as an ABI specifier. with this change, putting "x32" at the end of the tuple, the way ABI specifiers are normally done, is also permitted.
* x32: fix struct statfsrofl0r2014-03-171-2/+4
| | | | | the omission of the padding was uncovered by the latest regression statvfs regression test added to libc-test.
* fix negated error codes from ptsname_rRich Felker2014-03-171-1/+1
| | | | | | 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.
* superh: fix dynamic linking of __fpscr_valuesBobby Bingham2014-03-162-1/+7
| | | | | | | | | | | | | | Applications ended up with copy relocations for this array, which resulted in libc's references to this array pointing to the application's copy. The dynamic linker, however, can require this array before the application is relocated, and therefore before the application's copy of this array is initialized. This resulted in garbage being loaded into FPSCR before executing main, which violated the ABI. We fix this by putting the array in crt1 and making the libc copy private. This prevents libc's reference to the array from pointing to an uninitialized copy in the application.
* semctl: fix UB causing crashes on powerpcrofl0r2014-03-131-4/+8
| | | | | | | | 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.
* fix statfs struct on mipsSzabolcs Nagy2014-03-121-3/+4
| | | | | | The mips statfs struct layout is different than on other archs, so the statfs, fstatfs, statvfs and fstatvfs APIs were broken on mips. Now the ordering is fixed, the types are kept consistent with other archs.
* fix semid_ds structure on mipsSzabolcs Nagy2014-03-121-2/+0
| | | | | This used to be broken when all archs had the same semid_ds definition: there is no padding around the time_t members on mips.
* fix socket.h struct msghdr member types on powerpcRich Felker2014-03-111-4/+4
| | | | | | these were incorrectly copied from the kernel, whose ABI matches the POSIX requirements but with the wrong underlying types and wrong signedness.
* fix sysvipc structures on powerpcRich Felker2014-03-114-20/+16
| | | | | | | | these have been wrong for a long time and were never detected or corrected. powerpc needs some gratuitous extra padding/reserved slots in ipc_perm, big-endian ordering for the padding of time_t slots that was intended by the kernel folks to allow a transition to 64-bit time_t, and some minor gratuitous reordering of struct members.
* move struct semid_ds to from shared sys/sem.h to bitsRich Felker2014-03-119-16/+129
| | | | | | | | | | | | the definition was found to be incorrect at least for powerpc, and fixing this cleanly requires making the definition arch-specific. this will allow cleaning up the definition for other archs to make it more specific, and reversing some of the ugliness (time_t hacks) introduced with the x32 port. this first commit simply copies the existing definition to each arch without any changes. this is intentional, to make it easier to review changes made on a per-arch basis.