18894 Commits

Author SHA1 Message Date
Koakuma
672cd2f02f stage2: sparc64: Implement SPARCv9 and 2022-06-24 21:19:33 +07:00
Koakuma
6218d70d09 stage2: sparc64: Implement airBinOp for and, or, and xor 2022-06-24 21:19:33 +07:00
Koakuma
921f776224 stage2: sparc64: Implement airTry 2022-06-24 21:19:27 +07:00
Koakuma
40590c8bf9 stage2: sparc64: Save registers before calling another function 2022-06-24 21:08:41 +07:00
Koakuma
5c8612642b stage2: sparc64: Use official encoding for not rs2, rs1 2022-06-24 21:08:41 +07:00
Koakuma
e7fde5f64e stage2: sparc64: Introduce condition_register MCValue type
Introduce condition_register MCValue type for future uses with BPr/MOVr
(mostly when needing to compare a signed value with zero)
2022-06-24 21:08:41 +07:00
Koakuma
accc3bad63 stage2: sparc64: Move conditional branch emission out of airCondBr 2022-06-24 21:08:41 +07:00
Koakuma
8b3f7d2ad8 stage2: sparc64: Merge the compare_flag structs into condition_flags
This follows the design in the aarch64 backend (commit
61844b6bd405b4cca3ab673284609aa6a651d506).
2022-06-24 21:08:40 +07:00
Luuk de Gram
7c87f9c828 link:clarification & enable MachO getGlobalSymbol
This adds clarification to the getGlobalSymbol doc comments,
as well as renames the `addExternFn` function for MachO to `getGlobalSymbol`.
This function will now be called from 'src/link.zig' as well.

Finally, this also enables compiling zig's libc using LLVM even though
the `fno-LLVM` flag is given.
2022-06-24 08:12:17 +02:00
Luuk de Gram
3868864695 Revert "wasm: Enable f16 behavior tests"
This reverts commit 3c34c9f13c67ff1716a9531e87d23a6dad12b45e.
2022-06-24 08:12:17 +02:00
Luuk de Gram
6ae898b244 wasm: more f16 support and cleanup of intrinsics
`genFunctype` now accepts calling convention, param types, and return type
as part of its function signature rather than `fnData`. This means
we no longer have to create a dummy for our intrinsic call abstraction.
This also adds support for f16 division and builtins such as `@ceil` & more.
2022-06-24 08:12:17 +02:00
Luuk de Gram
ba37bc81e9 wasm: Enable f16 behavior tests 2022-06-24 08:12:17 +02:00
Luuk de Gram
a6747d328c stage2: Enable compiler-rt when LLVM is existant
Rather than checking if the user wants to use LLVM for the current compilation,
check for the existance of LLVM as part of the compiler. This is temporarily,
until other backends gain the ability to compiler LLVM themselves.
This means that when a user passed `-fno-LLVM` we will use the native
backend for the user's code, but use LLVM for compiler-rt.

This also fixes emitting names for symbols in the Wasm linker,
by deduplicating symbol names when multiple symbols point the same object.
2022-06-24 08:12:17 +02:00
Luuk de Gram
9015efe405 wasm: Implement @mulAdd for f16
Implements `@mulAdd` for floats with bitsize 16, where it generates
a call into compiler-rt's `fmaf` function. Note that arguments
for fmaf are different in order than `@mulAdd`.
2022-06-24 08:12:17 +02:00
Luuk de Gram
5ebaf49ebb wasm: Implement basic f16 support
This implements binary operations and comparisons
for floats with bitsize 16. It does this by calling into
compiler-rt to first extend the float to 32 bits, perform the operation,
and then finally truncate back to 16 bits. When loading and storing the f16,
we do this as an unsigned 16bit integer.
2022-06-24 08:12:17 +02:00
Luuk de Gram
241180216f wasm-linker: Parse object file from the archive
Rather than finding the original object file, we seekTo to the
object file's position within the archive file, and from there open
a new file handle. This file handle is passed to the `Object` parser
which will create the object.
2022-06-24 08:12:17 +02:00
Luuk de Gram
c9f929a18b fix memory leaks 2022-06-24 08:12:17 +02:00
Luuk de Gram
16daf3f3bc wasm-link: Discard old symbols correctly
When a new symbol is resolved to an existing symbol where
it doesn't overwrite the existing symbol, we now add this symbol
to the discarded list. This is required so when any relocation points
to the symbol, we can retrieve the correct symbol it's resolved by instead.
2022-06-24 08:12:17 +02:00
Luuk de Gram
1a3f58f5e5 wasm-linker: Correctly resolve function type
When performing relocations for a type index,
we first check if the target symbol is undefined. In which case,
we will obtain the type from the `import` rather than look into the
`functions` table.
2022-06-24 08:12:17 +02:00
Luuk de Gram
cb28fc2e63 wasm-linker: Resolve symbols from archives
Lazily load object files by default, and only load the object file
when an unresolved symbol has been found within an archive.
2022-06-24 08:12:17 +02:00
Luuk de Gram
0606fbbc4b wasm-linker: Implement Archive parsing
This implements a very basic archive file parser that validates
the magic bytes, and then parses the symbol table and stores
the symbol and their position.
2022-06-24 08:12:17 +02:00
Luuk de Gram
4d3715d89f wasm-linker: de-duplicate functions+atom sorting
Multiple symbols can point to the same function, this means that when we loop over
the symbol list, we must deduplicate those functions being added twice.
Additionaly, we must also ensure that when we append a new type and set the type
index on a function, we must not do this again for the same function.

This commit also implements sorting of code atoms to ensure their order matches
the order of the function section to ensure the function signature matches
that of the function body.
2022-06-24 08:12:17 +02:00
Luuk de Gram
8d03e4fc6b link: Implement API to get global symbol index 2022-06-24 08:12:17 +02:00
Luuk de Gram
359b61aec3 wasm: Create compiler-rt symbols and lowering
Implements the creation of an undefined symbol for a compiler-rt intrinsic.
Also implements the building of the function call to said compiler-rt intrinsic.
2022-06-24 08:12:17 +02:00
Jakub Konka
291c08f7b0
Merge pull request #11910 from ziglang/linker-tests 2022-06-24 00:02:12 +02:00
FlandreScarlet
87d8cb19e4
std.debug: fix ConfigurableTrace.dump OOB
The for-loop in dump() would index out of bounds if `t.index` is greater
than size, because `end` is the maximum of `t.index` and `size` rather than the
minimum.
2022-06-23 15:07:08 +03:00
Jakub Konka
03ddb42b8b link-tests: rename check() to checkStart()
Do not hardcode the symtab label; instead allow each parser to define
its own.

Check for missing extractor value in the matcher when matching `{}`.
2022-06-23 13:16:03 +02:00
Jakub Konka
6e04c2faab link-tests: fix parsing symtab for macho 2022-06-23 13:16:03 +02:00
Jakub Konka
4497e422f0 macho: fix aligning linkedit sections
Align by file offsets and not file size.
2022-06-23 13:16:00 +02:00
Jakub Konka
ab8a670a57 link-tests: enable on macos CI host only for now 2022-06-22 23:04:47 +02:00
Jakub Konka
e6c012c743 link-tests: add better docs 2022-06-22 22:40:05 +02:00
Jakub Konka
51f2442fc4 link-tests: clean up error messages in case of failure 2022-06-22 22:24:52 +02:00
Jakub Konka
ba768614ac link-tests: frameworks example can test for libobjc autolink in safety modes 2022-06-22 18:51:35 +02:00
Jakub Konka
b35e434cae link-tests: clean up linker testing harness 2022-06-22 18:34:39 +02:00
frmdstryr
6de0c622ff Add missing adddf3
```
LLD Link... ld.lld: error: undefined symbol: __aeabi_dadd
>>> referenced by errol.zig:366 (/home/usr/projects/zig/build/lib/zig/std/fmt/errol.zig:366)
```
2022-06-22 14:32:52 +02:00
Jakub Konka
211de9b63b link-tests: fix dumping of LOAD_DYLIB: name instead of path field 2022-06-22 10:40:10 +02:00
Jakub Konka
23a63f4ce4 link-tests: rename CheckMachOStep to CheckObjectStep and accept obj format 2022-06-22 10:27:51 +02:00
Jakub Konka
b5601a2da6 link-tests: extract values into variables
We can then collect multiple variables (currently assumed always
in global scope) and run a comparison with some very basic
arithmetic on the values.
2022-06-22 00:49:22 +02:00
Jakub Konka
3bb4d65b2f link-tests: move macho tests to subfolder
Handle `-e` option in MachO linker allowing the user to set a custom
entrypoint address.
2022-06-21 23:01:09 +02:00
Jakub Konka
937464f398 link-tests: dump metadata to string and grep results
This approach is more inline with what LLVM/LLD does for testing
of their output, and seems to be more generic and easier to extend
than implementing a lot of repetitive and nontrivial comparison
logic when working directly on structures.
2022-06-21 22:19:57 +02:00
Jakub Konka
5fbdfb3f34 link-tests: add CheckMachOStep
CheckMachOStep specialises CheckFileStep into directed (surgical)
MachO file fuzzy searches. This will be the building block for
comprehensive MachO linker tests.
2022-06-21 15:44:24 +02:00
Veikka Tuominen
d980c6a38d
Merge pull request #11899 from Vexu/stage2
Stage2: fixes for std tests
2022-06-21 13:56:38 +03:00
Jonathan Marler
ca98625789
std.os.execvpe: fix buffer overflow
The NameTooLong check isn't taking the sentinel 0 into account which
would result in a buffer overflow on the stack.
2022-06-21 11:21:45 +02:00
Jakub Konka
2d09540a63 link-tests: test pagezero_size option for macho 2022-06-20 18:25:20 +02:00
Jakub Konka
6e56a8df20 link-tests: CheckFileStep to do grep test on the binary 2022-06-20 17:59:17 +02:00
Jakub Konka
38edef35bf test: introduce link(er) tests - builds on standalone tests 2022-06-20 17:59:17 +02:00
Jakub Konka
74ed7c1f09
Merge pull request #11875 from motiejus/pagezero-size
[MachO] add -pagezero_size
2022-06-20 17:51:20 +02:00
Veikka Tuominen
d0d5052b39 std.fmt: update test to stage2 fn pointer semantics 2022-06-20 16:12:40 +03:00
Jakub Konka
8752db3285 macho: -pagezero_size is always in hex
This matches the behavior of other linkers out there including
`ld64` and `lld`.
2022-06-20 14:26:59 +02:00
Veikka Tuominen
38a1222c87 std.crypto: fix invalid pass by value 2022-06-20 15:11:22 +03:00