Commit Graph

1488 Commits

Author SHA1 Message Date
Jeremy Soller 5d45042d5d Correct more asm! usages 2020-08-02 13:38:29 -06:00
Jeremy Soller 12777ba774 Use 2020-07-27 nightly, it has rustfmt 2020-08-02 13:06:44 -06:00
Jeremy Soller f2c2d7c52e Fix compilation on newer nightly, update nightly to 2020-08-01 2020-08-02 12:24:49 -06:00
Jeremy Soller f131391b0d Merge branch 'memory' into 'master'
Make munmap use funmap2

See merge request redox-os/relibc!297
2020-07-30 14:04:06 +00:00
jD91mZM2 7d4d73dd83 Update redox_syscall 2020-07-30 15:58:21 +02:00
jD91mZM2 4c148c1860 Make munmap use funmap2 2020-07-30 13:39:20 +02:00
4lDO2 a5e02650d7 Remove ptrace write call. 2020-07-25 22:30:38 +02:00
4lDO2 285a7c62d4 Use mmap2 version of redox_syscall. 2020-07-25 22:30:38 +02:00
4lDO2 e38d185870 Use fmap2 to support passing an address. 2020-07-25 22:30:38 +02:00
Jeremy Soller d6b03de7a4 Align stack to 128 bytes 2020-07-19 21:04:16 -06:00
Jeremy Soller 677f0c989d Merge branch 'dlopen_dlclose_dlsym' into 'master'
Dlopen dlclose dlsym

See merge request redox-os/relibc!290
2020-07-19 19:35:31 +00:00
oddcoder 37a462de5d Apply cargo fmt to the whole repo 2020-07-19 21:27:38 +02:00
no name 890a9ed033 Implement dlopen/close 2020-07-19 21:27:38 +02:00
oddcoder ea3265766c Allow struct Linker to specify which library space to use 2020-07-19 21:21:48 +02:00
oddcoder 02aa400c5c Add callbacks to ld.so version of Linker's function
It is fact that ld.so has libc statially linked into it.

Normally we wouldn't need ld.so functionality once the program is
finalyl loaded, but with the next few patches, we will have dlopen which
will reuse the same ld.so functionality.

The problem is that it seams that huge part of the code is possible not
referntially transparent. That is, it is not impossible that some of the
functions have internals states. So when using the struct Linker that is
initialized by ld.so's copy of libc. we must access it using the same
copy even if both copies are identical.
For example in dlopen if you do linker.load_library(..). That would
segfault because it is using the function from libc not ld.so

So I don't truly undestand why should this be needed, but after long
hours of being stuck I thought maybe.. maybe that is the issue and
indeed it turned out to be so.
2020-07-19 21:21:48 +02:00
oddcoder b4a6a7ece5 Refactor init and fini by merging common code 2020-07-19 21:21:48 +02:00
oddcoder 6d0c9dccd5 Allow Linker struct to specify with library name space to operate on 2020-07-19 21:21:48 +02:00
oddcoder 01b1738b3a Separate library specific data from main Linker struct 2020-07-19 21:21:48 +02:00
oddcoder aaf017d9d1 Fix regression introduced in 5fcf9206
I by mistake commented _dl_debug_state() function which would break
debugging
2020-07-19 21:21:48 +02:00
Jeremy Soller 36ac4166ef Define MAP_ANON for dlmalloc 2020-07-19 12:40:01 -06:00
Jeremy Soller cf8cbe625b Merge branch 'allocator' into 'master'
Allocator

See merge request redox-os/relibc!295
2020-07-18 19:51:37 +00:00
no name 40acadc7d5 Sanity checking 04f77881d0 2020-07-18 21:15:57 +02:00
oddcoder 4d982f86b2 use only mspaces 2020-07-18 21:05:18 +02:00
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