Re: [PATCH v6 12/34] gpu: nova-core: don't assume 64-bit firmware images
From: Alexandre Courbot
Date: Tue Mar 10 2026 - 06:38:46 EST
On Tue Mar 10, 2026 at 11:11 AM JST, John Hubbard wrote:
<snip>
> - /// Tries to extract section with name `name` from the ELF64 image `elf`, and returns it.
> - pub(super) fn elf64_section<'a, 'b>(elf: &'a [u8], name: &'b str) -> Option<&'a [u8]> {
> - let hdr = &elf
> - .get(0..size_of::<bindings::elf64_hdr>())
> - .and_then(Elf64Hdr::from_bytes)?
> - .0;
> + fn elf_section_generic<'a, H, S>(elf: &'a [u8], name: &str) -> Option<&'a [u8]>
> + where
> + H: ElfHeader,
> + S: ElfSectionHeader,
This allows mixing the 64-bit with the 32-bit section header. Let's have
another trait combining the two using associated types, so this function
takes only one generic parameter that unambiguously describes the
correct format.