about summary refs log tree commit diff
path: root/arch
Commit message (Collapse)AuthorAgeFilesLines
* fix regression in mips dynamic linkerRich Felker2014-06-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this issue caused the address of functions in shared libraries to resolve to their PLT thunks in the main program rather than their correct addresses. it was observed causing crashes, though the mechanism of the crash was not thoroughly investigated. since the issue is very subtle, it calls for some explanation: on all well-behaved archs, GOT entries that belong to the PLT use a special relocation type, typically called JMP_SLOT, so that the dynamic linker can avoid having the jump destinations for the PLT resolve to PLT thunks themselves (they also provide a definition for the symbol, which must be used whenever the address of the function is taken so that all DSOs see the same address). however, the traditional mips PIC ABI lacked such a JMP_SLOT relocation type, presumably because, due to the way PIC works, the address of the PLT thunk was never needed and could always be ignored. prior to commit adf94c19666e687a728bbf398f9a88ea4ea19996, the mips version of reloc.h contained a hack that caused all symbol lookups to be treated like JMP_SLOT, inhibiting undefined symbols from ever being used to resolve symbolic relocations. this hack goes all the way back to commit babf820180368f00742ec65b2050a82380d7c542, when the mips dynamic linker was first made usable. during the recent refactoring to eliminate arch-specific relocation processing (commit adf94c19666e687a728bbf398f9a88ea4ea19996), this hack was overlooked and no equivalent functionality was provided in the new code. fixing the problem is not as simple as adding back an equivalent hack, since there is now also a "non-PIC ABI" that can be used for the main executable, which actually does use a PLT. the closest thing to official documentation I could find for this ABI is nonpic.txt, attached to Message-ID: 20080701202236.GA1534@caradoc.them.org, which can be found in the gcc mailing list archives and elsewhere. per this document, undefined symbols corresponding to PLT thunks have the STO_MIPS_PLT bit set in the symbol's st_other field. thus, I have added an arch-specific rule for mips, applied at the find_sym level rather than the relocation level, to reject undefined symbols with the STO_MIPS_PLT bit clear. the previous hack of treating all mips relocations as JMP_SLOT-like, rather than rejecting the unwanted symbols in find_sym, probably also caused dlsym to wrongly return PLT thunks in place of the correct address of a function under at least some conditions. this should now be fixed, at least for global-scope symbol lookups.
* add tlsdesc support for x86_64Rich Felker2014-06-191-0/+2
|
* add tlsdesc support for i386Rich Felker2014-06-191-0/+2
|
* refactor to remove arch-specific relocation code from dynamic linkerRich Felker2014-06-188-200/+98
| | | | | | | | | | | 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.
* fix powerpc dynamic linker thread-pointer-relative relocationsRich Felker2014-06-171-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.
* multiple fixes to sh (superh) dynamic linker relocationsRich Felker2014-06-171-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.
* dynamic linker: permit error returns from arch-specific reloc functionRich Felker2014-06-168-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.
* add vdso clock_gettime acceleration support to i386Rich Felker2014-06-061-0/+4
|
* add sched_{get,set}attr syscall numbers and SCHED_DEADLINE macroSzabolcs Nagy2014-05-307-0/+30
| | | | | | | | | | | | linux 3.14 introduced sched_getattr and sched_setattr syscalls in commit d50dde5a10f305253cbc3855307f608f8a3c5f73 and the related SCHED_DEADLINE scheduling policy in commit aab03e05e8f7e26f51dee792beddcb5cca9215a5 but struct sched_attr "extended scheduling parameters data structure" is not yet exported to userspace (necessary for using the syscalls) so related uapi definitions are not added yet.
* fix for broken kernel side RLIM_INFINITY on mipsSzabolcs Nagy2014-05-301-0/+2
| | | | | | | | | | | | | | | | | | | | On 32 bit mips the kernel uses -1UL/2 to mark RLIM_INFINITY (and this is the definition in the userspace api), but since it is in the middle of the valid range of limits and limits are often compared with relational operators, various kernel side logic is broken if larger than -1UL/2 limits are used. So we truncate the limits to -1UL/2 in get/setrlimit and prlimit. Even if the kernel side logic consistently treated -1UL/2 as greater than any other limit value, there wouldn't be any clean workaround that allowed using large limits: * using -1UL/2 as RLIM_INFINITY in userspace would mean different infinity value for get/setrlimt and prlimit (where infinity is always -1ULL) and userspace logic could break easily (just like the kernel is broken now) and more special case code would be needed for mips. * translating -1UL/2 kernel side value to -1ULL in userspace would mean that -1UL/2 limit cannot be set (eg. -1UL/2+1 had to be passed to the kernel instead).
* fix arm thread-pointer/atomic asm when compiling to thumb codeRich Felker2014-04-302-6/+7
| | | | | | | | | | | armv7/thumb2 provides a way to do atomics in thumb mode, but for armv6 we need a call to arm mode. this commit is based on a patch by Stephen Thomas which fixed the armv7 cases but not the armv6 ones. all of this should be revisited if/when runtime selection of thread pointer access and atomics are added.
* fix missing SO_RCVBUFFORCE and SO_SNDBUFFORCE in mips socket.hRich Felker2014-04-301-1/+2
|
* make socketcall types common as they are same for all architecturesTimo Teräs2014-04-172-40/+0
|
* add working vdso clock_gettime support, including static linkingRich Felker2014-04-161-0/+4
| | | | | | | | | | | | | | | | the vdso symbol lookup code is based on the original 2011 patch by Nicholas J. Kain, with some streamlining, pointer arithmetic fixes, and one symbol version matching fix. on the consumer side (clock_gettime), per-arch macros for the particular symbol name and version to lookup are added in syscall_arch.h, and no vdso code is pulled in on archs which do not define these macros. at this time, vdso is enabled only on x86_64. the vdso support at the dynamic linker level is no longer useful to libc, but is left in place for the sake of debuggers (which may need the vdso in the link map to find its functions) and possibly use with dlsym.
* fix RLIMIT_ constants for mipsSzabolcs Nagy2014-04-158-0/+5
| | | | | | | The mips arch is special in that it uses different RLIMIT_ numbers than other archs, so allow bits/resource.h to override the default RLIMIT_ numbers (empty on all archs except mips). Reported by orc.
* add namespace-protected name for sysinfo functionRich Felker2014-04-151-1/+4
| | | | | | | | | | | it will be needed to implement some things in sysconf, and the syscall can't easily be used directly because the x32 syscall uses the wrong structure layout. the l (uncreative, for "linux") prefix is used since the symbol name __sysinfo is already taken for AT_SYSINFO from the aux vector. the way the x32 override of this function works is also changed to be simpler and avoid the useless jump instruction.
* use dmb barrier instruction for atomics on arm v7Rich Felker2014-04-141-2/+9
| | | | | | | aside from potentially offering better performance, this change is needed since the old coprocessor-based approach to barriers is deprecated in arm v7, and some compilers/assemblers issue errors when using the deprecated instruction for v7 targets.
* 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.
* 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.
* fix signal.h breakage from moving stack_t to arch-specific bitsRich Felker2014-03-188-48/+48
| | | | | | 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-188-0/+48
| | | | | it's different at least on mips. mips version will be fixed in a separate commit to show the change.
* 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.
* 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.
* 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.
* 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-118-0/+128
| | | | | | | | | | | | 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.
* add bits/user.h for sh portRich Felker2014-03-081-0/+75
| | | | | this seems to have been overlooked, and resulted in breakage in anything including sys/user.h.
* x32: fix sysinfo()rofl0r2014-03-061-0/+47
| | | | | | | | 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.
* add nofpu subarchs to the sh arch, and properly detect compiler's fpu configRich Felker2014-02-271-0/+9
|
* fix endian subarchs for sh archRich Felker2014-02-272-5/+5
| | | | | default endianness for sh on linux is little, and while conventions vary, "eb" seems to be the most widely used suffix for big endian.
* rename superh port to "sh" for consistencyRich Felker2014-02-2730-0/+0
| | | | | | | | | 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.
* mips: add mips-sf subarch support (soft-float)Szabolcs Nagy2014-02-242-1/+12
| | | | | | | | | 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.
* fixup general __syscall breakage introduced in x32 portrofl0r2014-02-243-0/+6
| | | | | | | | | the reordering of headers caused some risc archs to not see the __syscall declaration anymore. this caused build errors on mips with any compiler, and on arm and microblaze with clang. we now declare it locally just like the powerpc port does.
* make the x32 port use the correct ld-musl-x32.path filenameRich Felker2014-02-231-1/+1
| | | | | previously it was wrongly using the x86_64 one, precluding having both x32 and x86_64 libs present on the same system.
* superh portBobby Bingham2014-02-2330-0/+1950
|
* fix x32 syscall arch.h timespec fixup coderofl0r2014-02-231-53/+49
| | | | | | | | it's legal to call the __syscall functions with more arguments than necessary, and the __syscall_cp cancel dummy impl. does just that. thus we must insert the switch for all possible syscalls numbers into all of the syscallN inline functions.
* fix some issues in x32 syscall_cp_fixuprofl0r2014-02-231-11/+8
| | | | | | - the nanosleep fixup "fixed" the second timespec* argument erroneusly. - the futex fixup was missing the check for FUTEX_WAIT. - general cleanup using a macro.
* mostly-cosmetic fixups to x32 port mergeRich Felker2014-02-231-1/+1
|
* x32 port (diff against vanilla x86_64)rofl0r2014-02-2313-679/+762
|
* import vanilla x86_64 code as x32rofl0r2014-02-2330-0/+1986
|
* sys/shm.h: move arch specific structs to bits/rofl0r2014-02-236-0/+66
|
* remove more unnecessary operand-size suffixes from x86_64 atomic.hRich Felker2014-01-151-3/+3
|
* remove gratuitous temp vars, casts, and suffixes in x86_64 atomic.hRich Felker2014-01-111-13/+11
| | | | | aside from general cleanup, this should allow the identical atomic.h file to be used for the upcoming x32 port.