crosvm/kernel_loader/bindgen.sh
Zihan Chen cbba480ebe crosvm: Uprev zerocopy to 0.7.x
zerocopy 0.7.x has finally released as a stable version, uprev it
to allow some remaining structs to be derivable.

TEST=CQ

BUG=b:300969352
FIXED=b:300969352

Change-Id: I90f0dfb09494f875fef1cd11bfcbd48030846092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878761
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-10-10 17:34:32 +00:00

33 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright 2022 The ChromiumOS Authors
# 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
KERNEL_LOADER_EXTRA="// Added by kernel_loader/bindgen.sh
use zerocopy::AsBytes;
use zerocopy::FromBytes;
use zerocopy::FromZeroes;"
bindgen_generate \
--raw-line "${KERNEL_LOADER_EXTRA}" \
--allowlist-type='Elf32_Ehdr' \
--allowlist-type='Elf32_Phdr' \
--allowlist-type='Elf64_Ehdr' \
--allowlist-type='Elf64_Phdr' \
--allowlist-var='.+' \
--with-derive-custom "elf32_hdr=FromZeroes,FromBytes,AsBytes" \
--with-derive-custom "elf64_hdr=FromZeroes,FromBytes,AsBytes" \
--with-derive-custom "elf32_phdr=FromZeroes,FromBytes,AsBytes" \
--with-derive-custom "elf64_phdr=FromZeroes,FromBytes,AsBytes" \
"${BINDGEN_LINUX}/include/uapi/linux/elf.h" \
-- \
-isystem "${BINDGEN_LINUX}/include" \
| replace_linux_int_types \
> kernel_loader/src/elf.rs