commit a49f2d9f8d45ea5d556ebcb24c6f38a13ec3e94b (tree)
parent b7c7fba5b4f3cf80b36b75bacd401e12a25cf6f8
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date: Sat, 29 Jan 2022 13:27:18 +1100
Add bits for the Linux Auditing System
Also adds the _CSKY and _FRV ELF machines that are defined in
`<linux/elf-em.h>`
Diffstat:
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/lib/std/elf.zig b/lib/std/elf.zig
@@ -1480,6 +1480,12 @@ pub const EM = enum(u16) {
/// Linux kernel bpf virtual machine
_BPF = 247,
+ /// C-SKY
+ _CSKY = 252,
+
+ /// Fujitsu FR-V
+ _FRV = 0x5441,
+
_,
};
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
@@ -5369,3 +5369,55 @@ pub const PERF = struct {
pub const IOC_FLAG_GROUP = 1;
};
+
+// TODO: Add the rest of the AUDIT defines?
+pub const AUDIT = struct {
+ pub const ARCH = enum(u32) {
+ const _64BIT = 0x80000000;
+ const _LE = 0x40000000;
+
+ pub const current = switch (native_arch) {
+ .i386 => .I386,
+ .x86_64 => .X86_64,
+ .aarch64 => .AARCH64,
+ .arm, .thumb => .ARM,
+ .riscv64 => .RISCV64,
+ .sparcv9 => .SPARC64,
+ .mips => .MIPS,
+ .mipsel => .MIPSEL,
+ .powerpc => .PPC,
+ .powerpc64 => .PPC64,
+ .powerpc64le => .PPC64LE,
+ else => undefined,
+ };
+
+ AARCH64 = toAudit(.aarch64),
+ ARM = toAudit(.arm),
+ ARMEB = toAudit(.armeb),
+ CSKY = toAudit(.csky),
+ HEXAGON = @enumToInt(std.elf.EM._HEXAGON),
+ I386 = toAudit(.i386),
+ M68K = toAudit(.m68k),
+ MIPS = toAudit(.mips),
+ MIPSEL = toAudit(.mips) | _LE,
+ MIPS64 = toAudit(.mips64),
+ MIPSEL64 = toAudit(.mips64) | _LE,
+ PPC = toAudit(.powerpc),
+ PPC64 = toAudit(.powerpc64),
+ PPC64LE = toAudit(.powerpc64le),
+ RISCV32 = toAudit(.riscv32),
+ RISCV64 = toAudit(.riscv64),
+ S390X = toAudit(.s390x),
+ SPARC = toAudit(.sparc),
+ SPARC64 = toAudit(.sparcv9),
+ X86_64 = toAudit(.x86_64),
+
+ fn toAudit(arch: std.Target.Cpu.Arch) u32 {
+ var res: u32 = @enumToInt(arch.toElfMachine());
+ if (arch.endian() == .Little) res |= _LE;
+ if (arch.ptrBitWidth() == 64) res |= _64BIT;
+
+ return res;
+ }
+ };
+};
diff --git a/lib/std/target.zig b/lib/std/target.zig
@@ -962,7 +962,7 @@ pub const Target = struct {
.amdgcn => ._NONE,
.bpfel => ._BPF,
.bpfeb => ._BPF,
- .csky => ._NONE,
+ .csky => ._CSKY,
.sparcv9 => ._SPARCV9,
.s390x => ._S390,
.ve => ._NONE,