Add bits for the Linux Auditing System

Also adds the _CSKY and _FRV ELF machines that are defined in
`<linux/elf-em.h>`
This commit is contained in:
Stephen Gregoratto 2022-01-29 13:27:18 +11:00
parent b7c7fba5b4
commit a49f2d9f8d
3 changed files with 59 additions and 1 deletions

View File

@ -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,
_,
};

View File

@ -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;
}
};
};

View File

@ -962,7 +962,7 @@ pub const Target = struct {
.amdgcn => ._NONE,
.bpfel => ._BPF,
.bpfeb => ._BPF,
.csky => ._NONE,
.csky => ._CSKY,
.sparcv9 => ._SPARCV9,
.s390x => ._S390,
.ve => ._NONE,