1
0

bindgen.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. # Regenerate kernel_loader bindgen bindings.
  6. set -euo pipefail
  7. cd "$(dirname "${BASH_SOURCE[0]}")/.."
  8. source tools/impl/bindgen-common.sh
  9. KERNEL_LOADER_EXTRA="// Added by kernel_loader/bindgen.sh
  10. use zerocopy::AsBytes;
  11. use zerocopy::FromBytes;
  12. use zerocopy::FromZeroes;"
  13. bindgen_generate \
  14. --raw-line "${KERNEL_LOADER_EXTRA}" \
  15. --allowlist-type='Elf32_Ehdr' \
  16. --allowlist-type='Elf32_Phdr' \
  17. --allowlist-type='Elf64_Ehdr' \
  18. --allowlist-type='Elf64_Phdr' \
  19. --allowlist-var='.+' \
  20. --with-derive-custom "elf32_hdr=FromZeroes,FromBytes,AsBytes" \
  21. --with-derive-custom "elf64_hdr=FromZeroes,FromBytes,AsBytes" \
  22. --with-derive-custom "elf32_phdr=FromZeroes,FromBytes,AsBytes" \
  23. --with-derive-custom "elf64_phdr=FromZeroes,FromBytes,AsBytes" \
  24. "${BINDGEN_LINUX}/include/uapi/linux/elf.h" \
  25. -- \
  26. -isystem "${BINDGEN_LINUX}/include" \
  27. | replace_linux_int_types \
  28. > kernel_loader/src/elf.rs