zig/lib/std
Andrew Kelley 1ba3fc90be link.Elf: eliminate an O(N^2) algorithm in flush()
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-12 10:44:17 -07:00
..
Build link.Elf: eliminate an O(N^2) algorithm in flush() 2024-10-12 10:44:17 -07:00
c fix typo in segset_t 2024-10-03 09:37:57 -07:00
compress std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
crypto Add post-quantum key agreement X25519MLKEM768 2024-09-24 13:18:32 -07:00
debug update safety test cases to new panic API 2024-09-26 17:14:17 -07:00
dwarf Dwarf: fix and test allowzero pointers 2024-08-17 05:57:45 -04:00
fmt std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
fs Explain why POLL_FD_READWRITE is not dangerous at sites of use 2024-10-06 09:47:12 +01:00
hash Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
heap std: deprecate some incorrect default initializations 2024-09-01 17:34:07 +01:00
http disable failing test 2024-09-19 18:20:22 -07:00
io std.io.Reader: Fix test erroneously using undefined. 2024-09-26 17:04:36 +02:00
json Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
math std.math: Re-enable isSignalNan test on most targets. 2024-10-03 04:38:53 +02:00
mem std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
meta std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
net
os link.Elf: eliminate an O(N^2) algorithm in flush() 2024-10-12 10:44:17 -07:00
posix std.posix: Skip Stat struct comparison in fstatat test for s390x-linux. 2024-10-04 00:26:55 +02:00
process fix IB in fifoToOwnedArrayList 2024-09-24 13:19:06 -07:00
Random add std.testing.random_seed 2024-07-23 11:43:12 -07:00
sort compiler,lib,test,langref: migrate @setCold to @branchHint 2024-08-27 00:44:35 +01:00
tar Remove old deprecated symbols in std (#21584) 2024-10-04 13:50:25 -07:00
Target Adds new cpu architectures propeller1 and propeller2. (#21563) 2024-10-04 13:53:28 -07:00
testing
Thread remove @fence (#21585) 2024-10-04 22:21:27 +00:00
time std.time.epoch: Fix comments referring to epoch as 1970-10-01 2024-08-15 17:54:27 -07:00
tz
unicode
valgrind port cachegrind.h to zig (#19241) 2024-08-23 22:59:30 -07:00
zig link: fix false positive crtbegin/crtend detection 2024-10-10 14:21:52 -07:00
zip std: Convert deprecated aliases to compile errors and fix usages 2024-06-13 10:18:59 -04:00
array_hash_map.zig Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
array_list.zig Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
ascii.zig std.ascii: make toLower toUpper branchless (#21369) 2024-09-13 17:22:19 -07:00
atomic.zig Merge pull request #21587 from alexrp/hexagon-porting 2024-10-06 13:35:56 +02:00
base64.zig stdlib : base64 encode to writer (#20961) 2024-09-04 08:10:12 +00:00
bit_set.zig std.DynamicBitSet: remove wrong and useless comments (#21418) 2024-09-19 17:06:23 -07:00
BitStack.zig std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
bounded_array.zig Revert "Smaller memory footprint for BoundedArray (#16299)" 2024-08-23 22:30:10 -07:00
buf_map.zig
buf_set.zig
Build.zig Build: Add option(LazyPath, ...) support 2024-10-06 12:39:35 -07:00
builtin.zig add loongarch valist support 2024-10-11 02:49:00 -07:00
c.zig dragonfly std: more std.c support 2024-10-07 13:19:33 -04:00
coff.zig std.{coff,elf}: Remove the {MachineType,EM}.toTargetCpuArch() functions. 2024-08-23 19:56:24 +02:00
compress.zig
crypto.zig Rename the namespace for ml_kem variants of Kyber to nist 2024-08-22 07:54:12 +02:00
debug.zig std.debug: Fix defaultPanic() uefi build 2024-10-07 02:40:01 +09:00
dwarf.zig Dwarf: cleanup emitted debug info 2024-08-22 08:44:08 +02:00
dynamic_library.zig std.DynLib: Prefer std.fs.File.stat() over posix.fstat(). 2024-09-06 20:03:15 +02:00
elf.zig link.Elf: eliminate an O(N^2) algorithm in flush() 2024-10-12 10:44:17 -07:00
enums.zig std: avoid field/decl name conflicts 2024-08-29 20:39:11 +01:00
fifo.zig
fmt.zig remove formatted panics 2024-09-26 12:35:14 -07:00
fs.zig std.fs.Dir: Refactor atomicSymLink from std.fs 2024-07-28 20:08:52 -07:00
gpu.zig
hash.zig
hash_map.zig Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
heap.zig Remove old deprecated symbols in std (#21584) 2024-10-04 13:50:25 -07:00
http.zig add std.http.WebSocket 2024-08-07 00:48:32 -07:00
io.zig std: async read into small temporary buffer between poll calls on Windows 2024-10-06 07:01:12 +01:00
json.zig
leb128.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
linked_list.zig
log.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
macho.zig remove hard tabs from source code 2024-07-31 16:57:42 -07:00
math.zig std.math: rename make_f80 to F80.toFloat and break_f80 to F80.fromFloat 2024-09-02 00:10:22 +03:00
mem.zig std.mem.readVarInt: assert ReturnType is large enough (#20946) 2024-10-11 19:32:10 +00:00
meta.zig Merge pull request #21331 from bobf/std-meta-DeclEnum-empty-struct 2024-10-06 02:52:20 +02:00
multi_array_list.zig std.MultiArrayList: add empty initalizer value 2024-10-11 10:33:54 -07:00
net.zig std.c reorganization 2024-07-19 00:30:32 -07:00
once.zig compiler,lib,test,langref: migrate @setCold to @branchHint 2024-08-27 00:44:35 +01:00
os.zig std.c reorganization 2024-07-19 00:30:32 -07:00
packed_int_array.zig chore: correct non-standard comments. 2024-07-28 21:34:14 -07:00
pdb.zig std.pdb: obey naming conventions 2024-08-29 23:43:52 +01:00
posix.zig freebsd posix: add SystemOutdated to MemFdCreateError 2024-10-07 13:19:33 -04:00
priority_dequeue.zig add std.testing.random_seed 2024-07-23 11:43:12 -07:00
priority_queue.zig std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
process.zig move std.zig.fatal to std.process.fatal 2024-07-20 01:06:28 -07:00
Progress.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
Random.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
RingBuffer.zig
segmented_list.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
SemanticVersion.zig
simd.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
sort.zig std.equalRange: Compute lower and upper bounds simultaneously 2024-09-23 13:03:06 -07:00
start.zig std ppc64: add nop to start inline-asm 2024-10-05 10:27:13 -04:00
static_string_map.zig std.static_string_map: Cast length of input for runtime initialization 2024-06-20 23:22:39 +00:00
std.zig std: Convert deprecated aliases to compile errors and fix usages 2024-06-13 10:18:59 -04:00
tar.zig Remove old deprecated symbols in std (#21584) 2024-10-04 13:50:25 -07:00
Target.zig Merge pull request #21611 from alexrp/target-abi-default 2024-10-07 06:14:10 +02:00
testing.zig Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
Thread.zig move std.time.sleep to std.Thread.sleep 2024-09-26 12:35:14 -07:00
time.zig move std.time.sleep to std.Thread.sleep 2024-09-26 12:35:14 -07:00
treap.zig Condense and extend std.Treap's traversal functionalities. (#20002) 2024-07-28 19:47:55 -07:00
tz.zig
unicode.zig std: update eval branch quotas after bdbc485 2024-08-21 01:30:46 +01:00
Uri.zig
valgrind.zig port cachegrind.h to zig (#19241) 2024-08-23 22:59:30 -07:00
wasm.zig
zig.zig std.Target: Remove Cpu.Arch.dxil and ObjectFormat.dxcontainer. 2024-09-23 17:17:25 -07:00
zip.zig std.zip: Fix typo in doc comments 2024-06-17 16:12:19 -04:00