11909 Commits

Author SHA1 Message Date
Jakub Konka
3f7dbde92a macho: bring back allocatedSize function 2020-12-19 23:51:39 +01:00
Jakub Konka
6712575e04 macho: preallocate space for linkedit hidden sections; 2020-12-19 23:37:21 +01:00
Jakub Konka
ca1d03fe77 macho: fix findFreeSpace start value 2020-12-19 19:44:13 +01:00
Jakub Konka
c89f4781bd macho: add missing dirty markers 2020-12-19 12:19:20 +01:00
Jakub Konka
f32681033d macho: auto-coerce to slice 2020-12-19 12:19:10 +01:00
Jakub Konka
99578e828b macho: move findFreeSpace back to MachO struct
However, adding a twist where `findFreeSpace` accepts a `SegmentCommand`
as argument meaning we want to look for free space specifically within
that segment and nowhere else.
2020-12-19 12:19:00 +01:00
Jakub Konka
6a021d845a macho: find free space even for __text section 2020-12-19 12:18:49 +01:00
Jakub Konka
f33b644c4f macho: redo how we allocate within a segment
Firstly, we preallocate segments offset and sizes, and then
when adding sections, we find the free space within each segment.
Currently, this applies to any segment that is not __LINKEDIT
segment since this requires special treatment.
2020-12-19 12:18:35 +01:00
Jakub Konka
b090451646
Merge pull request #7318 from kubkon/cc-macho
stage1: cross compile to x86_64 and arm64 macOS from anywhere with LLVM
2020-12-19 12:13:03 +01:00
Jakub Konka
3f81ddb735 macho: address review comments 2020-12-19 09:59:38 +01:00
Andrew Kelley
506af7e52e
Merge pull request #7482 from ziglang/tlcsprng
std: introduce a thread-local CSPRNG for general use
2020-12-18 23:57:46 -05:00
Andrew Kelley
f416535768 work around compiler bug regarding generic function slice alignment
See #7495
2020-12-18 18:30:06 -07:00
Andrew Kelley
53987c932c std.crypto.random: introduce fork safety
Everybody gets what they want!

 * AT_RANDOM is completely ignored.
 * On Linux, MADV_WIPEONFORK is used to provide fork safety.
 * On pthread systems, `pthread_atfork` is used to provide fork safety.
 * For systems that do not have the capability to provide fork safety,
   the implementation falls back to calling getrandom() every time.
 * If madvise is unavailable or returns an error, or pthread_atfork
   fails for whatever reason, it falls back to calling getrandom() every
   time.
 * Applications may choose to opt-out of fork safety.
 * Applications may choose to opt-in to unconditionally calling
   getrandom() for every call to std.crypto.random.fillFn.
 * Added `std.meta.globalOption`.
 * Added `std.os.madvise` and related bits.
 * Bumped up the size of the main thread TLS buffer. See the comment
   there for justification.
 * Simpler hot path in TLS initialization.
2020-12-18 15:54:01 -07:00
Andrew Kelley
2b8dcc76eb take advantage of std.os.linux.getauxval 2020-12-18 12:22:46 -07:00
Andrew Kelley
d9368d7012 update test-stack-traces because start.zig updated 2020-12-18 12:22:46 -07:00
Andrew Kelley
2e4b409f31 std: tlcsprng: cleanups & improvements
* get rid of the pointless fences
 * make seed_len 16 instead of 32, which is accurate since it was
   already padding the rest anyway; now we do 1 pad instead of 2.
 * secureZero to clear the AT_RANDOM auxval
 * add a flag root source files can use to disable the start code. This
   is in case people want to opt out of the initialization when they
   don't depend on it.
2020-12-18 12:22:46 -07:00
Andrew Kelley
228a0937a2 memory fences to make sure TLS init happens 2020-12-18 12:22:46 -07:00
Andrew Kelley
7dab3ae135 update guess number standalone test 2020-12-18 12:22:46 -07:00
Andrew Kelley
4dcd1e6059 start code: overwrite AT_RANDOM after we use it 2020-12-18 12:22:46 -07:00
Andrew Kelley
013efaf139 std: introduce a thread-local CSPRNG for general use
std.crypto.random

* cross platform, even freestanding
* can't fail. on initialization for some systems requires calling
  os.getrandom(), in which case there are rare but theoretically
  possible errors. The code panics in these cases, however the
  application may choose to override the default seed function and then
  handle the failure another way.
* thread-safe
* supports the full Random interface
* cryptographically secure
* no syscall required to initialize on Linux (AT_RANDOM)
* calls arc4random on systems that support it

`std.crypto.randomBytes` is removed in favor of `std.crypto.random.bytes`.

I moved some of the Random implementations into their own files in the
interest of organization.

stage2 no longer requires passing a RNG; instead it uses this API.

Closes #6704
2020-12-18 12:22:46 -07:00
LemonBoy
ce65533985 std: Properly fix the TLS alignment problem
ad05509 introduced a fix for the wrong problem, the logic to align the
start of main_thread_tls_buffer was already there but was flawed.

Fix it for good and avoid wasting too many bytes for alignment purposes.
2020-12-18 14:22:30 -05:00
Andrew Kelley
ad05509930 std: align(16) main_thread_tls_buffer
Before this change, thread local variables were landmines if LLVM
decided to optimize any writes to them using vector instructions.
2020-12-17 22:58:56 -07:00
Tau
9b86dde7b9 Add baudrate constants
This adds the missing baudrate constants for linux where I've used them
directly.
2020-12-17 19:17:10 +02:00
Luuk de Gram
d73f46b57c Fix StackFallbackAllocator 2020-12-17 19:09:29 +02:00
Josh Holland
e93cb22541 Improve documentation for string slices.
Closes #7454.
2020-12-17 19:01:13 +02:00
Dmitry Atamanov
e16997a66c
Add process_madvise to Linux syscalls (#7450) 2020-12-17 18:58:09 +02:00
Jakub Konka
b42ef0e6ea macho: refactor calculating LEB128 sizes 2020-12-17 10:04:53 +01:00
Jakub Konka
3e9e79378d macho: deduplicate libc headers between macos arch 2020-12-17 10:04:53 +01:00
Jakub Konka
2d5d661703 macho: no need to parse symbol/string tables 2020-12-17 10:04:53 +01:00
Jakub Konka
ae535111a4 macho: cleanup (lazy) binding info tables 2020-12-17 10:04:53 +01:00
Jakub Konka
5e913c9c2c macho: move (lazy)binding tables into imports module 2020-12-17 10:04:53 +01:00
Jakub Konka
46b2a08d06 macho: parse binding info into a table of entries 2020-12-17 10:04:53 +01:00
Jakub Konka
77e545892e macho: do not error out on unknown load commands
Also, do not try to fixup missing libSystem for dylibs.
2020-12-17 10:04:53 +01:00
Jakub Konka
b099fdff93 macho: parse symbol and string tables 2020-12-17 10:04:53 +01:00
Jakub Konka
f5a0b9315b macho: calculate next available dylib ordinal 2020-12-17 10:04:53 +01:00
Jakub Konka
cc2592969d macho: clean up formatting 2020-12-17 10:04:53 +01:00
Jakub Konka
3971522fee macos: add unfiltered aarch64 libc headers 2020-12-17 10:04:53 +01:00
Jakub Konka
2e7883c597 lld+macho: lld xcomp to x86_64 macos now works 2020-12-17 10:04:53 +01:00
Jakub Konka
eb528a9cbc lld+macho: add missing LC_LOAD_DYLIB cmd 2020-12-17 10:04:53 +01:00
Andrew Kelley
6dfe9cc83e zig cc: default to a.exe on windows
This matches Clang. Thanks to Abner Coimbre for pointing this out.
2020-12-16 21:37:15 -07:00
Andrew Kelley
8975fa5b38 stage2: add test_evented_io to cache hash 2020-12-16 19:22:48 -07:00
data-man
d877eb0e8d Fix typo in math.order 2020-12-16 12:14:44 +02:00
Veikka Tuominen
d3a57b96a9 translate-c: detect parenthesized string literals 2020-12-16 12:13:23 +02:00
Andrew Kelley
b3c1ced2c3
Merge pull request #7431 from LemonBoy/fix-7426
stage1: Fix crash in can_mutate_comptime_var_state
2020-12-15 15:07:49 -05:00
Christian Wesselhoeft
b3f4802aa0 mingw-w64: add .def files for xaudio2_8 2020-12-15 15:00:39 -05:00
luna
0c33624a45
create SendToError (#7417)
* add SendToError

* remove error catch

* add missing SendToError entries

* add mappings to new errors for posix

* map windows sendto() errors
2020-12-15 14:56:42 -05:00
LemonBoy
5f7352b5b5 stage2: Add -include libc-symbols.h when building crtn.S
This -include is added for nearly every file in glibc's makefiles.
2020-12-15 14:53:46 -05:00
Sébastien Marie
96e3222796 openbsd: crt0.o file is different when build static or dynamic mode
it is a first step for support static *and* dynamic mode for openbsd
2020-12-15 14:53:23 -05:00
Sébastien Marie
8bf5a3a5c1 openbsd: correct few structs
- addrinfo: addr and canonname are switched (wrong layout)
- addrinfo, Flock, msghdr struct: use proper c_xxx type instead of fixed size. it should help using struct on all architectures supported by openbsd
2020-12-15 14:49:42 -05:00
Sebastien Marie
7cd6c25c8f
openbsd: link with required system libraries (#7380)
* openbsd: use -lpthread when linking

and while compiling zig stage2, use c++ and c++abi too
2020-12-15 14:45:48 -05:00