Commit Graph

31 Commits

Author SHA1 Message Date
Luuk de Gram 8627858bbc test/link: add test for extern resolution
Adds a linker tests to verify extern/undefined symbols
representing non-functions are being resolved correctly.
2022-08-30 18:32:08 +02:00
Luuk de Gram 7fe2a3d104 test/link: add wasm linker-test for archives
Adds a test case that will pull-in compiler-rt symbols,
and therefore link with the compiler-rt archive file.
2022-08-20 15:46:39 +02:00
Jakub Konka 9b595dd55f link-test: refactor and reorg
Move common tests by target file format (Wasm, MachO) into helper
functions in `link.zig`, and sort alphabetically within for easier
tracking versus file organization on disk.
2022-08-17 23:13:49 +02:00
Jakub Konka d84282174c link-test: move tls test to macho/tls
This test was always really testing correct behavior of our in-house
MachO linker to begin with.
2022-08-17 09:00:26 +02:00
Luuk de Gram 72c0cebe5c test/link/macho: use EmulationStep for dead_strip 2022-07-23 17:27:47 +02:00
Luuk de Gram 4776065036 Use EmulatableRunStep for MachO linker tests 2022-07-23 10:03:51 +02:00
Jakub Konka 2c184f9a5f link-tests: add checkNotPresent and add -dead_strip smoke test
`checkNotPresent` is the inverse of `checkNext` - if the phrase is
found in the output, then it fails the test.
2022-07-22 16:58:21 +02:00
Jakub Konka d80fcc8a0b macho: rework symbol handling for incremental stage2 builds 2022-07-22 16:58:20 +02:00
Jakub Konka 03feea0fb2 macho: split section into subsections if requested and/or possible 2022-07-22 16:58:20 +02:00
Luuk de Gram 8033767082 wasm-linker: Implement linker tests (#12006)
* test/link: initial wasm support

This adds basic parsing and dumping of wasm section so they
can be tested using the new linker-test infrastructure.

* test/link: all wasm sections parsing and dumping

We now parse and dump all sections for the wasm binary format.
Currently, this only dumps the name of a custom section.
Later this should also dump symbol table, name, linking metadata and relocations.
All of those live within the custom sections.

* Add wasm linker test

This also fixes a parser mistake in reading the flags.

* test/link: implement linker tests wasm & fixes

Adds several test cases to test the wasm self-hosted linker.
This also introduces fixes that were caught during the implementation
of those tests.

* test-runner: obey omit_stage2 for standalone

When a standalone test requires stage2, but stage2 is omit
from the compiler, such test case will not be included as part
of the test suite that is being ran. This is to support CI's
where we omit stage2 to lower the memory usage.
2022-07-12 14:36:33 +02:00
Jakub Konka 5834a608fc link-tests: do not save global extracted var unless a match
Improve testing MachO binaries by verbose printing of the symtab
which includes segment,section names for defined symbols, and
import (dylib) name for imports.
2022-06-28 10:23:25 +02:00
Jakub Konka 075f5bc5ff link-tests: test -weak-lx and -weak_framework x 2022-06-28 09:22:04 +02:00
Jakub Konka 0dd28920da macho: implement and handle -needed-* and -needed_* family of flags
MachO linker now handles `-needed-l<name>`, `-needed_library=<name>`
and `-needed_framework=<name>`. While on macOS `-l` is equivalent
to `-needed-l`, and `-framework` to `-needed_framework`, it can be
used to the same effect as on Linux if combined with `-dead_strip_dylibs`.

This commit also adds handling for `-needed_library` which is macOS
specific flag only (in addition to `-needed-l`).

Finally, in order to leverage new linker testing harness, this commit
added ability to specify lowering to those flags via `build.zig`:
`linkSystemLibraryNeeded` (and related), and `linkFrameworkNeeded`.
2022-06-27 19:53:38 +02:00
Jakub Konka efc5c97bff macho: implement -dead_strip_dylibs linker flag 2022-06-27 19:53:38 +02:00
Jakub Konka 589bf67635 macho: implement -headerpad_max_install_names 2022-06-25 18:04:40 +02:00
Jakub Konka a6fbdfabb9 link-tests: add -headerpad_size test scenario 2022-06-25 17:59:09 +02:00
Jakub Konka f91503e577 link-tests: defer parsing of the RPN program until running the action 2022-06-25 17:56:03 +02:00
Jakub Konka 8f00bc9d23 link-tests: put macho search strategy tests into one test case 2022-06-25 10:57:56 +02:00
Jakub Konka 24821dd17f link-tests: test -search_paths_first and -search_dylibs_first macho flags 2022-06-24 22:07:51 +02: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 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
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
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