Commit Graph

1381 Commits

Author SHA1 Message Date
Jeremy Soller a6fffd3fb5 Add getrandom and sys/random.h 2020-05-22 11:50:54 -06:00
Jeremy Soller 2cf3ccae72 Fix import of user_regs_struct 2020-05-21 20:01:47 -06:00
Jeremy Soller a1034b697d Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2020-05-21 14:59:41 -06:00
Jeremy Soller 06429ccc4c Fix redox socket inner_get_name 2020-05-21 14:59:22 -06:00
Jeremy Soller f6a119d3fc Merge branch 'binutils_regressions' into 'master'
Binutils regressions

See merge request redox-os/relibc!269
2020-05-13 22:02:31 +00:00
oddcoder 43fbaf9970 Fix a bug in thread local reloations
There was a bug (also uncovered via binutils) where R_X86_64_DTPOFF64 is
set uncorrectly. This program is the minimal reproducer of the seg fault

  #include <errno.h>
  int main() {
        int oerrno = errno;
  }

But it works after the bug fix.
2020-05-13 23:46:39 +02:00
oddcoder a39447e6a4 Test printf space padding regression 2020-05-08 22:38:42 +02:00
oddcoder d373bcb032 Avoid accessing memory without initialization 2020-05-08 22:38:42 +02: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 d62f9b6819 Fix regression in ld.so elf size calculation
In patch 1182d12006, I mistakingly added
the size of the gap to the total size of the binary, which was not
accurate. As the size of the binary was calculate by subtracting the
upperbound from the lower bound, thus all gaps in the middle are taking
into account.
2020-05-08 22:38:42 +02:00
Jeremy Soller 8b7c45b39e Merge branch 'ld.so_regressions' into 'master'
Ld.so regressions

See merge request redox-os/relibc!268
2020-05-03 13:16:43 +00:00
oddcoder 850dfd971b Make "./a.out" entry the first in rmap list
This fixes a regression in gdb where sometimes it decides to ignore the
first entry in the list.
2020-05-03 14:59:55 +02:00
oddcoder 67be05d3a3 Use segments instead of sections for calculating which offset to write,
I noticed that the implementation is noth precise although it worked.
and instead of using the sections to identify memory addresses of
DT_DEBUG. I used segements
2020-05-03 14:59:52 +02:00
oddcoder 1182d12006 Fill gaps in binary memory image
Some ELFs can have gaps between the segments, this results in problems
when mprotecting or when converting (addr + size) into rust slice.
Motivated by this This patch will fill these gaps with mmaped addresses.
In theory no real memory should be allocated because mmap is lazy
allocator.
2020-05-03 13:57:24 +02:00
Jeremy Soller c799dad4e9 Merge branch 'wide-strings' into 'master'
Wide strings Functions

See merge request redox-os/relibc!267
2020-05-02 12:56:51 +00:00
oddcoder e9615065ac Add tests for both wcsncasecmp and wcscasecmp 2020-04-26 19:13:03 +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 9725d3418a Test towlower and towupper 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
Jeremy Soller a8a73f87c7 Merge branch 'procfs' into 'master'
Implement #include<sys/user.h> and #include<sys/procfs.h>

See merge request redox-os/relibc!266
2020-04-24 22:47:59 +00: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
Jeremy Soller 763bb2488d Merge branch 'init_fini_ld.so' into 'master'
Init fini ld.so

See merge request redox-os/relibc!265
2020-04-19 12:40:00 +00:00
oddcoder b717f6cf5a Move IO Initialization to .init_array section
Most shared object in linux have their initialization in a separate
.init_array section. but glibc does not have the same behavour. Instead
the initialization is part of crt0. which (as it seams to me) run after
.init_array section. As such, this patch move IO initialization to
separate function that is marked as .init_array member and then the crt0
call this function only if init_array was never invoked (as in
statically linked binaries).
2020-04-19 14:21:23 +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
oddcoder cc7ff54d12 Catch circular dependency when resolving loading shared libraries
This patch implements tree-based data-structure for catching circular
dependency where libA.so will depen on arbitrarily long chain (including
zero length) of libNs.so one of which will depend on libA.so again. The
main intention of this patch was merely capturing the dependency tree to
prioterize which Elf's .init_array and which .fini_array should run
first, but as a side effect it can capture circular dependencies as well.
2020-04-19 13:28:53 +02:00
Jeremy Soller 7724989b33 Merge branch 'Debugger_Support' into 'master'
Debugger support

See merge request redox-os/relibc!263
2020-04-15 17:59:01 +00:00
Jeremy Soller 77ad82a9dd Merge branch 'sigaction-restore' into 'master'
sigaction should set sigaction.sa_restorer

See merge request redox-os/relibc!264
2020-04-15 17:56:27 +00:00
Graham MacDonald 2283e25cde sigaction should set sigaction.sa_restorer 2020-04-14 23:37:54 +01:00
oddcoder de03566158 Enable RTLD debugging protocol system-wide
This patch makes use of the data structures and functions impelemented
in the last patch to enable RTLD debugging protocol as per SVR4
2020-04-13 12:39:51 +02:00
oddcoder 369d7b42c6 Initial implementation of SVR4 debugging interface for runtime linker 2020-04-13 12:12:48 +02:00
Jeremy Soller cdbbd4a426 Merge branch 'cbindgen' into 'master'
Remove vendored cbindgen, use cbindgen dependency to generate includes in build.rs

See merge request redox-os/relibc!261
2020-04-10 23:05:58 +00:00
Graham MacDonald 2253ef609e Remove vendored cbindgen, use cbindgen dependency to generate includes in build.rs 2020-04-10 23:05:58 +00:00
Jeremy Soller 69fc62278a Merge branch 'use_kernel_loaded_elf' into 'master'
Use Kernel mapped binaries when available.

See merge request redox-os/relibc!262
2020-04-07 21:42:37 +00: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 701e64b3a1 ld_so: Default to non-verbose 2020-03-29 20:17:29 -06:00
Jeremy Soller d7a859fb84 Keep exported functions 2020-03-24 20:05:38 -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 2629918100 Fix issue if test:redox is run without build:redox 2020-03-10 21:12:40 -06:00
Jeremy Soller 0090396132 Run cargo test 2020-03-10 21:03:52 -06:00
Jeremy Soller 880e3c7854 Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2020-03-10 20:57:13 -06: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 77a0294114 Merge branch 'stdc-compatiability' into 'master'
Stdc compatiability

See merge request redox-os/relibc!258
2020-03-06 03:58:42 +00:00
oddcoder 3ac6ef1848 Adjust stddef.h to be compatiable with other libc(s)
I faced many issues when compiling libstdC++-V3 and linking against
relibc mainly:
- Missing types (max_align_t)
- Different types definitions(ptrdiff_t , size_t)
- and the fact that wchar_t is part of standard C++ and it seams that we
  canno redefine standard types
2020-03-02 00:06:49 +02:00
oddcoder a2f2484e45 Add minimal basic features.h resembling musl lib's own 2020-03-01 22:59:39 +02:00
Jeremy Soller 79f265745a Fix redox ld_so 2020-02-28 19:33:20 -07:00
Jeremy Soller b1aad49df4 Merge branch 'linux-ld' of gitlab.redox-os.org:oddcoder/relibc 2020-02-28 19:12:19 -07:00
oddcoder bc53164293 Reduce Verbosity level when ld.so is invoked as interpreter 2020-02-24 11:56:12 +02:00