Commit Graph

900 Commits

Author SHA1 Message Date
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 701e64b3a1 ld_so: Default to non-verbose 2020-03-29 20:17:29 -06: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 4860ab12fa Resolve Both strong and weak symbols
This patch keep 2 lists, one for strong symbols and one for weak
symbols. First it will check for the symbol to be resolved in the strong
symbols' list, if it is not there it will then check in the weak symbol
list.
2020-03-08 22:03:21 +02: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
Jeremy Soller 79f265745a Fix redox ld_so 2020-02-28 19:33:20 -07:00
oddcoder bc53164293 Reduce Verbosity level when ld.so is invoked as interpreter 2020-02-24 11:56:12 +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 76f07b163b platform/redox: Support AF_UNIX in accept.
As with the previous commit, accept() was calling inner_get_name() and
assuming only "tcp:" or "udp:" addresses would be received. Thus, in
order to support AF_UNIX sockets, inner_get_name() was split into two,
inner_af_inet() and inner_af_unix() - where the former keeps the
previous logic, dealing with "tcp:" and "udp:" addresses, and the latter
deals now with "chan:" addresses and filling in the sockaddr_un
appropriately.
2020-02-06 08:41:51 +00:00
Tiago Lam d36cd72788 platform/redox: Support AF_UNIX in bind / connect.
Previously, domain AF_INET was assumed while processing bind() /
connect(), which end up calling bind_or_connect!. Instead, match on the
domain type and process the path for AF_UNIX domains.
2020-02-06 08:41:48 +00:00
Tiago Lam 12f6ffd152 platform/redox: Support AF_UNIX in socket.
To add support for UNIX sockets (AF_UNIX), of SOCK_STREAM type, the
"chan:" scheme is used, which will be supportedby the ipcd running in
userspace.

Later commits add similar AF_UNIX support for the rest of the methods in
impl PalSocket.
2020-02-06 08:21:12 +00: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 9a449d4f6c Stub for SO_ERROR to fix curl 2020-01-21 20:29:26 -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 2cbc78f238 Add linker pointer 2019-12-18 21:15:00 -07:00
Jeremy Soller 36eb561128 Format 2019-12-18 20:01:48 -07:00
Jeremy Soller 086c8f6702 Allow running linker more than once 2019-12-17 21:35:47 -07:00
Jeremy Soller 0a06388d2a Store globals and mappings on Linker struct 2019-12-16 21:27:42 -07:00
Jeremy Soller b882ce527d Fix allocation of TLS masters if main image does not require TLS 2019-12-15 11:19:37 -07:00
Jeremy Soller 4818ad61ab Always zero mmap'd memory 2019-12-15 07:46:59 -07:00
Jeremy Soller 886f859bb9 Clear FPU registers before jumping to loaded program 2019-12-15 07:46:49 -07:00
Jeremy Soller 76798b7d6b Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2019-12-06 19:55:21 -07:00
Jeremy Soller fe3607d4e8 ld_so: Zero mapped memory and panic on unsupported relocation 2019-12-06 19:54:54 -07:00
Peter Limkilde Svendsen 74555698fb Handle infinity and NaN in printf 2019-12-05 01:37:17 +00:00
Jeremy Soller 8ba70792e9 Implement DTPOFF64 2019-12-01 13:47:06 -07:00
Jeremy Soller 2ac349d2d2 Add msync function and stub for Redox 2019-12-01 10:58:47 -07:00
Jeremy Soller e3ce41da79 Fix compilation on newer nightly 2019-11-29 18:05:31 -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
Xavier L'Heureux 5156a13b3e Add a test for futimens 2019-09-16 12:25:29 -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
Jeremy Soller d1d45ff00d Merge branch 'warning' into 'master'
Fix few warnings

See merge request redox-os/relibc!236
2019-09-15 19:31:08 +00:00
Xavier L'Heureux 30d3cd5c88 Fix the mkfifo call on Linux and add a test to avoid regression 2019-09-13 12:35:08 -04: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