MCPcopy Index your code
hub / github.com/encounter/objdiff / elf_detect_arm_version

Method elf_detect_arm_version

objdiff-core/src/arch/arm.rs:40–74  ·  view source on GitHub ↗
(file: &object::File)

Source from the content-addressed store, hash-verified

38 }
39
40 fn elf_detect_arm_version(file: &object::File) -> Result<Option<unarm::Version>> {
41 // Check ARM attributes
42 if let Some(arm_attrs) = file.sections().find(|s| {
43 s.kind() == object::SectionKind::Elf(elf::SHT_ARM_ATTRIBUTES)
44 && s.name() == Ok(".ARM.attributes")
45 }) {
46 let attr_data = arm_attrs.uncompressed_data()?;
47 let build_attrs = BuildAttrs::new(&attr_data, match file.endianness() {
48 object::Endianness::Little => arm_attr::Endian::Little,
49 object::Endianness::Big => arm_attr::Endian::Big,
50 })?;
51 for subsection in build_attrs.subsections() {
52 let subsection = subsection?;
53 if !subsection.is_aeabi() {
54 continue;
55 }
56 // Only checking first CpuArch tag. Others may exist, but that's very unlikely.
57 let cpu_arch = subsection.into_public_tag_iter()?.find_map(|(_, tag)| {
58 if let Tag::CpuArch(cpu_arch) = tag { Some(cpu_arch) } else { None }
59 });
60 match cpu_arch {
61 Some(CpuArch::V4) => return Ok(Some(unarm::Version::V4)),
62 Some(CpuArch::V4T) => return Ok(Some(unarm::Version::V4T)),
63 Some(CpuArch::V5TE) => return Ok(Some(unarm::Version::V5Te)),
64 Some(CpuArch::V5TEJ) => return Ok(Some(unarm::Version::V5Tej)),
65 Some(CpuArch::V6) => return Ok(Some(unarm::Version::V6)),
66 Some(CpuArch::V6K) => return Ok(Some(unarm::Version::V6K)),
67 Some(arch) => bail!("ARM arch {} not supported", arch),
68 None => {}
69 };
70 }
71 }
72
73 Ok(None)
74 }
75
76 fn get_mapping_symbols(
77 sections: &[Section],

Callers

nothing calls this directly

Calls 1

nameMethod · 0.80

Tested by

no test coverage detected