authorgravatar for dev@sgregoratto.meStephen Gregoratto <dev@sgregoratto.me> 2022-01-29 13:27:18+11:00
committergravatar for dev@sgregoratto.meStephen Gregoratto <dev@sgregoratto.me> 2022-01-29 13:57:14+11:00
loga49f2d9f8d45ea5d556ebcb24c6f38a13ec3e94b
treedd56a1efff9473d4d4827bb9d19473b4e0d4e7f6
parentb7c7fba5b4f3cf80b36b75bacd401e12a25cf6f8

Add bits for the Linux Auditing System

Also adds the _CSKY and _FRV ELF machines that are defined in `<linux/elf-em.h>`

3 files changed, 59 insertions(+), 1 deletions(-)

lib/std/elf.zig+6
...@@ -1480,6 +1480,12 @@ pub const EM = enum(u16) {...@@ -1480,6 +1480,12 @@ pub const EM = enum(u16) {
1480 /// Linux kernel bpf virtual machine1480 /// Linux kernel bpf virtual machine
1481 _BPF = 247,1481 _BPF = 247,
14821482
1483 /// C-SKY
1484 _CSKY = 252,
1485
1486 /// Fujitsu FR-V
1487 _FRV = 0x5441,
1488
1483 _,1489 _,
1484};1490};
14851491
lib/std/os/linux.zig+52
...@@ -5369,3 +5369,55 @@ pub const PERF = struct {...@@ -5369,3 +5369,55 @@ pub const PERF = struct {
53695369
5370 pub const IOC_FLAG_GROUP = 1;5370 pub const IOC_FLAG_GROUP = 1;
5371};5371};
5372
5373// TODO: Add the rest of the AUDIT defines?
5374pub const AUDIT = struct {
5375 pub const ARCH = enum(u32) {
5376 const _64BIT = 0x80000000;
5377 const _LE = 0x40000000;
5378
5379 pub const current = switch (native_arch) {
5380 .i386 => .I386,
5381 .x86_64 => .X86_64,
5382 .aarch64 => .AARCH64,
5383 .arm, .thumb => .ARM,
5384 .riscv64 => .RISCV64,
5385 .sparcv9 => .SPARC64,
5386 .mips => .MIPS,
5387 .mipsel => .MIPSEL,
5388 .powerpc => .PPC,
5389 .powerpc64 => .PPC64,
5390 .powerpc64le => .PPC64LE,
5391 else => undefined,
5392 };
5393
5394 AARCH64 = toAudit(.aarch64),
5395 ARM = toAudit(.arm),
5396 ARMEB = toAudit(.armeb),
5397 CSKY = toAudit(.csky),
5398 HEXAGON = @enumToInt(std.elf.EM._HEXAGON),
5399 I386 = toAudit(.i386),
5400 M68K = toAudit(.m68k),
5401 MIPS = toAudit(.mips),
5402 MIPSEL = toAudit(.mips) | _LE,
5403 MIPS64 = toAudit(.mips64),
5404 MIPSEL64 = toAudit(.mips64) | _LE,
5405 PPC = toAudit(.powerpc),
5406 PPC64 = toAudit(.powerpc64),
5407 PPC64LE = toAudit(.powerpc64le),
5408 RISCV32 = toAudit(.riscv32),
5409 RISCV64 = toAudit(.riscv64),
5410 S390X = toAudit(.s390x),
5411 SPARC = toAudit(.sparc),
5412 SPARC64 = toAudit(.sparcv9),
5413 X86_64 = toAudit(.x86_64),
5414
5415 fn toAudit(arch: std.Target.Cpu.Arch) u32 {
5416 var res: u32 = @enumToInt(arch.toElfMachine());
5417 if (arch.endian() == .Little) res |= _LE;
5418 if (arch.ptrBitWidth() == 64) res |= _64BIT;
5419
5420 return res;
5421 }
5422 };
5423};
lib/std/target.zig+1-1
...@@ -962,7 +962,7 @@ pub const Target = struct {...@@ -962,7 +962,7 @@ pub const Target = struct {
962 .amdgcn => ._NONE,962 .amdgcn => ._NONE,
963 .bpfel => ._BPF,963 .bpfel => ._BPF,
964 .bpfeb => ._BPF,964 .bpfeb => ._BPF,
965 .csky => ._NONE,965 .csky => ._CSKY,
966 .sparcv9 => ._SPARCV9,966 .sparcv9 => ._SPARCV9,
967 .s390x => ._S390,967 .s390x => ._S390,
968 .ve => ._NONE,968 .ve => ._NONE,