1#!/usr/bin/env bash 2# Copyright 2022 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# Regenerate kernel_loader bindgen bindings. 7 8set -euo pipefail 9cd "$(dirname "${BASH_SOURCE[0]}")/.." 10 11source tools/impl/bindgen-common.sh 12 13KERNEL_LOADER_EXTRA="// Added by kernel_loader/bindgen.sh 14use zerocopy::FromBytes; 15use zerocopy::Immutable; 16use zerocopy::IntoBytes; 17use zerocopy::KnownLayout;" 18 19bindgen_generate \ 20 --raw-line "${KERNEL_LOADER_EXTRA}" \ 21 --blocklist-item='ASM_INPUT_.*' \ 22 --blocklist-item='.*BITS_PER_.*' \ 23 --blocklist-item='__FD_SETSIZE' \ 24 --allowlist-type='Elf32_Ehdr' \ 25 --allowlist-type='Elf32_Phdr' \ 26 --allowlist-type='Elf64_Ehdr' \ 27 --allowlist-type='Elf64_Phdr' \ 28 --allowlist-var='.+' \ 29 --with-derive-custom "elf32_hdr=FromBytes,Immutable,IntoBytes,KnownLayout" \ 30 --with-derive-custom "elf64_hdr=FromBytes,Immutable,IntoBytes,KnownLayout" \ 31 --with-derive-custom "elf32_phdr=FromBytes,Immutable,IntoBytes,KnownLayout" \ 32 --with-derive-custom "elf64_phdr=FromBytes,Immutable,IntoBytes,KnownLayout" \ 33 "${BINDGEN_LINUX}/include/uapi/linux/elf.h" \ 34 -- \ 35 -isystem "${BINDGEN_LINUX}/include" \ 36 | replace_linux_int_types \ 37 > kernel_loader/src/elf.rs 38