Commit Graph

1008 Commits

Author SHA1 Message Date
uwe
3582b90734 Use existing lo() and hi() macros. Same object code is generated. 2019-12-08 23:49:16 +00:00
uwe
f3a8613fae Resolve ADDR16_LO, ADDR16_HI, and ADDR16_HA relocs.
Recent GNU ld does not resolve them statically if the reloc is in a
writable section and the symbol is not already referenced from text.
2019-12-08 22:57:51 +00:00
uwe
1cea4da77d Fix typo in a comment. 2019-12-08 22:41:42 +00:00
uwe
9332bf7c88 _rtld_relro - fix debug printf format for a size_t argument 2019-12-08 22:35:27 +00:00
joerg
336e4f812b Use alignof and not size_t for platforms with non-natural base
alignments.
2019-11-05 22:22:42 +00:00
joerg
a0e0f8b685 PR 54093: Align static TLS area to max_align_t. 2019-11-04 12:45:10 +00:00
christos
ba0758a3b7 simplify pointer gymnastics that sprained gcc-8 2019-11-03 03:15:59 +00:00
mrg
9d7a8fa9a3 use strlcpy to ensure termination.
the buffer is statically sized so that it works without an
allocator, so truncation is the desired effect here.
2019-10-13 20:18:42 +00:00
christos
7519806b07 use __func__ (c99, c++11) instead of __FUNCTION__ 2019-10-04 01:57:53 +00:00
tnn
e91fbc780d improve error message 2019-10-03 10:34:30 +00:00
kamil
3b610a6e8d Return the ELF loader dl_phdr_info information for dl_iterate_phdr(3)
Sync the behavior of dl_iterate_phdr(3) with Linux/FreeBSD/OpenBSD.
2019-09-15 13:40:46 +00:00
maya
3bb853ed54 r_symndx is no longer declared, use symnum and initialize it before use.
Completes the changes in the commit:
"Replace COMBREL with just-in-time check in _rtld_relocate_nonplt_objects."
http://mail-index.netbsd.org/source-changes/2017/06/19/msg085496.html
2019-04-15 19:13:03 +00:00
maya
53dcb847d9 $ORIGIN support is now enabled.
Thanks martin for the heads up.
2019-04-15 10:17:01 +00:00
abhinav
55eec9d71a Typo: s/a indirection/an indirection/ 2019-04-15 06:42:06 +00:00
wiz
a30bc70869 Use more Dv. 2019-04-14 22:09:50 +00:00
maya
9a04775cfa Note that we now search DT_RUNPATH paths as well. 2019-04-14 20:27:02 +00:00
christos
fb007af046 undo previous unlock/relock; it is not needed now that we added the tls model
declaration to all externs in jemalloc (suggested by joerg@)
2019-04-14 19:21:37 +00:00
christos
15018ca013 Fix c++ exceptions on arm; jemalloc calls _rtld_tls_get_addr from inside
dl_iterate_phdr, so we need to unlock and relock.
2019-04-13 03:15:25 +00:00
rin
e66054b66e Do not compile __tls_get_addr() into ldd(1), which fixes ldd(1) crashing
on arm after switching to new jemalloc.

jemalloc invokes __tls_get_addr() under some condition. If anything other
than ld.elf_so nor libc exports it, inconsistency arises as a result.
2019-04-13 00:23:32 +00:00
christos
39fadeea40 Disable optimization for rtld.c on the vax with gcc-7. 2019-04-03 21:37:58 +00:00
skrll
69e8dca2e5 Adapt https://svnweb.freebsd.org/base?view=revision&revision=342113 to
NetBSD.

This brings us resolving for dynamically loaded libraries and makes
tests/libexec/ld.elf_so/t_thread_local_dtor pass.

With suggestions from joerg@
2019-01-18 11:59:03 +00:00
christos
d17b8a0ea7 print the program name when we don't find a library.
XXX: really most _rtld_error() should do that, and most do.
2019-01-12 18:58:10 +00:00
joerg
06c9aa1116 When loading a non-PIE main binary, the virtual address must match.
Use MAP_TRYFIXED and verify that the result matches the expectation.
2019-01-06 19:44:54 +00:00
joerg
08e505b543 MAP_ALIGNED has existed for years, just assume it exists. 2019-01-04 19:54:56 +00:00
martin
e4d02a93c7 Add support for DT_RUNPATH - it is just the same as we always have treated
DT_RPATH.  Approved by core.
2018-12-30 11:55:15 +00:00
christos
d30b19ef3d - fix wrong reloc name in assert
- fix uninitialized
2018-12-30 03:23:46 +00:00
christos
61268f23da binutils 2.31.1 can put copy relocations in the relro segment. Delay
protecting the relro segment for the main object until copy relocations
are done.
2018-12-30 01:48:37 +00:00
christos
2c62c57fa6 initfini array support for everyone. 2018-12-27 18:58:14 +00:00
christos
ba044c6310 explain why we skip objmain. 2018-12-27 18:57:43 +00:00
skrll
66b7511afb Fix typos 2018-12-01 13:01:57 +00:00
joerg
335f313f07 Now that lib/csu no longer uses the object handle, drop the magic and
version field from the internal object. It is kept in the legacy version
of the main object.
2018-11-26 17:40:26 +00:00
skrll
c7af211bee Fix RTLD_DEBUG_RELOC build 2018-11-23 11:26:05 +00:00
skrll
0d71550e67 Trailing whitespace 2018-11-23 10:59:20 +00:00
joerg
4312beab4f Move compatibility for pre-2.0 ELF binaries into separate file.
Early ELF binaries defined dlopen and friends in crt0.o by
using function pointers in the object handle passed from rtld.
This contract wastes space when many shared objects are allocated
and ties dynamic linker and rest of the system tightly together.
Fake the entry points in a static object and restrict them to the
platforms that had working ELF support at the time. Keep the magic and
version field used by modern crt0.o for all architectures. The checks
will be removed from crt0.o in a follow-up step.
2018-10-17 23:36:58 +00:00
jakllsch
3c05430e55 Revise previous to not deadlock. 2018-09-20 19:02:22 +00:00
jakllsch
df54aa978e Improve support for R_AARCH64_TLSDESC relocations.
In large part from FreeBSD.
2018-09-20 18:41:05 +00:00
joerg
da0b29937f Apply relocbase for tlsinit of the executable itself. Fixes PIE where
relocbase typically is not zero.

PR bin/53465
2018-07-24 13:48:48 +00:00
christos
8de0d28182 Initialize new_value to account for bogus return from the function. 2018-07-16 00:29:37 +00:00
christos
64715b9aa8 We can't build those three with MKSANITIZER, they are used too early. 2018-06-09 22:41:55 +00:00
christos
b5fd6cb2a8 rename flag to the official name. 2018-05-24 17:05:54 +00:00
joerg
f80c3669c3 Rework ifunc support to address a number of short comings:
- Move to a shared _rtld_call_ifunc for rel and rela architectures
- Architectures using rel format must patch IRELATIVE non-PLT
  relocations like RELATIVE in additition to the later ifunc handling
- Consistently record the delta to the end of the relocation group for
  non-PLT IRELATIVE relocations

Hidden ifunc is now supported on all ifunc platforms, even when using
-fno-plt. The combination of -fno-plt and relro is broken due to
incorrect GNU ld output though.
2018-04-03 21:10:27 +00:00
joerg
2d65afd272 Move the complex logic for dynamically writing branches from ld.elf_so
into a header for reuse in crt0.o for static ifunc support. Change the
existing logic for sparc64 to use the Bicc variant of ba,a as it allows
+-8MB displacement compared to the BPcc variant's +-1MB. Teach the sparc
variant the same trick for using ba,a and not sethi+jmp when possible.
2018-03-29 13:23:39 +00:00
joerg
033ffc4d89 Don't skip PLT processing for the main binary. It can still contain
ifunc references.
2018-03-25 18:56:01 +00:00
joerg
64156cbaf3 Like Sparc, PowerPC can use IRELATIVE relocations in non-PLT sections. 2018-03-09 20:19:11 +00:00
jakllsch
db546b38aa Wrap PowerPC #pragma goop in #if __GNUC_PREREQ__(6,0).
Our older GCC warns/errors on it.
2018-02-11 18:58:44 +00:00
mrg
1bf47496e9 update for GCC 6:
ignore -Wframe-address warnings for the ppc hack.
2018-02-07 06:17:45 +00:00
skrll
e958e889a2 Various fixes / changes from Ryo Shimizu / Toru Nishimura to make this
work.

_rtld_call_ifunc copied from other rela platforms by me - not tested in
any way.
2018-02-04 21:49:51 +00:00
christos
381da60e92 don't forget to eat the high bits. 2018-01-19 23:17:41 +00:00
joerg
e5e34a6c86 Since GNU ld doesn't honor the PLT entry reservation, also compensate
for JMP_IREL relocations at the start of the PLT.
2017-12-25 17:00:15 +00:00
maya
0a4e3118cb Fix typo in comment
from freebsd
2017-12-25 05:29:27 +00:00