| ... | ... | @@ -13,6 +13,7 @@ const elf = std.elf; |
| 13 | 13 | const vdso = @import("linux/vdso.zig"); |
| 14 | 14 | const dl = @import("../dynamic_library.zig"); |
| 15 | 15 | const native_arch = builtin.cpu.arch; |
| 16 | const native_abi = builtin.abi; |
| 16 | 17 | const native_endian = native_arch.endian(); |
| 17 | 18 | const is_mips = native_arch.isMIPS(); |
| 18 | 19 | const is_ppc = native_arch.isPPC(); |
| ... | ... | @@ -7353,67 +7354,101 @@ pub const PERF = struct { |
| 7353 | 7354 | // TODO: Add the rest of the AUDIT defines? |
| 7354 | 7355 | pub const AUDIT = struct { |
| 7355 | 7356 | pub const ARCH = enum(u32) { |
| 7357 | const CONVENTION_MIPS64_N32 = 0x20000000; |
| 7356 | 7358 | const @"64BIT" = 0x80000000; |
| 7357 | 7359 | const LE = 0x40000000; |
| 7358 | 7360 | |
| 7361 | AARCH64 = toAudit(.AARCH64, @"64BIT" | LE), |
| 7362 | ALPHA = toAudit(.ALPHA, @"64BIT" | LE), |
| 7363 | ARCOMPACT = toAudit(.ARC_COMPACT, LE), |
| 7364 | ARCOMPACTBE = toAudit(.ARC_COMPACT, 0), |
| 7365 | ARCV2 = toAudit(.ARC_COMPACT2, LE), |
| 7366 | ARCV2BE = toAudit(.ARC_COMPACT2, 0), |
| 7367 | ARM = toAudit(.ARM, LE), |
| 7368 | ARMEB = toAudit(.ARM, 0), |
| 7369 | C6X = toAudit(.TI_C6000, LE), |
| 7370 | C6XBE = toAudit(.TI_C6000, 0), |
| 7371 | CRIS = toAudit(.CRIS, LE), |
| 7372 | CSKY = toAudit(.CSKY, LE), |
| 7373 | FRV = toAudit(.FRV, 0), |
| 7374 | H8300 = toAudit(.H8_300, 0), |
| 7375 | HEXAGON = toAudit(.HEXAGON, 0), |
| 7376 | I386 = toAudit(.@"386", LE), |
| 7377 | IA64 = toAudit(.IA_64, @"64BIT" | LE), |
| 7378 | M32R = toAudit(.M32R, 0), |
| 7379 | M68K = toAudit(.@"68K", 0), |
| 7380 | MICROBLAZE = toAudit(.MICROBLAZE, 0), |
| 7381 | MIPS = toAudit(.MIPS, 0), |
| 7382 | MIPSEL = toAudit(.MIPS, LE), |
| 7383 | MIPS64 = toAudit(.MIPS, @"64BIT"), |
| 7384 | MIPS64N32 = toAudit(.MIPS, @"64BIT" | CONVENTION_MIPS64_N32), |
| 7385 | MIPSEL64 = toAudit(.MIPS, @"64BIT" | LE), |
| 7386 | MIPSEL64N32 = toAudit(.MIPS, @"64BIT" | LE | CONVENTION_MIPS64_N32), |
| 7387 | NDS32 = toAudit(.NDS32, LE), |
| 7388 | NDS32BE = toAudit(.NDS32, 0), |
| 7389 | NIOS2 = toAudit(.ALTERA_NIOS2, LE), |
| 7390 | OPENRISC = toAudit(.OPENRISC, 0), |
| 7391 | PARISC = toAudit(.PARISC, 0), |
| 7392 | PARISC64 = toAudit(.PARISC, @"64BIT"), |
| 7393 | PPC = toAudit(.PPC, 0), |
| 7394 | PPC64 = toAudit(.PPC64, @"64BIT"), |
| 7395 | PPC64LE = toAudit(.PPC64, @"64BIT" | LE), |
| 7396 | RISCV32 = toAudit(.RISCV, LE), |
| 7397 | RISCV64 = toAudit(.RISCV, @"64BIT" | LE), |
| 7398 | S390 = toAudit(.S390, 0), |
| 7399 | S390X = toAudit(.S390, @"64BIT"), |
| 7400 | SH = toAudit(.SH, 0), |
| 7401 | SHEL = toAudit(.SH, LE), |
| 7402 | SH64 = toAudit(.SH, @"64BIT"), |
| 7403 | SHEL64 = toAudit(.SH, @"64BIT" | LE), |
| 7404 | SPARC = toAudit(.SPARC, 0), |
| 7405 | SPARC64 = toAudit(.SPARCV9, @"64BIT"), |
| 7406 | TILEGX = toAudit(.TILEGX, @"64BIT" | LE), |
| 7407 | TILEGX32 = toAudit(.TILEGX, LE), |
| 7408 | TILEPRO = toAudit(.TILEPRO, LE), |
| 7409 | UNICORE = toAudit(.UNICORE, LE), |
| 7410 | X86_64 = toAudit(.X86_64, @"64BIT" | LE), |
| 7411 | XTENSA = toAudit(.XTENSA, 0), |
| 7412 | LOONGARCH32 = toAudit(.LOONGARCH, LE), |
| 7413 | LOONGARCH64 = toAudit(.LOONGARCH, @"64BIT" | LE), |
| 7414 | |
| 7415 | fn toAudit(em: elf.EM, flags: u32) u32 { |
| 7416 | return @intFromEnum(em) | flags; |
| 7417 | } |
| 7418 | |
| 7359 | 7419 | pub const current: AUDIT.ARCH = switch (native_arch) { |
| 7360 | | .x86 => .X86, |
| 7361 | | .x86_64 => .X86_64, |
| 7362 | | .aarch64 => .AARCH64, |
| 7363 | 7420 | .arm, .thumb => .ARM, |
| 7364 | | .riscv32 => .RISCV32, |
| 7365 | | .riscv64 => .RISCV64, |
| 7366 | | .sparc64 => .SPARC64, |
| 7421 | .armeb, .thumbeb => .ARMEB, |
| 7422 | .aarch64 => .AARCH64, |
| 7423 | .arc => .ARCV2, |
| 7424 | .csky => .CSKY, |
| 7425 | .hexagon => .HEXAGON, |
| 7426 | .loongarch32 => .LOONGARCH32, |
| 7427 | .loongarch64 => .LOONGARCH64, |
| 7428 | .m68k => .M68K, |
| 7367 | 7429 | .mips => .MIPS, |
| 7368 | 7430 | .mipsel => .MIPSEL, |
| 7431 | .mips64 => switch (native_abi) { |
| 7432 | .gnuabin32 => .MIPS64N32, |
| 7433 | else => .MIPS64, |
| 7434 | }, |
| 7435 | .mips64el => switch (native_abi) { |
| 7436 | .gnuabin32 => .MIPSEL64N32, |
| 7437 | else => .MIPSEL64, |
| 7438 | }, |
| 7369 | 7439 | .powerpc => .PPC, |
| 7370 | 7440 | .powerpc64 => .PPC64, |
| 7371 | 7441 | .powerpc64le => .PPC64LE, |
| 7442 | .riscv32 => .RISCV32, |
| 7443 | .riscv64 => .RISCV64, |
| 7444 | .sparc => .SPARC, |
| 7445 | .sparc64 => .SPARC64, |
| 7446 | .s390x => .S390X, |
| 7447 | .x86 => .I386, |
| 7448 | .x86_64 => .X86_64, |
| 7449 | .xtensa => .XTENSA, |
| 7372 | 7450 | else => @compileError("unsupported architecture"), |
| 7373 | 7451 | }; |
| 7374 | | |
| 7375 | | AARCH64 = toAudit(.aarch64), |
| 7376 | | ARM = toAudit(.arm), |
| 7377 | | ARMEB = toAudit(.armeb), |
| 7378 | | CSKY = toAudit(.csky), |
| 7379 | | HEXAGON = @intFromEnum(std.elf.EM.HEXAGON), |
| 7380 | | LOONGARCH64 = toAudit(.loongarch64), |
| 7381 | | M68K = toAudit(.m68k), |
| 7382 | | MIPS = toAudit(.mips), |
| 7383 | | MIPSEL = toAudit(.mips) | LE, |
| 7384 | | MIPS64 = toAudit(.mips64), |
| 7385 | | MIPSEL64 = toAudit(.mips64) | LE, |
| 7386 | | PPC = toAudit(.powerpc), |
| 7387 | | PPC64 = toAudit(.powerpc64), |
| 7388 | | PPC64LE = toAudit(.powerpc64le), |
| 7389 | | RISCV32 = toAudit(.riscv32), |
| 7390 | | RISCV64 = toAudit(.riscv64), |
| 7391 | | S390X = toAudit(.s390x), |
| 7392 | | SPARC = toAudit(.sparc), |
| 7393 | | SPARC64 = toAudit(.sparc64), |
| 7394 | | X86 = toAudit(.x86), |
| 7395 | | X86_64 = toAudit(.x86_64), |
| 7396 | | XTENSA = toAudit(.xtensa), |
| 7397 | | |
| 7398 | | fn toAudit(arch: std.Target.Cpu.Arch) u32 { |
| 7399 | | var res: u32 = @intFromEnum(arch.toElfMachine()); |
| 7400 | | if (arch.endian() == .little) res |= LE; |
| 7401 | | switch (arch) { |
| 7402 | | .aarch64, |
| 7403 | | .loongarch64, |
| 7404 | | .mips64, |
| 7405 | | .mips64el, |
| 7406 | | .powerpc64, |
| 7407 | | .powerpc64le, |
| 7408 | | .riscv64, |
| 7409 | | .s390x, |
| 7410 | | .sparc64, |
| 7411 | | .x86_64, |
| 7412 | | => res |= @"64BIT", |
| 7413 | | else => {}, |
| 7414 | | } |
| 7415 | | return res; |
| 7416 | | } |
| 7417 | 7452 | }; |
| 7418 | 7453 | }; |
| 7419 | 7454 | |