aboutsummaryrefslogtreecommitdiff
path: root/src/link/Elf/Symbol.zig
AgeCommit message (Collapse)Author
2025-08-31std.fmt: delete deprecated APIsAndrew Kelley
std.fmt.Formatter -> std.fmt.Alt std.fmt.format -> std.Io.Writer.print
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-07-07compiler: update a bunch of format stringsAndrew Kelley
2025-07-07compiler: update all instances of std.fmt.FormatterAndrew Kelley
2025-06-12x86_64: remove linker references from codegenJacob Young
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.Elf: fix merge sections namespacingAndrew Kelley
`link.Elf.merge_section.MergeSection` -> `link.Elf.Merge.Section`
2024-10-11link.Elf: group section indexesAndrew Kelley
so they cannot be forgotten when updating them after sorting them.
2024-10-09elf: fix creation of synthetic sectionsJakub Konka
2024-09-23elf: remove dead codeJakub Konka
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: streamline sections containerJakub Konka
2024-08-15elf: introduce Symbol.flags.is_extern_ptr for refs potentially needing GOTJakub 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: commit non-indirected symbol address to symtabJakub Konka
2024-08-13elf: make zig jump table indirection implicit via Symbol.addressJakub Konka
2024-08-13elf: rename OffsetTable to JumpTableJakub Konka
2024-08-13elf: nuke ZigGotSection from existenceJakub Konka
2024-08-13elf: indirect via offset table in the linker away from backendJakub Konka
2024-08-13elf: allocate new offset table via Atom.allocate mechanismJakub Konka
2024-08-07elf: fix compile errorsJakub Konka
2024-08-07elf: redo symbol mgmt and ownership in ZigObjectJakub Konka
2024-08-07elf: always create symbol extraJakub Konka
2024-07-30elf: move merge subsections ownership into merge sectionsJakub Konka
2024-07-30elf: simplify output section tracking for symbolsJakub Konka
2024-07-30elf: remove obsolete flags from atomJakub Konka
2024-07-30elf: move ownership of atoms into objectsJakub Konka
2024-04-20link/elf: implement string mergingJakub Konka
2024-04-20link/elf: port macho symbol extras handlingJakub Konka
2024-04-08link/elf: handle symbols to begin/end of .eh_frame sectionJakub Konka
2024-03-08elf+aarch64: implement basic thunk supportJakub 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-02-13elf: use u32 for all section indexesJakub Konka
2024-02-13elf: store relative offsets in atom and symbolJakub Konka
2024-01-01update codegen.llvm references to bin_file.optionsAndrew Kelley
2023-11-12elf: set symbol flags such as needs_zig_got in ZigObjectJakub Konka
2023-11-12x86_64: get something going for the local exec modelJakub Konka
2023-11-08elf: emit SHN_COMMON symbols in -r modeJakub Konka
2023-11-08elf: LLVM emits relocs to undef local symbols - color me surprised!Jakub Konka
2023-11-07elf: actually track output symtab index of symbolsJakub Konka
2023-11-07elf: generate section symbols when writing symtabJakub Konka
2023-11-04elf: collect exports from ZigObject into AR symtabJakub Konka
2023-11-04elf: postpone creation of .got.zig entry until code emitJakub Konka
2023-11-04elf: emit STT_SECTION symbolsJakub Konka
2023-11-04elf: make sure we never emit .got.zig relocs when linking object filesJakub Konka
2023-11-04elf: improve Symbol to handle emitting relocatable object filesJakub Konka
2023-11-04elf: redo strings management in the linkerJakub Konka
* atom names - are stored locally and pulled from defining object's strtab * local symbols - same * global symbols - in principle, we could store them locally, but for better debugging experience - when things go wrong - we store the offsets in a global strtab used by the symbol resolver