commit 2a0a11aa6632aa3180ebb1c528b0d1fcb970d5ff (tree)
parent 0088efc4b22645698faf328369a1deca2dc9070f
Author: Sébastien Marie <semarie@online.fr>
Date: Sun, 25 Oct 2020 11:13:42 +0000
openbsd: make dl_phdr_info cross arches
introduce Addr and Half definition to std.elf, and use them for dl_phdr_info
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git 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
@@ -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 {