Commit Graph

246 Commits

Author SHA1 Message Date
Anhad Singh aa86e9e027 fix(riscv64/x86): build
Stub `__tlsdesc_dynamic` for riscv64/x86 for now.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-10 13:52:37 +11:00
Anhad Singh 64d3793190 fix(ld_so): page faulting when library not found
The error handling was already in place. The reason it was page faulting
is that, on failure, the function exits as soon as it encounters an
`Err` variant. When that happens, the DSO object for which the
dependency was being loaded is dropped. Dropping it calls `munmap` to
unload the executable and also runs the functions in `.fini`. However,
`run_fini` should only be called if the `DSO` is being unloaded after it
has been successfully loaded (i.e. all dependencies were satisfied and
all init functions had run).

Closes #1599

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-10 13:24:53 +11:00
Anhad Singh 8572c855fc feat(ld_so/dso): TLSDESC
The dynamic linker now works on aarch64. You can also try it on Linux by
setting `TEST_RUNNER` to `qemu-aarch64` when running `make test
TARGET=aarch64-unknown-linux-gnu`

Co-authored-by: @willnode
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-09 22:28:39 +11:00
Anhad Singh 4f1920ab96 feat(ld_so/tcb): implement os_arch_activate for aarch64 linux
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:07 +11:00
Anhad Singh 6262c4ae50 fix(ld_so): getting TP on linux
`ARCH_GET_FS` is x86_64 specific. On aarch64 it is not platform
specific and just need to read out the TP from `TPIDR_EL0`

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:46:07 +11:00
Jeremy Soller 0844e6fc90 WIP: use upper fd table 2025-11-15 07:55:37 -07:00
Jeremy Soller 74e3ad1c2c Do TLS alignment in reliable way 2025-11-13 12:07:06 -07:00
Jeremy Soller c4050203e8 Revert "Align TLS to 16 bytes again"
This reverts commit 860a8e6e4b.
2025-11-13 08:16:22 -07:00
Jeremy Soller 860a8e6e4b Align TLS to 16 bytes again 2025-11-10 17:05:57 -07:00
Jeremy Soller cb0acf3e57 Revert "Make sure TLS modules are aligned to 16 bytes for SSE"
This reverts commit d39fe6c9fb.
2025-11-01 10:44:34 -06:00
Wildan M abdfd3d0ac Fix ld_so multiple objects loading the same object 2025-10-29 15:46:35 +07:00
Wildan M ab8021fdbe Expose PIE information with LD_DEBUG 2025-10-06 12:53:22 +07:00
bjorn3 70487a2555 Fix compilation on arm64 2025-10-05 19:42:21 +02:00
Josh Megnauth e39b27664f unsafe_op_in_unsafe_fn: ld_so, generic/redox-rt
There are a few functions where I allowed the lint. The lower level and
FFI nature of relibc means that there are areas with a lot of unsafe.
Some functions are basically long blocks of unsafe or contain lots of
small blocks of unsafe. unsafe_op_in_unsafe_fn doesn't add clarity to
these functions. Instead, it reduces readability by adding an indent or
small "unsafe { .. }" clutter.
2025-10-04 21:36:51 -04:00
Jeremy Soller ced734c162 Add RawCell::unsafe_set 2025-10-04 07:50:16 -06:00
Jeremy Soller 82084440ad Support nightly-2025-10-03 2025-10-03 21:51:10 -06:00
Jeremy Soller d39fe6c9fb Make sure TLS modules are aligned to 16 bytes for SSE 2025-09-29 17:08:51 -06:00
Jacob Lorentzon 9c5f11fbc8 Add Out<T> wrapper 2025-09-21 14:36:12 +02:00
Wildan M b541ee43be Change PATH separator to double colon 2025-09-19 21:48:38 +07:00
elle a5c41f77d0 ld_so: remove access dead code 2025-09-08 21:03:27 +00:00
elle 5d77f617f5 ld_so: use mutex for _r_debug
Uses a `spin::Mutex` for the global static `_r_debug` instance to remove
warning about a global mutable static.

Guarantees exclusive mutable access to the `_r_debug` variable.
2025-09-08 20:23:36 +00:00
elle 09015a218e ld_so: remove unsafe transmute in mmap_and_copy
Refactors casting the `raw` address as a byte array to use idiomatic
Rust APIs instead of the unsafe call to `transmute`.
2025-09-08 20:23:36 +00:00
Wildan Mubarok c7a1966a67 Fix trace feature 2025-08-08 23:41:07 +00:00
Jeremy Soller 84bbf90ce1 Fix ___tls_get_addr on x86 2025-07-03 10:52:46 -06:00
Jeremy Soller 0bd38ac2ad Fix DTPMOD relocation 2025-05-09 10:06:06 -06:00
Jeremy Soller b887ad1ce6 Fix DTPOFF relocation 2025-05-07 21:04:31 -06:00
Jeremy Soller 0b1133a965 ld_so: do relocations before TLS 2025-05-07 16:27:00 -06:00
Jeremy Soller 4daade9721 log where unresolved symbol was required 2025-05-07 10:38:21 -06:00
Jeremy Soller 2b06118d5f Fix deadlock when logging scopes 2025-05-06 21:50:38 -06:00
Jeremy Soller 78bab94ee0 Add end of dynamic library mapping to debug messages 2025-05-06 20:45:39 -06:00
4lDO2 e6c06a7cf7 Fix signals for spawned threads, and async signal waiting. 2025-04-19 19:27:03 +02:00
4lDO2 59090a83f4 Fix thread+proc fd init in ld.so 2025-04-19 19:26:59 +02:00
4lDO2 779c1e60c5 Add todo!() to fix compilation. 2025-04-19 19:26:58 +02:00
4lDO2 ad5efd0f11 Reach init fork 2025-04-19 19:26:57 +02:00
Anhad Singh c64058c8b7 tcb: aarch64 2025-04-20 02:41:35 +10:00
Jeremy Soller 228d53dcd5 More improvements for relocation handling 2025-04-18 16:03:09 -06:00
Jeremy Soller 03f863d742 ld_so: better support for other arches 2025-04-18 14:26:39 -06:00
Jeremy Soller 310b097da6 Fix check for Sym size 2025-04-18 12:39:27 -06:00
Josh Megnauth 51c04d2470 Use C string literals & deprecate c_str! 2025-03-14 21:17:53 -04:00
Jeremy Soller da174f9626 Fixes for 32-bit builds 2025-02-07 09:18:56 -07:00
Anhad Singh d3073fdad4 feat(ld.so): more debug info for scopes
When scopes is set for `LD_DEBUG`, more debug information is displayed
now,

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-19 00:11:51 +11:00
Anhad Singh 99449094d4 chore: formatting
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-19 00:03:07 +11:00
Anhad Singh 4a08220664 fix(ld.so): copy relocations
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-18 23:51:53 +11:00
Anhad Singh e3dc5d0617 chore(dso): remove unused members
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-18 21:20:10 +11:00
Anhad Singh 3440985729 fix(dso): 32-bit
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-15 21:32:40 +11:00
Anhad Singh 07ff79069e feat(ld.so): add support for DT_RELR
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-15 13:49:27 +11:00
Jeremy Soller a3c12e27e4 Fix build for i686 2025-01-14 18:01:26 -07:00
Anhad Singh b9e0505715 fix(ld.so): less locks
Acquire the global scope lock at the start of relocate.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-01-13 23:48:03 +11:00
Jeremy Soller af50d18d16 Return error instead of panic when load_library cannot find root DSO 2025-01-09 13:33:29 -07:00
Jeremy Soller 02520b194e Fix compilation with trace feature 2025-01-09 12:23:23 -07:00