Commit Graph

8 Commits

Author SHA1 Message Date
Rich Felker 4e0b4a5de7 add tlsdesc support for i386 2014-06-19 02:50:45 -04:00
Rich Felker adf94c1966 refactor to remove arch-specific relocation code from dynamic linker
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-18 02:44:02 -04:00
Rich Felker bfa09700b9 dynamic linker: permit error returns from arch-specific reloc function
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-16 03:09:07 -04:00
Rich Felker f389c4984a make the dynamic linker find its path file relative to its own location
prior to this change, using a non-default syslibdir was impractical on
systems where the ordinary library paths contain musl-incompatible
library files. the file containing search paths was always taken from
/etc, which would either correspond to a system-wide musl
installation, or fail to exist at all, resulting in searching of the
default library path.

the new search strategy is safe even for suid programs because the
pathname used comes from the PT_INTERP header of the program being
run, rather than any external input.

as part of this change, I have also begun differentiating the names of
arch variants that differ by endianness or floating point calling
convention. the corresponding changes in the build system and and gcc
wrapper script (to use an alternate dynamic linker name) for these
configurations have not yet been made.
2013-07-18 19:29:44 -04:00
Rich Felker 9c74856af7 dynamic-linked TLS support for everything but dlopen'd libs
currently, only i386 is tested. x86_64 and arm should probably work.
the necessary relocation types for mips and microblaze have not been
added because I don't understand how they're supposed to work, and I'm
not even sure if it's defined yet on microblaze. I may be able to
reverse engineer the requirements out of gcc/binutils output.
2012-10-04 22:48:33 -04:00
Rich Felker 32de61e81a fix some symbol resolution issues in dynamic linker
1. search was wrongly beginning with lib itself rather than dso head
2. inconsistent resolution of function pointers for functions in plt
2011-06-25 22:36:21 -04:00
Rich Felker 568b8075a4 proper path searching for dynamic linker
first, use $LD_LIBRARY_PATH unless suid. if that fails, read path from
/etc/ld-musl-$ARCH.path and fallback to a builtin default.
2011-06-25 01:56:34 -04:00
Rich Felker 51e2d83102 experimental dynamic linker!
some notes:
- library search path is hard coded
- x86_64 code is untested and may not work
- dlopen/dlsym is not yet implemented
- relocations in read-only memory won't work
2011-06-18 19:48:42 -04:00