aboutsummaryrefslogtreecommitdiff
path: root/src/link
AgeCommit message (Collapse)Author
2022-09-13stage2: remove pointless discards from source codeAndrew Kelley
Good riddance!
2022-09-10coff: remove unused functionJakub Konka
2022-09-10macho: refactor direct use of locals container in favour of helpersJakub Konka
2022-09-10x86_64: combine got_load, direct_load and imports_load into linker_load MCVJakub Konka
2022-09-09macho+coff: return index into global table from getGlobalSymbolJakub Konka
2022-09-09coff: use global accessor abstractions from MachOJakub Konka
2022-09-09macho: use globals free list like in COFF linkerJakub Konka
2022-09-09Merge pull request #12772 from ziglang/coff-basic-importsJakub Konka
coff: implement enough of the incremental linker to pass behavior and incremental tests on Windows
2022-09-09macho: fix compilation for 32bit targetsJakub Konka
2022-09-08[ld] add --print-* for diagnosticsMotiejus Jakštys
This adds the following for passthrough to lld: - `--print-gc-sections` - `--print-icf-sections` - `--print-map` I am not adding these to the cache manifest, since it does not change the produced artifacts. Tested with an example from #11398: it successfully prints the resulting map and the GC'd sections.
2022-09-09macho: prefill any space between __DATA and __LINKEDIT with 0s if requiredJakub Konka
If there are zerofill sections, the loader may copy the contents of the physical space in file directly into memory and attach that to the zerofill section. This is a performance optimisation in the loader but requires us, the linker, to properly zero-out any space between __DATA and __LINKEDIT segments in file. This is of course completely skipped if there are no zerofill sections present.
2022-09-08wasm: temporarily save curr file pointer before pwriting on WinJakub Konka
This is a temporary workaround to an unclear platform-dependence behavior we have in libstd for `std.fs.File` abstraction. See https://github.com/ziglang/zig/issues/12783 for more information.
2022-09-07macho+wasm: unify and clean up closing file handlesJakub Konka
2022-09-07macho: set file instance in linkOneShot only if not already setJakub Konka
2022-09-07macho: properly close file handles owned by the linker in deinit()Jakub Konka
2022-09-07coff: fix tracking of got and import entries; free relocs in update* fnsJakub Konka
2022-09-07coff: track globals in contiguous array to allow for tombstonesJakub Konka
2022-09-07coff: fix memory leak in incorrectly disposing of globals tableJakub Konka
2022-09-07coff: use more generous initial memory sizes for sectionsJakub Konka
2022-09-07coff: remove redundant bits and clean upJakub Konka
2022-09-07coff: grow section in virtual address space when requiredJakub Konka
2022-09-07coff: find new file space for a section (file offsets)Jakub Konka
2022-09-07coff: differentiate between file space and VM space for allocJakub Konka
2022-09-07coff: create a helper for allocating sectionsJakub Konka
2022-09-07coff: fix writing strtab to PE image fileJakub Konka
2022-09-07coff: mark relocations dirty when target atoms changeJakub Konka
2022-09-07coff: fix bug in lowerUnnamedConstJakub Konka
2022-09-07coff: fix runtime trapsJakub Konka
2022-09-07coff: implement lowering unnamed constsJakub Konka
2022-09-07coff: fix contents of IAT, and ensure codegen loads addr into regJakub Konka
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-07coff: populate import address table dirJakub Konka
2022-09-07coff: create import atoms and matching bindingsJakub Konka
2022-09-07coff: re-enable default entrypoint for WindowsJakub Konka
2022-09-07wasm-linker: support incremental debug infoLuuk de Gram
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-07wasm-linker: Mix Zig -and Object debug atomsLuuk de Gram
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-07wasm-linker: use Atoms for zig debug infoLuuk de Gram
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-07wasm-linker: perform debug relocationsLuuk de Gram
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-07wasm-linker: write debug sections from objectsLuuk de Gram
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-07wasm-linker: create atoms from debug sectionsLuuk de Gram
2022-09-07wasm/Object: parse debug sections into reloc dataLuuk de Gram
Rather than storing the name of a debug section into the structure `RelocatableData`, we use the `index` field as an offset into the debug names table. This means we do not have to store an extra 16 bytes for non-debug sections which can be massive for object files where each data symbol has its own data section. The name of a debug section can then be retrieved again when needed by using the offset and then reading until the 0-delimiter.
2022-08-31coff: write base relocations for the dynamic linkerJakub Konka
This means we can request ASLR on by default as other COFF linkers do. Currently, we write the base relocations in bulk, however, given that there is a mechanism for padding in place in PE/COFF I believe there might be room for making it an incremental operation (write base relocation whenever we add/update a pointer that would require it).
2022-08-30wasm: create relocations for extern declsLuuk de Gram
This also fixes performing relocations for data symbols of which the target symbol exists in an external object file. We do this by checking if the target symbol was discarded, and if so: get the new location so that we can find the corresponding atom that belongs to said new location. Previously it would always assume the symbol would live in the same file as the atom/symbol that is doing the relocation.
2022-08-30link/Wasm: handle extern variablesLuuk de Gram
Generate symbols for extern variables and try to resolve them. Unresolved 'data' symbols generate an error as they cannot be exported from the Wasm runtime into a Wasm module. This means, they can only be resolved by other object files such as from other Zig or C code compiled to Wasm.
2022-08-30coff: cleanup relocations; remove COFF support from other backendsJakub Konka
Given that COFF will want to support PIC from ground-up, there is no point in leaving outdated code for COFF in other backends such as arm or aarch64. Instead, when we are ready to look into those, we can start figuring out what to add and where.
2022-08-30coff: commit missing Object.zig placeholderJakub Konka
2022-08-30coff: add basic handling of GOT PC relative indirectionJakub Konka
2022-08-30coff: fallback to _start as default entry point for nowJakub Konka
This is not technically correct, but given that we are not yet able to link against the CRT, it's a good default until then. Add basic logging of generated symbol table in the linker.
2022-08-30coff: ...and lift-off!Jakub Konka
2022-08-30coff: add missing bits required for minimal PE exampleJakub Konka
2022-08-30coff: allocate and write atoms to fileJakub Konka