From 4f15073e4ffd095832fe3b25fcc89099a3c2e5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Fri, 14 Aug 2026 04:12:05 +0200 Subject: [PATCH] std.elf: update hash structures for the 64-bit variant --- lib/std/elf.zig | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/std/elf.zig b/lib/std/elf.zig index 35266dc1d2a57ce32d94dd13a0e35a2c20275356..8ebb002a24efe0801950ca3f4eb284b8a3c0370e 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -3311,6 +3311,7 @@ pub const gnu_hash = struct { /// Resources: /// * https://refspecs.linuxfoundation.org/elf/gabi4+/ch5.dynamic.html#hash /// * https://flapenguin.me/elf-dt-hash +/// * https://github.com/IBM/s390x-abi pub const hash = struct { pub fn calculate(name: []const u8) u32 { var h: u32 = 0; @@ -3322,7 +3323,7 @@ pub const hash = struct { return h; } - /// The header of a `SHT.HASH` section. Immediately followed by: + /// The header of a `SHT.HASH` section on most architectures. Immediately followed by: /// * `buckets: [nbucket]u32` /// * `chains: [nchain]u32` /// @@ -3333,10 +3334,22 @@ pub const hash = struct { /// /// `chain[sym_index]` is the index of the next symbol in the same bucket as `sym_index`. If /// `sym_index` is the last symbol in its bucket then the value is 0 (`STN_UNDEF`). - pub const Header = extern struct { + /// + /// See also `Header64`. + pub const Header32 = extern struct { nbucket: u32, nchain: u32, }; + + /// The header of a `SHT.HASH` section on alpha and s390x. Immediately followed by: + /// * `buckets: [nbucket]u64` + /// * `chains: [nchain]u64` + /// + /// See also `Header32`. + pub const Header64 = extern struct { + nbucket: u64, + nchain: u64, + }; }; pub const EhdrFlags = packed union(Word) { -- 2.54.0