aboutsummaryrefslogtreecommitdiff
path: root/src/link/Elf/Atom.zig
AgeCommit message (Collapse)Author
2025-09-26compiler: move self-hosted backends from src/arch to src/codegenAlex Rønne Petersen
2025-08-31std.fmt: delete deprecated APIsAndrew Kelley
std.fmt.Formatter -> std.fmt.Alt std.fmt.format -> std.Io.Writer.print
2025-08-28link.Elf: update to not use GenericWriterAndrew Kelley
2025-08-25start adding big endian RISC-V supportAlex Rønne Petersen
The big endian RISC-V effort is mostly driven by MIPS (the company) which is pivoting to RISC-V, and presumably needs a big endian variant to fill the niche that big endian MIPS (the ISA) did. GCC already supports these targets, but LLVM support will only appear in 22; this commit just adds the necessary target knowledge and checks on our end.
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-07-22aarch64: add new from scratch self-hosted backendJacob Young
2025-07-09eliminate all uses of std.io.Writer.count except for CBEAndrew Kelley
2025-07-07compiler: update a bunch of format stringsAndrew Kelley
2025-07-07compiler: fix a bunch of format stringsAndrew Kelley
2025-07-07compiler: upgrade various std.io API usageAndrew Kelley
2025-07-07compiler: update all instances of std.fmt.FormatterAndrew Kelley
2025-06-06x86_64: add support for pie executablesJacob Young
2025-03-27std.meta.FieldType -> @FieldTypeАндрей Краевский
2025-02-11link.Elf: implement non-alloc `{SET,SUB}_ULEB128`David Rubin
2025-01-16x86_64: implement clz and notJacob Young
2025-01-16x86_64: demolish the oldJacob Young
2025-01-15wasm linker: fix crashes when parsing compiler_rtAndrew Kelley
2024-12-14Elf.Atom: fix truncated dyn abs relocsJacob Young
2024-10-23link.Elf: untangle parseObject and parseArchiveAndrew Kelley
from link.Elf, so that they can be used earlier in the pipeline
2024-10-12link.Elf: eliminate an O(N^2) algorithm in flush()Andrew Kelley
Make shared_objects a StringArrayHashMap so that deduping does not need to happen in flush. That deduping code also was using an O(N^2) algorithm, which is not allowed in this codebase. There is another violation of this rule in resolveSymbols but this commit does not address it. This required reworking shared object parsing, breaking it into independent components so that we could access soname earlier. Shared object parsing had a few problems that I noticed and fixed in this commit: * Many instances of incorrect use of align(1). * `shnum * @sizeOf(elf.Elf64_Shdr)` can overflow based on user data. * `@divExact` can cause illegal behavior based on user data. * Strange versyms logic that wasn't present in mold nor lld. The logic was not commented and there is no git blame information in ziglang/zig nor kubkon/zld. I changed it to match mold and lld instead. * Use of ArrayList for slices of memory that are never resized. * finding DT_VERDEFNUM in a different loop than finding DT_SONAME. Ultimately I think we should follow mold's lead and ignore this integer, relying on null termination instead. * Doing logic based on VER_FLG_BASE rather than ignoring it like mold and LLD do. No comment explaining why the behavior is different. * Mutating the original ELF symbols rather than only storing the mangled name on the new Symbol struct. I noticed something that I didn't try to address in this commit: Symbol stores a lot of redundant information that is already present in the ELF symbols. I suspect that the codebase could benefit from reworking Symbol to not store redundant information. Additionally: * Add some type safety to std.elf. * Eliminate 1-3 file system reads for determining the kind of input files, by taking advantage of file name extension and handling error codes properly. * Move more error handling methods to link.Diags and make them infallible and thread-safe * Make the data dependencies obvious in the parameters of parseSharedObject. It's now clear that the first two steps (Header and Parsed) can be done during the main Compilation pipeline, rather than waiting for flush().
2024-10-11link: consolidate diagnosticsAndrew Kelley
By organizing linker diagnostics into this struct, it becomes possible to share more code between linker backends, and more importantly it becomes possible to pass only the Diag struct to some functions, rather than passing the entire linker state object in. This makes data dependencies more obvious, making it easier to rearrange code and to multithread. Also fix MachO code abusing an atomic variable. Not only was it using the wrong atomic operation, it is unnecessary additional state since the state is already being protected by a mutex.
2024-10-09Merge pull request #21629 from ziglang/elf-incrAndrew Kelley
elf: more incremental progress
2024-10-09link.Elf.Object.initAtoms: reduce state access and indirectionAndrew Kelley
The initAtoms function now only uses the `elf_file` parameter for reporting linker error messages, making it easier to see that the function has no data dependencies other than the Object struct itself, making it easier to parallelize or otherwise move that logic around. Also removed an indirect call via `addExtra` since we already know the atom's file is the current Object instance. All calls to `Atom.addExtra` should be audited for similar reasons. Also removed unjustified use of `inline fn`.
2024-10-09elf: change how we manage debug atoms in Dwarf linkerJakub Konka
2024-10-09elf: do not create atoms for section symbols that do not require itJakub Konka
2024-10-09elf: add some extra logging for created dynamic relocsJakub Konka
2024-09-04dwarf: make Section.off a functionJakub Konka
2024-09-04elf: split Atom.allocate into Atom-independent partsJakub Konka
2024-08-29compiler: avoid field/decl name conflictsmlugg
Most of the required renames here are net wins for readaibility, I'd say. The ones in `arch` are a little more verbose, but I think better. I didn't bother renaming the non-conflicting functions in `arch/arm/bits.zig` and `arch/aarch64/bits.zig`, since these backends are pretty bit-rotted anyway AIUI.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-08-26elf: make Atom.allocate and related ZigObject-independentJakub Konka
2024-08-25elf: simplify output section symbol trackingJakub Konka
2024-08-25elf: streamline sections containerJakub Konka
2024-08-21elf: emit .rela.debug* sections for relocatable if requiredJakub Konka
2024-08-16Dwarf: rework self-hosted debug info from scratchJacob Young
This is in preparation for incremental and actually being able to debug executables built by the x86_64 backend.
2024-08-15elf: fix GOT32 reloc resolution logicJakub Konka
2024-08-15riscv: do not emit GOT relocations for special linker symbolsJakub Konka
2024-08-14elf: re-use old atom slot for a trampoline to that atomJakub Konka
This is the initial implementation of Jacob Young's idea of re-using old function slots as trampolines for new function's location. This way the trampoline is guaranteed to be aligned to the function's alignment. The only edge case is if an incremental update further overaligns the function in which case we skip/delete the trampoline and re-evaluate all references.
2024-08-13elf: only apply zig jump table indirection to function calls (PLT32)Jakub Konka
2024-08-13elf: pretty print alingment when pretty printing atomsJakub Konka
2024-08-13elf: make zig jump table indirection implicit via Symbol.addressJakub Konka
2024-08-13x86_64: emit call rel32 for near calls with linker relocJakub Konka
2024-08-13elf: rename OffsetTable to JumpTableJakub Konka
2024-08-13elf: nuke ZigGotSection from existenceJakub Konka
2024-08-13elf: relax R_X86_64_32 into jump table indirection if zig_offset_table setJakub Konka
2024-08-13elf: indirect via offset table in the linker away from backendJakub Konka
2024-08-07elf: fix compile errorsJakub Konka
2024-08-07elf: always create symbol extraJakub Konka
2024-07-31riscv: fix `.got` symbol loadingDavid Rubin
2024-07-30elf: do not store merge section output section name in strings bufferJakub Konka