Commit Graph

2505 Commits

Author SHA1 Message Date
gugz0r e96eb6dac6 Fix formatting issues detected by rustfmt. 2024-12-18 23:11:02 +01:00
gugz0r 6fc19f8fdf Add tests and improve comments. 2024-12-18 22:59:36 +01:00
gugz0r a4cd089189 Implement 'tar.h' 2024-12-18 22:11:33 +01:00
Jeremy Soller 6fdcd4f44a Merge branch 'unsafe_blocks-getopt-grp' into 'master'
Unsafe blocks: `getopt.h`, `grp.h`

See merge request redox-os/relibc!580
2024-12-15 14:34:38 +00:00
Jeremy Soller 444bb5b485 Merge branch 'glob' into 'master'
Implement `glob.h`

See merge request redox-os/relibc!579
2024-12-15 14:32:11 +00:00
Jeremy Soller 0da7e3befb Merge branch 'unsafe_blocks-fcntl-fnmatch' into 'master'
Unsafe blocks: `fcntl.h`, `fnmatch.h`

See merge request redox-os/relibc!578
2024-12-13 14:38:48 +00:00
Jeremy Soller 15de4e67c5 Merge branch 'redox_dynlink' into 'master'
fix(ld.so): redox

See merge request redox-os/relibc!577
2024-12-13 14:13:11 +00:00
Josh Megnauth 14988e33b2 Unsafe blocks: getopt.h, grp.h 2024-12-13 01:20:24 -05:00
bitstr0m 5d6ae507e1 Implement glob.h 2024-12-12 15:17:16 +00: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 20b9af633d chore: bump redox_syscall
Bumps redox_syscall to 0.5.8

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-12 13:50:04 +11:00
Jeremy Soller a04870d1f3 Merge branch 'devel' into 'master'
feat(dbg): lift the latest version

See merge request redox-os/relibc!576
2024-12-11 13:49:40 +00:00
Josh Megnauth 624947211a Unsafe blocks: fcntl.h, fnmatch.h 2024-12-11 01:56:30 -05:00
Anhad Singh 8c1722d583 fix(ld.so): redox
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-11 16:51:51 +11:00
Jeremy Soller 76f1a4c0a8 Merge branch 'unsafe_blocks-dlfcn-dl_tls' into 'master'
Unsafe blocks: `dl-tls`, `dlfcn`

See merge request redox-os/relibc!575
2024-12-10 14:49:31 +00:00
Anhad Singh 064c7c31c5 feat(dbg): lift the latest version
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-10 22:15:11 +11:00
Josh Megnauth a7cb1c4176 Unsafe blocks: dl-tls, dlfcn 2024-12-10 02:13:32 -05:00
Jeremy Soller dfb71665be Merge branch 'dirent-unsafe_op_in_unsafe_fn' into 'master'
Use unsafe blocks in `dirint.h`

See merge request redox-os/relibc!574
2024-12-09 12:56:51 +00:00
Jeremy Soller 0dd6e27597 Merge branch 'dynamic_linker' into 'master'
fix(ld_so): for Linux

See merge request redox-os/relibc!570
2024-12-09 12:56:04 +00:00
Josh Megnauth 1642c1e1bc Use unsafe blocks in dirint.h 2024-12-08 01:54:55 -05: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 e34ecc31a1 Revert "feat(redox_rt): map PT_TLS"
This reverts commit 4b959776e0.
2024-12-05 23:12:32 +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 a527cc53ea tests(pthread): status must be 0 if not leader
Fix CI break.

man pthread_barrier_wait(3)
> ...the constant PTHREAD_BARRIER_SERIAL_THREAD shall be returned to
> one *unspecified* thread and zero shall be  returned  to  each  of  the  remaining
> threads.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-05 16:24:10 +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 d8f7590848 fix(__tls_get_addr): NULL check
Has to be done before adding the offsets.

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 43301848b9 Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Andrey Turkin <andrey.turkin+redox@gmail.com>
2024-12-05 02:55:34 +00:00
Jeremy Soller 6d94805cda Merge branch 'fix-glib-netinet-in' into 'master'
Impl `sockaddr_storage`, structs in `netinet.h`

See merge request redox-os/relibc!573
2024-12-03 21:45:47 +00:00
Josh Megnauth 6295ce73ea Impl sockaddr_storage, structs in netinet.h 2024-12-03 21:45:47 +00:00
Jeremy Soller 618954dd39 Merge branch 'add-stdnoreturn-h' into 'master'
Add `stdnoreturn.h`

See merge request redox-os/relibc!572
2024-12-03 21:41:59 +00:00
Jeremy Soller 98aa4ea57c Merge branch 'fix-200-round_up_to_page_size-overflow' into 'master'
fix: `round_up_to_page_size` overflow

Closes #200

See merge request redox-os/relibc!569
2024-12-03 21:41:36 +00:00
Jeremy Soller 366c036a3a Merge branch 'all-posix-headers' into 'master'
Add TODOs for remaining POSIX headers

See merge request redox-os/relibc!571
2024-12-03 21:41:07 +00:00
Anhad Singh 4b959776e0 feat(redox_rt): map PT_TLS
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-30 00:02:52 +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
Josh Megnauth 96de114be8 Add stdnoreturn.h
This header is more or less the same across libc implementations.

`musl` uses its `_Noreturn` macro to detect which `noreturn`
should be used: C11 or GCC's extension as a fallback.

`glibc` simply defines `noreturn` as `_Noreturn`.

This implementation is based off of `musl`'s.

`_Noreturn` is deprecated as of C23.
2024-11-27 01:25:53 -05:00
Peter Limkilde Svendsen 5045d40fa2 Add TODOs for remaining POSIX headers 2024-11-26 22:02:42 +01:00
Anhad Singh e8e6b8cbc5 fix(expected): dynamic bins
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-26 19:51:06 +11:00
Anhad Singh cdb4843164 fix(tests): fix UB in mk{fifo,nod,nodat}
Memory chunk is allocated with `malloc` and used as the `dest` buffer
for `strncat`. The `dest` argument in `strncat` has to be NUL terminated,
however it was not.

This commit fixes this issue in mk{fifo,nod,noat}.c.

Almost all dynamic tests pass now.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-26 16:56:05 +11:00
Josh Megnauth 6ec03b6f4a fix: round_up_to_page_size overflow
Closes: #200

The spec doesn't define which error code to set if `len` is too large.
`ENOMEM` is the closest defined condition that fits:

>> [...] the range [addr,addr+len) exceeds that allowed for the address
space of a process [...]

Logically, `len` would lead to `addr` exceeding the address space of a
process if rounding it up to the next page size causes an overflow.
2024-11-26 00:37:12 -05:00
Anhad Singh 22bbdb025c misc(tests): fix compilation of dlfcn.c
From man dlopen(3)
> According to the ISO C standard, casting between function
> pointers and 'void *', as done above, produces undefined results.
> POSIX.1-2001 and POSIX.1-2008 accepted this state of affairs and
> proposed the following workaround:
>
>   *(void **) (&cosine) = dlsym(handle, "cos");
>
> This (clumsy) cast conforms with the ISO C standard and will
> avoid any compiler warnings.
>
> The 2013 Technical Corrigendum 1 to POSIX.1-2008 improved matters
> by requiring that conforming implementations support casting
> 'void *' to a function pointer.  Nevertheless, some compilers
> (e.g., gcc with the '-pedantic' option) may complain about the
> cast used in this program.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 18:00:03 +11:00
Anhad Singh 6020c54ce7 chore(test): add expected outputs for dynamic tests
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 16:16:07 +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
Anhad Singh 00746c2566 misc(tests): disable dlfcn test for now
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 12:31:33 +11:00
Anhad Singh b9bef59d8a fix(libc.so): link with libgcc
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 12:20:32 +11:00