aboutsummaryrefslogtreecommitdiff
path: root/src/link/Elf/Archive.zig
AgeCommit message (Collapse)Author
4 dayslink: update to new file system APIsAndrew Kelley
4 daysupdate all stat() to stat(io)Andrew Kelley
2025-11-20update deprecated ArrayListUnmanaged usage (#25958)Benjamin Jurk
2025-11-08link.Elf: Ensure archive header fields are not left blankCarl Ã…stholm
ld.lld fails with "truncated or malformed archive" errors when reading archive header field values that are not valid numbers.
2025-10-29Elf2: simplify archive loadingJacob Young
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-08-28link.Elf: update to not use GenericWriterAndrew Kelley
2025-07-07std.fmt: fully remove format string from format methodsAndrew Kelley
Introduces `std.fmt.alt` which is a helper for calling alternate format methods besides one named "format".
2025-07-07compiler: update a bunch of format stringsAndrew Kelley
2025-07-07compiler: update all instances of std.fmt.FormatterAndrew Kelley
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2024-10-23glibc sometimes makes archives be ld scriptsAndrew Kelley
it is incredible how many bad ideas glibc is bundled into one project.
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-10link: fix false positive crtbegin/crtend detectionAndrew Kelley
Embrace the Path abstraction, doing more operations based on directory handles rather than absolute file paths. Most of the diff noise here comes from this one. Fix sorting of crtbegin/crtend atoms. Previously it would look at all path components for those strings. Make the C runtime path detection partially a pure function, and move some logic to glibc.zig where it belongs.
2024-10-08link.Elf: avoid needless file system reads in flush()Andrew Kelley
flush() must not do anything more than necessary. Determining the type of input files must be done only once, before flush. Fortunately, we don't even need any file system accesses to do this since that information is statically known in most cases, and in the rest of the cases can be determined by file extension alone. This commit also updates the nearby code to conform to the convention for error handling where there is exactly one error code to represent the fact that error messages have already been emitted. This had the side effect of improving the error message for a linker script parse error. "positionals" is not a linker concept; it is a command line interface concept. Zig's linker implementation should not mention "positionals". This commit deletes that array list in favor of directly making function calls, eliminating that heap allocation during flush().
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-04-25fix: object size error in archivezhylmzr
2024-02-13macho: scrap reader for preads when parsing archivesJakub Konka
2024-02-13elf: scrap reader for preads when parsing archivesJakub Konka
2024-02-12elf: do not prealloc input objects, pread selectivelyJakub Konka
2024-01-01linker: fix some allocator referencesAndrew Kelley
2023-12-05elf: report malformed archive when parsing errorsJakub Konka
2023-11-06CheckObject: support parsing and dumping archive symtab for ELFJakub Konka
2023-11-05elf: hook up saving object files in an archiveJakub Konka
2023-11-05elf: actually save correct object names in the archiveJakub Konka
2023-11-04elf: do not store filename in strtab unless longer than 15 charsJakub Konka
2023-11-04elf: store ar state per input object fileJakub Konka
2023-11-04elf: do not align end of archive to 2bytes; fix archive parserJakub Konka
2023-11-04elf: align ar_hdr to at least 2 bytesJakub Konka
2023-11-04elf: generate pretty rudimentary archiveJakub Konka
2023-11-04elf: collect exports from ZigObject into AR symtabJakub Konka
2023-10-24elf: improve parsing of ld scripts and actually test linking against themJakub Konka
2023-10-18elf: parse GNU ld script as system lib indirectionJakub Konka
2023-09-13elf: parse archivesJakub Konka