zig/lib/std/os/linux
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
..
bpf std.os.linux: Fix bunch of compilation errors (#21138) 2024-08-23 14:21:19 +00:00
aarch64.zig std.os.linux: Rename some arch bits files to match std.Target.Cpu.Arch tags. 2024-10-03 09:12:35 +02:00
arm.zig std.os.linux: Rename some arch bits files to match std.Target.Cpu.Arch tags. 2024-10-03 09:12:35 +02:00
bpf.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
hexagon.zig std.os.linux: Add hexagon arch bits. 2024-10-03 09:12:35 +02:00
io_uring_sqe.zig std.posix.iovec: use .base and .len instead of .iov_base and .iov_len 2024-04-28 00:20:30 -07:00
ioctl.zig std.Target: Remove sparcel architecture tag. 2024-07-30 06:30:25 +02:00
IoUring.zig IoUring: fix an issue in tests where InvalidVersion might get thrown by skipKernelLessThan, due to some kernel versions not being SemVer compliant. 2024-10-11 17:07:34 +02:00
loongarch64.zig add getcontext 2024-08-13 10:11:17 -07:00
mips.zig std.os.linux: Fix Stat struct for mips/mips64. 2024-08-18 07:27:23 +02:00
mips64.zig std.os.linux: Fix Stat struct for mips/mips64. 2024-08-18 07:27:23 +02:00
pie.zig std.os.linux: Rename some arch bits files to match std.Target.Cpu.Arch tags. 2024-10-03 09:12:35 +02:00
powerpc.zig std.os.linux: Move clone() here and stop exporting it. 2024-08-07 01:19:51 -07:00
powerpc64.zig stage1 ppc64: remove inline-asm overlapping clobbers 2024-10-05 10:26:47 -04:00
riscv32.zig std.os.linux: Define the Stat struct for riscv32. 2024-08-31 03:31:58 +02:00
riscv64.zig std.os.linux: Move clone() here and stop exporting it. 2024-08-07 01:19:51 -07:00
s390x.zig std: add arch bits for s390x-linux (#21342) 2024-09-24 13:35:12 -07:00
seccomp.zig
sparc64.zig std: Fix assembler comment syntax for sparc. 2024-09-07 13:16:22 -07:00
syscalls.zig generate_linux_syscalls: Rename mmap_pgoff to mmap2. 2024-10-03 09:12:35 +02:00
test.zig std.os.linux: Fix bunch of compilation errors (#21138) 2024-08-23 14:21:19 +00:00
thumb.zig std.os.linux: Rename some arch bits files to match std.Target.Cpu.Arch tags. 2024-10-03 09:12:35 +02:00
tls.zig std.os.linux: Fix mmap() syscall invocation for s390x. 2024-10-04 00:26:53 +02:00
vdso.zig link.Elf: eliminate an O(N^2) algorithm in flush() 2024-10-12 10:44:17 -07:00
x86.zig std.os.linux: Fix syscall6() when building for PIC/PIE. 2024-08-30 14:48:17 -07:00
x86_64.zig Dwarf: implement .eh_frame 2024-08-27 03:55:56 -04:00