Anhad Singh
01e6eda258
misc(dlfcn): cleanup
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-31 19:03:05 +11:00
Anhad Singh
42d884c6a3
fix(ld.so): errors UB
...
Currently, how ld.so errors are handled by functions in dlfcn is wrong.
dlopen calls `linker.load_library` which returns a
`Result<ObjectHandler, goblin::Error>`. Now `goblin::Error` may have
variants that are heap allocated. For example:
`Error::Malformed(format!("invalid path: '{}': {}", path, err))`. The
error string would be allocated by ld.so's allocator but will be dropped
inside libc. This is UB.
After this patch, we now return a custom `DlError` instead. To get more
information about the error, `LD_DEBUG=all` can be set.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-31 18:35:20 +11:00
Anhad Singh
9cf72fd0b2
feat(ld.so): add all option for LD_DEBUG
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-31 18:00:45 +11:00
Anhad Singh
60f700fb50
chore(linker): remove todo
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-31 15:26:23 +11:00
Anhad Singh
c25292ae21
misc(ld.so): clippy fixes
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-31 15:25:40 +11:00
Anhad Singh
cfe89f828a
feat: rwlock instead of mutex for global scope
...
* Rwlock -> InnerRwLock
* RwLock makes use of InnerRwLock.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-31 00:54:52 +11:00
Anhad Singh
2be4316aec
feat(dlfcn): return DSO as the handle
...
Fine because:
> The value of this handle should not be interpreted in any way by the
> caller.
From: https://pubs.opengroup.org/onlinepubs/009696599/functions/dlopen.html
* Add tests for unload
* Implement NOLOAD so we can test that the loaded object has been
destroyed.
* Minor cleanup.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-25 16:17:51 +11:00
Anhad Singh
1612c78774
fix(ld.so): disable lazy binding on non-x86_64
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
023a005688
fix(ld.so): non-pie lazy
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
1db68ab978
feat(ld.so): scopes
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
13d819ac89
misc(ld.so: __plt_resolve_inner): println -> trace
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
e3587017f6
fix(ld.so): stub plt stub for non-x86_64
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
0a0ecb018f
fix(ld.so: adjust_stack): remove dead code
...
Does not do anything.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
c6fd0517ac
feat(ld.so: config): handle LD_BIND_NOW
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
5ae1b8e974
feat(ld.so): lazy binding
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
30970e111a
feat(ld.so): enable warnings just for ld.so
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
959982b8a4
fix(ld.so): use Strtab::get_at()
...
> use of deprecated method `goblin::strtab::Strtab::<'a>::get`: Bad performance, use get_at() instead
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
cc5e0ceebc
fix(ld.so): function signature
...
No longer expects a self TLS.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
eb82f9afeb
misc(lint): unused variables and imports
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
500848bc76
fix(ld.so): remove unreachable loop {}
...
_exit() is noreturn
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-24 20:51:53 +11:00
Anhad Singh
39c8cc864d
fix(ci): formatting
...
Was my fault.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-17 03:14:33 +11:00
Anhad Singh
de9e8a6177
feat(ld.so): config
...
Currently supported options are `LD_DEBUG` and `LD_LIBRARY_PATH`.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-17 01:07:17 +11:00
Anhad Singh
9928091aad
fix(ci)
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-12 16:11:42 +11:00
Anhad Singh
d3bab6eeee
fix(redox: ld.so): unmap old TCB
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-12 16:00:11 +11:00
Anhad Singh
8c1722d583
fix(ld.so): redox
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-11 16:51:51 +11:00
Anhad Singh
de00d6c6b9
fix(ld.so): temporary fix
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-05 23:34:16 +11:00
Anhad Singh
32077ee341
fix(ld.so): set tls module id to 0 if no tls
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-05 23:33:41 +11:00
Anhad Singh
c286ad2868
fix(ld.so): do not depend on TLS at all
...
In the next big refactor (next PR), all of the platform functionality
used by both relibc and ld.so will be moved into a `platform`/`sysdeps`
crate and then ld.so would be moved out of relibc and not link with it.
I think doing it in a seperate PR would make it more managable, as when
I did half of it, the diff was pretty huge and that way it would be
easier to review too :)
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-05 23:11:59 +11:00
Anhad Singh
55ba8d8f6b
misc(load_objs_recursive): do not add empty masters
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-05 15:00:35 +11:00
Anhad Singh
1c846f8013
fix comment
...
x86 and x86_64 are below TP and others are above TP
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-12-05 15:00:35 +11:00
Anhad Singh
f6fa4e8246
feat(ld_so): setup sighandler
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-11-30 00:02:33 +11:00
Anhad Singh
e9f3147e3b
fix(tcb): do not use Vec::from_raw_parts
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-11-29 20:55:02 +11:00
Anhad Singh
1a7726541a
fix TCB and TLS
...
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-11-29 18:40:16 +11:00
Anhad Singh
c88eb3d5d0
Revert "fix(linker): deref uninit TCB"
...
This reverts commit 37dbf5cbb2 .
2024-11-29 00:03:09 +11:00
Anhad Singh
37dbf5cbb2
fix(linker): deref uninit TCB
...
The bug is described for `x86_64` and Linux but is the same for other architectures and on Redox.
`Tcb::current()` is used to retrieve the current TCB, which is done by by reading `fs:[0x10]`. The TCB layout describes that at offset `0x10`, there is `tcb_ptr: *mut GenericTcb<...>`, which is nothing more but a pointer to itself.
This is fine as otherwise a system call would be required to get the TCB (`arch_prctl(ARCH_GET_FS)` on Linux).
However, this is problematic as the function may be called when the FS base is not set, and in that case the expected output of the function should be [`None`], but we don't currently handle that.
To fix this, any code paths that maybe call this function on an uninitialized TCB are be switched to call `current_slow()`. Which just uses `arch_prctl(ARCH_GET_FS)` to get the FS base and check if it's non-zero.
Signed-off-by: Anhad Singh <andypython@protonmail.com >
2024-11-25 16:09:06 +11:00
Peter Limkilde Svendsen
06fec0b843
Add various basic docstrings
2024-10-27 23:25:57 +01:00
Andrey Turkin
a4122753e6
Initial RISC-V64 support
2024-10-11 06:44:54 +03:00
4lDO2
57f098931a
Remove ld.so's now unnecessary access() wrapper.
2024-09-30 16:55:27 +02:00
4lDO2
f6761407e5
Pass si_pid to all realtime signals.
2024-09-24 19:34:51 +02:00
bjorn3
49c708f537
Remove all uses of the legacy scheme syntax"
2024-08-04 13:49:10 +02:00
4lDO2
c286dd6d33
Use new-thread proc API
2024-07-18 23:59:47 +02:00
4lDO2
f37bb3cb16
Fix sigaction test on Linux, and rustfmt.
2024-07-09 15:00:55 +02:00
4lDO2
0ea2b5d45f
Fix compilation on Linux.
2024-07-09 15:00:55 +02:00
4lDO2
42c24dd755
Successfully run more userspace.
2024-07-09 15:00:53 +02:00
4lDO2
4e93f68324
Implement hack to ensure TCB exists in bootstrap.
2024-07-09 15:00:53 +02:00
4lDO2
58d1153536
Split part of TCB into generic-rt
2024-07-09 15:00:53 +02:00
4lDO2
edfe46c60b
Write x86-64 signal trampoline asm stub.
2024-07-09 15:00:52 +02:00
4lDO2
5177ca3926
Remove memoffset dependency.
2024-07-09 15:00:52 +02:00
4lDO2
53ed7aae59
Move rlct_clone, sigprocmask, sigaction, to rt.
2024-07-09 15:00:52 +02:00
4lDO2
4c11b607de
Implement pread and pwrite using the syscalls.
2024-06-14 14:10:47 +02:00