Commit Graph

1465 Commits

Author SHA1 Message Date
oddcoder f4f68a3441 Make use of mspaces 2020-07-18 21:03:46 +02:00
oddcoder 3a8817072c Initialize the mspaces of allocator and keep track of it 2020-07-18 21:03:20 +02:00
oddcoder 67c703610b Compile dlmalloc with mspace support 2020-07-18 20:54:58 +02:00
oddcoder 9a1efda121 Initial allocator structure 2020-07-18 20:54:30 +02:00
Jeremy Soller 04f77881d0 Merge branch 'TLS' into 'master'
Fix wrong TLS resolving

See merge request redox-os/relibc!294
2020-07-18 18:48:14 +00:00
oddcoder d4b2391221 Fix wrong TLS resolving
I attempted fixing this issue before at 43fbaf99. Although it did work,
it worked wrong, and it was just consistently working (but in wrong way)
until it didn't.

Since this is (hopefully) the real fix, I will try to explain exactly
what is going on.

This is explaination by example:

our TLS is memory of size 0x1000 starting at 0x7ffff6c50000,
but the real size is 0x000068 so we have padding stored at master.offset
= 0xf98

Now our symbol looks as follows

  Offset          Type                Sym. Value    Name
000000432b20  R_X86_64_DTPOFF64   0000000000000058 errno

The old code did 0x7ffff6c50000 + 0xf98 + 000000432b20 which is
obviosly overflowing the memory and wrong.

The right way 0x7ffff6c50000 + 0xf98 + 0000000000000058.

THe Tls base part and offset are added at __tls_get_addr function.
What is left is storing the 0x58 at the relocation address. The problem
is that we don't have 0x58, but we have (binary base + 0x58) in global
symbol table and binary base so what we store is the (binarybase + 0x58
- binary base).

I hope this does turn out to be wrong.
2020-07-18 20:45:37 +02:00
jD91mZM2 e17c6049c6 Fix libgmp compilation 2020-07-15 11:12:59 +02:00
Jeremy Soller cbd7ead0ff Merge branch 'add_fwide' into 'master'
Add fwide function

See merge request redox-os/relibc!291
2020-07-09 12:29:53 +00:00
Wren Turkal 9a1e9c327a Make byte stream functions set stream orientation.
When a byte-oriented stream function touches a stream, that stream
should be set to byte-oriented mode if it hasn't been set yet. If
it has been set, the opertion should only succeed if the stream is
already in byte-oriented mode.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal 746a86a267 Add unlocked variation of fwide function.
Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal b623e245c0 Make freopen reset the stream orientation.
Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal 865b7962a1 Add implmentation for fwide posix function.
This function is used to set the orientation of a stream to either
byte-oriented or wchar-oriented.

More info on this function is here:
https://man7.org/linux/man-pages/man3/fwide.3p.html

This implementation only impmlemnts the manual switching and does
not yet guard against using a byte-oriented stream with wchar
functions and vice versa. Those step will come in additional
commits.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:06 -07:00
Jeremy Soller c13ba64832 Merge branch 'socketpair' into 'master'
Various socket-related changes and other

See merge request redox-os/relibc!289
2020-07-01 13:56:58 +00:00
jD91mZM2 29ad5b75c9 Fix broken CVec
Oops, forgot to initiate the pointer after uses of CVec::new()
2020-06-29 21:03:29 +02:00
jD91mZM2 56e1eceb28 Replace AllocStringWriter with CVec 2020-06-29 17:44:57 +02:00
jD91mZM2 39ce623d2d Fix bind/connect's AF_UNIX socket path... again
I don't really know for sure what all these silly rules are, but I think
I got it now...
2020-06-29 11:36:07 +02:00
jD91mZM2 593925ceb4 Unambiguate all include guards
GNU binutils also uses _FNMATCH_H for a guard, maybe along others!
2020-06-29 11:34:51 +02:00
jD91mZM2 f8b49936bc Various unix socket fixes (+socketpair!) 2020-06-27 16:39:50 +02:00
jD91mZM2 b7053b673d Fix missing types when compiling GDB 2020-06-25 13:03:06 +02:00
Jeremy Soller 7ea5cd5133 Merge branch 'rename-lcg48-rand48' into 'master'
Rename lcg48 module as rand48

See merge request redox-os/relibc!287
2020-06-24 16:55:27 +00:00
Jeremy Soller ce2de698c4 Merge branch 'random-alignment' into 'master'
Don't assume u32 alignment of random() state buffer

See merge request redox-os/relibc!286
2020-06-24 16:46:59 +00:00
Peter Limkilde Svendsen 5c8393d5aa Don't assume u32 alignment of random() state buffer 2020-06-24 16:46:59 +00:00
Jeremy Soller 954f010cc1 Merge branch 'pie' into 'master'
Fix bugs in handling non pie elfs

See merge request redox-os/relibc!285
2020-06-24 12:33:47 +00:00
oddcoder 5fcf920675 Fix bugs in handling non pie elfs
The problem here was that we alway added the base address, and we
assumed that all addresses we access are relative but this is not the
case in case of non pie binaries. The issue is that all addresses were
base+offset. so if we added the base again it will ofcourse generate
wrong address.
2020-06-24 10:21:20 +02:00
Peter Limkilde Svendsen 59b040258a Rename lcg48 as rand48 2020-06-23 18:34:44 +02:00
Jeremy Soller 547edcc267 Merge branch 'arpa_inet-types' into 'master'
Use C type names in byteorder functions

See merge request redox-os/relibc!274
2020-06-22 21:57:24 +00:00
Jeremy Soller 22a7f71282 Merge branch 'ctime_r' into 'master'
Add test for ctime_r(), replace mem::uninitialized()

See merge request redox-os/relibc!273
2020-06-22 21:57:04 +00:00
Jeremy Soller c95a5fa574 Merge branch 'random' into 'master'
Implement random() and friends

See merge request redox-os/relibc!284
2020-06-22 21:56:39 +00:00
Peter Limkilde Svendsen cc33874363 Implement random() and friends 2020-06-22 21:56:39 +00:00
Jeremy Soller db6a589421 Merge branch 'LD_LIBRARY_PATH' into 'master'
Ld library path

See merge request redox-os/relibc!279
2020-06-20 13:17:40 +00:00
Jeremy Soller d7089a09bf Merge branch 'LD_SO_ASM_REM' into 'master'
Get rid of assembly code in call_inits_finis

See merge request redox-os/relibc!282
2020-06-20 13:13:26 +00:00
oddcoder 0977133cc9 Get rid of assembly code in call_inits_finis 2020-06-20 15:01:13 +02:00
Jeremy Soller 73e1d6307b Merge branch 'socket-fix' into 'master'
Socket fix

See merge request redox-os/relibc!281
2020-06-19 11:58:24 +00:00
jD91mZM2 cdc9aa06e3 Fix getpeername
Rust's TcpListener fails because of the address format being wrong. The format
comes from `accept`, but there we internally use this function.
2020-06-19 13:56:06 +02:00
Jeremy Soller ca8b848b48 Merge branch 'headers' into 'master'
Headers

See merge request redox-os/relibc!280
2020-06-14 20:38:04 +00:00
oddcoder f4d95ce43f Add sys/select.h to sys/types.h
This was triggered by gcc for some reason It included sys/types.h and
assumed sys/select.h to be there. And that seams to be the case in musl.

The problem with relibc here is that sys/types.h is are part of relibc
"include/*.h" files, while sys/select.h is generated by cbindgen. That
makes it impossible to #include select.h in types.h epsecially that
there are files like fcntl.c that uses types.h. They would complain
about missing headers. I fixed this by renaming sys/types.h to
sys/types_internal.h and then generating types.h using cbindgen as well
except for that. however fcntl and dlmalloc can include types_internal
instead of types.h
2020-06-14 22:00:16 +02:00
oddcoder a125b8be15 Make stdbool.h C++ compatiable
The problem here is that _Bool type is not defined in C++ yet this file
is using it. That leads to issues when compiling gcc. I borrowed the
same techniques used in other stdbool.h
2020-06-14 22:00:10 +02:00
oddcoder 81da1bb1a3 Fix the avoid accessing errno issue from ld_so for real this time
This patch implements access function for both redox and linux and makes
sure that neither access errno variable
2020-06-13 19:55:33 +02:00
no name d5b63a85a4 Revert "Fix compilation on Redox by removing use of access in ld_so"
This reverts commit d9bacaec04.
2020-06-13 19:55:33 +02:00
no name c3ae8022ba Revert "Handle missing paths in load_library search without using access"
This reverts commit b0dde81c75.

The main issue was not with "access" being used, it was with errno being
accessed. This patch accesses errno as well

LD_LIBRARY_PATH="/folder/with/no/libc" ./a.out

gives segfault with the following stack trace

0x00000000004d1cae in relibc::platform::sys::e (sys=18446744073709551614) at src/platform/linux/mod.rs:54
 54                  errno = -(sys as isize) as c_int;
(gdb) bt
 #0  0x00000000004d1cae in relibc::platform::sys::e (sys=18446744073709551614) at src/platform/linux/mod.rs:54
 #1  0x00000000004d361e in <relibc::platform::sys::Sys as relibc::platform::pal::Pal>::open (path=0x5555555634c0, oflag=524288, mode=0) at src/platform/linux/mod.rs:330
 #2  0x000000000049a2ad in relibc::fs::File::open (path=0x5555555634c0, oflag=524288) at src/fs.rs:28
 #3  0x0000000000482b49 in relibc::ld_so::linker::Linker::load_recursive (self=0x7fffffffdd30, name=..., path=...) at src/ld_so/linker.rs:119
 #4  0x0000000000484963 in relibc::ld_so::linker::Linker::load_library (self=0x7fffffffdd30, name=...) at src/ld_so/linker.rs:184
 #5  0x0000000000483b53 in relibc::ld_so::linker::Linker::load_data (self=0x7fffffffdd30, name=..., data=...) at src/ld_so/linker.rs:152
 #6  0x00000000004831fe in relibc::ld_so::linker::Linker::load_recursive (self=0x7fffffffdd30, name=..., path=...) at src/ld_so/linker.rs:140
 #7  0x000000000048228a in relibc::ld_so::linker::Linker::load (self=0x7fffffffdd30, name=..., path=...) at src/ld_so/linker.rs:97
 #8  0x0000000000414a3b in relibc_ld_so_start (sp=0x7fffffffe310, ld_entry=4198896) at src/ld_so/start.rs:182
 #9  0x0000000000401209 in _start () at src/ld_so/src/lib.rs:10
 #10 0x0000000000000001 in ?? ()
 #11 0x00007fffffffe592 in ?? ()
 #12 0x0000000000000000 in ?? ()
2020-06-13 19:55:33 +02:00
Jeremy Soller 68679e41f0 Add redoxer.sh script to simplify running tests on redox 2020-06-09 20:55:55 -06:00
Jeremy Soller b771313ffd Merge branch 'master' of https://gitlab.redox-os.org/redox-os/relibc 2020-06-07 14:01:00 -06:00
Jeremy Soller b0dde81c75 Handle missing paths in load_library search without using access 2020-06-07 14:00:48 -06:00
Jeremy Soller 7bc11dc6c2 Merge branch 'relibc-netdb-v1' into 'master'
netdb: implement getnetbynane and getnetent

See merge request redox-os/relibc!278
2020-06-07 12:27:54 +00:00
Giuseppe Longo 12beb13987 netdb: implement getnetbynane and getnetent
This patch implements getnetbyname and getnetent functions.
2020-06-07 14:02:41 +02:00
Jeremy Soller d9bacaec04 Fix compilation on Redox by removing use of access in ld_so 2020-06-06 21:00:57 -06:00
Jeremy Soller d0c1160299 Merge branch 'scanf' into 'master'
Scanf

See merge request redox-os/relibc!277
2020-06-06 19:32:54 +00:00
oddcoder 92d6735e3f Add more scanf tests 2020-06-03 23:20:53 +02:00
oddcoder 8973535fdc Make scanf write to string and increase match count only when a pattern is matched
This is the behavior of glibc which I assume to be right
2020-06-03 23:20:52 +02:00
oddcoder 018f7a3f38 Fix scanf.stdout as per glibc 2020-06-03 23:20:52 +02:00