Commit Graph

350 Commits

Author SHA1 Message Date
Jeremy Soller c7910a8754 Add __need_winit_t to wctype.h 2020-05-28 13:43:55 -06:00
Peter Limkilde Svendsen da8d2fa7aa Always set memptr in posix_memalign() 2020-05-24 18:29:57 +02:00
Peter Limkilde Svendsen 60b23003c7 Simplify alignment check in posix_memalign() 2020-05-24 18:17:27 +02:00
oddcoder ee5e2bad5a Support negative padding size in printf and friends
as it seams you can do something like
        printf ("A%*s%s/\n", -5, "B", "CC");
and it will print the padding to the left
2020-05-23 16:20:20 +02:00
oddcoder d7d3e00867 Fix off-by-1 error in vfscanf
Scanf function requires look ahead to function properly, In case of
scanning from a buffer that will not be an issue, but in our case we are
reading from file, so lookaheads needs to be undone (via lseek) in our
case. The only problem here is that if we opened a file that doesn't
support lseek such as many of the file /dev/*
2020-05-23 16:20:20 +02:00
oddcoder 1733b3da6e Fix bug related to ungetc and ftell()
At least in relibc, each call to ungetc should decrement ftell() by one
also allowing negative ftell() this is not possible on relibc thus gcc
failing to compile (gcc compiles tools that is later used to compile gcc
itself and these tools are the ones that fail)
2020-05-23 16:20:20 +02:00
oddcoder 7a6f96373e Add support for multiple unget at the same time
According to the standards, only one ungetc may be guaranteed however
glibc allows more than one of those, and to be glibc compatiable, one
needs to be able to do the same, allowing only 1 ungetc may trigger bug
while compiling gcc as ungetc is used there alot
2020-05-23 16:20:20 +02:00
Jeremy Soller 0cc0fbecdc Export getrandom function 2020-05-22 15:49:51 -06:00
Jeremy Soller a6fffd3fb5 Add getrandom and sys/random.h 2020-05-22 11:50:54 -06:00
oddcoder 4a47bc4a6f Fix regressing in printf padding with space
There was bug in printf where space paddings cause segfault,
the problem was that it was pulled from the stack twice while it should
be only done once.
2020-05-08 22:38:42 +02:00
oddcoder eac69c920d Implement wcscasecmp and wcsncasecmp
This patch implements wcscasecmp and wcsncasecmp. These two
function are required for binutils to link against relibc.
2020-04-26 19:13:03 +02:00
oddcoder 162999ac0b Move towlower and towupper to wctype.h and Implement it
This patch creates wctype.h and impelementat two functions
that belong to that header file towupper and towlower. These
functions are building blocks for wcscasecmp and wcsncasecmp
which are utilized by binutils.

The implementation for towlower and towupper seams to be complex
so this implementation is mimicking that of musl libc
2020-04-26 19:13:03 +02:00
oddcoder 3a923aa62d Implement #include<sys/user.h> and #include<sys/procfs.h>
This patch implements sys/user.h file that works for both x86_64 as well
as aarch64. This include file is used by sys/procfs.h which is needed
dependency for binutils. There is bug in this patch in aarch64 implementation
which is the lack of f128 implementation in rust, thus we can't create cbinding
for long double.
2020-04-24 22:08:49 +02:00
oddcoder 6aeb2d6fa2 Implement code that use .init_array and .fini_array
This patch implements ld.so code that makes use of both .init_array and
.fini_array. .init_array is fully utilized and is used in the correct
manner. However .fini_array is not used yet although the function that
runs .fini_array exists
2020-04-19 14:21:23 +02:00
Graham MacDonald 2283e25cde sigaction should set sigaction.sa_restorer 2020-04-14 23:37:54 +01:00
oddcoder cc305fc574 Use Kernel mapped binaries when available.
At least in linux kernel, assuming that a.out is an elf that is linked
against relibc's own ld.so. When a user attempts `./a.out`, Linux kernel
will map `./a.out`, then map `ld.so` and jump into ld.so entry point.
In relibc ld.so will simply ignore the kernel mapped a.out and create
its own mapping. This patch forces relic ld.so to use the already mapped
`a.out` when ever possible. This would normally have slight performance
improvement (especially that currently relibc doesn't map a.out but
instead copy the data into empty mmaped memory).

The real motivation behind this patch is while impelemnting Runtime
linker debugging protocol for relibc. part of the protocol is ld.so
inseting address of some ld.so managed data structure into .dynamic
seciton of a.out then the debugger would check it there. The thing is
that debuggers have information about the kernel loaded ./a.out and they
check that one specifically which is in our case totally ignored by
relibc.
2020-04-07 21:26:58 +02:00
Jeremy Soller 6ed37efaeb Merge branch 'weak-symbols' into 'master'
Weak symbols

See merge request redox-os/relibc!260
2020-03-19 17:56:22 +00:00
Jeremy Soller 2e27cf525e Work on adding cargo test capability 2020-03-10 20:57:07 -06:00
oddcoder c2488b5094 Running ./fmt.sh
These files needs formating by the auto formatter and It keeps popping
up every time I format my own code.
2020-03-07 23:52:27 +02:00
oddcoder 04ea2f9397 Refactor Linker::Link
This patch does basically two things:
- First make `global` variable not public, And make it accessable via a
function `get_sym`.
- Isolate the procedure that collect global symbols into single function
that does that and call it `collect_syms`.

The motivation of this patch is the second one where this procedure is
extended, thus it needs a seamless way to access those symbols
2020-03-07 23:52:27 +02:00
oddcoder 7f8dc2f251 Add support for invoking ld.so via execve() and friends
Introduction:

The original implementation of `relibc_ld_so_start` assumes that
ld.so will always be invoked manually as in "/lib/ld64.so ./a.out"
The problem is regarding this snippet.
    if sp.argc < 2 {
      eprintln!("ld.so [executable] [arguments...]");
      unistd::_exit(1);
      loop {}
    }

As such, In linux when user types "./a.out" he will recieve the message
    ld.so [executable] [arguments...]

This patch makes use of AUXV, specifically AT_ENTRY. When invoking ld.so
manually, AT_ENTRY happens to be the entry point of ld.so. But when
running `./a.out` directly, AT_ENTRY becomes the entry point of `a.out`
this patch compares AT_ENTRY to the entry point of ld.so, if they are
equal only then it will assume that argv[1] is the real program and
adjust the stack, otherwise it will proceed with the stack unadjusted.
2020-02-24 11:56:09 +02:00
Tiago Lam 2bc667f71c header/sys_un: Set sockaddr_un members to public.
Future commits will make use of this, in order to support AF_UNIX
sockets.
2020-02-06 08:21:12 +00:00
Jeremy Soller 662051a91b Only call epoll_ctl once per descriptor, fixing vim on Redox 2020-01-28 20:15:01 -07:00
Jeremy Soller 4c4ce7ec03 Add Redox termios definitions 2020-01-27 21:01:59 -07:00
Jeremy Soller 2e5d4a4d25 Merge remote-tracking branch 'origin/truncate-n-mkfifo' 2020-01-20 11:17:15 -07:00
Peter Limkilde Svendsen 0b4b3cd55c Use lossless type conversion in ctype.h 2020-01-20 17:57:56 +00:00
AdminXVII 884ec85838 Replace occurences of uninitialized with MaybeUninit
mem::uninitialized is deprecated, so move over the not-UB MaybeUninit.
2020-01-20 16:54:22 +00:00
Jeremy Soller a3f7a174f6 WIP - implementation of dlfcn 2019-12-18 21:21:25 -07:00
Jeremy Soller 36eb561128 Format 2019-12-18 20:01:48 -07:00
Peter Limkilde Svendsen 74555698fb Handle infinity and NaN in printf 2019-12-05 01:37:17 +00:00
Jeremy Soller 2ac349d2d2 Add msync function and stub for Redox 2019-12-01 10:58:47 -07:00
Andrzej J. Skalski 278a70c813 added ctime_r 2019-11-28 02:41:58 +00:00
Peter Limkilde Svendsen 0b2c3fe5ea Implement wcsstr(), fix return type of wcslen() 2019-11-14 02:46:53 +00:00
Jeremy Soller ae69586f20 Implement getrlimit on Linux and stub on Redox 2019-09-18 20:29:25 -06:00
Jeremy Soller 46a330ec9e Fix compilation of sys/resource 2019-09-18 15:55:27 -06:00
Xavier L'Heureux e8b8b7eb25 Fix format and disable stat check for access time 2019-09-17 21:23:07 -04:00
Xavier L'Heureux 64f93fe6e0 Implement the truncate function 2019-09-17 19:57:43 -04:00
Jeremy Soller 64dde1548c Merge branch 'patch-2' into 'master'
sys/uio.h: include sys/types.h

See merge request redox-os/relibc!244
2019-09-15 19:34:43 +00:00
Peter Limkilde Svendsen 7fdd450e16 lcg48 refactor 2019-09-15 19:34:12 +00:00
Peter Limkilde Svendsen a80ec357e3 Refactor of a64l and l64a 2019-09-15 19:33:29 +00:00
Matija Skala 81470916be sys/uio.h: include sys/types.h
needed for ssize_t
2019-09-08 08:36:22 +00:00
Steve McKay 4859c222e7 Make program_invocation_name modifiable
libiconv expects program_invocation_name to be an lvalue
2019-08-17 12:35:43 -04:00
jD91mZM2 4f2a93ea90 Vast refactor of pwd.h, add getpwent/setpwent/endpwent 2019-08-12 09:58:11 +02:00
jD91mZM2 aeab6a986d Fix a few GDB compilation issues 2019-08-12 09:30:05 +02:00
Xavier L'Heureux 5799555566 Remove print statements 2019-08-11 21:53:32 -04:00
Xavier L'Heureux 0a558de76c Fix reference getting moved
The sigaction handler called map on an option, creating a pointer to a
move value. This in turned caused UB for signal handlers. Avoid using
pointers directly, and instead prefer references.
2019-08-11 20:47:18 -04:00
Xavier L'Heureux 225583230f Test 2019-08-11 18:11:19 -04:00
Jeremy Soller e7d19e2a58 Move SIG_IGN and friends to C in order to define them correctly 2019-08-08 20:06:38 -06:00
jD91mZM2 b8c50c7c64 Format 2019-08-04 19:05:45 +02:00
jD91mZM2 c7d499d4f2 Upgrade to the 2018 edition
I didn't think it'd be this useful first, but thank god for `cargo fix --edition`!
2019-08-04 19:05:45 +02:00