20357 Commits

Author SHA1 Message Date
Martin Stuurwold
a7661f115d NativeTargetInfo.zig: fix typo 2022-09-08 01:53:32 -04:00
Veikka Tuominen
44b9a1d031 translate-c: use correct name for failDecl
Closes #12737
2022-09-08 01:00:19 +03:00
Veikka Tuominen
99826a2ba8 Sema: fix UAF in zirClosureGet
Previously if a decl failed its capture scope would be deallocated and
set to undefined which would then lead to invalid dereference in
`zirClosureGet`. To avoid this set the capture scope to a special
failed state and fail the current decl with dependency failure if
the failed state is encountered in `zirClosureGet`.

Closes #12433
Closes #12530
Closes #12593
2022-09-08 00:37:11 +03:00
Veikka Tuominen
37afab2add Sema: preserve alignment of const decl pointers
Closes #12769
2022-09-08 00:37:11 +03:00
Veikka Tuominen
0fa80e66b7 Sema: correct types in @memset and @memcpy
Closes #12750
2022-09-08 00:37:11 +03:00
Jakub Konka
b98b3252be revert part of 945111ae92c28f8ad642a64af4dc83acd3bef4a5 2022-09-07 23:18:57 +02:00
Jakub Konka
0e152b76ac tests: force LLD off for stage2 backends until auto-select deems worthy 2022-09-07 23:16:42 +02:00
Jakub Konka
c4d297b1af test-cases: add missing incremental x86_64-windows test cases 2022-09-07 22:42:59 +02:00
Jakub Konka
a226aef36c test-cases: enable stage2 tests on Windows 2022-09-07 22:42:59 +02:00
Jakub Konka
678e07b924 macho+wasm: unify and clean up closing file handles 2022-09-07 22:42:59 +02:00
Jakub Konka
639237c7b4 macho: set file instance in linkOneShot only if not already set 2022-09-07 22:42:59 +02:00
Jakub Konka
8ef1c62f2e macho: properly close file handles owned by the linker in deinit() 2022-09-07 22:42:59 +02:00
Jakub Konka
215fce8c51 coff: fix tracking of got and import entries; free relocs in update* fns 2022-09-07 22:42:59 +02:00
Jakub Konka
99c2cb72e8 coff: track globals in contiguous array to allow for tombstones 2022-09-07 22:42:59 +02:00
Jakub Konka
f3e4e44a2b coff: fix memory leak in incorrectly disposing of globals table 2022-09-07 22:42:58 +02:00
Jakub Konka
945111ae92 enable testing of x86_64-windows-gnu using self-hosted backend and linker 2022-09-07 22:42:58 +02:00
Jakub Konka
7b8cc599d9 coff: use more generous initial memory sizes for sections 2022-09-07 22:42:58 +02:00
Jakub Konka
16ca47b9b8 coff: remove redundant bits and clean up 2022-09-07 22:42:58 +02:00
Jakub Konka
2b373b0579 coff: grow section in virtual address space when required 2022-09-07 22:42:58 +02:00
Jakub Konka
9116e0f746 coff: find new file space for a section (file offsets) 2022-09-07 22:42:58 +02:00
Jakub Konka
79e51c5e4b coff: differentiate between file space and VM space for alloc 2022-09-07 22:42:58 +02:00
Jakub Konka
08f6546c84 coff: create a helper for allocating sections 2022-09-07 22:42:58 +02:00
Jakub Konka
f1bdf3f62f coff: fix writing strtab to PE image file 2022-09-07 22:42:57 +02:00
Jakub Konka
467d69c68a x86_64: fix SystemV calling convention 2022-09-07 22:42:57 +02:00
Jakub Konka
56a131d27a test-cases: fix compiler error locations for hello world with updates 2022-09-07 22:42:57 +02:00
Jakub Konka
66bad3eaaf coff: mark relocations dirty when target atoms change 2022-09-07 22:42:57 +02:00
Jakub Konka
1e2a2d6fad coff: fix bug in lowerUnnamedConst 2022-09-07 22:42:57 +02:00
Jakub Konka
423f424c27 libstd: use windows.GetStdHandle() with stage2_x86_64 backend for now 2022-09-07 22:42:57 +02:00
Jakub Konka
e0167ae0e3 x86_64: allow for any index register in complex SIB encodings
This relieves register pressure, and reduce generated code size
(since now we can use the same index register for both `mov_scale_src`
and `mov_scale_dst` MIR instructions).

Fix lowering of ModRM + SIB encodings where index register is extended
- previously, we would carelessly ignore the fact generating incorrect
encodings.
2022-09-07 22:42:57 +02:00
Jakub Konka
619d82234e x86_64: clean up return registers for unspecified cc 2022-09-07 22:42:57 +02:00
Jakub Konka
28f525baa4 x86_64: handle ptr_stack_offset for blocks 2022-09-07 22:42:56 +02:00
Jakub Konka
1d57b347e9 x86_64: clean up logging 2022-09-07 22:42:56 +02:00
Jakub Konka
b9c31a8703 x86_64: refactor cond_br with canonicaliseBranches helper 2022-09-07 22:42:56 +02:00
Jakub Konka
c0e288c782 x86_64: implement canonicalising branches in switch expression 2022-09-07 22:42:56 +02:00
Jakub Konka
3a4c69c018 x86_64: implement Windows x64 calling convention 2022-09-07 22:42:56 +02:00
Jakub Konka
38573fed0b coff: fix runtime traps 2022-09-07 22:42:56 +02:00
Jakub Konka
49b1716064 coff: implement lowering unnamed consts 2022-09-07 22:42:56 +02:00
Jakub Konka
a19e6adbf9 x86_64: add support for Win64/C calling convention 2022-09-07 22:42:56 +02:00
Jakub Konka
aac4c1d3b2 coff: fix contents of IAT, and ensure codegen loads addr into reg
As far as I can see, unlike with MachO, we don't have any stubs
helper routines available and need to load a bound pointer into
a register to then call it.
2022-09-07 22:42:55 +02:00
Jakub Konka
0ebeb58d91 coff: populate import address table dir 2022-09-07 22:42:55 +02:00
Jakub Konka
1ab149c5fc coff: create import atoms and matching bindings 2022-09-07 22:42:55 +02:00
Jakub Konka
51fba37af7 coff: add relocation for call_extern 2022-09-07 22:42:55 +02:00
Jakub Konka
a35f156cf6 coff: re-enable default entrypoint for Windows 2022-09-07 22:42:55 +02:00
Jakub Konka
11d14a23a3 win-ci: add missing ZIGPREFIXPATH variable def 2022-09-07 22:21:12 +02:00
Luuk de Gram
a8d137d05a
wasm-linker: support incremental debug info
Although the wasm-linker previously already supported
debug information in incremental-mode, this was no longer
working as-is with the addition of supporting object-file-parsed
debug information. This commit implements the Zig-created debug information
structure from scratch which is a lot more robust and also allows
being linked with debug information from other object files.
2022-09-07 18:59:36 +02:00
Luuk de Gram
971327d6e0
wasm: fix memory leak 2022-09-07 18:53:16 +02:00
Luuk de Gram
f2c8d09c4f
wasm-linker: Mix Zig -and Object debug atoms
When linking a Zig-compilation with an object file,
we allow mixing the debug atoms to make sure debug
information is preserved from object files. By default,
we now always initialize all debug sections if the `strip` flag
is unset.

This also fixes relocations for debug information as previously
the offset of an atom wasn't calculated, and neither was the code
size itself which meant that debug lines were off and file names
from other object files were missing.
2022-09-07 18:53:16 +02:00
Luuk de Gram
b2718e213e
wasm-linker: use Atoms for zig debug info
Previously we used single arraylists for each debug section for debug
information that was generated from Zig code. (e.i. `Module` is available).
This information is now stored in Atoms, similarly to debug information
from object files. This will allow us to link them together and resolve
debug relocations.
2022-09-07 18:53:16 +02:00
Luuk de Gram
46c932a2c9
wasm-linker: perform debug relocations
This correctly performs a relocation for debug sections.
The result is that the wasm-linker can now correctly create
a binary from object files while preserving all debug information.
2022-09-07 18:53:16 +02:00
Luuk de Gram
c347751338
wasm-linker: write debug sections from objects
We now link relocatable debug sections with the correct
section symbol and then allocate and resolve the debug atoms
before writing them into the final binary.

Although this does perform the relocation, the actual relocations
are not done correctly yet.
2022-09-07 18:53:16 +02:00