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::AsBytes; 15use zerocopy::FromBytes; 16use zerocopy::FromZeroes;" 17 18bindgen_generate \ 19 --raw-line "${KERNEL_LOADER_EXTRA}" \ 20 --allowlist-type='Elf32_Ehdr' \ 21 --allowlist-type='Elf32_Phdr' \ 22 --allowlist-type='Elf64_Ehdr' \ 23 --allowlist-type='Elf64_Phdr' \ 24 --allowlist-var='.+' \ 25 --with-derive-custom "elf32_hdr=FromZeroes,FromBytes,AsBytes" \ 26 --with-derive-custom "elf64_hdr=FromZeroes,FromBytes,AsBytes" \ 27 --with-derive-custom "elf32_phdr=FromZeroes,FromBytes,AsBytes" \ 28 --with-derive-custom "elf64_phdr=FromZeroes,FromBytes,AsBytes" \ 29 "${BINDGEN_LINUX}/include/uapi/linux/elf.h" \ 30 -- \ 31 -isystem "${BINDGEN_LINUX}/include" \ 32 | replace_linux_int_types \ 33 > kernel_loader/src/elf.rs 34