Commit Graph

1544 Commits

Author SHA1 Message Date
Mateusz Tabaka 79643c293b Fix formatiing issues 2020-09-30 11:40:38 +02:00
Jeremy Soller 687f4d4923 Merge branch 'dynamic' into 'master'
Add tests for ld_so

See merge request redox-os/relibc!314
2020-09-30 00:42:45 +00:00
Mateusz Tabaka 675101ac0e Add tests for dynamic linker 2020-09-29 23:01:52 +02:00
Mateusz Tabaka 7829a7ade9 Add support for RUNPATH 2020-09-29 23:01:48 +02:00
Mateusz Tabaka 58cc9efbc0 Call pthread_init in libc's init_array 2020-09-29 19:20:24 +02:00
Mateusz Tabaka 42acd32ac0 Fix TCB master address 2020-09-29 19:15:21 +02:00
Mateusz Tabaka b05d8df5f8 Restore previous load address for ld_so
Current value gives us 0x1234000 - 0x400000 ~ 14 MB for executable,
which is too low for certain programs.
2020-09-29 18:58:35 +02:00
Mateusz Tabaka c000373a08 Add symlink from libc.so to libc.so.6
Typically it's the other way around, but we can't have shared library named libc.so.6 in target/release directory.
cargo includes 'target/release' in LD_LIBRARY_PATH for build script, so even if clean build runs fine,
every subsquent run will make build script link with relibc.
2020-09-29 00:08:11 +02:00
Jeremy Soller 2c6114be75 Merge branch 'asctime-ub-asserts' into 'master'
Catch UB in asctime_r()

See merge request redox-os/relibc!312
2020-09-17 23:19:08 +00:00
Peter Limkilde Svendsen 00642dd940 Test extreme tm member values 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen aef1be7c1b Remove errno setting 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen 8ef64676fe Use stricter/simpler type handling 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen 18a12c6c3d Add range assertions to asctime_r() 2020-09-17 23:10:13 +02:00
Jeremy Soller 36bb60cacc Do not unmap stack while it is being used, add a comment to fix it later 2020-09-09 18:49:44 -06:00
Jeremy Soller 2ed55a926b Merge branch 'gmtime-refactor' into 'master'
Refactor gmtime_r(), fix localtime() test

See merge request redox-os/relibc!309
2020-09-08 18:45:20 +00:00
Jeremy Soller 9f25fa39ea Merge branch 'gmtime-tests' into 'master'
Add more gmtime() tests

See merge request redox-os/relibc!308
2020-09-08 18:44:55 +00:00
Peter Limkilde Svendsen ff6bc68260 Add more gmtime() tests 2020-09-08 18:44:55 +00:00
Jeremy Soller f285128657 Merge branch 'asctime-char-cast' into 'master'
Avoid assuming c_char is i8 in asctime()

See merge request redox-os/relibc!307
2020-09-08 18:44:38 +00:00
Jeremy Soller dd193bcb8c Merge branch 'fix-asprintf-test-free' into 'master'
Add needed include for asprintf() test

See merge request redox-os/relibc!306
2020-09-08 18:43:57 +00:00
Jeremy Soller 4a6ef0221f Merge branch 'weak_rust_probestack' into 'master'
link: Weaken __rust_probestack symbol

See merge request redox-os/relibc!310
2020-09-06 13:04:34 +00:00
Esteban Blanc 9e0e88346d link: Weaken __rust_probestack symbol 2020-09-06 10:26:42 +02:00
Peter Limkilde Svendsen 59b0a36e81 Fix localtime() test 2020-08-27 23:16:17 +02:00
Peter Limkilde Svendsen 63711f6ca7 Formatting 2020-08-27 23:16:17 +02:00
Peter Limkilde Svendsen 845c74a82e Refactor gmtime_r() 2020-08-27 23:16:17 +02:00
Peter Limkilde Svendsen 86138c9f8a Align parameter naming with POSIX 2020-08-27 23:16:17 +02:00
Jeremy Soller 3a0d2177cd Variable for weakened symbols, weaken umodti3 2020-08-25 08:21:31 -06:00
Peter Limkilde Svendsen 23b2eb2573 Avoid assuming c_char is i8 2020-08-23 21:45:08 +02:00
Jeremy Soller 5472e117a5 Weaken __fixdfti 2020-08-21 21:28:51 -06:00
Peter Limkilde Svendsen aec4a84e90 Include stdlib.h so free() can be used 2020-08-20 20:43:28 +02:00
Jeremy Soller 5af8e3ca35 Merge branch 'bump-fmap' into 'master'
Use renamed fmap call

See merge request redox-os/relibc!305
2020-08-17 12:36:11 +00:00
Jeremy Soller a78f829dca Merge branch 'brk' into 'master'
Emulate brk

See merge request redox-os/relibc!304
2020-08-17 12:35:16 +00:00
jD91mZM2 e33aea434f Use renamed fmap call 2020-08-17 13:57:39 +02:00
jD91mZM2 eaee4e6329 Emulate brk 2020-08-15 18:44:22 +02:00
Jeremy Soller 7db83596a2 Merge branch 'gcc_compile' into 'master'
Gcc compile

See merge request redox-os/relibc!303
2020-08-14 15:19:14 +00:00
oddcoder ab92ff9d41 make all ld printlns happen in case of verbose = true and apply cargo fmt
It seams that stdout of ld.so is not that much of an issue but actually
it unfortunately is. The major problem here is that sometimes programs
generate header files in stdout (./getmy_custom_headers > header.h) and
we need to keep that cleen. and this is very very popular in gcc.
2020-08-12 18:57:37 +02:00
oddcoder 7b29f6eb27 Avoid relinking already linked libs
This patch avoids collecting symbols, resolving relocs if they are
already done (usually for example libc.so during a dlopen for another
libfoo.so). This patch is purely for performance boost.
2020-08-12 18:57:37 +02:00
oddcoder 61fcc018fc Refer to libraries with soname if available and avoid loading libs twice
It is usually not optimal to load a library twice and for specifics,
it is **terrible** idea to load libc twice it was enough trouble
dealing with libc statically linked into ld.so. So What this patch does
it check for soname and if a library is already loaded it won't get
loaded again. Why soname ? because unfortunately some bins gets linked
againt libc.so while of their dependencies gets linked against
libc.so.6 while one is usually symbolic link for the other.
2020-08-12 18:57:37 +02:00
oddcoder 9826cea092 Add SONAME for libc.so
Usually it is possible to refer to library either by the file name or by
elf "soname" soname is very similar for specifying something like
(LIB/API version) combination so if for example you have ./prog that
loads libx.so which is version 5.1.1 and there is ./plugin.so that ./prog
would load that requires libx.so version 5.1.2 both libx.so should have
the same soname to hint that they offer the exact same functionality.
And this patch specifies the soname for relibc libc.so.
2020-08-12 18:57:37 +02:00
jD91mZM2 7b6ba2c73a Merge branch 'lD_PATH' into 'master'
L d path

See merge request redox-os/relibc!300
2020-08-12 10:19:32 +00:00
Ahmed Abd El Mawgood 40328a0d09 Modify ld_script so that it works on linux.
Honestly, I have no idea why are these modifications needed, but it
seams they are needed
2020-08-12 10:19:32 +00:00
jD91mZM2 b9828bd863 Merge branch 'elf_And_flock' into 'master'
Elf and flock

See merge request redox-os/relibc!283
2020-08-12 10:17:59 +00:00
jD91mZM2 d827c0f166 Run Linux tests in CI
commit 09cb17e66f46c6687fa0b9dc0895ad3279caa092
Author: jD91mZM2 <me@krake.one>
Date:   Mon Aug 10 18:03:20 2020 +0200

    comment out cargo tests

commit 1915c7306e40f5c6af36b04c765e25ad9ffe9d16
Author: jD91mZM2 <me@krake.one>
Date:   Mon Aug 10 17:58:52 2020 +0200

    Update redoxer docker image
2020-08-11 11:14:13 +02:00
Jeremy Soller 91f0be8790 Merge branch 'weaken_floattidf' into 'master'
Also weaken `__floattidf`

See merge request redox-os/relibc!299
2020-08-08 14:15:55 +00:00
oddcoder b5deadbeea Add (POSIX defined) struct flock
struct flock is posix defined locking mechanism on *nix platform

Example usage (copied from https://gavv.github.io/articles/file-locks/) :

  #include <fcntl.h>

  struct flock fl;
  memset(&fl, 0, sizeof(fl));

  // lock in shared mode
  fl.l_type = F_RDLCK;

  // lock entire file
  fl.l_whence = SEEK_SET; // offset base is start of the file
  fl.l_start = 0;         // starting offset is zero
  fl.l_len = 0;           // len is zero, which is a special value representing end
                        // of file (no matter how large the file grows in future)

  fl.l_pid = 0; // F_SETLK(W) ignores it; F_OFD_SETLK(W) requires it to be zero

  // F_SETLKW specifies blocking mode
  if (fcntl(fd, F_SETLKW, &fl) == -1) {
    exit(1);
  }

  // atomically upgrade shared lock to exclusive lock, but only
  // for bytes in range [10; 15)
  //
  // after this call, the process will hold three lock regions:
  //  [0; 10)        - shared lock
  //  [10; 15)       - exclusive lock
  //  [15; SEEK_END) - shared lock
  fl.l_type = F_WRLCK;
  fl.l_start = 10;
  fl.l_len = 5;

  // F_SETLKW specifies non-blocking mode
  if (fcntl(fd, F_SETLK, &fl) == -1) {
      exit(1);
  }

  // release lock for bytes in range [10; 15)
  fl.l_type = F_UNLCK;

  if (fcntl(fd, F_SETLK, &fl) == -1) {
      exit(1);
  }

  // close file and release locks for all regions
  // remember that locks are released when process calls close()
  // on any descriptor for a lock file
  close(fd);
2020-08-08 10:16:50 +02:00
oddcoder e14b3e09a5 Add elf.h header to relibc 2020-08-08 10:16:50 +02:00
jD91mZM2 d08c63b1e7 Merge branch 'fix-ci' into 'master'
Fix CI

See merge request redox-os/relibc!302
2020-08-07 14:16:45 +00:00
jD91mZM2 6952a079ae Fix CI 2020-08-07 14:16:45 +00:00
jD91mZM2 72532b8280 Fix printf issue found in GDB 2020-08-05 16:49:10 +02:00
Jeremy Soller 4f93e43593 Merge branch 'fix-linker' into 'master'
Make linker work somewhat on Redox

See merge request redox-os/relibc!296
2020-08-04 12:24:51 +00:00
jD91mZM2 0178565f71 Move text section of linker away
Seems to collide with the program being loaded
2020-08-04 12:24:51 +00:00