First, the correct length for decoding should be computed with
/4*3 , not the other way round as when encoding.
But also, without padding, a string such as "Zg" is valid base64
(here, it's the character 'f', padded base64 would be "Zg==").
decodedLenUpperBound() returned 0 instead of 1 in that example.
Correctly fix the computation of the upper bound.
We should append TupleHashXOF's right_encode(0) marker directly
to the cSHAKE instance, not treat is as another tuple element.
The existing tests didn't catch this because they were using
TupleHash as a hash function, not as a XOF.
Without this change, on some targets (e.g. aarch64-freebsd),
calling `cmsg.data()` with `Iterator.message.header` as the
argument would result in compilation failures like:
error: expected type '*align(8) c.posix_cmsghdr', found '*c.posix_cmsghdr'
The safety check of @shrExact is to shift the result the same amount
back to the left and compare if this matches the input of the
@shrExact. But since the 'lshr exact' llvm instruction was used, llvm
was allowed to assume, that the result of the left-shift matches the input.
As with __zig_elf_auxv, we need a canonical location for __tls_get_addr (or
__tls_get_offset on s390x), and compiler-rt is the obvious place. But that also
means that moving all of std.os.linux.tls there just makes sense. I decided not
to namespace this under linux because it's expected that most of this code will
apply to the BSDs too.
The ABI that std now expects is:
extern fn __zig_elf_static_tls_init(phdrs: [*]elf.ElfN.Phdr, phnum: usize) void;
extern fn __zig_elf_static_tls_fill(area: [*]u8) usize;
extern var __zig_elf_static_tls: extern struct {
size: usize,
alignment: usize,
gdt_entry_number: usize,
};
Users can override all three weak symbols with strong symbols if they want to
provide their own ELF TLS implementation, which may be useful to do when doing
manual dynamic loading from a static executable. Note that __tls_get_addr (or
__tls_get_offset on s390x) must also be provided, per the ELF TLS specification.
This gets rid of the super confusing and (as far as I can tell) incorrect
getauxval logic in std.os.linux, and clarifies exactly who owns this state.
The ABI that std now expects is:
extern var __zig_elf_auxv: [*]std.elf.Auxv;
Users can technically override this weak symbol with a strong symbol if they
wish, although I see no particularly useful reason to do so.
It is now a compile error to use std.os.linux.getauxval if libc is linked,
whereas previously it would just give useless results in some cases. I consider
this to be strictly an improvement. Just use std.c.getauxval when linking libc,
which std already does correctly where it needs getauxval.
This code is expected to be further simplified once our baseline Linux version
allows implementing https://codeberg.org/ziglang/zig/issues/31290.
closes https://codeberg.org/ziglang/zig/issues/36203