From 2a0a11aa6632aa3180ebb1c528b0d1fcb970d5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Sun, 25 Oct 2020 11:13:42 +0000 Subject: [PATCH] openbsd: make dl_phdr_info cross arches introduce Addr and Half definition to std.elf, and use them for dl_phdr_info --- lib/std/elf.zig | 10 ++++++++++ lib/std/os/bits/openbsd.zig | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/std/elf.zig b/lib/std/elf.zig index 9f56721214..983dc6f9fd 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -937,6 +937,16 @@ pub const Verdaux = switch (@sizeOf(usize)) { 8 => Elf64_Verdaux, else => @compileError("expected pointer size of 32 or 64"), }; +pub const Addr = switch (@sizeOf(usize)) { + 4 => Elf32_Addr, + 8 => Elf64_Addr, + else => @compileError("expected pointer size of 32 or 64"), +}; +pub const Half = switch (@sizeOf(usize)) { + 4 => Elf32_Half, + 8 => Elf64_Half, + else => @compileError("expected pointer size of 32 or 64"), +}; /// Machine architectures /// See current registered ELF machine architectures at: diff --git a/lib/std/os/bits/openbsd.zig b/lib/std/os/bits/openbsd.zig index 1419e7f27a..5a9dfab119 100644 --- a/lib/std/os/bits/openbsd.zig +++ b/lib/std/os/bits/openbsd.zig @@ -33,10 +33,10 @@ pub const Kevent = extern struct { }; pub const dl_phdr_info = extern struct { - dlpi_addr: usize, + dlpi_addr: std.elf.Addr, dlpi_name: ?[*:0]const u8, dlpi_phdr: [*]std.elf.Phdr, - dlpi_phnum: u16, + dlpi_phnum: std.elf.Half, }; pub const Flock = extern struct {