starnix_uapi/
elf.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#![allow(dead_code)]
6#![allow(non_camel_case_types)]
7#![allow(non_upper_case_globals)]
8
9use crate::error;
10use crate::errors::Errno;
11use inspect_stubs::track_stub;
12
13#[derive(Clone, Copy, PartialEq)]
14#[repr(usize)]
15pub enum ElfNoteType {
16    // NT_PRSTATUS
17    PrStatus = 1,
18    // NT_FPREGSET
19    FpRegSet = 2,
20    // NT_X86_XSTATE
21    X86_XState = 0x202,
22    // NT_ARM_TAGGED_ADDR_CTRL
23    ArmTaggedAddrCtrl = 0x409,
24    // NT_ARM_PAC_ENABLED_KEYS
25    ArmPacEnabledKeys = 0x40a,
26}
27
28impl TryFrom<usize> for ElfNoteType {
29    type Error = Errno;
30
31    fn try_from(v: usize) -> Result<Self, Errno> {
32        match v {
33            x if x == ElfNoteType::PrStatus as usize => Ok(ElfNoteType::PrStatus),
34            x if x == ElfNoteType::FpRegSet as usize => Ok(ElfNoteType::FpRegSet),
35            x if x == ElfNoteType::X86_XState as usize => Ok(ElfNoteType::X86_XState),
36            x if x == ElfNoteType::ArmTaggedAddrCtrl as usize => {
37                track_stub!(TODO("https://fxbug.dev/441149562"), "NT_ARM_TAGGED_ADDR_CTRL");
38                error!(ENOTSUP)
39            }
40            x if x == ElfNoteType::ArmPacEnabledKeys as usize => {
41                track_stub!(TODO("https://fxbug.dev/441149562"), "NT_ARM_PAC_ENABLED_KEYS");
42                error!(ENOTSUP)
43            }
44            _ => error!(EINVAL),
45        }
46    }
47}