diff --git a/kernel_loader/bindgen.sh b/kernel_loader/bindgen.sh new file mode 100755 index 0000000000..a5542f379f --- /dev/null +++ b/kernel_loader/bindgen.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Copyright 2022 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Regenerate kernel_loader bindgen bindings. + +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +source tools/impl/bindgen-common.sh + +bindgen_generate \ + --allowlist-type='Elf64_Ehdr' \ + --allowlist-type='Elf64_Phdr' \ + --allowlist-var='.+' \ + "${BINDGEN_LINUX_X86_HEADERS}/include/linux/elf.h" \ + -- \ + -isystem "${BINDGEN_LINUX_X86_HEADERS}/include" \ + | replace_linux_int_types \ + > kernel_loader/src/elf.rs diff --git a/kernel_loader/src/elf.rs b/kernel_loader/src/elf.rs index cc6dcf899d..5f75b18dce 100644 --- a/kernel_loader/src/elf.rs +++ b/kernel_loader/src/elf.rs @@ -1,15 +1,9 @@ -// Copyright 2019 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +/* automatically generated by tools/bindgen-all-the-things */ -/* - * automatically generated by bindgen - * From chromeos-linux v4.19 include/uapi/linux/elf.h - * $ bindgen \ - * --no-layout-tests --with-derive-default \ - * --allowlist-type Elf64_Ehdr --allowlist-type Elf64_Phdr --allowlist-var .+ \ - * include/uapi/linux/elf.h - */ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] pub const __BITS_PER_LONG: u32 = 64; pub const __FD_SETSIZE: u32 = 1024; @@ -40,14 +34,22 @@ pub const EM_CRIS: u32 = 76; pub const EM_M32R: u32 = 88; pub const EM_MN10300: u32 = 89; pub const EM_OPENRISC: u32 = 92; +pub const EM_ARCOMPACT: u32 = 93; +pub const EM_XTENSA: u32 = 94; pub const EM_BLACKFIN: u32 = 106; +pub const EM_UNICORE: u32 = 110; pub const EM_ALTERA_NIOS2: u32 = 113; pub const EM_TI_C6000: u32 = 140; +pub const EM_HEXAGON: u32 = 164; +pub const EM_NDS32: u32 = 167; pub const EM_AARCH64: u32 = 183; pub const EM_TILEPRO: u32 = 188; pub const EM_MICROBLAZE: u32 = 189; pub const EM_TILEGX: u32 = 191; +pub const EM_ARCV2: u32 = 195; +pub const EM_RISCV: u32 = 243; pub const EM_BPF: u32 = 247; +pub const EM_CSKY: u32 = 252; pub const EM_FRV: u32 = 21569; pub const EM_ALPHA: u32 = 36902; pub const EM_CYGNUS_M32R: u32 = 36929; @@ -66,6 +68,7 @@ pub const PT_HIOS: u32 = 1879048191; pub const PT_LOPROC: u32 = 1879048192; pub const PT_HIPROC: u32 = 2147483647; pub const PT_GNU_EH_FRAME: u32 = 1685382480; +pub const PT_GNU_PROPERTY: u32 = 1685382483; pub const PT_GNU_STACK: u32 = 1685382481; pub const PN_XNUM: u32 = 65535; pub const ET_NONE: u32 = 0; @@ -239,18 +242,24 @@ pub const NT_ARM_HW_BREAK: u32 = 1026; pub const NT_ARM_HW_WATCH: u32 = 1027; pub const NT_ARM_SYSTEM_CALL: u32 = 1028; pub const NT_ARM_SVE: u32 = 1029; +pub const NT_ARM_PAC_MASK: u32 = 1030; +pub const NT_ARM_PACA_KEYS: u32 = 1031; +pub const NT_ARM_PACG_KEYS: u32 = 1032; +pub const NT_ARM_TAGGED_ADDR_CTRL: u32 = 1033; +pub const NT_ARM_PAC_ENABLED_KEYS: u32 = 1034; pub const NT_ARC_V2: u32 = 1536; pub const NT_VMCOREDD: u32 = 1792; pub const NT_MIPS_DSP: u32 = 2048; pub const NT_MIPS_FP_MODE: u32 = 2049; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __u32 = ::std::os::raw::c_uint; -pub type __u64 = ::std::os::raw::c_ulonglong; -pub type Elf64_Addr = __u64; -pub type Elf64_Half = __u16; -pub type Elf64_Off = __u64; -pub type Elf64_Word = __u32; -pub type Elf64_Xword = __u64; +pub const NT_MIPS_MSA: u32 = 2050; +pub const NT_GNU_PROPERTY_TYPE_0: u32 = 5; +pub const GNU_PROPERTY_AARCH64_FEATURE_1_AND: u32 = 3221225472; +pub const GNU_PROPERTY_AARCH64_FEATURE_1_BTI: u32 = 1; +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Off = u64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct elf64_hdr { diff --git a/tools/bindgen-all-the-things b/tools/bindgen-all-the-things index f933cd07bf..2fd23e890f 100755 --- a/tools/bindgen-all-the-things +++ b/tools/bindgen-all-the-things @@ -21,6 +21,7 @@ die() { dirs=( common/io_uring devices/src/virtio/gpu + kernel_loader ) for d in "${dirs[@]}"; do