aboutsummaryrefslogtreecommitdiff
path: root/src/link
AgeCommit message (Collapse)Author
2024-03-08elf+aarch64: handle gottp and .tls_commonJakub Konka
2024-03-08elf+aarch64: fix incorrectly emitted TLSDESC relocsJakub Konka
2024-03-08elf+aarch64: set _GLOBAL_OFFSET_TABLE_ to .got sectionJakub Konka
2024-03-08elf+aarch64: relax TLSDESC for executablesJakub Konka
2024-03-08elf+aarch64: handle TLSDESC non-relaxedJakub Konka
2024-03-08link: refactor common aarch64 helpersJakub Konka
2024-03-08elf+aarch64: resolve TLS LE modelJakub Konka
2024-03-08elf+aarch64: use correctly offset tp addressJakub Konka
2024-03-08elf+aarch64: implement .plt.gotJakub Konka
2024-03-08elf+aarch64: implement enough to link dynamically with gcc as the driverJakub Konka
2024-03-07Merge pull request #19190 from mlugg/struct-equivalenceAndrew Kelley
compiler: namespace type equivalence based on AST node + captures
2024-03-06feat: add support for --enable-new-dtags and --disable-new-dtagsDillen Meijboom
2024-03-06InternPool: create specialized functions for loading namespace typesmlugg
Namespace types (`struct`, `enum`, `union`, `opaque`) do not use structural equality - equivalence is based on their Decl index (and soon will change to AST node + captures). However, we previously stored all other information in the corresponding `InternPool.Key` anyway. For logical consistency, it makes sense to have the key only be the true key (that is, the Decl index) and to load all other data through another function. This introduces those functions, by the name of `loadStructType` etc. It's a big diff, but most of it is no-brainer changes. In future, it might be nice to eliminate a bunch of the loaded state in favour of accessor functions on the `LoadedXyzType` types (like how we have `LoadedUnionType.size()`), but that can be explored at a later date.
2024-03-01macho: correctly find N_GSYM symbols when parsing symbol stabsJakub Konka
In `ld -r` mode, the linker will emit `N_GSYM` for any defined external symbols as well as private externals. In the former case, the thing is easy since `N_EXT` bit will be set in the nlist's type. In the latter however we will encounter a local symbol with `N_PEXT` bit set (non-extern, but was private external) which we also need to include when resolving symbol stabs. The major change in the logic for parsing symbol stabs per input object file is that we no longer try to force-resolve a `N_GSYM` as a global symbol. This was a mistake since every symbol stab always describes a symbol defined within the parsed input object file. We then work out if we should forward `N_GSYM` in the output symtab after we have resolved all symbols, but never before - intel we lack when initially parsing symbol stabs. Therefore, we simply record which symbol has a debug symbol stab, and work out its precise type when emitting output symtab after symbol resolution has been done.
2024-02-29fix memory leaksLuuk de Gram
2024-02-29wasm: gc fixes and re-enable linker testsLuuk de Gram
Certain symbols were left unmarked, meaning they would not be emit into the final binary incorrectly. We now mark the synthetic symbols to ensure they are emit as they are already created under the circumstance they're needed for. This also re-enables disabled tests that were left disabled in a previous merge conflict. Lastly, this adds the shared-memory test to the test harnass as it was previously forgotten and therefore regressed.
2024-02-29wasm: integrate linker errors with `Compilation`Luuk de Gram
Rather than using the logger, we now emit proper 'compiler'-errors just like the ELF and MachO linkers with notes. We now also support emitting multiple errors before quiting the linking process in certain phases, such as symbol resolution. This means we will print all symbols which were resolved incorrectly, rather than the first one we encounter.
2024-02-29wasm: make symbol indexes a non-exhaustive enumLuuk de Gram
This introduces some type safety so we cannot accidently give an atom index as a symbol index. This also means we do not have to store any optionals and therefore allow for memory optimizations. Lastly, we can now always simply access the symbol index of an atom, rather than having to call `getSymbolIndex` as it is easy to forget.
2024-02-29wasm: consolidate flushModule and linkWithZldLuuk de Gram
We now use a single function to use the in-house WebAssembly linker rather than wasm-ld. For both incremental compilation and traditional linking we use the same codepath.
2024-02-29wasm: correctly generate relocations for type indexLuuk de Gram
Previously we could directly write the type index because we used the index that was known in the final binary. However, as we now process the Zig module as its own relocatable object file, we must ensure to generate a relocation for type indexes. This also ensures that we can later link the relocatable object file as a standalone also. This also fixes generating indirect function table entries for ZigObject as it now correctly points to the relocation symbol index rather than the symbol index that owns the relocation.
2024-02-29wasm: reimplement Zig errors in linkerLuuk de Gram
2024-02-29wasm: ensure unique function indexesLuuk de Gram
We cannot keep function indexes as maxInt(u32) due to functions being dedupliated when they point to the same function. For this reason we now use a regular arraylist which will have new functions appended to, and when deleted, its index is appended to the free list, allowing us to re-use slots in the function list.
2024-02-29wasm: reimplement `deleteDeclExport`Luuk de Gram
Removes the symbol from the decl's list of exports, marks it as dead, as well as appends it to the symbol free list. Also removes it from the list of global symbols as all exports are global. In the future we should perhaps use a map for the export list to prevent linear lookups. But this requires a benchmark as having more than 1 export for the same decl is very rare.
2024-02-29wasm: re-implement `updateExports`Luuk de Gram
We now correctly create a symbol for each exported decl with its export- name. The symbol points to the same linker-object. We store a map from decl to all of its exports so we can update exports if it already exists rather than infinitely create new exports.
2024-02-29wasm: update `freeDecl` and `finishDecl`Luuk de Gram
We now parse the decls right away into atoms and allocate the corresponding linker-object, such as segment and function, rather than waiting until `flushModule`.
2024-02-29wasm: Move `createFunction` to `ZigObject`Luuk de Gram
This function was previously only called by the backend which generates a synthetical function that is not represented by any AIR or Zig code. For this reason, the ownership is moved to the zig-object and stored there so it can be linked with the other object files without the driver having to specialize it.
2024-02-29wasm: Use `File.Index` for symbol locationsLuuk de Gram
Rather than using the optional, we now directly use `File.Index` which can already represent an unknown file due to its `.null` value. This means we do not pay for the memory cost. This type of index is now used for: - SymbolLoc - Key of the functions map - InitFunc Now we can simply pass things like atom.file, object.file, loc.file etc whenever we need to access its representing object file which makes it a lot easier.
2024-02-29wasm: Add `File` abstractionLuuk de Gram
2024-02-29wasm: fix symbol resolution and atom processingLuuk de Gram
2024-02-29wasm: use `File` abstraction instead of objectLuuk de Gram
When merging sections we now make use of the `File` abstraction so all objects such as globals, functions, imports, etc are also merged from the `ZigObject` module. This allows us to use a singular way to perform each link action without having to check the kind of the file. The logic is mostly handled in the abstract file module, unless its complexity warrants the handling within the corresponding module itself.
2024-02-29wasm: store `File.Index` on the AtomLuuk de Gram
Also, consolidate the creation of Atoms so they all use `createAtom`.
2024-02-29wasm: create linking objects in correct moduleLuuk de Gram
CodeGen will create linking objects such as symbols, function types, etc in ZigObject, rather than in the linker driver where the final result will be stored. They will end up in the linker driver module during the `flush` phase instead. This must mean we must call functions such as `addOrGetFuncType` in the correct namespace or else it will be created in the incorrect list and therefore return incorrect indexes.
2024-02-29wasm: initialize a `ZigObject` when requiredLuuk de Gram
When we have a ZigCompileUnit and don't use LLVM, we initialize the ZigObject which will encapsulate the Zig Module as an object file in- memory. During initialization we also create symbols which the object will need such as the stack pointer.
2024-02-29wasm: move incremental Dwarf info into ZigObjectLuuk de Gram
2024-02-29wasm: move Zig module-linkage to ZigObjectLuuk de Gram
Rather than specializing the linker-driver to be able to handle objects generated by a ZCU, we store all data in-memory in ZigObject. ZigObject acts more like a regular object file which will allow us to treat it as us. This will make linking much more simple, but will also reduce the complexity of incremental-linking as we can simply update ZigObject and relink it.
2024-02-28use hash.addListOfBytes where applicableAndrew Kelley
2024-02-27move `zig libc` command to be lazily builtAndrew Kelley
part of #19063 This is a prerequisite for doing the same for Resinator.
2024-02-26change default WASI stack sizeAndrew Kelley
to match the other operating systems. 16 MiB closes #18885
2024-02-25test: rework how filtering worksJacob Young
* make test names contain the fully qualified name * make test filters match the fully qualified name * allow multiple test filters, where a test is skipped if it does not match any of the specified filters
2024-02-26macho: count rebases for synthetic __objc_selrefsJakub Konka
2024-02-26macho: fix section to segment mappingJakub Konka
2024-02-26macho: actually set SG_READ_ONLY on __DATA_CONST segmentJakub Konka
2024-02-23Merge pull request #19034 from ziglang/elf-riscvJakub Konka
elf: add basic aarch64 and riscv64 support
2024-02-21elf+riscv: return an error for unimplemented HI20 forward lookupJakub Konka
2024-02-21link+riscv: simplify bitSlice helperJakub Konka
2024-02-21link+riscv: use riscv64/bits.zig to implement write helpersJakub Konka
2024-02-21elf+riscv: implement enough to get basic hello world in C workingJakub Konka
2024-02-21elf+riscv: skip parsing .riscv.attributes section for nowJakub Konka
2024-02-21elf: skip STT_NOTYPE only if SHN_UNDEF from symtab inclusionJakub Konka
2024-02-21link: commit missing filesJakub Konka