Commit Graph

65 Commits

Author SHA1 Message Date
riastradh c73729f0bb t_dlinfo, t_rtld_r_debug: Audit ATF_REQUIRE/CHECK, sprinkle messages.
Make sure to use ATF_REQUIRE when the subsequent code doesn't work if
the check fails.
2023-11-24 17:40:20 +00:00
riastradh e441ef5517 rtld tests: Don't use RZ for dlinfo.
Use

	ATF_REQUIRE_EQ_MSG(dlinfo(...), 0, "dlinfo: %s", dlerror())

instead, in order to accurately report the error on failure.  RZ is
only for functions like pthread_create(3) that return zero on success
and errno(3) code on failure, but dlinfo returns -1 on failure and
sets dlerror() to report the nature of the error.
2023-11-24 17:40:09 +00:00
riastradh 3b7c09b692 ld.elf_so: Add some known-answer tests for hash functions.
Make sure the testing mechanism detects the traditional overflow bug.
2023-07-30 09:22:02 +00:00
riastradh d2876e0fc7 tests/libexec/ld.elf_so: Fix helper library makefiles.
1. Consolidate logic into a single helper.mk to reduce duplication.
2. Set NO* variables, not MK* variables which are reserved for user.
3. Avoid eager X!= in favour of lazy ${X:sh}.
4. Mark _g.a set list entries obsolete.  Never should've been built!

PR misc/57462
2023-07-05 22:42:46 +00:00
joerg 3caa8dc735 Fix interactions of initial-exec TLS model and dlopen
(1) If an initial-exec relocation was used for a non-local symbol
(i.e. the definition of the symbol is in a different DSO), the
computation of the static TLS offset used the wrong DSO.
This would effectively mean the wrong address was computed
(PR toolchain/50277, PR pkg/57445).

Fix this by forcing the computation of the correct DSO (the one defining
the symbol).

This code uses __UNCONST to avoid the vast interface changes for this
special case.

(2) If symbols from a DSO loaded via dlopen are used with both
global-dynamic/local-dynamic and initial-exec relocations AND
a initial-exec relocation was resolved first in a thread, a split brain
situation could exist where the dynamic relocations would use one memory
block (separate allocation) and the initial-exec relocations the static
per-thread TLS space.

(3) If the initial-exec relocation in (2) is seen after any thread has
already used a GD/LD allocation, bail out. Since IE relocations are used
only in the GOT, this will prevent the dlopen. This is a bit more
aggressive than necessary, but a full blown reference counting doesn't
seem to be justified.
2023-06-04 01:24:56 +00:00
lukem 58beaa2b43 adapt to ${CC_WNO_MAYBE_UNINITIALIZED}
Use ${CC_WNO_MAYBE_UNINITIALIZED} instead of
the older style more complex expressions.

Remove workarounds if they were for a specific
version of gcc < 10.
2023-06-03 21:31:45 +00:00
riastradh 067c5136b3 ld.elf_so: Test dynamic-then-static abuse via ctor.
XXX pullup-10
2023-06-02 19:09:11 +00:00
riastradh f4e534dd53 ld.elf_so: Test another edge case of mismatched TLS models.
One library defines a symbol and _doesn't_ use it, so it has no
indication of whether the symbol is for static TLS or dynamic TLS,
and then two other libraries use it in different ways.

XXX pullup-10
2023-06-02 19:08:48 +00:00
riastradh 4dedd5fc26 ld.elf_so: tls_extern dynamic_defabuse_eager must xfail differently.
If a symbol has already been resolved as dynamic TLS, any library
that tries to use it as static TLS cannot be dlopened.

XXX pullup-10
2023-06-02 19:08:01 +00:00
riastradh 98256cacf3 ld.elf_so: Separately test eager and lazy resolution of def tls ptr.
eager: before loading use library
lazy: after loading use library

XXX pullup-10
2023-06-01 23:47:24 +00:00
riastradh e04ffa379b ld.elf_so: Shorter test names.
No functional non-cosmetic change intended.

XXX pullup-10
2023-06-01 22:26:51 +00:00
riastradh 6b7ae3bea1 ld.elf_so: Test TLS abuse of static def, dynamic use and vice versa.
XXX pullup-10
2023-06-01 22:26:40 +00:00
riastradh bc9d9d1143 ld.elf_so: Factor out logic in TLS tests to make writing more easier.
No functional change intended.

XXX pullup-10
2023-06-01 22:24:52 +00:00
riastradh 05e97b5a42 ld.elf_so: Test extern dynamic TLS too.
XXX pullup-10
2023-06-01 20:50:18 +00:00
riastradh f4e155a450 ld.elf_so: Test variations on PR toolchain/50277.
XXX pullup-10
2023-06-01 20:48:30 +00:00
riastradh fca22ba5cb ld.elf_so: Nix inadvertently committed private test program. 2023-05-31 01:06:43 +00:00
riastradh 111bb99c35 ld.elf_so: Fix extern TLS test to match PR toolchain/50277.
Now it's actually testing the problem.
2023-05-31 00:46:11 +00:00
riastradh 12037d6a69 ld.elf_so: New test for extern initial-exec TLS, PR toolchain/50277.
XXX pullup-10
2023-05-31 00:18:44 +00:00
christos 546ccfe0da sort; it is the same list as in h_ifunc_static.c; perhaps it should be
a HAVE_ something?
2022-06-21 16:24:37 +00:00
skrll f927c76aaf Support ifunc on aarch64. The tests pass at least. 2022-06-21 06:52:17 +00:00
skrll 810da4c4dd Wrap long #if defined(...) || ... and sort. NFCI. 2022-06-21 06:47:37 +00:00
skrll 95e95a0b5c Whitespace 2022-06-13 19:49:33 +00:00
skrll f59dda2318 Trailing whitespace 2022-01-14 07:34:07 +00:00
christos 9f4fca625f Good bye oabi! Tested building earmv7hf. 2021-06-07 17:11:16 +00:00
christos bb9221f69f PR/56230: Don't try to use ifunc with arm and oabi 2021-06-04 15:37:48 +00:00
joerg ea1995c1a3 Drop explicit -msecure-plt, it's the default for both clang and gcc. 2021-05-30 02:26:51 +00:00
roy fd5c758a79 Whitespace 2020-09-29 16:35:42 +00:00
roy d76886af8e Fix build with clang. 2020-09-29 16:34:07 +00:00
kamil 8f03799314 Add new RTLD test file for r_debug
New tests:
 - self
 - dlopen

Both check whether the r_debug structure seems to be well-formed, without
and with a dlopen(3) call.
2020-09-22 01:09:32 +00:00
skrll bda3cfd2fc Disable attempt to use ifunc on hppa. It doesn't work and new binutils
throws a build error.
2020-05-05 20:47:14 +00:00
maya 36592171e1 return return atf_no_error() instead of 0 for consistency.
suggested by moritzbuhl in https://github.com/NetBSD/src/pull/11/
2019-07-09 16:24:01 +00:00
christos 292b510fe2 clang ifunc's on powerpc require secure-plt. 2019-05-14 19:07:07 +00:00
joerg d3d2a5f92e Avoid casting fun by switching ifunc helper functions to return
long long. Dead beef is too useful to switch to a different constant.
2018-03-09 20:15:03 +00:00
maya f076331dd4 Build less of the test code if there's no linker ifunc support.
r1.6 changed the code in such a way that it was hitting a BFD assert on
MIPS, causing the builds to fail.

we were hitting the assert at binutils/dist/bfd/elfxx-mips.c:10879
2018-01-01 06:34:13 +00:00
martin d2225bb82b Skip all tests on architectures w/o ifunc linker/ld.elf_so support. 2017-12-30 16:53:34 +00:00
joerg da03f1ef14 init/fini for the main program is handled by crt0.o, so ifunc handling
is skipped right now as it iterates the same list. Don't repeat that
mistake and explicitly take care of it in the dynamic linker.
2017-11-06 21:16:03 +00:00
joerg 610e531ea3 Add sparc/sparc64 support for irelative relocations. 2017-08-12 09:03:27 +00:00
joerg e78cfb8eb8 Add IRELATIVE support for ARM, X86 and PowerPC. 2017-08-10 19:03:25 +00:00
joerg df826237c7 Avoid a race condition between dlclose and thread termination. 2017-07-21 16:39:20 +00:00
joerg e5678be828 Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
2017-07-11 15:21:31 +00:00
christos c54cb81102 Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
2017-01-13 21:30:39 +00:00
joerg 6c18385369 Really revert to the original version. 2014-08-26 17:13:42 +00:00
joerg 497e202f2a Revert. There is no such thing as __HAVE_IFUNC and there should not be
one in first place.
2014-08-26 16:25:35 +00:00
christos 5a3404e066 effectively disable the test to fix the build and explain why. 2014-08-26 11:10:02 +00:00
joerg 7a1a6f1cf3 Add basic support for indirect functions. It allows providing a public
function symbol with an implementation choosen at run time.
Refactor calls to functions by address in ld.elf_so to create temporary
function descriptors on the stack, if the address is not leaked outside.

Limitations:
- no support for initialising static storage with function pointers
- no support for unnamed resolver functions

Inspired by FreeBSD's r228435 by kib@freebsd.org.
2014-08-25 20:40:52 +00:00
he f693807fd8 Fix static linking for the tests: -lrump is also used by -lrumpuser,
so we also need -lrump after -lrumpuser.  Fixes build for sun2.
2014-06-10 04:28:39 +00:00
joerg d0ebb0ebfa ARM now works with integrated-as. 2014-02-14 20:33:32 +00:00
joerg 1fd04761e2 Disable integrated-assembler for clang on ARM for two files that are
victims of the @ comment mess on that platform. Add a reference to the
upstream PR.
2013-12-25 22:26:35 +00:00
joerg 71d0bcc69f Introduce __HAVE_NO___THREAD for sun2 and vax to disable the TLS usage.
Require __HAVE_TLS_VARIANT_I or __HAVE_TLS_VARIANT_II as well as
__lwp_getprivate_fast / __lwp_gettcb_fast to exist for libpthread.
Define VAX as going to use TLS variant I, if it is ever implemented.
2012-01-17 20:34:57 +00:00
mrg 6520ba9809 avoid building stuff that depends upon pic objects if MKPIC == no. 2011-07-03 15:28:25 +00:00