AgeCommit message (Collapse)AuthorLines
2014-06-25release 1.1.3v1.1.3Rich Felker-1/+27
2014-06-25add tarball-producing targets to Makefile for ease of releaseRich Felker-0/+4
my old, out-of-tree release script that performed a clone rather than using git archive checked the VERSION file to make sure that it matched before doing a release. I believe there should be a way to do the same with git commands (without resorting to checking out the desired tag) but I have not yet found a way, so care should be taken when using these targets that the correctness of the VERSION file is not overlooked.
2014-06-25update version reference in the README fileRich Felker-1/+1
2014-06-25add note to INSTALL file about gcc 4.9.0 not being supportedRich Felker-1/+2
2014-06-24add routing protocols to getprotoent-family functionsTimo Teräs-0/+2
iptables and quagga need them to work.
2014-06-23rename dynamic linker _start to _dlstart in the stub versionRich Felker-1/+1
the renaming was previously applied to all real versions of the function in commit 3fa2eb2aba8d6b54dec53e7ad4c37e17392b166f.
2014-06-22add __sysv_signal abi-compat alias for the signal functionRich Felker-0/+1
it should be noted that the "real" __sysv_signal, which we do not implement, is semantically different from signal. references to __sysv_signal arise in code built against glibc under certain combinations of feature test macros, and are almost surely unintentional since the legacy sysv signal behavior has fundamental race conditions that cannot be worked around and which make it impossible to use safely.
2014-06-22add __xmknod and __xmknodat abi-compat functionsRich Felker-0/+10
these are put alongside the similar functions for __xstat, etc. in __xstat.c to avoid bloating the number of source files.
2014-06-22consolidate __xstat abi-compat functions into a single source fileRich Felker-27/+18
these are mostly intended for use with dynamic linking (although they can also be used statically with object files compiled against glibc headers), so having them broken down into separate source files to optimize for static linking is unlikely to be worth the cost having more files in the source tree (which contributes to libc.a overhead, compile time, link time, ar/linker command line size exhaustion, and so on).
2014-06-21implement fmtmsg functionRich Felker-0/+137
contributed by Isaac Dunham. this seems to be the last interface that was missing for complete POSIX 2008 base + XSI coverage.
2014-06-21implement result address sorting in the resolver (getaddrinfo, etc.)Rich Felker-0/+136
2014-06-21remove hack in syslog.h that resulted in aliasing violationsRich Felker-6/+2
this issue affected the prioritynames and facilitynames arrays which are only provided when requested (usually by syslogd implementations) and which are presently defined as compound literals. the aliasing violation seems to have been introduced as a workaround for bad behavior by gcc's -Wwrite-strings option, but it caused compilers to completely optimize out the contents of prioritynames and facilitynames since, under many usage cases, the aliasing rules prove that the contents are never accessed.
2014-06-20remove optimization-inhibiting behavior from configure's --enable-debugRich Felker-5/+2
this behavior turned out to be counter-intuitive to users and in any case it's unnecessary. optimization can be disabled explicitly using the --disable-optimize option, or both can be achieved without any enable/disable options by passing CFLAGS="-O0 -g".
2014-06-20fix gethostby*_r result pointer value on errorTimo Teräs-0/+3
according to the documentation in the man pages, the GNU extension functions gethostbyaddr_r, gethostbyname_r and gethostbyname2_r are guaranteed to set the result pointer to NULL in case of error or no result.
2014-06-20fix sendmmsg emulation return value for zero-length vectorRich Felker-0/+1
this case is not even documented, but the kernel returns 0 here and it makes sense to be consistent.
2014-06-20rename dynamic linker entry point from _start to _dlstartRich Felker-20/+20
the main motivation for this change is to aid in debugging. since the main program's entry point is also named _start, it was difficult to set breakpoints or quickly identify which _start execution stopped in.
2014-06-19implement sendmmsg and recvmmsgRich Felker-0/+55
these are not pure syscall wrappers because they have to work around kernel API bugs on 64-bit archs. the workarounds could probably be made somewhat more efficient, but at the cost of more complexity. this may be revisited later.
2014-06-19add tlsdesc support for x86_64Rich Felker-0/+42
2014-06-19separate __tls_get_addr implementation from dynamic linker/init_tlsRich Felker-11/+23
such separation serves multiple purposes: - by having the common path for __tls_get_addr alone in its own function with a tail call to the slow case, code generation is greatly improved. - by having __tls_get_addr in it own file, it can be replaced on a per-arch basis as needed, for optimization or ABI-specific purposes. - by removing __tls_get_addr from __init_tls.c, a few bytes of code are shaved off of static binaries (which are unlikely to use this function unless the linker messed up).
2014-06-19add tlsdesc support for i386Rich Felker-0/+29
2014-06-19optimize i386 ___tls_get_addr asmRich Felker-1/+8
2014-06-19change dynamic TLS installation strategy to optimize accessRich Felker-8/+14
previously, accesses to dynamic TLS had to check two conditions before being able to use a dtv slot: (1) that the module index was within the bounds of the current dtv size, and (2) that the dynamic tls for the requested module index was already installed in the dtv. this commit changes the installation strategy so that, whenever an attempt is made to access dynamic TLS that's not yet installed in the dtv, the dynamic TLS for all lower-index modules is also installed. thus it provides a new invariant: if a given module index is within the bounds of the current dtv size, we automatically know that its TLS is installed and directly available. the requirement that the second condition (above) be checked is eliminated.
2014-06-19add arch-generic support for tlsdesc relocations to dynamic linkerRich Felker-0/+54
this code is non-functional without further changes to link up the arch-specific reloc types for tlsdesc and add asm implementations of __tlsdesc_static and __tlsdesc_dynamic.
2014-06-19fix incorrect comparison loop condition in memmemRich Felker-2/+2
the logic for this loop was copied from null-terminated-string logic in strstr without properly adapting it to work with explicit lengths. presumably this error could result in false negatives (wrongly comparing past the end of the needle/haystack), false positives (stopping comparison early when the needle contains null bytes), and crashes (from runaway reads past the end of mapped memory).
2014-06-18reduce code duplication in dynamic linker error pathsRich Felker-16/+16
eventually this should help making dlerror thread-safe too.
2014-06-18refactor to remove arch-specific relocation code from dynamic linkerRich Felker-208/+187
this was one of the main instances of ugly code duplication: all archs use basically the same types of relocations, but roughly equivalent logic was duplicated for each arch to account for the different naming and numbering of relocation types and variation in whether REL or RELA records are used. as an added bonus, both REL and RELA are now supported on all archs, regardless of which is used by the standard toolchain.
2014-06-17fix powerpc dynamic linker thread-pointer-relative relocationsRich Felker-3/+3
processing of R_PPC_TPREL32 was ignoring the addend provided by the RELA-style relocation and instead using the inline value as the addend. this presumably broke dynamic-linked access to initial TLS in cases where the addend was nonzero.
2014-06-17multiple fixes to sh (superh) dynamic linker relocationsRich Felker-10/+8
the following issues are fixed: - R_SH_REL32 was adding the load address of the module being relocated to the result. this seems to have been a mistake in the original port, since it does not match other dynamic linker implementations and since adding a difference between two addresses (the symbol value and the relocation address) to a load address does not make sense. - R_SH_TLS_DTPMOD32 was wrongly accepting an inline addend (i.e. using += rather than = on *reloc_addr) which makes no sense; addition is not an operation that's defined on module ids. - R_SH_TLS_DTPOFF32 and R_SH_TLS_TPOFF32 were wrongly using inline addends rather than the RELA-provided addends. in addition, handling of R_SH_GLOB_DAT, R_SH_JMP_SLOT, and R_SH_DIR32 are merged to all honor the addend. the first two should not need it for correct usage generated by toolchains, but other dynamic linkers allow addends here, and it simplifies the code anyway. these issues were spotted while reviewing the code for the purpose of refactoring this part of the dynamic linker. no testing was performed.
2014-06-16dynamic linker: permit error returns from arch-specific reloc functionRich Felker-8/+16
the immediate motivation is supporting TLSDESC relocations which require allocation and thus may fail (unless we pre-allocate), but this mechanism should also be used for throwing an error on unsupported or invalid relocation types, and perhaps in certain cases, for reporting when a relocation is not satisfiable.
2014-06-14fix missing argument to syscall in fanotify_markClément Vasseur-1/+1
2014-06-11support optional-argument extension to getopt via double-colonRich Felker-2/+5
this extension is not incompatible with the standard behavior of the function, not expensive, and avoids requiring a replacement getopt with full GNU extensions for a few important apps including busybox's sed with the -i option.
2014-06-10fail configure on --enable-shared if -Bsymbolic-functions doesn't workRich Felker-1/+4
previously, a warning was issued in this case no matter what, even if --disable-shared was used. now, the default for --enable-shared is changed from "yes" to "auto", and the warning is issued by default, but becomes an error if --enable-shared is used, and the test is suppressed completely if --disable-shared is used.
2014-06-10simplify errno implementationRich Felker-4/+2
the motivation for the errno_ptr field in the thread structure, which this commit removes, was to allow the main thread's errno to keep its address when lazy thread pointer initialization was used. &errno was evaluated prior to setting up the thread pointer and stored in errno_ptr for the main thread; subsequently created threads would have errno_ptr pointing to their own errno_val in the thread structure. since lazy initialization was removed, there is no need for this extra level of indirection; __errno_location can simply return the address of the thread's errno_val directly. this does cause &errno to change, but the change happens before entry to application code, and thus is not observable.
2014-06-10replace all remaining internal uses of pthread_self with __pthread_selfRich Felker-12/+12
prior to version 1.1.0, the difference between pthread_self (the public function) and __pthread_self (the internal macro or inline function) was that the former would lazily initialize the thread pointer if it was not already initialized, whereas the latter would crash in this case. since lazy initialization is no longer supported, use of pthread_self no longer makes sense; it simply generates larger, slower code.
2014-06-10add thread-pointer support for pre-2.6 kernels on i386Rich Felker-13/+22
such kernels cannot support threads, but the thread pointer is also important for other purposes, most notably stack protector. without a valid thread pointer, all code compiled with stack protector will crash. the same applies to any use of thread-local storage by applications or libraries. the concept of this patch is to fall back to using the modify_ldt syscall, which has been around since linux 1.0, to setup the gs segment register. since the kernel does not have a way to automatically assign ldt entries, use of slot zero is hard-coded. if this fallback path is used, __set_thread_area returns a positive value (rather than the usual zero for success, or negative for error) indicating to the caller that the thread pointer was successfully set, but only for the main thread, and that thread creation will not work properly. the code in __init_tp has been changed accordingly to record this result for later use by pthread_create.
2014-06-07avoid spurious lookup failures from badly-behaved nameserversRich Felker-5/+22
the results of a dns query, whether it's performed as part of one of the standard name-resolving functions or directly by res_send, should be a function of the query, not of the particular nameserver that responds to it. thus, all responses which indicate a failure or refusal by the nameserver, as opposed to a positive or negative result for the query, should be ignored. the strategy used is to re-issue the query immediately (but with a limit on the number of retries, in case the server is really broken) when a response code of 2 (server failure, typically transient) is seen, and otherwise take no action on bad responses (which generally indicate a misconfigured nameserver or one which the client does not have permission to use), allowing the normal retry interval to apply and of course accepting responses from other nameservers queried in parallel. empirically this matches the traditional resolver behavior for nameservers that respond with a code of 2 in the case where there is just a single nameserver configured. the behavior diverges when multiple nameservers are available, since musl is querying them in parallel. in this case we are mildly more aggressive at retrying.
2014-06-06use default timezone from /etc/localtime if $TZ is unset/blankRich Felker-2/+3
the way this is implemented, it also allows explicit setting of TZ=/etc/localtime even for suid programs. this is not a problem because /etc/localtime is a trusted path, much like the trusted zoneinfo search path.
2014-06-06release 1.1.2v1.1.2Rich Felker-1/+32
2014-06-06implement %y and %C specifiers in strptimeTimo Teräs-4/+10
2014-06-06avoid invalid use of va_arg in openRich Felker-5/+8
reading the variadic mode argument is only valid when the O_CREAT flag is present. this probably does not matter, but is needed for formal correctness, and could affect LTO or other full-program analysis.
2014-06-06add O_CLOEXEC fallback for open and related functionsRich Felker-1/+9
since there is no easy way to detect whether open honored or ignored the O_CLOEXEC flag, the optimal solution to providing a fallback is simply to make the fcntl syscall to set the close-on-exec flag immediately after open returns.
2014-06-06optimize SOCK_CLOEXEC fallback for socket functionRich Felker-2/+2
the fcntl function is heavy, so make the syscall directly instead. also, avoid the code size and runtime overhead of querying the old flags, since it's reasonable to assume nothing will be set on a newly-created socket. this code is only used on old kernels which lack proper atomic close-on-exec support, so future changes that might invalidate such an assumption do not need to be considered.
2014-06-06add SOCK_CLOEXEC fallback for socketpair on old kernelsRich Felker-1/+19
as usual, this is non-atomic, but better than producing an error or failing to set the close-on-exec flag at all.
2014-06-06implement dn_comp RFC 1035 domain name compressionSzabolcs Nagy-1/+102
the input name is validated, the other parameters are assumed to be valid (the list of already compressed names are not checked for infinite reference loops or out-of-bound offsets). names are handled case-sensitively for now.
2014-06-06accept trailing . and empty domain namesSzabolcs Nagy-12/+16
trailing . should be accepted in domain name strings by convention (RFC 1034), host name lookup accepts "." but rejects empty "", res_* interfaces also accept empty name following existing practice.
2014-06-06add vdso clock_gettime acceleration support to i386Rich Felker-0/+4
2014-06-06fix fd leak in tmpfile when the fdopen operation failsRich Felker-1/+2
this condition could only happen due to malloc failure. the fdopen operation is also moved to take place after the unlink to minimize the window during which a link to the file exists in the directory table.
2014-06-05fix the domain name length limit checksSzabolcs Nagy-8/+8
A domain name is at most 255 bytes long (RFC 1035), but the string representation is two bytes smaller so the strlen maximum is 253.
2014-06-05fix multiple validation issues in dns response label parsingSzabolcs Nagy-4/+6
Due to an error introduced in commit fcc522c92335783293ac19df318415cd97fbf66b, checking of the remaining output buffer space was not performed correctly, allowing malformed input to write past the end of the buffer. In addition, the loop detection logic failed to account for the possibility of infinite loops with no output, which would hang the function. The output size is now limited more strictly so only names with valid length are accepted.
2014-06-05fix missing function declarations in refactored ip literal parsing codeRich Felker-0/+1