diff --git a/crates/examples/src/bin/elftoefi.rs b/crates/examples/src/bin/elftoefi.rs index 3d80825d..46ac4e39 100644 --- a/crates/examples/src/bin/elftoefi.rs +++ b/crates/examples/src/bin/elftoefi.rs @@ -378,17 +378,19 @@ fn copy_file>( // Include both code and read only data in the text section. fn is_text(s: &S, endian: S::Endian) -> bool { - let flags = s.sh_flags(endian).into() as u32; - flags & elf::SHF_ALLOC != 0 && (flags & elf::SHF_EXECINSTR != 0 || flags & elf::SHF_WRITE == 0) + let flags = s.sh_flags(endian); + flags.contains(elf::SHF_ALLOC) + && (flags.contains(elf::SHF_EXECINSTR) || !flags.contains(elf::SHF_WRITE)) } // Anything that is alloc but not text. fn is_data(s: &S, endian: S::Endian) -> bool { - let flags = s.sh_flags(endian).into() as u32; - flags & elf::SHF_ALLOC != 0 && flags & elf::SHF_EXECINSTR == 0 && flags & elf::SHF_WRITE != 0 + let flags = s.sh_flags(endian); + flags.contains(elf::SHF_ALLOC) + && !flags.contains(elf::SHF_EXECINSTR) + && flags.contains(elf::SHF_WRITE) } fn is_alloc(s: &S, endian: S::Endian) -> bool { - let flags = s.sh_flags(endian).into() as u32; - flags & elf::SHF_ALLOC != 0 + s.sh_flags(endian).contains(elf::SHF_ALLOC) } diff --git a/crates/examples/src/readobj/elf.rs b/crates/examples/src/readobj/elf.rs index e844b655..e009d86d 100644 --- a/crates/examples/src/readobj/elf.rs +++ b/crates/examples/src/readobj/elf.rs @@ -35,11 +35,11 @@ fn print_file_header(p: &mut Printer<'_>, endian: Elf::Endian, } p.group("FileHeader", |p| { p.group("Ident", |p| print_ident(p, elf.e_ident())); - p.field_enum("Type", elf.e_type(endian), FLAGS_ET); - p.field_enum("Machine", elf.e_machine(endian), FLAGS_EM); + p.field_consts("Type", elf.e_type(endian), FileType::NAMES); + p.field_consts("Machine", elf.e_machine(endian), Machine::NAMES); let version = elf.e_version(endian); if version < 256 { - p.field_enum("Version", version as u8, FLAGS_EV); + p.field_consts("Version", FileVersion(version as u8), FileVersion::NAMES); } else { p.field_hex("Version", version); } @@ -52,16 +52,25 @@ fn print_file_header(p: &mut Printer<'_>, endian: Elf::Endian, p.field("ProgramHeaderCount", elf.e_phnum(endian)); p.field_hex("SectionHeaderEntrySize", elf.e_shentsize(endian)); p.field("SectionHeaderCount", elf.e_shnum(endian)); - p.field("SectionHeaderStringTableIndex", elf.e_shstrndx(endian)); + let shstrndx = elf.e_shstrndx(endian); + if let Some(index) = shstrndx.index() { + p.field("SectionHeaderStringTableIndex", index); + } else { + p.field_consts( + "SectionHeaderStringTableIndex", + shstrndx, + SymbolSection::NAMES, + ); + } }); } fn print_ident(p: &mut Printer<'_>, ident: &Ident) { p.field("Magic", format!("{:X?}", ident.magic)); - p.field_enum("Class", ident.class, FLAGS_EI_CLASS); - p.field_enum("Data", ident.data, FLAGS_EI_DATA); - p.field_enum("Version", ident.version, FLAGS_EV); - p.field_enum("OsAbi", ident.os_abi, FLAGS_EI_OSABI); + p.field_consts("Class", ident.class, FileClass::NAMES); + p.field_consts("Data", ident.data, DataEncoding::NAMES); + p.field_consts("Version", ident.version, FileVersion::NAMES); + p.field_consts("OsAbi", ident.os_abi, OsAbi::NAMES); p.field_hex("AbiVersion", ident.abi_version); p.field("Unused", format!("{:X?}", ident.padding)); } @@ -145,7 +154,7 @@ fn print_segment_dynamic( let mut strtab = 0; let mut strsz = 0; for d in dynamic { - let tag = d.d_tag(endian).into(); + let tag = d.d_tag(endian); if tag == DT_STRTAB { strtab = d.d_val(endian).into(); } else if tag == DT_STRSZ { @@ -199,12 +208,7 @@ fn print_section_headers( ); p.field_consts("Type", section.sh_type(endian), constants.sht); - // TODO: handle flag overflow - p.field_flags( - "Flags", - section.sh_flags(endian).into() as u32, - constants.shf, - ); + p.field_flags("Flags", section.sh_flags(endian), constants.shf); p.field_hex("Address", section.sh_addr(endian).into()); p.field_hex("Offset", section.sh_offset(endian).into()); p.field_hex("Size", section.sh_size(endian).into()); @@ -216,7 +220,7 @@ fn print_section_headers( if let Some(Some((compression, _, _))) = section.compression(endian, data).print_err(p) { p.group("CompressionHeader", |p| { - p.field_enum("Type", compression.ch_type(endian), FLAGS_ELFCOMPRESS); + p.field_consts("Type", compression.ch_type(endian), CompressionType::NAMES); p.field_hex("Size", compression.ch_size(endian).into()); p.field_hex("AddressAlign", compression.ch_addralign(endian).into()); }); @@ -313,10 +317,10 @@ fn print_section_symbols( p.field_flags("Other", symbol.st_other(), constants.sto); let shndx = symbol.st_shndx(endian); - if shndx == SHN_UNDEF || shndx >= SHN_LORESERVE { - p.field_consts("SectionIndex", shndx, constants.shn); + if let Some(index) = shndx.index() { + p.field("SectionIndex", index); } else { - p.field("SectionIndex", shndx); + p.field_consts("SectionIndex", shndx, constants.shn); } if let Some(shndx) = symbols.shndx(endian, index) { p.field("ExtendedSectionIndex", shndx); @@ -512,7 +516,7 @@ fn print_section_group( section: &Elf::SectionHeader, ) { if let Some(Some((flag, members))) = section.group(endian, data).print_err(p) { - p.field_enum("GroupFlag", flag, FLAGS_GRP); + p.field_flags("GroupFlag", flag, GroupFlags::NAMES); p.group("GroupSections", |p| { for member in members { let index = member.get(endian); @@ -538,6 +542,7 @@ fn print_notes( elf: &Elf, mut notes: NoteIterator, ) { + let machine = elf.e_machine(endian); while let Some(Some(note)) = notes.next().print_err(p) { p.group("Note", |p| { let name = note.name(); @@ -547,47 +552,11 @@ fn print_notes( while let Some(Some(property)) = properties.next().print_err(p) { p.group("Property", |p| { let pr_type = property.pr_type(); - let proc = match elf.e_machine(endian) { - EM_386 | EM_X86_64 => FLAGS_GNU_PROPERTY_X86, - EM_AARCH64 => FLAGS_GNU_PROPERTY_AARCH64, - _ => &[], - }; - p.field_enums("Type", pr_type, &[FLAGS_GNU_PROPERTY, proc]); - match pr_type { - GNU_PROPERTY_1_NEEDED => { - if let Some(val) = property.data_u32(endian).print_err(p) { - p.field_hex("Value", val); - p.flags(val, 0, FLAGS_GNU_PROPERTY_1_NEEDED); - } - } - _ => {} - } - match elf.e_machine(endian) { - EM_386 | EM_X86_64 => match pr_type { - GNU_PROPERTY_X86_ISA_1_USED | GNU_PROPERTY_X86_ISA_1_NEEDED => { - if let Some(val) = property.data_u32(endian).print_err(p) { - p.field_hex("Value", val); - p.flags(val, 0, FLAGS_GNU_PROPERTY_X86_ISA_1); - } - } - GNU_PROPERTY_X86_FEATURE_1_AND => { - if let Some(val) = property.data_u32(endian).print_err(p) { - p.field_hex("Value", val); - p.flags(val, 0, FLAGS_GNU_PROPERTY_X86_FEATURE_1); - } - } - _ => {} - }, - EM_AARCH64 => match pr_type { - GNU_PROPERTY_AARCH64_FEATURE_1_AND => { - if let Some(val) = property.data_u32(endian).print_err(p) { - p.field_hex("Value", val); - p.flags(val, 0, FLAGS_GNU_PROPERTY_AARCH64_FEATURE_1); - } - } - _ => {} - }, - _ => {} + p.field_consts("Type", pr_type, GnuPropertyType::type_names(machine)); + if let Some(names) = pr_type.u32_value_names(machine) + && let Some(val) = property.data_u32(endian).print_err(p) + { + p.field_flags("Value", val, names); } }); } @@ -607,18 +576,19 @@ fn print_dynamic( ) { let constants = constants(endian, elf); for d in dynamic { - let tag = d.d_tag(endian).into(); + let tag = d.d_tag(endian); let val = d.d_val(endian).into(); p.group("Dynamic", |p| { p.field_consts("Tag", tag, constants.dt); if d.is_string(endian) { p.field_string("Value", val, d.string(endian, dynstr)); } else { - p.field_hex("Value", val); if tag == DT_FLAGS { - p.flags(val, 0, FLAGS_DF); + p.field_flags("Value", DynamicFlags(val), DynamicFlags::NAMES); } else if tag == DT_FLAGS_1 { - p.flags(val, 0, FLAGS_DF_1); + p.field_flags("Value", DynamicFlags1(val), DynamicFlags1::NAMES); + } else { + p.field_hex("Value", val); } } }); @@ -723,9 +693,8 @@ fn print_gnu_verdef( while let Some(Some((verdef, mut verdauxs))) = verdefs.next().print_err(p) { p.group("VersionDefinition", |p| { p.field("Version", verdef.vd_version.get(endian)); - p.field_hex("Flags", verdef.vd_flags.get(endian)); - p.flags(verdef.vd_flags.get(endian), 0, FLAGS_VER_FLG); - p.field("Index", verdef.vd_ndx.get(endian)); + p.field_flags("Flags", verdef.vd_flags.get(endian), VersionFlags::NAMES); + p.field_consts_display("Index", verdef.vd_ndx.get(endian), VersionIndex::NAMES); p.field("AuxCount", verdef.vd_cnt.get(endian)); p.field_hex("Hash", verdef.vd_hash.get(endian)); p.field("AuxOffset", verdef.vd_aux.get(endian)); @@ -772,9 +741,12 @@ fn print_gnu_verneed( while let Some(Some(vernaux)) = vernauxs.next().print_err(p) { p.group("Aux", |p| { p.field_hex("Hash", vernaux.vna_hash.get(endian)); - p.field_hex("Flags", vernaux.vna_flags.get(endian)); - p.flags(vernaux.vna_flags.get(endian), 0, FLAGS_VER_FLG); - p.field("Index", vernaux.vna_other.get(endian)); + p.field_flags("Flags", vernaux.vna_flags.get(endian), VersionFlags::NAMES); + p.field_consts_display( + "Index", + vernaux.vna_other.get(endian), + VersionIndex::NAMES, + ); p.field_string( "Name", vernaux.vna_name.get(endian), @@ -802,7 +774,7 @@ fn print_gnu_versym( if let Some(Some((syms, _link))) = section.gnu_versym(endian, data).print_err(p) { let versions = sections.versions(endian, data).print_err(p).flatten(); for (index, sym) in syms.iter().enumerate() { - let version_index = VersionIndex(sym.0.get(endian)); + let version_index = sym.0.get(endian); p.group("VersionSymbol", |p| { p.field("Index", index); print_version(p, versions.as_ref(), version_index); @@ -831,7 +803,7 @@ fn print_attributes( let mut subsubsections = subsection.subsubsections(); while let Some(Some(subsubsection)) = subsubsections.next().print_err(p) { p.group("Subsubsection", |p| { - p.field_enum("Tag", subsubsection.tag(), FLAGS_TAG); + p.field_consts("Tag", subsubsection.tag(), AttributeTag::NAMES); let mut indices = subsubsection.indices(); while let Some(Some(index)) = indices.next().print_err(p) { p.field("Index", index); @@ -849,301 +821,20 @@ fn print_attributes( fn print_version( p: &mut Printer<'_>, versions: Option<&VersionTable>, - version_index: VersionIndex, + version_index: VersymIndex, ) { match versions.and_then(|versions| versions.version(version_index).print_err(p)) { Some(Some(version)) => { - p.field_string_option("Version", version_index.0, Some(version.name())) + p.field_string_option("Version", version_index, Some(version.name())); + p.flag_bits( + VersymIndex(version_index.0 & VERSYM_HIDDEN.0), + VersymIndex::NAMES, + ); } - _ => p.field_enum("Version", version_index.0, FLAGS_VER_NDX), + _ => p.field_flags("Version", version_index, VersymIndex::NAMES), } - p.flags(version_index.0, 0, FLAGS_VERSYM); } fn constants(endian: Elf::Endian, elf: &Elf) -> &'static Constants { machine_constants(elf.e_machine(endian)) } - -const FLAGS_EI_CLASS: &[Flag] = &flags!(ELFCLASSNONE, ELFCLASS32, ELFCLASS64); -const FLAGS_EI_DATA: &[Flag] = &flags!(ELFDATANONE, ELFDATA2LSB, ELFDATA2MSB); -const FLAGS_EV: &[Flag] = &flags!(EV_NONE, EV_CURRENT); -const FLAGS_EI_OSABI: &[Flag] = &flags!( - ELFOSABI_SYSV, - ELFOSABI_HPUX, - ELFOSABI_NETBSD, - ELFOSABI_GNU, - ELFOSABI_HURD, - ELFOSABI_SOLARIS, - ELFOSABI_AIX, - ELFOSABI_IRIX, - ELFOSABI_FREEBSD, - ELFOSABI_TRU64, - ELFOSABI_MODESTO, - ELFOSABI_OPENBSD, - ELFOSABI_OPENVMS, - ELFOSABI_NSK, - ELFOSABI_AROS, - ELFOSABI_FENIXOS, - ELFOSABI_CLOUDABI, - ELFOSABI_ARM_AEABI, - ELFOSABI_ARM, - ELFOSABI_STANDALONE, -); -const FLAGS_ET: &[Flag] = &flags!(ET_NONE, ET_REL, ET_EXEC, ET_DYN, ET_CORE); -const FLAGS_EM: &[Flag] = &flags!( - EM_NONE, - EM_M32, - EM_SPARC, - EM_386, - EM_68K, - EM_88K, - EM_IAMCU, - EM_860, - EM_MIPS, - EM_S370, - EM_MIPS_RS3_LE, - EM_PARISC, - EM_VPP500, - EM_SPARC32PLUS, - EM_960, - EM_PPC, - EM_PPC64, - EM_S390, - EM_SPU, - EM_V800, - EM_FR20, - EM_RH32, - EM_RCE, - EM_ARM, - EM_FAKE_ALPHA, - EM_SH, - EM_SPARCV9, - EM_TRICORE, - EM_ARC, - EM_H8_300, - EM_H8_300H, - EM_H8S, - EM_H8_500, - EM_IA_64, - EM_MIPS_X, - EM_COLDFIRE, - EM_68HC12, - EM_MMA, - EM_PCP, - EM_NCPU, - EM_NDR1, - EM_STARCORE, - EM_ME16, - EM_ST100, - EM_TINYJ, - EM_X86_64, - EM_PDSP, - EM_PDP10, - EM_PDP11, - EM_FX66, - EM_ST9PLUS, - EM_ST7, - EM_68HC16, - EM_68HC11, - EM_68HC08, - EM_68HC05, - EM_SVX, - EM_ST19, - EM_VAX, - EM_CRIS, - EM_JAVELIN, - EM_FIREPATH, - EM_ZSP, - EM_MMIX, - EM_HUANY, - EM_PRISM, - EM_AVR, - EM_FR30, - EM_D10V, - EM_D30V, - EM_V850, - EM_M32R, - EM_MN10300, - EM_MN10200, - EM_PJ, - EM_OPENRISC, - EM_ARC_COMPACT, - EM_XTENSA, - EM_VIDEOCORE, - EM_TMM_GPP, - EM_NS32K, - EM_TPC, - EM_SNP1K, - EM_ST200, - EM_IP2K, - EM_MAX, - EM_CR, - EM_F2MC16, - EM_MSP430, - EM_BLACKFIN, - EM_SE_C33, - EM_SEP, - EM_ARCA, - EM_UNICORE, - EM_EXCESS, - EM_DXP, - EM_ALTERA_NIOS2, - EM_CRX, - EM_XGATE, - EM_C166, - EM_M16C, - EM_DSPIC30F, - EM_CE, - EM_M32C, - EM_TSK3000, - EM_RS08, - EM_SHARC, - EM_ECOG2, - EM_SCORE7, - EM_DSP24, - EM_VIDEOCORE3, - EM_LATTICEMICO32, - EM_SE_C17, - EM_TI_C6000, - EM_TI_C2000, - EM_TI_C5500, - EM_TI_ARP32, - EM_TI_PRU, - EM_MMDSP_PLUS, - EM_CYPRESS_M8C, - EM_R32C, - EM_TRIMEDIA, - EM_HEXAGON, - EM_8051, - EM_STXP7X, - EM_NDS32, - EM_ECOG1X, - EM_MAXQ30, - EM_XIMO16, - EM_MANIK, - EM_CRAYNV2, - EM_RX, - EM_METAG, - EM_MCST_ELBRUS, - EM_ECOG16, - EM_CR16, - EM_ETPU, - EM_SLE9X, - EM_L10M, - EM_K10M, - EM_AARCH64, - EM_AVR32, - EM_STM8, - EM_TILE64, - EM_TILEPRO, - EM_MICROBLAZE, - EM_CUDA, - EM_TILEGX, - EM_CLOUDSHIELD, - EM_COREA_1ST, - EM_COREA_2ND, - EM_ARC_COMPACT2, - EM_OPEN8, - EM_RL78, - EM_VIDEOCORE5, - EM_78KOR, - EM_56800EX, - EM_BA1, - EM_BA2, - EM_XCORE, - EM_MCHP_PIC, - EM_KM32, - EM_KMX32, - EM_EMX16, - EM_EMX8, - EM_KVARC, - EM_CDP, - EM_COGE, - EM_COOL, - EM_NORC, - EM_CSR_KALIMBA, - EM_Z80, - EM_VISIUM, - EM_FT32, - EM_MOXIE, - EM_AMDGPU, - EM_RISCV, - EM_BPF, - EM_SBF, - EM_CSKY, - EM_ALPHA, - EM_LOONGARCH, -); -const FLAGS_ELFCOMPRESS: &[Flag] = &flags!(ELFCOMPRESS_ZLIB, ELFCOMPRESS_ZSTD); -const FLAGS_GNU_PROPERTY: &[Flag] = &flags!( - GNU_PROPERTY_STACK_SIZE, - GNU_PROPERTY_NO_COPY_ON_PROTECTED, - GNU_PROPERTY_1_NEEDED, -); -const FLAGS_GNU_PROPERTY_1_NEEDED: &[Flag] = - &flags!(GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS); -const FLAGS_GNU_PROPERTY_AARCH64: &[Flag] = &flags!( - GNU_PROPERTY_AARCH64_FEATURE_1_AND, - GNU_PROPERTY_AARCH64_FEATURE_PAUTH, -); -const FLAGS_GNU_PROPERTY_AARCH64_FEATURE_1: &[Flag] = &flags!( - GNU_PROPERTY_AARCH64_FEATURE_1_BTI, - GNU_PROPERTY_AARCH64_FEATURE_1_PAC, -); -const FLAGS_GNU_PROPERTY_X86: &[Flag] = &flags!( - GNU_PROPERTY_X86_ISA_1_USED, - GNU_PROPERTY_X86_ISA_1_NEEDED, - GNU_PROPERTY_X86_FEATURE_1_AND, -); -const FLAGS_GNU_PROPERTY_X86_ISA_1: &[Flag] = &flags!( - GNU_PROPERTY_X86_ISA_1_BASELINE, - GNU_PROPERTY_X86_ISA_1_V2, - GNU_PROPERTY_X86_ISA_1_V3, - GNU_PROPERTY_X86_ISA_1_V4, -); -const FLAGS_GNU_PROPERTY_X86_FEATURE_1: &[Flag] = &flags!( - GNU_PROPERTY_X86_FEATURE_1_IBT, - GNU_PROPERTY_X86_FEATURE_1_SHSTK, -); -const FLAGS_GRP: &[Flag] = &flags!(GRP_COMDAT); -const FLAGS_DF: &[Flag] = &flags!( - DF_ORIGIN, - DF_SYMBOLIC, - DF_TEXTREL, - DF_BIND_NOW, - DF_STATIC_TLS, -); -const FLAGS_DF_1: &[Flag] = &flags!( - DF_1_NOW, - DF_1_GLOBAL, - DF_1_GROUP, - DF_1_NODELETE, - DF_1_LOADFLTR, - DF_1_INITFIRST, - DF_1_NOOPEN, - DF_1_ORIGIN, - DF_1_DIRECT, - DF_1_TRANS, - DF_1_INTERPOSE, - DF_1_NODEFLIB, - DF_1_NODUMP, - DF_1_CONFALT, - DF_1_ENDFILTEE, - DF_1_DISPRELDNE, - DF_1_DISPRELPND, - DF_1_NODIRECT, - DF_1_IGNMULDEF, - DF_1_NOKSYMS, - DF_1_NOHDR, - DF_1_EDITED, - DF_1_NORELOC, - DF_1_SYMINTPOSE, - DF_1_GLOBAUDIT, - DF_1_SINGLETON, - DF_1_STUB, - DF_1_PIE, -); -const FLAGS_VER_FLG: &[Flag] = &flags!(VER_FLG_BASE, VER_FLG_WEAK); -const FLAGS_VER_NDX: &[Flag] = &flags!(VER_NDX_LOCAL, VER_NDX_GLOBAL); -const FLAGS_VERSYM: &[Flag] = &flags!(VERSYM_HIDDEN); -const FLAGS_TAG: &[Flag] = &flags!(Tag_File, Tag_Section, Tag_Symbol); diff --git a/crates/examples/src/readobj/mod.rs b/crates/examples/src/readobj/mod.rs index f53dbb3a..f6b3cf23 100644 --- a/crates/examples/src/readobj/mod.rs +++ b/crates/examples/src/readobj/mod.rs @@ -236,19 +236,6 @@ impl<'a> Printer<'a> { self.field(name, value); } - fn field_enums(&mut self, name: &str, value: T, enums: &[&[Flag]]) { - for flags in enums { - for flag in *flags { - if value == flag.value { - self.field_name(name); - writeln!(self.w, "{} (0x{:X})", flag.name, value).unwrap(); - return; - } - } - } - self.field_hex(name, value); - } - fn field_consts(&mut self, name: &str, value: T, consts: &ConstantNames) where T: Wrap + Copy, diff --git a/crates/examples/testfiles/elf/base-aarch64.o.objdump b/crates/examples/testfiles/elf/base-aarch64.o.objdump index e90a2051..b9ed925a 100644 --- a/crates/examples/testfiles/elf/base-aarch64.o.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.o.objdump @@ -1,32 +1,32 @@ Format: Elf Little-endian 64-bit Kind: Relocatable Architecture: Aarch64 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 0 -1: Section { name: ".text", address: 0, size: 20, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -2: Section { name: ".rela.text", address: 0, size: 48, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 40 } } -3: Section { name: ".data", address: 0, size: 0, align: 1, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -4: Section { name: ".bss", address: 0, size: 0, align: 1, kind: UninitializedData, flags: Elf { sh_type: 8, sh_flags: 3 } } -5: Section { name: ".rodata", address: 0, size: d, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -6: Section { name: ".comment", address: 0, size: 31, align: 1, kind: OtherString, flags: Elf { sh_type: 1, sh_flags: 30 } } -7: Section { name: ".note.GNU-stack", address: 0, size: 0, align: 1, kind: Other, flags: Elf { sh_type: 1, sh_flags: 0 } } -8: Section { name: ".symtab", address: 0, size: 120, align: 8, kind: Metadata, flags: Elf { sh_type: 2, sh_flags: 0 } } -9: Section { name: ".strtab", address: 0, size: 1a, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } -10: Section { name: ".shstrtab", address: 0, size: 52, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } +1: Section { name: ".text", address: 0, size: 20, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +2: Section { name: ".rela.text", address: 0, size: 48, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_INFO_LINK } } +3: Section { name: ".data", address: 0, size: 0, align: 1, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +4: Section { name: ".bss", address: 0, size: 0, align: 1, kind: UninitializedData, flags: Elf { sh_type: SHT_NOBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +5: Section { name: ".rodata", address: 0, size: d, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +6: Section { name: ".comment", address: 0, size: 31, align: 1, kind: OtherString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_MERGE | SHF_STRINGS } } +7: Section { name: ".note.GNU-stack", address: 0, size: 0, align: 1, kind: Other, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: 0 } } +8: Section { name: ".symtab", address: 0, size: 120, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_SYMTAB, sh_flags: 0 } } +9: Section { name: ".strtab", address: 0, size: 1a, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } +10: Section { name: ".shstrtab", address: 0, size: 52, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } Symbols -1: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -2: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -3: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -4: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -5: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -6: Symbol { name: "$d", address: 0, size: 0, kind: Unknown, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -7: Symbol { name: "$x", address: 0, size: 0, kind: Unknown, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -8: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -9: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -10: Symbol { name: "main", address: 0, size: 20, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -11: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +1: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +2: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +3: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +4: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +5: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +6: Symbol { name: "$d", address: 0, size: 0, kind: Unknown, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +7: Symbol { name: "$x", address: 0, size: 0, kind: Unknown, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +8: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +9: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +10: Symbol { name: "main", address: 0, size: 20, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +11: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } .text relocations (8, Relocation { kind: Unknown, encoding: Unknown, size: 0, target: Symbol(SymbolIndex(5)), addend: 0, implicit_addend: false, flags: Elf { r_type: 113 } }) diff --git a/crates/examples/testfiles/elf/base-aarch64.objdump b/crates/examples/testfiles/elf/base-aarch64.objdump index 44ffbdbc..79ad1da4 100644 --- a/crates/examples/testfiles/elf/base-aarch64.objdump +++ b/crates/examples/testfiles/elf/base-aarch64.objdump @@ -1,138 +1,138 @@ Format: Elf Little-endian 64-bit Kind: Dynamic Architecture: Aarch64 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 620 Build ID: [f7, 5e, 1f, d9, 4, 9a, 3f, cb, 21, dc, 15, f2, 7b, 5, 32, d8, 61, cf, 16, 2] Segment { address: 0, size: 7fc, permissions: R-X } Segment { address: 10d80, size: 298, permissions: RW- } -1: Section { name: ".interp", address: 200, size: 1b, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -2: Section { name: ".note.ABI-tag", address: 21c, size: 20, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -3: Section { name: ".note.gnu.build-id", address: 23c, size: 24, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -4: Section { name: ".gnu.hash", address: 260, size: 1c, align: 8, kind: Unknown, flags: Elf { sh_type: 6ffffff6, sh_flags: 2 } } -5: Section { name: ".dynsym", address: 280, size: f0, align: 8, kind: Metadata, flags: Elf { sh_type: b, sh_flags: 2 } } -6: Section { name: ".dynstr", address: 370, size: 89, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 2 } } -7: Section { name: ".gnu.version", address: 3fa, size: 14, align: 2, kind: Unknown, flags: Elf { sh_type: 6fffffff, sh_flags: 2 } } -8: Section { name: ".gnu.version_r", address: 410, size: 20, align: 8, kind: Unknown, flags: Elf { sh_type: 6ffffffe, sh_flags: 2 } } -9: Section { name: ".rela.dyn", address: 430, size: f0, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 2 } } -10: Section { name: ".rela.plt", address: 520, size: 78, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 42 } } -11: Section { name: ".init", address: 598, size: 14, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -12: Section { name: ".plt", address: 5b0, size: 70, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -13: Section { name: ".text", address: 620, size: 1ac, align: 8, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -14: Section { name: ".fini", address: 7cc, size: 10, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -15: Section { name: ".rodata", address: 7e0, size: 15, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -16: Section { name: ".eh_frame", address: 7f8, size: 4, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -17: Section { name: ".init_array", address: 10d80, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: e, sh_flags: 3 } } -18: Section { name: ".fini_array", address: 10d88, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: f, sh_flags: 3 } } -19: Section { name: ".dynamic", address: 10d90, size: 1f0, align: 8, kind: Metadata, flags: Elf { sh_type: 6, sh_flags: 3 } } -20: Section { name: ".got", address: 10f80, size: 80, align: 8, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -21: Section { name: ".data", address: 11000, size: 10, align: 8, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -22: Section { name: ".bss", address: 11010, size: 8, align: 1, kind: UninitializedData, flags: Elf { sh_type: 8, sh_flags: 3 } } -23: Section { name: ".comment", address: 0, size: 30, align: 1, kind: OtherString, flags: Elf { sh_type: 1, sh_flags: 30 } } -24: Section { name: ".symtab", address: 0, size: 840, align: 8, kind: Metadata, flags: Elf { sh_type: 2, sh_flags: 0 } } -25: Section { name: ".strtab", address: 0, size: 347, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } -26: Section { name: ".shstrtab", address: 0, size: ec, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } +1: Section { name: ".interp", address: 200, size: 1b, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +2: Section { name: ".note.ABI-tag", address: 21c, size: 20, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +3: Section { name: ".note.gnu.build-id", address: 23c, size: 24, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +4: Section { name: ".gnu.hash", address: 260, size: 1c, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_GNU_HASH, sh_flags: SHF_ALLOC } } +5: Section { name: ".dynsym", address: 280, size: f0, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_DYNSYM, sh_flags: SHF_ALLOC } } +6: Section { name: ".dynstr", address: 370, size: 89, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: SHF_ALLOC } } +7: Section { name: ".gnu.version", address: 3fa, size: 14, align: 2, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERSYM, sh_flags: SHF_ALLOC } } +8: Section { name: ".gnu.version_r", address: 410, size: 20, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERNEED, sh_flags: SHF_ALLOC } } +9: Section { name: ".rela.dyn", address: 430, size: f0, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_ALLOC } } +10: Section { name: ".rela.plt", address: 520, size: 78, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_ALLOC | SHF_INFO_LINK } } +11: Section { name: ".init", address: 598, size: 14, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +12: Section { name: ".plt", address: 5b0, size: 70, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +13: Section { name: ".text", address: 620, size: 1ac, align: 8, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +14: Section { name: ".fini", address: 7cc, size: 10, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +15: Section { name: ".rodata", address: 7e0, size: 15, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +16: Section { name: ".eh_frame", address: 7f8, size: 4, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +17: Section { name: ".init_array", address: 10d80, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_INIT_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +18: Section { name: ".fini_array", address: 10d88, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_FINI_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +19: Section { name: ".dynamic", address: 10d90, size: 1f0, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_DYNAMIC, sh_flags: SHF_WRITE | SHF_ALLOC } } +20: Section { name: ".got", address: 10f80, size: 80, align: 8, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +21: Section { name: ".data", address: 11000, size: 10, align: 8, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +22: Section { name: ".bss", address: 11010, size: 8, align: 1, kind: UninitializedData, flags: Elf { sh_type: SHT_NOBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +23: Section { name: ".comment", address: 0, size: 30, align: 1, kind: OtherString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_MERGE | SHF_STRINGS } } +24: Section { name: ".symtab", address: 0, size: 840, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_SYMTAB, sh_flags: 0 } } +25: Section { name: ".strtab", address: 0, size: 347, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } +26: Section { name: ".shstrtab", address: 0, size: ec, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } Symbols -1: Symbol { name: "", address: 200, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -2: Symbol { name: "", address: 21c, size: 0, kind: Section, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -3: Symbol { name: "", address: 23c, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -4: Symbol { name: "", address: 260, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -5: Symbol { name: "", address: 280, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -6: Symbol { name: "", address: 370, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -7: Symbol { name: "", address: 3fa, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -8: Symbol { name: "", address: 410, size: 0, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -9: Symbol { name: "", address: 430, size: 0, kind: Section, section: Section(SectionIndex(9)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -10: Symbol { name: "", address: 520, size: 0, kind: Section, section: Section(SectionIndex(a)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -11: Symbol { name: "", address: 598, size: 0, kind: Section, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -12: Symbol { name: "", address: 5b0, size: 0, kind: Section, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -13: Symbol { name: "", address: 620, size: 0, kind: Section, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -14: Symbol { name: "", address: 7cc, size: 0, kind: Section, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -15: Symbol { name: "", address: 7e0, size: 0, kind: Section, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -16: Symbol { name: "", address: 7f8, size: 0, kind: Section, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -17: Symbol { name: "", address: 10d80, size: 0, kind: Section, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -18: Symbol { name: "", address: 10d88, size: 0, kind: Section, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -19: Symbol { name: "", address: 10d90, size: 0, kind: Section, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -20: Symbol { name: "", address: 10f80, size: 0, kind: Section, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -21: Symbol { name: "", address: 11000, size: 0, kind: Section, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -22: Symbol { name: "", address: 11010, size: 0, kind: Section, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -23: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -24: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/Scrt1.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -25: Symbol { name: "$d", address: 21c, size: 0, kind: Unknown, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -26: Symbol { name: "$x", address: 620, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -27: Symbol { name: "$d", address: 7e0, size: 0, kind: Unknown, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -28: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/crti.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -29: Symbol { name: "$x", address: 658, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -30: Symbol { name: "call_weak_fn", address: 658, size: 14, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -31: Symbol { name: "$x", address: 598, size: 0, kind: Unknown, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -32: Symbol { name: "$x", address: 7cc, size: 0, kind: Unknown, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -33: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/crtn.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -34: Symbol { name: "$x", address: 5a4, size: 0, kind: Unknown, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -35: Symbol { name: "$x", address: 7d4, size: 0, kind: Unknown, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -36: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -37: Symbol { name: "$x", address: 670, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -38: Symbol { name: "deregister_tm_clones", address: 670, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -39: Symbol { name: "register_tm_clones", address: 6a0, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -40: Symbol { name: "$d", address: 11008, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -41: Symbol { name: "__do_global_dtors_aux", address: 6d8, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -42: Symbol { name: "completed.8500", address: 11010, size: 1, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -43: Symbol { name: "$d", address: 10d88, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -44: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 10d88, size: 0, kind: Data, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -45: Symbol { name: "frame_dummy", address: 720, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -46: Symbol { name: "$d", address: 10d80, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -47: Symbol { name: "__frame_dummy_init_array_entry", address: 10d80, size: 0, kind: Data, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -48: Symbol { name: "$d", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -49: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -50: Symbol { name: "$d", address: 7e8, size: 0, kind: Unknown, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -51: Symbol { name: "$x", address: 724, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -52: Symbol { name: "elf-init.oS", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -53: Symbol { name: "$x", address: 748, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -54: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -55: Symbol { name: "$d", address: 7f8, size: 0, kind: Unknown, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -56: Symbol { name: "__FRAME_END__", address: 7f8, size: 0, kind: Data, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -57: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -58: Symbol { name: "__init_array_end", address: 10d88, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -59: Symbol { name: "_DYNAMIC", address: 10d90, size: 0, kind: Data, section: Absolute, scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -60: Symbol { name: "__init_array_start", address: 10d80, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -61: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 10fc0, size: 0, kind: Data, section: Absolute, scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -62: Symbol { name: "$x", address: 5b0, size: 0, kind: Unknown, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -63: Symbol { name: "__libc_csu_fini", address: 7c8, size: 4, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -64: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -65: Symbol { name: "data_start", address: 11000, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -66: Symbol { name: "__bss_start__", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -67: Symbol { name: "__cxa_finalize@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } -68: Symbol { name: "_bss_end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -69: Symbol { name: "_edata", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -70: Symbol { name: "_fini", address: 7cc, size: 0, kind: Text, section: Section(SectionIndex(e)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -71: Symbol { name: "__bss_end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -72: Symbol { name: "__libc_start_main@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -73: Symbol { name: "__data_start", address: 11000, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -74: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -75: Symbol { name: "__dso_handle", address: 11008, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -76: Symbol { name: "abort@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -77: Symbol { name: "_IO_stdin_used", address: 7e0, size: 4, kind: Data, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } -78: Symbol { name: "__libc_csu_init", address: 748, size: 80, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -79: Symbol { name: "_end", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -80: Symbol { name: "_start", address: 620, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -81: Symbol { name: "__end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -82: Symbol { name: "__bss_start", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -83: Symbol { name: "main", address: 724, size: 20, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -84: Symbol { name: "__TMC_END__", address: 11010, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -85: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -86: Symbol { name: "printf@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -87: Symbol { name: "_init", address: 598, size: 0, kind: Text, section: Section(SectionIndex(b)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } +1: Symbol { name: "", address: 200, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +2: Symbol { name: "", address: 21c, size: 0, kind: Section, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +3: Symbol { name: "", address: 23c, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +4: Symbol { name: "", address: 260, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +5: Symbol { name: "", address: 280, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +6: Symbol { name: "", address: 370, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +7: Symbol { name: "", address: 3fa, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +8: Symbol { name: "", address: 410, size: 0, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +9: Symbol { name: "", address: 430, size: 0, kind: Section, section: Section(SectionIndex(9)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +10: Symbol { name: "", address: 520, size: 0, kind: Section, section: Section(SectionIndex(a)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +11: Symbol { name: "", address: 598, size: 0, kind: Section, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +12: Symbol { name: "", address: 5b0, size: 0, kind: Section, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +13: Symbol { name: "", address: 620, size: 0, kind: Section, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +14: Symbol { name: "", address: 7cc, size: 0, kind: Section, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +15: Symbol { name: "", address: 7e0, size: 0, kind: Section, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +16: Symbol { name: "", address: 7f8, size: 0, kind: Section, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +17: Symbol { name: "", address: 10d80, size: 0, kind: Section, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +18: Symbol { name: "", address: 10d88, size: 0, kind: Section, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +19: Symbol { name: "", address: 10d90, size: 0, kind: Section, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +20: Symbol { name: "", address: 10f80, size: 0, kind: Section, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +21: Symbol { name: "", address: 11000, size: 0, kind: Section, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +22: Symbol { name: "", address: 11010, size: 0, kind: Section, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +23: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +24: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/Scrt1.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +25: Symbol { name: "$d", address: 21c, size: 0, kind: Unknown, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +26: Symbol { name: "$x", address: 620, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +27: Symbol { name: "$d", address: 7e0, size: 0, kind: Unknown, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +28: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/crti.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +29: Symbol { name: "$x", address: 658, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +30: Symbol { name: "call_weak_fn", address: 658, size: 14, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +31: Symbol { name: "$x", address: 598, size: 0, kind: Unknown, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +32: Symbol { name: "$x", address: 7cc, size: 0, kind: Unknown, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +33: Symbol { name: "/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/lib/../lib/crtn.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +34: Symbol { name: "$x", address: 5a4, size: 0, kind: Unknown, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +35: Symbol { name: "$x", address: 7d4, size: 0, kind: Unknown, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +36: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +37: Symbol { name: "$x", address: 670, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +38: Symbol { name: "deregister_tm_clones", address: 670, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +39: Symbol { name: "register_tm_clones", address: 6a0, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +40: Symbol { name: "$d", address: 11008, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +41: Symbol { name: "__do_global_dtors_aux", address: 6d8, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +42: Symbol { name: "completed.8500", address: 11010, size: 1, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +43: Symbol { name: "$d", address: 10d88, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +44: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 10d88, size: 0, kind: Data, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +45: Symbol { name: "frame_dummy", address: 720, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +46: Symbol { name: "$d", address: 10d80, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +47: Symbol { name: "__frame_dummy_init_array_entry", address: 10d80, size: 0, kind: Data, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +48: Symbol { name: "$d", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +49: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +50: Symbol { name: "$d", address: 7e8, size: 0, kind: Unknown, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +51: Symbol { name: "$x", address: 724, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +52: Symbol { name: "elf-init.oS", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +53: Symbol { name: "$x", address: 748, size: 0, kind: Unknown, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +54: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +55: Symbol { name: "$d", address: 7f8, size: 0, kind: Unknown, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +56: Symbol { name: "__FRAME_END__", address: 7f8, size: 0, kind: Data, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +57: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +58: Symbol { name: "__init_array_end", address: 10d88, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +59: Symbol { name: "_DYNAMIC", address: 10d90, size: 0, kind: Data, section: Absolute, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +60: Symbol { name: "__init_array_start", address: 10d80, size: 0, kind: Unknown, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +61: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 10fc0, size: 0, kind: Data, section: Absolute, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +62: Symbol { name: "$x", address: 5b0, size: 0, kind: Unknown, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +63: Symbol { name: "__libc_csu_fini", address: 7c8, size: 4, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +64: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +65: Symbol { name: "data_start", address: 11000, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +66: Symbol { name: "__bss_start__", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +67: Symbol { name: "__cxa_finalize@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } +68: Symbol { name: "_bss_end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +69: Symbol { name: "_edata", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +70: Symbol { name: "_fini", address: 7cc, size: 0, kind: Text, section: Section(SectionIndex(e)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +71: Symbol { name: "__bss_end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +72: Symbol { name: "__libc_start_main@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +73: Symbol { name: "__data_start", address: 11000, size: 0, kind: Unknown, section: Section(SectionIndex(15)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +74: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +75: Symbol { name: "__dso_handle", address: 11008, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +76: Symbol { name: "abort@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +77: Symbol { name: "_IO_stdin_used", address: 7e0, size: 4, kind: Data, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_DEFAULT } } +78: Symbol { name: "__libc_csu_init", address: 748, size: 80, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +79: Symbol { name: "_end", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +80: Symbol { name: "_start", address: 620, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +81: Symbol { name: "__end__", address: 11018, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +82: Symbol { name: "__bss_start", address: 11010, size: 0, kind: Unknown, section: Section(SectionIndex(16)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +83: Symbol { name: "main", address: 724, size: 20, kind: Text, section: Section(SectionIndex(d)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +84: Symbol { name: "__TMC_END__", address: 11010, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +85: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +86: Symbol { name: "printf@@GLIBC_2.17", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +87: Symbol { name: "_init", address: 598, size: 0, kind: Text, section: Section(SectionIndex(b)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } Dynamic symbols -1: Symbol { name: "", address: 598, size: 0, kind: Section, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -2: Symbol { name: "", address: 11000, size: 0, kind: Section, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -3: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -4: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } -5: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -6: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -7: Symbol { name: "abort", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -8: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -9: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } +1: Symbol { name: "", address: 598, size: 0, kind: Section, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +2: Symbol { name: "", address: 11000, size: 0, kind: Section, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +3: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +4: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } +5: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +6: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +7: Symbol { name: "abort", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +8: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +9: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } Dynamic relocations (10d80, Relocation { kind: Unknown, encoding: Unknown, size: 0, target: Absolute, addend: 720, implicit_addend: false, flags: Elf { r_type: 403 } }) diff --git a/crates/examples/testfiles/elf/base-aarch64.readobj b/crates/examples/testfiles/elf/base-aarch64.readobj index b2335462..68b82fb2 100644 --- a/crates/examples/testfiles/elf/base-aarch64.readobj +++ b/crates/examples/testfiles/elf/base-aarch64.readobj @@ -161,8 +161,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -851,8 +850,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/examples/testfiles/elf/base-crel.o.objdump b/crates/examples/testfiles/elf/base-crel.o.objdump index c5bd87b2..cd3539e4 100644 --- a/crates/examples/testfiles/elf/base-crel.o.objdump +++ b/crates/examples/testfiles/elf/base-crel.o.objdump @@ -1,26 +1,26 @@ Format: Elf Little-endian 64-bit Kind: Relocatable Architecture: X86_64 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 0 -1: Section { name: ".strtab", address: 0, size: 7b, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } -2: Section { name: ".text", address: 0, size: 25, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -3: Section { name: ".crel.text", address: 0, size: 9, align: 1, kind: Metadata, flags: Elf { sh_type: 40000014, sh_flags: 40 } } -4: Section { name: ".rodata.str1.1", address: 0, size: d, align: 1, kind: ReadOnlyString, flags: Elf { sh_type: 1, sh_flags: 32 } } -5: Section { name: ".comment", address: 0, size: 57, align: 1, kind: OtherString, flags: Elf { sh_type: 1, sh_flags: 30 } } -6: Section { name: ".note.GNU-stack", address: 0, size: 0, align: 1, kind: Other, flags: Elf { sh_type: 1, sh_flags: 0 } } -7: Section { name: ".eh_frame", address: 0, size: 38, align: 8, kind: Unknown, flags: Elf { sh_type: 70000001, sh_flags: 2 } } -8: Section { name: ".crel.eh_frame", address: 0, size: 4, align: 1, kind: Metadata, flags: Elf { sh_type: 40000014, sh_flags: 40 } } -9: Section { name: ".llvm_addrsig", address: 0, size: 1, align: 1, kind: Unknown, flags: Elf { sh_type: 6fff4c03, sh_flags: 80000000 } } -10: Section { name: ".symtab", address: 0, size: 90, align: 8, kind: Metadata, flags: Elf { sh_type: 2, sh_flags: 0 } } +1: Section { name: ".strtab", address: 0, size: 7b, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } +2: Section { name: ".text", address: 0, size: 25, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +3: Section { name: ".crel.text", address: 0, size: 9, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_CREL, sh_flags: SHF_INFO_LINK } } +4: Section { name: ".rodata.str1.1", address: 0, size: d, align: 1, kind: ReadOnlyString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_MERGE | SHF_STRINGS } } +5: Section { name: ".comment", address: 0, size: 57, align: 1, kind: OtherString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_MERGE | SHF_STRINGS } } +6: Section { name: ".note.GNU-stack", address: 0, size: 0, align: 1, kind: Other, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: 0 } } +7: Section { name: ".eh_frame", address: 0, size: 38, align: 8, kind: Unknown, flags: Elf { sh_type: 70000001, sh_flags: SHF_ALLOC } } +8: Section { name: ".crel.eh_frame", address: 0, size: 4, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_CREL, sh_flags: SHF_INFO_LINK } } +9: Section { name: ".llvm_addrsig", address: 0, size: 1, align: 1, kind: Unknown, flags: Elf { sh_type: 6fff4c03, sh_flags: SHF_EXCLUDE } } +10: Section { name: ".symtab", address: 0, size: 90, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_SYMTAB, sh_flags: 0 } } Symbols -1: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -2: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -3: Symbol { name: ".L.str", address: 0, size: d, kind: Data, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -4: Symbol { name: "main", address: 0, size: 25, kind: Text, section: Section(SectionIndex(2)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -5: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +1: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +2: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +3: Symbol { name: ".L.str", address: 0, size: d, kind: Data, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +4: Symbol { name: "main", address: 0, size: 25, kind: Text, section: Section(SectionIndex(2)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +5: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } .text relocations (12, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(3)), addend: fffffffffffffffc, implicit_addend: false, flags: Elf { r_type: 2 } }) diff --git a/crates/examples/testfiles/elf/base-relr-i686.objdump b/crates/examples/testfiles/elf/base-relr-i686.objdump index 687df7dd..0e8a2321 100644 --- a/crates/examples/testfiles/elf/base-relr-i686.objdump +++ b/crates/examples/testfiles/elf/base-relr-i686.objdump @@ -1,7 +1,7 @@ Format: Elf Little-endian 32-bit Kind: Dynamic Architecture: I386 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 1060 Build ID: [20, f1, cf, 5c, 28, a0, 2e, 84, 7f, 7d, 64, 9b, 89, ed, 5e, 93, 3e, 47, 4b, 98] @@ -9,85 +9,85 @@ Segment { address: 0, size: 3e8, permissions: R-- } Segment { address: 1000, size: 1e8, permissions: R-X } Segment { address: 2000, size: 114, permissions: R-- } Segment { address: 3ec0, size: 14c, permissions: RW- } -1: Section { name: ".interp", address: 194, size: 13, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -2: Section { name: ".note.gnu.build-id", address: 1a8, size: 24, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -3: Section { name: ".note.ABI-tag", address: 1cc, size: 20, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -4: Section { name: ".gnu.hash", address: 1ec, size: 20, align: 4, kind: Unknown, flags: Elf { sh_type: 6ffffff6, sh_flags: 2 } } -5: Section { name: ".dynsym", address: 20c, size: 80, align: 4, kind: Metadata, flags: Elf { sh_type: b, sh_flags: 2 } } -6: Section { name: ".dynstr", address: 28c, size: ba, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 2 } } -7: Section { name: ".gnu.version", address: 346, size: 10, align: 2, kind: Unknown, flags: Elf { sh_type: 6fffffff, sh_flags: 2 } } -8: Section { name: ".gnu.version_r", address: 358, size: 50, align: 4, kind: Unknown, flags: Elf { sh_type: 6ffffffe, sh_flags: 2 } } -9: Section { name: ".rel.dyn", address: 3a8, size: 20, align: 4, kind: Metadata, flags: Elf { sh_type: 9, sh_flags: 2 } } -10: Section { name: ".rel.plt", address: 3c8, size: 10, align: 4, kind: Metadata, flags: Elf { sh_type: 9, sh_flags: 42 } } -11: Section { name: ".relr.dyn", address: 3d8, size: 10, align: 4, kind: Metadata, flags: Elf { sh_type: 13, sh_flags: 2 } } -12: Section { name: ".init", address: 1000, size: 20, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -13: Section { name: ".plt", address: 1020, size: 30, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -14: Section { name: ".plt.got", address: 1050, size: 8, align: 8, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -15: Section { name: ".text", address: 1060, size: 171, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -16: Section { name: ".fini", address: 11d4, size: 14, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -17: Section { name: ".rodata", address: 2000, size: 15, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -18: Section { name: ".eh_frame_hdr", address: 2018, size: 34, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -19: Section { name: ".eh_frame", address: 204c, size: c8, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -20: Section { name: ".init_array", address: 3ec0, size: 4, align: 4, kind: Unknown, flags: Elf { sh_type: e, sh_flags: 3 } } -21: Section { name: ".fini_array", address: 3ec4, size: 4, align: 4, kind: Unknown, flags: Elf { sh_type: f, sh_flags: 3 } } -22: Section { name: ".dynamic", address: 3ec8, size: 110, align: 4, kind: Metadata, flags: Elf { sh_type: 6, sh_flags: 3 } } -23: Section { name: ".got", address: 3fd8, size: 28, align: 4, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -24: Section { name: ".data", address: 4000, size: 8, align: 4, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -25: Section { name: ".bss", address: 4008, size: 4, align: 1, kind: UninitializedData, flags: Elf { sh_type: 8, sh_flags: 3 } } -26: Section { name: ".comment", address: 0, size: 26, align: 1, kind: OtherString, flags: Elf { sh_type: 1, sh_flags: 30 } } -27: Section { name: ".symtab", address: 0, size: 280, align: 4, kind: Metadata, flags: Elf { sh_type: 2, sh_flags: 0 } } -28: Section { name: ".strtab", address: 0, size: 223, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } -29: Section { name: ".shstrtab", address: 0, size: 106, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } +1: Section { name: ".interp", address: 194, size: 13, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +2: Section { name: ".note.gnu.build-id", address: 1a8, size: 24, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +3: Section { name: ".note.ABI-tag", address: 1cc, size: 20, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +4: Section { name: ".gnu.hash", address: 1ec, size: 20, align: 4, kind: Unknown, flags: Elf { sh_type: SHT_GNU_HASH, sh_flags: SHF_ALLOC } } +5: Section { name: ".dynsym", address: 20c, size: 80, align: 4, kind: Metadata, flags: Elf { sh_type: SHT_DYNSYM, sh_flags: SHF_ALLOC } } +6: Section { name: ".dynstr", address: 28c, size: ba, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: SHF_ALLOC } } +7: Section { name: ".gnu.version", address: 346, size: 10, align: 2, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERSYM, sh_flags: SHF_ALLOC } } +8: Section { name: ".gnu.version_r", address: 358, size: 50, align: 4, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERNEED, sh_flags: SHF_ALLOC } } +9: Section { name: ".rel.dyn", address: 3a8, size: 20, align: 4, kind: Metadata, flags: Elf { sh_type: SHT_REL, sh_flags: SHF_ALLOC } } +10: Section { name: ".rel.plt", address: 3c8, size: 10, align: 4, kind: Metadata, flags: Elf { sh_type: SHT_REL, sh_flags: SHF_ALLOC | SHF_INFO_LINK } } +11: Section { name: ".relr.dyn", address: 3d8, size: 10, align: 4, kind: Metadata, flags: Elf { sh_type: SHT_RELR, sh_flags: SHF_ALLOC } } +12: Section { name: ".init", address: 1000, size: 20, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +13: Section { name: ".plt", address: 1020, size: 30, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +14: Section { name: ".plt.got", address: 1050, size: 8, align: 8, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +15: Section { name: ".text", address: 1060, size: 171, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +16: Section { name: ".fini", address: 11d4, size: 14, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +17: Section { name: ".rodata", address: 2000, size: 15, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +18: Section { name: ".eh_frame_hdr", address: 2018, size: 34, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +19: Section { name: ".eh_frame", address: 204c, size: c8, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +20: Section { name: ".init_array", address: 3ec0, size: 4, align: 4, kind: Unknown, flags: Elf { sh_type: SHT_INIT_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +21: Section { name: ".fini_array", address: 3ec4, size: 4, align: 4, kind: Unknown, flags: Elf { sh_type: SHT_FINI_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +22: Section { name: ".dynamic", address: 3ec8, size: 110, align: 4, kind: Metadata, flags: Elf { sh_type: SHT_DYNAMIC, sh_flags: SHF_WRITE | SHF_ALLOC } } +23: Section { name: ".got", address: 3fd8, size: 28, align: 4, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +24: Section { name: ".data", address: 4000, size: 8, align: 4, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +25: Section { name: ".bss", address: 4008, size: 4, align: 1, kind: UninitializedData, flags: Elf { sh_type: SHT_NOBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +26: Section { name: ".comment", address: 0, size: 26, align: 1, kind: OtherString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_MERGE | SHF_STRINGS } } +27: Section { name: ".symtab", address: 0, size: 280, align: 4, kind: Metadata, flags: Elf { sh_type: SHT_SYMTAB, sh_flags: 0 } } +28: Section { name: ".strtab", address: 0, size: 223, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } +29: Section { name: ".shstrtab", address: 0, size: 106, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } Symbols -1: Symbol { name: "Scrt1.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -2: Symbol { name: "__abi_tag", address: 1cc, size: 20, kind: Data, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -3: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -4: Symbol { name: "deregister_tm_clones", address: 10a0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -5: Symbol { name: "register_tm_clones", address: 10e0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -6: Symbol { name: "__do_global_dtors_aux", address: 1130, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -7: Symbol { name: "completed.0", address: 4008, size: 1, kind: Data, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -8: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 3ec4, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -9: Symbol { name: "frame_dummy", address: 1180, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -10: Symbol { name: "__frame_dummy_init_array_entry", address: 3ec0, size: 0, kind: Data, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -11: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -12: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -13: Symbol { name: "__FRAME_END__", address: 2110, size: 0, kind: Data, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -14: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -15: Symbol { name: "_DYNAMIC", address: 3ec8, size: 0, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -16: Symbol { name: "__GNU_EH_FRAME_HDR", address: 2018, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -17: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 3fd8, size: 0, kind: Data, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -18: Symbol { name: "__libc_start_main@GLIBC_2.34", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -19: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -20: Symbol { name: "__x86.get_pc_thunk.bx", address: 1090, size: 4, kind: Text, section: Section(SectionIndex(f)), scope: Linkage, weak: false, flags: Elf { st_info: 12, st_other: 2 } } -21: Symbol { name: "data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -22: Symbol { name: "printf@GLIBC_2.0", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -23: Symbol { name: "_edata", address: 4008, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -24: Symbol { name: "_fini", address: 11d4, size: 0, kind: Text, section: Section(SectionIndex(10)), scope: Linkage, weak: false, flags: Elf { st_info: 12, st_other: 2 } } -25: Symbol { name: "__x86.get_pc_thunk.dx", address: 1189, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Linkage, weak: false, flags: Elf { st_info: 12, st_other: 2 } } -26: Symbol { name: "__cxa_finalize@GLIBC_2.1.3", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } -27: Symbol { name: "__data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -28: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -29: Symbol { name: "__dso_handle", address: 4004, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -30: Symbol { name: "_IO_stdin_used", address: 2004, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } -31: Symbol { name: "_end", address: 400c, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -32: Symbol { name: "_start", address: 1060, size: 2c, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -33: Symbol { name: "_fp_hw", address: 2000, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } -34: Symbol { name: "__bss_start", address: 4008, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -35: Symbol { name: "main", address: 118d, size: 40, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -36: Symbol { name: "__x86.get_pc_thunk.ax", address: 11cd, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Linkage, weak: false, flags: Elf { st_info: 12, st_other: 2 } } -37: Symbol { name: "__TMC_END__", address: 4008, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -38: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -39: Symbol { name: "_init", address: 1000, size: 0, kind: Text, section: Section(SectionIndex(c)), scope: Linkage, weak: false, flags: Elf { st_info: 12, st_other: 2 } } +1: Symbol { name: "Scrt1.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +2: Symbol { name: "__abi_tag", address: 1cc, size: 20, kind: Data, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +3: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +4: Symbol { name: "deregister_tm_clones", address: 10a0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +5: Symbol { name: "register_tm_clones", address: 10e0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +6: Symbol { name: "__do_global_dtors_aux", address: 1130, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +7: Symbol { name: "completed.0", address: 4008, size: 1, kind: Data, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +8: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 3ec4, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +9: Symbol { name: "frame_dummy", address: 1180, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +10: Symbol { name: "__frame_dummy_init_array_entry", address: 3ec0, size: 0, kind: Data, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +11: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +12: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +13: Symbol { name: "__FRAME_END__", address: 2110, size: 0, kind: Data, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +14: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +15: Symbol { name: "_DYNAMIC", address: 3ec8, size: 0, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +16: Symbol { name: "__GNU_EH_FRAME_HDR", address: 2018, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +17: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 3fd8, size: 0, kind: Data, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +18: Symbol { name: "__libc_start_main@GLIBC_2.34", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +19: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +20: Symbol { name: "__x86.get_pc_thunk.bx", address: 1090, size: 4, kind: Text, section: Section(SectionIndex(f)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_HIDDEN } } +21: Symbol { name: "data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +22: Symbol { name: "printf@GLIBC_2.0", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +23: Symbol { name: "_edata", address: 4008, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +24: Symbol { name: "_fini", address: 11d4, size: 0, kind: Text, section: Section(SectionIndex(10)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_HIDDEN } } +25: Symbol { name: "__x86.get_pc_thunk.dx", address: 1189, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_HIDDEN } } +26: Symbol { name: "__cxa_finalize@GLIBC_2.1.3", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } +27: Symbol { name: "__data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +28: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +29: Symbol { name: "__dso_handle", address: 4004, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +30: Symbol { name: "_IO_stdin_used", address: 2004, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_DEFAULT } } +31: Symbol { name: "_end", address: 400c, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +32: Symbol { name: "_start", address: 1060, size: 2c, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +33: Symbol { name: "_fp_hw", address: 2000, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_DEFAULT } } +34: Symbol { name: "__bss_start", address: 4008, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +35: Symbol { name: "main", address: 118d, size: 40, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +36: Symbol { name: "__x86.get_pc_thunk.ax", address: 11cd, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_HIDDEN } } +37: Symbol { name: "__TMC_END__", address: 4008, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +38: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +39: Symbol { name: "_init", address: 1000, size: 0, kind: Text, section: Section(SectionIndex(c)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_HIDDEN } } Dynamic symbols -1: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -2: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -3: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -4: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } -5: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -6: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -7: Symbol { name: "_IO_stdin_used", address: 2004, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } +1: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +2: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +3: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +4: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } +5: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +6: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +7: Symbol { name: "_IO_stdin_used", address: 2004, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_DEFAULT } } Dynamic relocations (3fec, Relocation { kind: Unknown, encoding: Unknown, size: 0, target: Symbol(SymbolIndex(2)), addend: 0, implicit_addend: true, flags: Elf { r_type: 6 } }) diff --git a/crates/examples/testfiles/elf/base-relr-i686.readobj b/crates/examples/testfiles/elf/base-relr-i686.readobj index a05aa9c3..ee09e849 100644 --- a/crates/examples/testfiles/elf/base-relr-i686.readobj +++ b/crates/examples/testfiles/elf/base-relr-i686.readobj @@ -181,8 +181,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -874,8 +873,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/examples/testfiles/elf/base-relr-x86_64.objdump b/crates/examples/testfiles/elf/base-relr-x86_64.objdump index a2b382cd..19361600 100644 --- a/crates/examples/testfiles/elf/base-relr-x86_64.objdump +++ b/crates/examples/testfiles/elf/base-relr-x86_64.objdump @@ -1,7 +1,7 @@ Format: Elf Little-endian 64-bit Kind: Dynamic Architecture: X86_64 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 1060 Build ID: [1f, 9b, 45, 6b, d0, 2a, 5, f3, 6b, 88, 90, ba, b6, bc, fb, 39, e9, 39, cd, 99] @@ -9,82 +9,82 @@ Segment { address: 0, size: 618, permissions: R-- } Segment { address: 1000, size: 179, permissions: R-X } Segment { address: 2000, size: f4, permissions: R-- } Segment { address: 3d88, size: 290, permissions: RW- } -1: Section { name: ".interp", address: 318, size: 1c, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -2: Section { name: ".note.gnu.property", address: 338, size: 30, align: 8, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -3: Section { name: ".note.gnu.build-id", address: 368, size: 24, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -4: Section { name: ".note.ABI-tag", address: 38c, size: 20, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -5: Section { name: ".gnu.hash", address: 3b0, size: 24, align: 8, kind: Unknown, flags: Elf { sh_type: 6ffffff6, sh_flags: 2 } } -6: Section { name: ".dynsym", address: 3d8, size: a8, align: 8, kind: Metadata, flags: Elf { sh_type: b, sh_flags: 2 } } -7: Section { name: ".dynstr", address: 480, size: a1, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 2 } } -8: Section { name: ".gnu.version", address: 522, size: e, align: 2, kind: Unknown, flags: Elf { sh_type: 6fffffff, sh_flags: 2 } } -9: Section { name: ".gnu.version_r", address: 530, size: 40, align: 8, kind: Unknown, flags: Elf { sh_type: 6ffffffe, sh_flags: 2 } } -10: Section { name: ".rela.dyn", address: 570, size: 78, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 2 } } -11: Section { name: ".rela.plt", address: 5e8, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 42 } } -12: Section { name: ".relr.dyn", address: 600, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: 13, sh_flags: 2 } } -13: Section { name: ".init", address: 1000, size: 1b, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -14: Section { name: ".plt", address: 1020, size: 20, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -15: Section { name: ".plt.got", address: 1040, size: 10, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -16: Section { name: ".plt.sec", address: 1050, size: 10, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -17: Section { name: ".text", address: 1060, size: 10c, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -18: Section { name: ".fini", address: 116c, size: d, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -19: Section { name: ".rodata", address: 2000, size: 11, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -20: Section { name: ".eh_frame_hdr", address: 2014, size: 34, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -21: Section { name: ".eh_frame", address: 2048, size: ac, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -22: Section { name: ".init_array", address: 3d88, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: e, sh_flags: 3 } } -23: Section { name: ".fini_array", address: 3d90, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: f, sh_flags: 3 } } -24: Section { name: ".dynamic", address: 3d98, size: 220, align: 8, kind: Metadata, flags: Elf { sh_type: 6, sh_flags: 3 } } -25: Section { name: ".got", address: 3fb8, size: 48, align: 8, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -26: Section { name: ".data", address: 4000, size: 10, align: 8, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -27: Section { name: ".bss", address: 4010, size: 8, align: 1, kind: UninitializedData, flags: Elf { sh_type: 8, sh_flags: 3 } } -28: Section { name: ".comment", address: 0, size: 26, align: 1, kind: OtherString, flags: Elf { sh_type: 1, sh_flags: 30 } } -29: Section { name: ".symtab", address: 0, size: 360, align: 8, kind: Metadata, flags: Elf { sh_type: 2, sh_flags: 0 } } -30: Section { name: ".strtab", address: 0, size: 1dc, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } -31: Section { name: ".shstrtab", address: 0, size: 124, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } +1: Section { name: ".interp", address: 318, size: 1c, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +2: Section { name: ".note.gnu.property", address: 338, size: 30, align: 8, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +3: Section { name: ".note.gnu.build-id", address: 368, size: 24, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +4: Section { name: ".note.ABI-tag", address: 38c, size: 20, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +5: Section { name: ".gnu.hash", address: 3b0, size: 24, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_GNU_HASH, sh_flags: SHF_ALLOC } } +6: Section { name: ".dynsym", address: 3d8, size: a8, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_DYNSYM, sh_flags: SHF_ALLOC } } +7: Section { name: ".dynstr", address: 480, size: a1, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: SHF_ALLOC } } +8: Section { name: ".gnu.version", address: 522, size: e, align: 2, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERSYM, sh_flags: SHF_ALLOC } } +9: Section { name: ".gnu.version_r", address: 530, size: 40, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERNEED, sh_flags: SHF_ALLOC } } +10: Section { name: ".rela.dyn", address: 570, size: 78, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_ALLOC } } +11: Section { name: ".rela.plt", address: 5e8, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_ALLOC | SHF_INFO_LINK } } +12: Section { name: ".relr.dyn", address: 600, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELR, sh_flags: SHF_ALLOC } } +13: Section { name: ".init", address: 1000, size: 1b, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +14: Section { name: ".plt", address: 1020, size: 20, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +15: Section { name: ".plt.got", address: 1040, size: 10, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +16: Section { name: ".plt.sec", address: 1050, size: 10, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +17: Section { name: ".text", address: 1060, size: 10c, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +18: Section { name: ".fini", address: 116c, size: d, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +19: Section { name: ".rodata", address: 2000, size: 11, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +20: Section { name: ".eh_frame_hdr", address: 2014, size: 34, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +21: Section { name: ".eh_frame", address: 2048, size: ac, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +22: Section { name: ".init_array", address: 3d88, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_INIT_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +23: Section { name: ".fini_array", address: 3d90, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_FINI_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +24: Section { name: ".dynamic", address: 3d98, size: 220, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_DYNAMIC, sh_flags: SHF_WRITE | SHF_ALLOC } } +25: Section { name: ".got", address: 3fb8, size: 48, align: 8, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +26: Section { name: ".data", address: 4000, size: 10, align: 8, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +27: Section { name: ".bss", address: 4010, size: 8, align: 1, kind: UninitializedData, flags: Elf { sh_type: SHT_NOBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +28: Section { name: ".comment", address: 0, size: 26, align: 1, kind: OtherString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_MERGE | SHF_STRINGS } } +29: Section { name: ".symtab", address: 0, size: 360, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_SYMTAB, sh_flags: 0 } } +30: Section { name: ".strtab", address: 0, size: 1dc, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } +31: Section { name: ".shstrtab", address: 0, size: 124, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } Symbols -1: Symbol { name: "Scrt1.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -2: Symbol { name: "__abi_tag", address: 38c, size: 20, kind: Data, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -3: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -4: Symbol { name: "deregister_tm_clones", address: 1090, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -5: Symbol { name: "register_tm_clones", address: 10c0, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -6: Symbol { name: "__do_global_dtors_aux", address: 1100, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -7: Symbol { name: "completed.0", address: 4010, size: 1, kind: Data, section: Section(SectionIndex(1b)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -8: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 3d90, size: 0, kind: Data, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -9: Symbol { name: "frame_dummy", address: 1140, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -10: Symbol { name: "__frame_dummy_init_array_entry", address: 3d88, size: 0, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -11: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -12: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -13: Symbol { name: "__FRAME_END__", address: 20f0, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -14: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -15: Symbol { name: "_DYNAMIC", address: 3d98, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -16: Symbol { name: "__GNU_EH_FRAME_HDR", address: 2014, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -17: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 3fb8, size: 0, kind: Data, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -18: Symbol { name: "__libc_start_main@GLIBC_2.34", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -19: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -20: Symbol { name: "data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(1a)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -21: Symbol { name: "_edata", address: 4010, size: 0, kind: Unknown, section: Section(SectionIndex(1a)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -22: Symbol { name: "_fini", address: 116c, size: 0, kind: Text, section: Section(SectionIndex(12)), scope: Linkage, weak: false, flags: Elf { st_info: 12, st_other: 2 } } -23: Symbol { name: "printf@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -24: Symbol { name: "__data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(1a)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -25: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -26: Symbol { name: "__dso_handle", address: 4008, size: 0, kind: Data, section: Section(SectionIndex(1a)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -27: Symbol { name: "_IO_stdin_used", address: 2000, size: 4, kind: Data, section: Section(SectionIndex(13)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } -28: Symbol { name: "_end", address: 4018, size: 0, kind: Unknown, section: Section(SectionIndex(1b)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -29: Symbol { name: "_start", address: 1060, size: 26, kind: Text, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -30: Symbol { name: "__bss_start", address: 4010, size: 0, kind: Unknown, section: Section(SectionIndex(1b)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -31: Symbol { name: "main", address: 1149, size: 23, kind: Text, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -32: Symbol { name: "__TMC_END__", address: 4010, size: 0, kind: Data, section: Section(SectionIndex(1a)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -33: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -34: Symbol { name: "__cxa_finalize@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } -35: Symbol { name: "_init", address: 1000, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Linkage, weak: false, flags: Elf { st_info: 12, st_other: 2 } } +1: Symbol { name: "Scrt1.o", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +2: Symbol { name: "__abi_tag", address: 38c, size: 20, kind: Data, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +3: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +4: Symbol { name: "deregister_tm_clones", address: 1090, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +5: Symbol { name: "register_tm_clones", address: 10c0, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +6: Symbol { name: "__do_global_dtors_aux", address: 1100, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +7: Symbol { name: "completed.0", address: 4010, size: 1, kind: Data, section: Section(SectionIndex(1b)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +8: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 3d90, size: 0, kind: Data, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +9: Symbol { name: "frame_dummy", address: 1140, size: 0, kind: Text, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +10: Symbol { name: "__frame_dummy_init_array_entry", address: 3d88, size: 0, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +11: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +12: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +13: Symbol { name: "__FRAME_END__", address: 20f0, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +14: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +15: Symbol { name: "_DYNAMIC", address: 3d98, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +16: Symbol { name: "__GNU_EH_FRAME_HDR", address: 2014, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +17: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 3fb8, size: 0, kind: Data, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +18: Symbol { name: "__libc_start_main@GLIBC_2.34", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +19: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +20: Symbol { name: "data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(1a)), scope: Dynamic, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +21: Symbol { name: "_edata", address: 4010, size: 0, kind: Unknown, section: Section(SectionIndex(1a)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +22: Symbol { name: "_fini", address: 116c, size: 0, kind: Text, section: Section(SectionIndex(12)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_HIDDEN } } +23: Symbol { name: "printf@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +24: Symbol { name: "__data_start", address: 4000, size: 0, kind: Unknown, section: Section(SectionIndex(1a)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +25: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +26: Symbol { name: "__dso_handle", address: 4008, size: 0, kind: Data, section: Section(SectionIndex(1a)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +27: Symbol { name: "_IO_stdin_used", address: 2000, size: 4, kind: Data, section: Section(SectionIndex(13)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_DEFAULT } } +28: Symbol { name: "_end", address: 4018, size: 0, kind: Unknown, section: Section(SectionIndex(1b)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +29: Symbol { name: "_start", address: 1060, size: 26, kind: Text, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +30: Symbol { name: "__bss_start", address: 4010, size: 0, kind: Unknown, section: Section(SectionIndex(1b)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +31: Symbol { name: "main", address: 1149, size: 23, kind: Text, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +32: Symbol { name: "__TMC_END__", address: 4010, size: 0, kind: Data, section: Section(SectionIndex(1a)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +33: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +34: Symbol { name: "__cxa_finalize@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } +35: Symbol { name: "_init", address: 1000, size: 0, kind: Text, section: Section(SectionIndex(d)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_HIDDEN } } Dynamic symbols -1: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -2: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -3: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -4: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -5: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -6: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } +1: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +2: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +3: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +4: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +5: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +6: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } Dynamic relocations (3fd8, Relocation { kind: Unknown, encoding: Unknown, size: 0, target: Symbol(SymbolIndex(1)), addend: 0, implicit_addend: false, flags: Elf { r_type: 6 } }) diff --git a/crates/examples/testfiles/elf/base-relr-x86_64.readobj b/crates/examples/testfiles/elf/base-relr-x86_64.readobj index 55cba1bf..d19189d3 100644 --- a/crates/examples/testfiles/elf/base-relr-x86_64.readobj +++ b/crates/examples/testfiles/elf/base-relr-x86_64.readobj @@ -181,8 +181,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -239,8 +238,7 @@ ProgramHeader { } Property { Type: GNU_PROPERTY_X86_ISA_1_NEEDED (0xC0008002) - Value: 0x1 - GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) + Value: GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) } } } @@ -355,8 +353,7 @@ SectionHeader { } Property { Type: GNU_PROPERTY_X86_ISA_1_NEEDED (0xC0008002) - Value: 0x1 - GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) + Value: GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) } } } @@ -929,8 +926,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/examples/testfiles/elf/base-strip.objdump b/crates/examples/testfiles/elf/base-strip.objdump index 66111b65..8bb4f45d 100644 --- a/crates/examples/testfiles/elf/base-strip.objdump +++ b/crates/examples/testfiles/elf/base-strip.objdump @@ -1,7 +1,7 @@ Format: Elf Little-endian 64-bit Kind: Dynamic Architecture: X86_64 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 570 Build ID: [d4, 46, a0, 61, bb, 9a, c2, 7a, b4, 3b, 11, 71, 8f, de, df, 5b, 7f, 3a, f6, f4] diff --git a/crates/examples/testfiles/elf/base-strip.readobj b/crates/examples/testfiles/elf/base-strip.readobj index 27705eb1..225081df 100644 --- a/crates/examples/testfiles/elf/base-strip.readobj +++ b/crates/examples/testfiles/elf/base-strip.readobj @@ -21,7 +21,7 @@ FileHeader { ProgramHeaderCount: 9 SectionHeaderEntrySize: 0x40 SectionHeaderCount: 0 - SectionHeaderStringTableIndex: 0 + SectionHeaderStringTableIndex: SHN_UNDEF (0x0) } ProgramHeader { Type: PT_PHDR (0x6) @@ -165,8 +165,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/examples/testfiles/elf/base.o.objdump b/crates/examples/testfiles/elf/base.o.objdump index 2688d7a3..21b47302 100644 --- a/crates/examples/testfiles/elf/base.o.objdump +++ b/crates/examples/testfiles/elf/base.o.objdump @@ -1,34 +1,34 @@ Format: Elf Little-endian 64-bit Kind: Relocatable Architecture: X86_64 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 0 -1: Section { name: ".text", address: 0, size: 1c, align: 1, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -2: Section { name: ".rela.text", address: 0, size: 30, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 40 } } -3: Section { name: ".data", address: 0, size: 0, align: 1, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -4: Section { name: ".bss", address: 0, size: 0, align: 1, kind: UninitializedData, flags: Elf { sh_type: 8, sh_flags: 3 } } -5: Section { name: ".rodata", address: 0, size: d, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -6: Section { name: ".comment", address: 0, size: 2a, align: 1, kind: OtherString, flags: Elf { sh_type: 1, sh_flags: 30 } } -7: Section { name: ".note.GNU-stack", address: 0, size: 0, align: 1, kind: Other, flags: Elf { sh_type: 1, sh_flags: 0 } } -8: Section { name: ".eh_frame", address: 0, size: 38, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -9: Section { name: ".rela.eh_frame", address: 0, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 40 } } -10: Section { name: ".symtab", address: 0, size: 120, align: 8, kind: Metadata, flags: Elf { sh_type: 2, sh_flags: 0 } } -11: Section { name: ".strtab", address: 0, size: 2a, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } -12: Section { name: ".shstrtab", address: 0, size: 61, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } +1: Section { name: ".text", address: 0, size: 1c, align: 1, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +2: Section { name: ".rela.text", address: 0, size: 30, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_INFO_LINK } } +3: Section { name: ".data", address: 0, size: 0, align: 1, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +4: Section { name: ".bss", address: 0, size: 0, align: 1, kind: UninitializedData, flags: Elf { sh_type: SHT_NOBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +5: Section { name: ".rodata", address: 0, size: d, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +6: Section { name: ".comment", address: 0, size: 2a, align: 1, kind: OtherString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_MERGE | SHF_STRINGS } } +7: Section { name: ".note.GNU-stack", address: 0, size: 0, align: 1, kind: Other, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: 0 } } +8: Section { name: ".eh_frame", address: 0, size: 38, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +9: Section { name: ".rela.eh_frame", address: 0, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_INFO_LINK } } +10: Section { name: ".symtab", address: 0, size: 120, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_SYMTAB, sh_flags: 0 } } +11: Section { name: ".strtab", address: 0, size: 2a, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } +12: Section { name: ".shstrtab", address: 0, size: 61, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } Symbols -1: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -2: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -3: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -4: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -5: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -6: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -7: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -8: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -9: Symbol { name: "main", address: 0, size: 1c, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -10: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -11: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 10, st_other: 0 } } +1: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +2: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +3: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +4: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +5: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +6: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +7: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +8: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +9: Symbol { name: "main", address: 0, size: 1c, kind: Text, section: Section(SectionIndex(1)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +10: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +11: Symbol { name: "printf", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } .text relocations (7, Relocation { kind: Relative, encoding: Generic, size: 20, target: Symbol(SymbolIndex(5)), addend: fffffffffffffffc, implicit_addend: false, flags: Elf { r_type: 2 } }) diff --git a/crates/examples/testfiles/elf/base.objdump b/crates/examples/testfiles/elf/base.objdump index c7c68abd..ff2ee2ee 100644 --- a/crates/examples/testfiles/elf/base.objdump +++ b/crates/examples/testfiles/elf/base.objdump @@ -1,114 +1,114 @@ Format: Elf Little-endian 64-bit Kind: Dynamic Architecture: X86_64 -Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 } +Flags: Elf { os_abi: ELFOSABI_SYSV, abi_version: 0, e_flags: 0 } Relative Address Base: 0 Entry Address: 570 Build ID: [d4, 46, a0, 61, bb, 9a, c2, 7a, b4, 3b, 11, 71, 8f, de, df, 5b, 7f, 3a, f6, f4] Segment { address: 0, size: 878, permissions: R-X } Segment { address: 200da8, size: 270, permissions: RW- } -1: Section { name: ".interp", address: 238, size: 1c, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -2: Section { name: ".note.ABI-tag", address: 254, size: 20, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -3: Section { name: ".note.gnu.build-id", address: 274, size: 24, align: 4, kind: Note, flags: Elf { sh_type: 7, sh_flags: 2 } } -4: Section { name: ".hash", address: 298, size: 30, align: 8, kind: Metadata, flags: Elf { sh_type: 5, sh_flags: 2 } } -5: Section { name: ".gnu.hash", address: 2c8, size: 1c, align: 8, kind: Unknown, flags: Elf { sh_type: 6ffffff6, sh_flags: 2 } } -6: Section { name: ".dynsym", address: 2e8, size: a8, align: 8, kind: Metadata, flags: Elf { sh_type: b, sh_flags: 2 } } -7: Section { name: ".dynstr", address: 390, size: 84, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 2 } } -8: Section { name: ".gnu.version", address: 414, size: e, align: 2, kind: Unknown, flags: Elf { sh_type: 6fffffff, sh_flags: 2 } } -9: Section { name: ".gnu.version_r", address: 428, size: 20, align: 8, kind: Unknown, flags: Elf { sh_type: 6ffffffe, sh_flags: 2 } } -10: Section { name: ".rela.dyn", address: 448, size: c0, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 2 } } -11: Section { name: ".rela.plt", address: 508, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: 4, sh_flags: 42 } } -12: Section { name: ".init", address: 520, size: 17, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -13: Section { name: ".plt", address: 540, size: 20, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -14: Section { name: ".plt.got", address: 560, size: 8, align: 8, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -15: Section { name: ".text", address: 570, size: 1a2, align: 10, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -16: Section { name: ".fini", address: 714, size: 9, align: 4, kind: Text, flags: Elf { sh_type: 1, sh_flags: 6 } } -17: Section { name: ".rodata", address: 720, size: 11, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -18: Section { name: ".eh_frame_hdr", address: 734, size: 3c, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -19: Section { name: ".eh_frame", address: 770, size: 108, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: 1, sh_flags: 2 } } -20: Section { name: ".init_array", address: 200da8, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: e, sh_flags: 3 } } -21: Section { name: ".fini_array", address: 200db0, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: f, sh_flags: 3 } } -22: Section { name: ".dynamic", address: 200db8, size: 200, align: 8, kind: Metadata, flags: Elf { sh_type: 6, sh_flags: 3 } } -23: Section { name: ".got", address: 200fb8, size: 48, align: 8, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -24: Section { name: ".data", address: 201000, size: 10, align: 8, kind: Data, flags: Elf { sh_type: 1, sh_flags: 3 } } -25: Section { name: ".bss", address: 201010, size: 8, align: 1, kind: UninitializedData, flags: Elf { sh_type: 8, sh_flags: 3 } } -26: Section { name: ".comment", address: 0, size: 29, align: 1, kind: OtherString, flags: Elf { sh_type: 1, sh_flags: 30 } } -27: Section { name: ".symtab", address: 0, size: 600, align: 8, kind: Metadata, flags: Elf { sh_type: 2, sh_flags: 0 } } -28: Section { name: ".strtab", address: 0, size: 204, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } -29: Section { name: ".shstrtab", address: 0, size: fe, align: 1, kind: Metadata, flags: Elf { sh_type: 3, sh_flags: 0 } } +1: Section { name: ".interp", address: 238, size: 1c, align: 1, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +2: Section { name: ".note.ABI-tag", address: 254, size: 20, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +3: Section { name: ".note.gnu.build-id", address: 274, size: 24, align: 4, kind: Note, flags: Elf { sh_type: SHT_NOTE, sh_flags: SHF_ALLOC } } +4: Section { name: ".hash", address: 298, size: 30, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_HASH, sh_flags: SHF_ALLOC } } +5: Section { name: ".gnu.hash", address: 2c8, size: 1c, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_GNU_HASH, sh_flags: SHF_ALLOC } } +6: Section { name: ".dynsym", address: 2e8, size: a8, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_DYNSYM, sh_flags: SHF_ALLOC } } +7: Section { name: ".dynstr", address: 390, size: 84, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: SHF_ALLOC } } +8: Section { name: ".gnu.version", address: 414, size: e, align: 2, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERSYM, sh_flags: SHF_ALLOC } } +9: Section { name: ".gnu.version_r", address: 428, size: 20, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_GNU_VERNEED, sh_flags: SHF_ALLOC } } +10: Section { name: ".rela.dyn", address: 448, size: c0, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_ALLOC } } +11: Section { name: ".rela.plt", address: 508, size: 18, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_RELA, sh_flags: SHF_ALLOC | SHF_INFO_LINK } } +12: Section { name: ".init", address: 520, size: 17, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +13: Section { name: ".plt", address: 540, size: 20, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +14: Section { name: ".plt.got", address: 560, size: 8, align: 8, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +15: Section { name: ".text", address: 570, size: 1a2, align: 10, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +16: Section { name: ".fini", address: 714, size: 9, align: 4, kind: Text, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC | SHF_EXECINSTR } } +17: Section { name: ".rodata", address: 720, size: 11, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +18: Section { name: ".eh_frame_hdr", address: 734, size: 3c, align: 4, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +19: Section { name: ".eh_frame", address: 770, size: 108, align: 8, kind: ReadOnlyData, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_ALLOC } } +20: Section { name: ".init_array", address: 200da8, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_INIT_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +21: Section { name: ".fini_array", address: 200db0, size: 8, align: 8, kind: Unknown, flags: Elf { sh_type: SHT_FINI_ARRAY, sh_flags: SHF_WRITE | SHF_ALLOC } } +22: Section { name: ".dynamic", address: 200db8, size: 200, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_DYNAMIC, sh_flags: SHF_WRITE | SHF_ALLOC } } +23: Section { name: ".got", address: 200fb8, size: 48, align: 8, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +24: Section { name: ".data", address: 201000, size: 10, align: 8, kind: Data, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +25: Section { name: ".bss", address: 201010, size: 8, align: 1, kind: UninitializedData, flags: Elf { sh_type: SHT_NOBITS, sh_flags: SHF_WRITE | SHF_ALLOC } } +26: Section { name: ".comment", address: 0, size: 29, align: 1, kind: OtherString, flags: Elf { sh_type: SHT_PROGBITS, sh_flags: SHF_MERGE | SHF_STRINGS } } +27: Section { name: ".symtab", address: 0, size: 600, align: 8, kind: Metadata, flags: Elf { sh_type: SHT_SYMTAB, sh_flags: 0 } } +28: Section { name: ".strtab", address: 0, size: 204, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } +29: Section { name: ".shstrtab", address: 0, size: fe, align: 1, kind: Metadata, flags: Elf { sh_type: SHT_STRTAB, sh_flags: 0 } } Symbols -1: Symbol { name: "", address: 238, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -2: Symbol { name: "", address: 254, size: 0, kind: Section, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -3: Symbol { name: "", address: 274, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -4: Symbol { name: "", address: 298, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -5: Symbol { name: "", address: 2c8, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -6: Symbol { name: "", address: 2e8, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -7: Symbol { name: "", address: 390, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -8: Symbol { name: "", address: 414, size: 0, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -9: Symbol { name: "", address: 428, size: 0, kind: Section, section: Section(SectionIndex(9)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -10: Symbol { name: "", address: 448, size: 0, kind: Section, section: Section(SectionIndex(a)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -11: Symbol { name: "", address: 508, size: 0, kind: Section, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -12: Symbol { name: "", address: 520, size: 0, kind: Section, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -13: Symbol { name: "", address: 540, size: 0, kind: Section, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -14: Symbol { name: "", address: 560, size: 0, kind: Section, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -15: Symbol { name: "", address: 570, size: 0, kind: Section, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -16: Symbol { name: "", address: 714, size: 0, kind: Section, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -17: Symbol { name: "", address: 720, size: 0, kind: Section, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -18: Symbol { name: "", address: 734, size: 0, kind: Section, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -19: Symbol { name: "", address: 770, size: 0, kind: Section, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -20: Symbol { name: "", address: 200da8, size: 0, kind: Section, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -21: Symbol { name: "", address: 200db0, size: 0, kind: Section, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -22: Symbol { name: "", address: 200db8, size: 0, kind: Section, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -23: Symbol { name: "", address: 200fb8, size: 0, kind: Section, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -24: Symbol { name: "", address: 201000, size: 0, kind: Section, section: Section(SectionIndex(18)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -25: Symbol { name: "", address: 201010, size: 0, kind: Section, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -26: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(1a)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -27: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -28: Symbol { name: "deregister_tm_clones", address: 5a0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -29: Symbol { name: "register_tm_clones", address: 5e0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -30: Symbol { name: "__do_global_dtors_aux", address: 630, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -31: Symbol { name: "completed.7698", address: 201010, size: 1, kind: Data, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -32: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 200db0, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -33: Symbol { name: "frame_dummy", address: 670, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: 2, st_other: 0 } } -34: Symbol { name: "__frame_dummy_init_array_entry", address: 200da8, size: 0, kind: Data, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -35: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -36: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -37: Symbol { name: "__FRAME_END__", address: 874, size: 0, kind: Data, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -38: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: 4, st_other: 0 } } -39: Symbol { name: "__init_array_end", address: 200db0, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -40: Symbol { name: "_DYNAMIC", address: 200db8, size: 0, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -41: Symbol { name: "__init_array_start", address: 200da8, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -42: Symbol { name: "__GNU_EH_FRAME_HDR", address: 734, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: 0, st_other: 0 } } -43: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 200fb8, size: 0, kind: Data, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: 1, st_other: 0 } } -44: Symbol { name: "__libc_csu_fini", address: 710, size: 2, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -45: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -46: Symbol { name: "data_start", address: 201000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -47: Symbol { name: "_edata", address: 201010, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -48: Symbol { name: "_fini", address: 714, size: 0, kind: Text, section: Section(SectionIndex(10)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -49: Symbol { name: "printf@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -50: Symbol { name: "__libc_start_main@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -51: Symbol { name: "__data_start", address: 201000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -52: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -53: Symbol { name: "__dso_handle", address: 201008, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -54: Symbol { name: "_IO_stdin_used", address: 720, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: 11, st_other: 0 } } -55: Symbol { name: "__libc_csu_init", address: 6a0, size: 65, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -56: Symbol { name: "_end", address: 201018, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -57: Symbol { name: "_start", address: 570, size: 2b, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -58: Symbol { name: "__bss_start", address: 201010, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: 10, st_other: 0 } } -59: Symbol { name: "main", address: 67a, size: 1c, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -60: Symbol { name: "__TMC_END__", address: 201010, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: 11, st_other: 2 } } -61: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -62: Symbol { name: "__cxa_finalize@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } -63: Symbol { name: "_init", address: 520, size: 0, kind: Text, section: Section(SectionIndex(c)), scope: Dynamic, weak: false, flags: Elf { st_info: 12, st_other: 0 } } +1: Symbol { name: "", address: 238, size: 0, kind: Section, section: Section(SectionIndex(1)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +2: Symbol { name: "", address: 254, size: 0, kind: Section, section: Section(SectionIndex(2)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +3: Symbol { name: "", address: 274, size: 0, kind: Section, section: Section(SectionIndex(3)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +4: Symbol { name: "", address: 298, size: 0, kind: Section, section: Section(SectionIndex(4)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +5: Symbol { name: "", address: 2c8, size: 0, kind: Section, section: Section(SectionIndex(5)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +6: Symbol { name: "", address: 2e8, size: 0, kind: Section, section: Section(SectionIndex(6)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +7: Symbol { name: "", address: 390, size: 0, kind: Section, section: Section(SectionIndex(7)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +8: Symbol { name: "", address: 414, size: 0, kind: Section, section: Section(SectionIndex(8)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +9: Symbol { name: "", address: 428, size: 0, kind: Section, section: Section(SectionIndex(9)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +10: Symbol { name: "", address: 448, size: 0, kind: Section, section: Section(SectionIndex(a)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +11: Symbol { name: "", address: 508, size: 0, kind: Section, section: Section(SectionIndex(b)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +12: Symbol { name: "", address: 520, size: 0, kind: Section, section: Section(SectionIndex(c)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +13: Symbol { name: "", address: 540, size: 0, kind: Section, section: Section(SectionIndex(d)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +14: Symbol { name: "", address: 560, size: 0, kind: Section, section: Section(SectionIndex(e)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +15: Symbol { name: "", address: 570, size: 0, kind: Section, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +16: Symbol { name: "", address: 714, size: 0, kind: Section, section: Section(SectionIndex(10)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +17: Symbol { name: "", address: 720, size: 0, kind: Section, section: Section(SectionIndex(11)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +18: Symbol { name: "", address: 734, size: 0, kind: Section, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +19: Symbol { name: "", address: 770, size: 0, kind: Section, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +20: Symbol { name: "", address: 200da8, size: 0, kind: Section, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +21: Symbol { name: "", address: 200db0, size: 0, kind: Section, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +22: Symbol { name: "", address: 200db8, size: 0, kind: Section, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +23: Symbol { name: "", address: 200fb8, size: 0, kind: Section, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +24: Symbol { name: "", address: 201000, size: 0, kind: Section, section: Section(SectionIndex(18)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +25: Symbol { name: "", address: 201010, size: 0, kind: Section, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +26: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(1a)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +27: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +28: Symbol { name: "deregister_tm_clones", address: 5a0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +29: Symbol { name: "register_tm_clones", address: 5e0, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +30: Symbol { name: "__do_global_dtors_aux", address: 630, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +31: Symbol { name: "completed.7698", address: 201010, size: 1, kind: Data, section: Section(SectionIndex(19)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +32: Symbol { name: "__do_global_dtors_aux_fini_array_entry", address: 200db0, size: 0, kind: Data, section: Section(SectionIndex(15)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +33: Symbol { name: "frame_dummy", address: 670, size: 0, kind: Text, section: Section(SectionIndex(f)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FUNC, st_other: STV_DEFAULT } } +34: Symbol { name: "__frame_dummy_init_array_entry", address: 200da8, size: 0, kind: Data, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +35: Symbol { name: "base.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +36: Symbol { name: "crtstuff.c", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +37: Symbol { name: "__FRAME_END__", address: 874, size: 0, kind: Data, section: Section(SectionIndex(13)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +38: Symbol { name: "", address: 0, size: 0, kind: File, section: None, scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_FILE, st_other: STV_DEFAULT } } +39: Symbol { name: "__init_array_end", address: 200db0, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +40: Symbol { name: "_DYNAMIC", address: 200db8, size: 0, kind: Data, section: Section(SectionIndex(16)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +41: Symbol { name: "__init_array_start", address: 200da8, size: 0, kind: Unknown, section: Section(SectionIndex(14)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +42: Symbol { name: "__GNU_EH_FRAME_HDR", address: 734, size: 0, kind: Unknown, section: Section(SectionIndex(12)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_NOTYPE, st_other: STV_DEFAULT } } +43: Symbol { name: "_GLOBAL_OFFSET_TABLE_", address: 200fb8, size: 0, kind: Data, section: Section(SectionIndex(17)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_OBJECT, st_other: STV_DEFAULT } } +44: Symbol { name: "__libc_csu_fini", address: 710, size: 2, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +45: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +46: Symbol { name: "data_start", address: 201000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +47: Symbol { name: "_edata", address: 201010, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +48: Symbol { name: "_fini", address: 714, size: 0, kind: Text, section: Section(SectionIndex(10)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +49: Symbol { name: "printf@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +50: Symbol { name: "__libc_start_main@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +51: Symbol { name: "__data_start", address: 201000, size: 0, kind: Unknown, section: Section(SectionIndex(18)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +52: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +53: Symbol { name: "__dso_handle", address: 201008, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +54: Symbol { name: "_IO_stdin_used", address: 720, size: 4, kind: Data, section: Section(SectionIndex(11)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_DEFAULT } } +55: Symbol { name: "__libc_csu_init", address: 6a0, size: 65, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +56: Symbol { name: "_end", address: 201018, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +57: Symbol { name: "_start", address: 570, size: 2b, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +58: Symbol { name: "__bss_start", address: 201010, size: 0, kind: Unknown, section: Section(SectionIndex(19)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_NOTYPE, st_other: STV_DEFAULT } } +59: Symbol { name: "main", address: 67a, size: 1c, kind: Text, section: Section(SectionIndex(f)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +60: Symbol { name: "__TMC_END__", address: 201010, size: 0, kind: Data, section: Section(SectionIndex(18)), scope: Linkage, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_OBJECT, st_other: STV_HIDDEN } } +61: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +62: Symbol { name: "__cxa_finalize@@GLIBC_2.2.5", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } +63: Symbol { name: "_init", address: 520, size: 0, kind: Text, section: Section(SectionIndex(c)), scope: Dynamic, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } Dynamic symbols -1: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -2: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -3: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 12, st_other: 0 } } -4: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -5: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 20, st_other: 0 } } -6: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: 22, st_other: 0 } } +1: Symbol { name: "_ITM_deregisterTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +2: Symbol { name: "printf", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +3: Symbol { name: "__libc_start_main", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: STB_GLOBAL | STT_FUNC, st_other: STV_DEFAULT } } +4: Symbol { name: "__gmon_start__", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +5: Symbol { name: "_ITM_registerTMCloneTable", address: 0, size: 0, kind: Unknown, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_NOTYPE, st_other: STV_DEFAULT } } +6: Symbol { name: "__cxa_finalize", address: 0, size: 0, kind: Text, section: Undefined, scope: Unknown, weak: true, flags: Elf { st_info: STB_WEAK | STT_FUNC, st_other: STV_DEFAULT } } Dynamic relocations (200da8, Relocation { kind: Unknown, encoding: Unknown, size: 0, target: Absolute, addend: 670, implicit_addend: false, flags: Elf { r_type: 8 } }) diff --git a/crates/examples/testfiles/elf/base.readobj b/crates/examples/testfiles/elf/base.readobj index 1fd14efd..9eab9795 100644 --- a/crates/examples/testfiles/elf/base.readobj +++ b/crates/examples/testfiles/elf/base.readobj @@ -165,8 +165,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -836,8 +835,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/examples/testfiles/elf/symtab_shndx.o.objdump-shndx b/crates/examples/testfiles/elf/symtab_shndx.o.objdump-shndx index 84ae5358..3796b853 100644 --- a/crates/examples/testfiles/elf/symtab_shndx.o.objdump-shndx +++ b/crates/examples/testfiles/elf/symtab_shndx.o.objdump-shndx @@ -1,10 +1,10 @@ -65530: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fff9)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65531: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffa)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65532: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffb)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65533: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffc)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65534: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffd)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65535: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffe)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65536: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(ffff)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65537: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(10000)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65538: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(10001)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } -65539: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(10002)), scope: Compilation, weak: false, flags: Elf { st_info: 3, st_other: 0 } } +65530: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fff9)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65531: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffa)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65532: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffb)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65533: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffc)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65534: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffd)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65535: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(fffe)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65536: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(ffff)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65537: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(10000)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65538: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(10001)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } +65539: Symbol { name: "", address: 0, size: 0, kind: Section, section: Section(SectionIndex(10002)), scope: Compilation, weak: false, flags: Elf { st_info: STB_LOCAL | STT_SECTION, st_other: STV_DEFAULT } } diff --git a/crates/rewrite/src/elf.rs b/crates/rewrite/src/elf.rs index bbe7970d..a7c97cd9 100644 --- a/crates/rewrite/src/elf.rs +++ b/crates/rewrite/src/elf.rs @@ -818,7 +818,7 @@ fn find_move_sections( move_sections.push(section.id()); continue; } - if section.sh_type == elf::SHT_NOBITS && section.sh_flags & u64::from(elf::SHF_TLS) != 0 { + if section.sh_type == elf::SHT_NOBITS && section.sh_flags.contains(elf::SHF_TLS) { // Uninitialized TLS sections are not part of the address space. continue; } diff --git a/crates/rewrite/testfiles/elf/base-mold-2.2.add-runpath b/crates/rewrite/testfiles/elf/base-mold-2.2.add-runpath index 875f3683..2b7df902 100644 --- a/crates/rewrite/testfiles/elf/base-mold-2.2.add-runpath +++ b/crates/rewrite/testfiles/elf/base-mold-2.2.add-runpath @@ -181,8 +181,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) - Value: 0x8000000 - DF_1_PIE (0x8000000) + Value: DF_1_PIE (0x8000000) } Dynamic { Tag: DT_DEBUG (0x15) @@ -655,8 +654,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) - Value: 0x8000000 - DF_1_PIE (0x8000000) + Value: DF_1_PIE (0x8000000) } Dynamic { Tag: DT_DEBUG (0x15) diff --git a/crates/rewrite/testfiles/elf/base-relr-i686.noop b/crates/rewrite/testfiles/elf/base-relr-i686.noop index b41b8ea2..647e1b5b 100644 --- a/crates/rewrite/testfiles/elf/base-relr-i686.noop +++ b/crates/rewrite/testfiles/elf/base-relr-i686.noop @@ -181,8 +181,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -874,8 +873,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base-relr-x86_64.noop b/crates/rewrite/testfiles/elf/base-relr-x86_64.noop index 0e1e2847..5ad6634b 100644 --- a/crates/rewrite/testfiles/elf/base-relr-x86_64.noop +++ b/crates/rewrite/testfiles/elf/base-relr-x86_64.noop @@ -181,8 +181,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -239,8 +238,7 @@ ProgramHeader { } Property { Type: GNU_PROPERTY_X86_ISA_1_NEEDED (0xC0008002) - Value: 0x1 - GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) + Value: GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) } } } @@ -355,8 +353,7 @@ SectionHeader { } Property { Type: GNU_PROPERTY_X86_ISA_1_NEEDED (0xC0008002) - Value: 0x1 - GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) + Value: GNU_PROPERTY_X86_ISA_1_BASELINE (0x1) } } } @@ -929,8 +926,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.add-needed b/crates/rewrite/testfiles/elf/base.add-needed index df5ac8dd..f0983450 100644 --- a/crates/rewrite/testfiles/elf/base.add-needed +++ b/crates/rewrite/testfiles/elf/base.add-needed @@ -149,8 +149,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -651,8 +650,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.add-rpath b/crates/rewrite/testfiles/elf/base.add-rpath index 6da43fde..bc1657c5 100644 --- a/crates/rewrite/testfiles/elf/base.add-rpath +++ b/crates/rewrite/testfiles/elf/base.add-rpath @@ -141,8 +141,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -639,8 +638,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.add-runpath b/crates/rewrite/testfiles/elf/base.add-runpath index 8e726874..3ae7c7e1 100644 --- a/crates/rewrite/testfiles/elf/base.add-runpath +++ b/crates/rewrite/testfiles/elf/base.add-runpath @@ -141,8 +141,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -639,8 +638,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.delete-needed b/crates/rewrite/testfiles/elf/base.delete-needed index 843c07ec..64f99ebc 100644 --- a/crates/rewrite/testfiles/elf/base.delete-needed +++ b/crates/rewrite/testfiles/elf/base.delete-needed @@ -137,8 +137,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -617,8 +616,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.delete-section b/crates/rewrite/testfiles/elf/base.delete-section index c1783384..6095ba2d 100644 --- a/crates/rewrite/testfiles/elf/base.delete-section +++ b/crates/rewrite/testfiles/elf/base.delete-section @@ -137,8 +137,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -562,8 +561,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.noop b/crates/rewrite/testfiles/elf/base.noop index 685d2b5e..23ef2713 100644 --- a/crates/rewrite/testfiles/elf/base.noop +++ b/crates/rewrite/testfiles/elf/base.noop @@ -165,8 +165,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -836,8 +835,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.rename-section b/crates/rewrite/testfiles/elf/base.rename-section index da08654d..26f923c9 100644 --- a/crates/rewrite/testfiles/elf/base.rename-section +++ b/crates/rewrite/testfiles/elf/base.rename-section @@ -141,8 +141,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -625,8 +624,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.replace-needed b/crates/rewrite/testfiles/elf/base.replace-needed index 7fa3b300..6a813710 100644 --- a/crates/rewrite/testfiles/elf/base.replace-needed +++ b/crates/rewrite/testfiles/elf/base.replace-needed @@ -141,8 +141,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -635,8 +634,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.set-interpreter b/crates/rewrite/testfiles/elf/base.set-interpreter index 9718ce31..348f7079 100644 --- a/crates/rewrite/testfiles/elf/base.set-interpreter +++ b/crates/rewrite/testfiles/elf/base.set-interpreter @@ -141,8 +141,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -625,8 +624,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/base.set-runpath b/crates/rewrite/testfiles/elf/base.set-runpath index 8e726874..3ae7c7e1 100644 --- a/crates/rewrite/testfiles/elf/base.set-runpath +++ b/crates/rewrite/testfiles/elf/base.set-runpath @@ -141,8 +141,7 @@ ProgramHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) @@ -639,8 +638,7 @@ SectionHeader { } Dynamic { Tag: DT_FLAGS (0x1E) - Value: 0x8 - DF_BIND_NOW (0x8) + Value: DF_BIND_NOW (0x8) } Dynamic { Tag: DT_FLAGS_1 (0x6FFFFFFB) diff --git a/crates/rewrite/testfiles/elf/libbase.so.noop b/crates/rewrite/testfiles/elf/libbase.so.noop index 454c2bf6..40b46388 100644 --- a/crates/rewrite/testfiles/elf/libbase.so.noop +++ b/crates/rewrite/testfiles/elf/libbase.so.noop @@ -506,9 +506,8 @@ SectionHeader { EntrySize: 0x0 VersionDefinition { Version: 1 - Flags: 0x1 - VER_FLG_BASE (0x1) - Index: 1 + Flags: VER_FLG_BASE (0x1) + Index: VER_NDX_GLOBAL (1) AuxCount: 1 Hash: 0x88E6A1F AuxOffset: 40 diff --git a/src/build/elf.rs b/src/build/elf.rs index 693c9737..3fffd244 100644 --- a/src/build/elf.rs +++ b/src/build/elf.rs @@ -314,7 +314,7 @@ impl<'data> Builder<'data> { _ => return Err(Error(format!("Unsupported section type {:x}", other))), }, }; - let sh_flags = section.sh_flags(endian).into(); + let sh_flags = section.sh_flags(endian); let sh_link = section.sh_link(endian); let sh_link_section = if sh_link == 0 { None @@ -328,7 +328,7 @@ impl<'data> Builder<'data> { Some(SectionId(sh_link as usize - 1)) }; let sh_info = section.sh_info(endian); - let sh_info_section = if sh_info == 0 || sh_flags & u64::from(elf::SHF_INFO_LINK) == 0 { + let sh_info_section = if sh_info == 0 || !sh_flags.contains(elf::SHF_INFO_LINK) { None } else { if sh_info as usize >= sections.len() { @@ -339,9 +339,9 @@ impl<'data> Builder<'data> { } Some(SectionId(sh_info as usize - 1)) }; - let sh_flags = section.sh_flags(endian).into(); + let sh_flags = section.sh_flags(endian); let sh_addr = section.sh_addr(endian).into(); - if sh_flags & u64::from(elf::SHF_ALLOC) != 0 { + if sh_flags.contains(elf::SHF_ALLOC) { for segment in &mut builder.segments { if segment.contains_address(sh_addr) { segment.sections.push(id); @@ -408,7 +408,7 @@ impl<'data> Builder<'data> { dynamic_symbols.len(), ) .map(SectionData::DynamicRelocation) - } else if link.0 == 0 || section.sh_flags(endian).into() & u64::from(elf::SHF_ALLOC) != 0 { + } else if link.0 == 0 || section.sh_flags(endian).contains(elf::SHF_ALLOC) { // If there's no link, then none of the relocations may reference symbols. // Assume that these are dynamic relocations, but don't use the dynamic // symbol table when parsing. @@ -566,8 +566,8 @@ impl<'data> Builder<'data> { let mut builder_subsection = AttributesSubsection::new(subsection.vendor().into()); let mut subsubsections = subsection.subsubsections(); while let Some(subsubsection) = subsubsections.next()? { - let tag = match subsubsection.tag() { - elf::Tag_File => AttributeTag::File, + let scope = match subsubsection.tag() { + elf::Tag_File => AttributeScope::File, elf::Tag_Section => { let mut tag_sections = Vec::new(); let mut indices = subsubsection.indices(); @@ -581,7 +581,7 @@ impl<'data> Builder<'data> { } tag_sections.push(SectionId(index - 1)); } - AttributeTag::Section(tag_sections) + AttributeScope::Section(tag_sections) } elf::Tag_Symbol => { let mut tag_symbols = Vec::new(); @@ -596,7 +596,7 @@ impl<'data> Builder<'data> { } tag_symbols.push(SymbolId(index - 1)); } - AttributeTag::Symbol(tag_symbols) + AttributeScope::Symbol(tag_symbols) } tag => { return Err(Error(format!( @@ -608,7 +608,7 @@ impl<'data> Builder<'data> { let data = subsubsection.attributes_data().into(); builder_subsection .subsubsections - .push(AttributesSubsubsection { tag, data }); + .push(AttributesSubsubsection { scope, data }); } builder_attributes.subsections.push(builder_subsection); } @@ -628,8 +628,8 @@ impl<'data> Builder<'data> { { let strings = dynamic_symbols.strings(); let mut ids = HashMap::new(); - ids.insert(0, VersionId::local()); - ids.insert(1, VersionId::global()); + ids.insert(elf::VER_NDX_LOCAL, VersionId::local()); + ids.insert(elf::VER_NDX_GLOBAL, VersionId::global()); if let Some((mut verdefs, link)) = sections.gnu_verdef(endian, data)? { if link != dynamic_symbols.string_section() { @@ -637,9 +637,9 @@ impl<'data> Builder<'data> { } while let Some((verdef, mut verdauxs)) = verdefs.next()? { let flags = verdef.vd_flags.get(endian); - if flags & elf::VER_FLG_BASE != 0 { + if flags.contains(elf::VER_FLG_BASE) { if flags != elf::VER_FLG_BASE - || verdef.vd_ndx.get(endian) != 1 + || verdef.vd_ndx.get(endian) != elf::VER_NDX_GLOBAL || verdef.vd_cnt.get(endian) != 1 { return Err(Error::new("Unsupported VER_FLG_BASE in SHT_GNU_VERDEF")); @@ -654,10 +654,10 @@ impl<'data> Builder<'data> { continue; } - let index = verdef.vd_ndx.get(endian) & elf::VERSYM_VERSION; + let index = verdef.vd_ndx.get(endian); let id = self.versions.next_id(); if ids.insert(index, id).is_some() { - return Err(Error(format!("Duplicate SHT_GNU_VERDEF index {}", index))); + return Err(Error(format!("Duplicate SHT_GNU_VERDEF index {}", index.0))); } let mut names = Vec::new(); @@ -686,10 +686,13 @@ impl<'data> Builder<'data> { name: verneed.file(endian, strings)?.into(), }); while let Some(vernaux) = vernauxs.next()? { - let index = vernaux.vna_other.get(endian) & elf::VERSYM_VERSION; + let index = vernaux.vna_other.get(endian); let id = self.versions.next_id(); if ids.insert(index, id).is_some() { - return Err(Error(format!("Duplicate SHT_GNU_VERNEED index {}", index))); + return Err(Error(format!( + "Duplicate SHT_GNU_VERNEED index {}", + index.0 + ))); } let data = VersionData::Need(VersionNeed { @@ -714,9 +717,9 @@ impl<'data> Builder<'data> { let index = versym.0.get(endian); let symbol = self.dynamic_symbols.get_mut(SymbolId(id)); symbol.version = *ids - .get(&(index & elf::VERSYM_VERSION)) + .get(&index.index()) .ok_or_else(|| Error(format!("Invalid SHT_GNU_VERSYM index {:x}", index)))?; - symbol.version_hidden = index & elf::VERSYM_HIDDEN != 0; + symbol.version_hidden = index.is_hidden(); } } Ok(()) @@ -1043,10 +1046,10 @@ impl<'data> Builder<'data> { for subsection in &attributes.subsections { writer.start_subsection(&subsection.vendor); for subsubsection in &subsection.subsubsections { - writer.start_subsubsection(subsubsection.tag.tag()); - match &subsubsection.tag { - AttributeTag::File => {} - AttributeTag::Section(sections) => { + writer.start_subsubsection(subsubsection.scope.tag()); + match &subsubsection.scope { + AttributeScope::File => {} + AttributeScope::Section(sections) => { for id in sections { if let Some(index) = out_sections_index[id.0] { writer.write_subsubsection_index(index.0); @@ -1054,7 +1057,7 @@ impl<'data> Builder<'data> { } writer.write_subsubsection_index(0); } - AttributeTag::Symbol(symbols) => { + AttributeScope::Symbol(symbols) => { for id in symbols { if let Some(index) = out_syms_index[id.0] { writer.write_subsubsection_index(index.0); @@ -1450,10 +1453,10 @@ impl<'data> Builder<'data> { writer.write_null_gnu_versym(); for out_dynsym in &out_dynsyms { let symbol = self.dynamic_symbols.get(out_dynsym.id); - let mut index = symbol.version.0 as u16; - if symbol.version_hidden { - index |= elf::VERSYM_HIDDEN; - } + let index = elf::VersymIndex::new( + symbol.version.index(), + symbol.version_hidden, + ); writer.write_gnu_versym(index); } } @@ -1463,7 +1466,7 @@ impl<'data> Builder<'data> { let verdef = write::elf::Verdef { version: elf::VER_DEF_CURRENT, flags: elf::VER_FLG_BASE, - index: 1, + index: elf::VER_NDX_GLOBAL, aux_count: 1, name: writer.get_dynamic_string(version_base), }; @@ -1482,7 +1485,7 @@ impl<'data> Builder<'data> { writer.write_gnu_verdef(&write::elf::Verdef { version: elf::VER_DEF_CURRENT, flags: def.flags, - index: version.id.0 as u16, + index: elf::VersionIndex(version.id.0 as u16), aux_count: def.names.len() as u16, name: writer.get_dynamic_string(name), }); @@ -1511,7 +1514,7 @@ impl<'data> Builder<'data> { debug_assert_eq!(*id, version.id); writer.write_gnu_vernaux(&write::elf::Vernaux { flags: need.flags, - index: version.id.0 as u16, + index: elf::VersionIndex(version.id.0 as u16), name: writer.get_dynamic_string(&need.name), }); } @@ -2148,7 +2151,7 @@ pub struct Header { /// The OS ABI field in the file header. /// /// One of the `ELFOSABI*` constants. - pub os_abi: u8, + pub os_abi: elf::OsAbi, /// The ABI version field in the file header. /// /// The meaning of this field depends on the `os_abi` value. @@ -2156,17 +2159,17 @@ pub struct Header { /// The object file type in the file header. /// /// One of the `ET_*` constants. - pub e_type: u16, + pub e_type: elf::FileType, /// The architecture in the file header. /// /// One of the `EM_*` constants. - pub e_machine: u16, + pub e_machine: elf::Machine, /// Entry point virtual address in the file header. pub e_entry: u64, /// The processor-specific flags in the file header. /// /// A combination of the `EF_*` constants. - pub e_flags: u32, + pub e_flags: elf::FileFlags, /// The file offset of the program header table. /// /// Writing will fail if the program header table cannot be placed at this offset. @@ -2206,11 +2209,11 @@ pub struct Segment<'data> { /// The `p_type` field in the ELF program header. /// /// One of the `PT_*` constants. - pub p_type: u32, + pub p_type: elf::ProgramType, /// The `p_flags` field in the ELF program header. /// /// A combination of the `PF_*` constants. - pub p_flags: u32, + pub p_flags: elf::ProgramFlags, /// The `p_offset` field in the ELF program header. /// /// This is the file offset of the data in the segment. This should @@ -2368,8 +2371,8 @@ impl<'data> Segments<'data> { self.push(Segment { id, delete: false, - p_type: 0, - p_flags: 0, + p_type: elf::PT_NULL, + p_flags: elf::ProgramFlags(0), p_offset: 0, p_vaddr: 0, p_paddr: 0, @@ -2393,7 +2396,11 @@ impl<'data> Segments<'data> { /// The file offset and address will be derived from the current maximum for any segment. /// The address will be chosen so that `p_paddr % align == p_offset % align`. /// You may wish to use [`Builder::load_align`] for the alignment. - pub fn add_load_segment(&mut self, flags: u32, align: u64) -> &mut Segment<'data> { + pub fn add_load_segment( + &mut self, + flags: elf::ProgramFlags, + align: u64, + ) -> &mut Segment<'data> { let mut max_offset = 0; let mut max_addr = 0; for segment in &*self { @@ -2484,11 +2491,11 @@ pub struct Section<'data> { /// The `sh_type` field in the ELF section header. /// /// One of the `SHT_*` constants. - pub sh_type: u32, + pub sh_type: elf::SectionType, /// The `sh_flags` field in the ELF section header. /// /// A combination of the `SHF_*` constants. - pub sh_flags: u64, + pub sh_flags: elf::SectionFlags, /// The `sh_addr` field in the ELF section header. pub sh_addr: u64, /// The `sh_offset` field in the ELF section header. @@ -2537,16 +2544,16 @@ impl<'data> Section<'data> { /// Returns true if the section flags include `SHF_ALLOC`. pub fn is_alloc(&self) -> bool { - self.sh_flags & u64::from(elf::SHF_ALLOC) != 0 + self.sh_flags.contains(elf::SHF_ALLOC) } /// Return the segment permission flags that are equivalent to the section flags. - pub fn p_flags(&self) -> u32 { + pub fn p_flags(&self) -> elf::ProgramFlags { let mut p_flags = elf::PF_R; - if self.sh_flags & u64::from(elf::SHF_WRITE) != 0 { + if self.sh_flags.contains(elf::SHF_WRITE) { p_flags |= elf::PF_W; } - if self.sh_flags & u64::from(elf::SHF_EXECINSTR) != 0 { + if self.sh_flags.contains(elf::SHF_EXECINSTR) { p_flags |= elf::PF_X; } p_flags @@ -2608,8 +2615,8 @@ impl<'data> Sections<'data> { id, delete: false, name: ByteString::default(), - sh_type: 0, - sh_flags: 0, + sh_type: elf::SHT_NULL, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: 0, sh_size: 0, @@ -2696,13 +2703,13 @@ pub struct Symbol<'data, const DYNAMIC: bool = false> { /// Used to set the `st_shndx` field in the ELF symbol. pub section: Option, /// The `st_info` field in the ELF symbol. - pub st_info: u8, + pub st_info: elf::SymbolInfo, /// The `st_other` field in the ELF symbol. - pub st_other: u8, + pub st_other: elf::SymbolOther, /// The `st_shndx` field in the ELF symbol. /// /// Only used if `Self::section` is `None`. - pub st_shndx: u16, + pub st_shndx: elf::SymbolSection, /// The `st_value` field in the ELF symbol. pub st_value: u64, /// The `st_size` field in the ELF symbol. @@ -2729,20 +2736,20 @@ impl<'data, const DYNAMIC: bool> Symbol<'data, DYNAMIC> { /// Get the `st_bind` component of the `st_info` field. #[inline] - pub fn st_bind(&self) -> u8 { - self.st_info >> 4 + pub fn st_bind(&self) -> elf::SymbolBind { + self.st_info.st_bind() } /// Get the `st_type` component of the `st_info` field. #[inline] - pub fn st_type(&self) -> u8 { - self.st_info & 0xf + pub fn st_type(&self) -> elf::SymbolType { + self.st_info.st_type() } /// Set the `st_info` field given the `st_bind` and `st_type` components. #[inline] - pub fn set_st_info(&mut self, st_bind: u8, st_type: u8) { - self.st_info = (st_bind << 4) + (st_type & 0xf); + pub fn set_st_info(&mut self, st_bind: elf::SymbolBind, st_type: elf::SymbolType) { + self.st_info = st_bind | st_type; } } @@ -2765,9 +2772,9 @@ impl<'data, const DYNAMIC: bool> Symbols<'data, DYNAMIC> { delete: false, name: ByteString::default(), section: None, - st_info: 0, - st_other: 0, - st_shndx: 0, + st_info: elf::SymbolInfo(0), + st_other: elf::SymbolOther(0), + st_shndx: elf::SHN_UNDEF, st_value: 0, st_size: 0, version: VersionId::local(), @@ -2817,14 +2824,14 @@ pub enum Dynamic<'data> { /// The `d_tag` field in the dynamic entry. /// /// One of the `DT_*` values. - tag: i64, + tag: elf::DynamicTag, }, /// The value is an integer. Integer { /// The `d_tag` field in the dynamic entry. /// /// One of the `DT_*` values. - tag: i64, + tag: elf::DynamicTag, /// The `d_val` field in the dynamic entry. val: u64, }, @@ -2833,7 +2840,7 @@ pub enum Dynamic<'data> { /// The `d_tag` field in the dynamic entry. /// /// One of the `DT_*` values. - tag: i64, + tag: elf::DynamicTag, /// The string value. /// /// This will be stored in the dynamic string section. @@ -2845,7 +2852,7 @@ impl<'data> Dynamic<'data> { /// The `d_tag` field in the dynamic entry. /// /// One of the `DT_*` values. - pub fn tag(&self) -> i64 { + pub fn tag(&self) -> elf::DynamicTag { match self { Dynamic::Auto { tag } => *tag, Dynamic::Integer { tag, .. } => *tag, @@ -2951,12 +2958,17 @@ impl VersionId { /// Return the ID for a version index of [`elf::VER_NDX_LOCAL`]. pub fn local() -> Self { - VersionId(elf::VER_NDX_LOCAL as usize) + VersionId(elf::VER_NDX_LOCAL.0 as usize) } /// Return the ID for a version index of [`elf::VER_NDX_GLOBAL`]. pub fn global() -> Self { - VersionId(elf::VER_NDX_GLOBAL as usize) + VersionId(elf::VER_NDX_GLOBAL.0 as usize) + } + + /// Convert to `elf::VersionIndex`. + pub fn index(self) -> elf::VersionIndex { + elf::VersionIndex(self.0 as u16) } } @@ -3006,7 +3018,7 @@ pub struct VersionDef<'data> { /// The version flags. /// /// A combination of the `VER_FLG_*` constants. - pub flags: u16, + pub flags: elf::VersionFlags, } impl<'data> VersionDef<'data> { @@ -3026,7 +3038,7 @@ pub struct VersionNeed<'data> { /// The version flags. /// /// A combination of the `VER_FLG_*` constants. - pub flags: u16, + pub flags: elf::VersionFlags, } /// A table of versions that are referenced by symbols. @@ -3081,36 +3093,36 @@ impl<'data> AttributesSubsection<'data> { /// A sub-subsection in an attributes section. #[derive(Debug, Clone)] pub struct AttributesSubsubsection<'data> { - /// The sub-subsection tag. - pub tag: AttributeTag, + /// The sub-subsection scope. + pub scope: AttributeScope, /// The data containing the attributes. pub data: Bytes<'data>, } -/// The tag for a sub-subsection in an attributes section. +/// The scope that the attributes in a sub-subsection apply to. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum AttributeTag { +pub enum AttributeScope { /// The attributes apply to the whole file. /// - /// Correspeonds to [`elf::Tag_File`]. + /// Corresponds to [`elf::Tag_File`]. File, /// The attributes apply to the given sections. /// - /// Correspeonds to [`elf::Tag_Section`]. + /// Corresponds to [`elf::Tag_Section`]. Section(Vec), /// The attributes apply to the given symbols. /// - /// Correspeonds to [`elf::Tag_Symbol`]. + /// Corresponds to [`elf::Tag_Symbol`]. Symbol(Vec), } -impl AttributeTag { - /// Return the corresponding `elf::Tag_*` value for this tag. - pub fn tag(&self) -> u8 { +impl AttributeScope { + /// Return the corresponding `elf::Tag_*` value for this scope. + pub fn tag(&self) -> elf::AttributeTag { match self { - AttributeTag::File => elf::Tag_File, - AttributeTag::Section(_) => elf::Tag_Section, - AttributeTag::Symbol(_) => elf::Tag_Symbol, + AttributeScope::File => elf::Tag_File, + AttributeScope::Section(_) => elf::Tag_Section, + AttributeScope::Symbol(_) => elf::Tag_Symbol, } } } diff --git a/src/common.rs b/src/common.rs index ef9a050d..464e18c8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -479,11 +479,11 @@ pub enum FileFlags { #[cfg(feature = "elf")] Elf { /// `os_abi` field in the ELF file header. - os_abi: u8, + os_abi: crate::elf::OsAbi, /// `abi_version` field in the ELF file header. abi_version: u8, /// `e_flags` field in the ELF file header. - e_flags: u32, + e_flags: crate::elf::FileFlags, }, /// Mach-O file flags. #[cfg(feature = "macho")] @@ -515,9 +515,9 @@ pub enum SegmentFlags { #[cfg(feature = "elf")] Elf { /// `p_type` field in the segment header. - p_type: u32, + p_type: crate::elf::ProgramType, /// `p_flags` field in the segment header. - p_flags: u32, + p_flags: crate::elf::ProgramFlags, }, /// Mach-O segment flags. #[cfg(feature = "macho")] @@ -616,9 +616,9 @@ pub enum SectionFlags { #[cfg(feature = "elf")] Elf { /// `sh_type` field in the section header. - sh_type: u32, + sh_type: crate::elf::SectionType, /// `sh_flags` field in the section header. - sh_flags: u64, + sh_flags: crate::elf::SectionFlags, }, /// Mach-O section flags. #[cfg(feature = "macho")] @@ -650,9 +650,9 @@ pub enum SymbolFlags { #[cfg(feature = "elf")] Elf { /// `st_info` field in the ELF symbol. - st_info: u8, + st_info: crate::elf::SymbolInfo, /// `st_other` field in the ELF symbol. - st_other: u8, + st_other: crate::elf::SymbolOther, }, /// Mach-O symbol flags. #[cfg(feature = "macho")] @@ -713,9 +713,9 @@ impl SymbolFlags { /// This corresponds to the lower 2 bits of the `st_other` field, /// and will be a value such as `elf::STV_DEFAULT`. #[cfg(feature = "elf")] - pub fn elf_visibility(&self) -> Option { + pub fn elf_visibility(&self) -> Option { match self { - SymbolFlags::Elf { st_other, .. } => Some(st_other & 0x3), + SymbolFlags::Elf { st_other, .. } => Some(st_other.visibility()), _ => None, } } diff --git a/src/elf.rs b/src/elf.rs index 786008f9..c335413e 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -21,44 +21,44 @@ use crate::pod::Pod; #[non_exhaustive] pub struct Constants { /// Values for `FileHeader*::e_type`. - pub et: &'static ConstantNames, + pub et: &'static ConstantNames, /// Values for `FileHeader*::e_flags`. - pub ef: &'static FlagNames, - /// Special values for section indices. - pub shn: &'static ConstantNames, + pub ef: &'static FlagNames, + /// Special values for `Sym*::st_shndx` and `FileHeader*::e_shstrndx`. + pub shn: &'static ConstantNames, /// Values for `SectionHeader*::sh_type`. - pub sht: &'static ConstantNames, + pub sht: &'static ConstantNames, /// Values for `SectionHeader*::sh_flags`. - pub shf: &'static FlagNames, + pub shf: &'static FlagNames, /// Values for `st_bind` field of `Sym*::st_info`. - pub stb: &'static ConstantNames, + pub stb: &'static ConstantNames, /// Values for `st_type` field of `Sym*::st_info`. - pub stt: &'static ConstantNames, + pub stt: &'static ConstantNames, /// Values for `Sym*::st_other`. - pub sto: &'static FlagNames, + pub sto: &'static FlagNames, /// Values for `ProgramHeader*::p_type`. - pub pt: &'static ConstantNames, + pub pt: &'static ConstantNames, /// Values for `ProgramHeader*::p_flags`. - pub pf: &'static FlagNames, + pub pf: &'static FlagNames, /// Values for `Dyn*::d_tag`. - pub dt: &'static ConstantNames, + pub dt: &'static ConstantNames, /// Values for `r_type` field of `Rel*::r_info`. pub r: &'static ConstantNames, } constants! { struct Base; - consts et: u16 = NAMES_ET; - flags ef: u32 = {}; - consts shn: u16 = NAMES_SHN; - consts sht: u32 = NAMES_SHT; - flags shf: u32 = NAMES_SHF; - consts stb: u8 = NAMES_STB; - consts stt: u8 = NAMES_STT; - flags sto: u8 = NAMES_STO; - consts pt: u32 = NAMES_PT; - flags pf: u32 = NAMES_PF; - consts dt: i64 = NAMES_DT; + consts et: FileType = NAMES_ET; + flags ef: FileFlags(u32) = {}; + consts shn: SymbolSection = NAMES_SHN; + consts sht: SectionType = NAMES_SHT; + flags shf: SectionFlags = NAMES_SHF; + consts stb: SymbolBind = NAMES_STB; + consts stt: SymbolType = NAMES_STT; + flags sto: SymbolFlags = NAMES_STO; + consts pt: ProgramType = NAMES_PT; + flags pf: ProgramFlags = NAMES_PF; + consts dt: DynamicTag = NAMES_DT; consts r: u32 = {}; } @@ -74,7 +74,7 @@ pub const fn constants() -> &'static Constants { /// /// `machine` corresponds to the `FileHeader*::e_machine` field. #[cfg(feature = "names")] -pub const fn machine_constants(machine: u16) -> &'static Constants { +pub const fn machine_constants(machine: Machine) -> &'static Constants { match machine { EM_386 => I386::constants(), EM_68K => M68k::constants(), @@ -123,9 +123,9 @@ pub struct FileHeader32 { /// Magic number and other information. pub e_ident: Ident, /// Object file type. One of the `ET_*` constants. - pub e_type: U16, + pub e_type: U16, /// Architecture. One of the `EM_*` constants. - pub e_machine: U16, + pub e_machine: U16, /// Object file version. Must be `EV_CURRENT`. pub e_version: U32, /// Entry point virtual address. @@ -137,7 +137,7 @@ pub struct FileHeader32 { /// Processor-specific flags. /// /// A combination of the `EF_*` constants. - pub e_flags: U32, + pub e_flags: U32, /// Size in bytes of this header. pub e_ehsize: U16, /// Program header table entry size. @@ -159,7 +159,7 @@ pub struct FileHeader32 { /// /// If the index is greater than or equal to `SHN_LORESERVE` then this field is set to /// `SHN_XINDEX` and the index is stored in the `sh_link` field of section 0. - pub e_shstrndx: U16, + pub e_shstrndx: U16, } /// The header at the start of every 64-bit ELF file. @@ -169,9 +169,9 @@ pub struct FileHeader64 { /// Magic number and other information. pub e_ident: Ident, /// Object file type. One of the `ET_*` constants. - pub e_type: U16, + pub e_type: U16, /// Architecture. One of the `EM_*` constants. - pub e_machine: U16, + pub e_machine: U16, /// Object file version. Must be `EV_CURRENT`. pub e_version: U32, /// Entry point virtual address. @@ -183,7 +183,7 @@ pub struct FileHeader64 { /// Processor-specific flags. /// /// A combination of the `EF_*` constants. - pub e_flags: U32, + pub e_flags: U32, /// Size in bytes of this header. pub e_ehsize: U16, /// Program header table entry size. @@ -205,7 +205,7 @@ pub struct FileHeader64 { /// /// If the index is greater than or equal to `SHN_LORESERVE` then this field is set to /// `SHN_XINDEX` and the index is stored in the `sh_link` field of section 0. - pub e_shstrndx: U16, + pub e_shstrndx: U16, } /// Magic number and other information. @@ -217,13 +217,13 @@ pub struct Ident { /// Magic number. Must be `ELFMAG`. pub magic: [u8; 4], /// File class. One of the `ELFCLASS*` constants. - pub class: u8, + pub class: FileClass, /// Data encoding. One of the `ELFDATA*` constants. - pub data: u8, + pub data: DataEncoding, /// ELF version. Must be `EV_CURRENT`. - pub version: u8, + pub version: FileVersion, /// OS ABI identification. One of the `ELFOSABI*` constants. - pub os_abi: u8, + pub os_abi: OsAbi, /// ABI version. /// /// The meaning of this field depends on the `os_abi` value. @@ -235,74 +235,111 @@ pub struct Ident { /// File identification bytes stored in `Ident::magic`. pub const ELFMAG: [u8; 4] = [0x7f, b'E', b'L', b'F']; -// Values for `Ident::class`. -/// Invalid class. -pub const ELFCLASSNONE: u8 = 0; -/// 32-bit object. -pub const ELFCLASS32: u8 = 1; -/// 64-bit object. -pub const ELFCLASS64: u8 = 2; - -// Values for `Ident::data`. -/// Invalid data encoding. -pub const ELFDATANONE: u8 = 0; -/// 2's complement, little endian. -pub const ELFDATA2LSB: u8 = 1; -/// 2's complement, big endian. -pub const ELFDATA2MSB: u8 = 2; - -// Values for `Ident::os_abi`. -/// UNIX System V ABI. -pub const ELFOSABI_NONE: u8 = 0; -/// UNIX System V ABI. -/// -/// Alias. -pub const ELFOSABI_SYSV: u8 = 0; -/// HP-UX. -pub const ELFOSABI_HPUX: u8 = 1; -/// NetBSD. -pub const ELFOSABI_NETBSD: u8 = 2; -/// Object uses GNU ELF extensions. -pub const ELFOSABI_GNU: u8 = 3; -/// Object uses GNU ELF extensions. -/// -/// Compatibility alias. -pub const ELFOSABI_LINUX: u8 = ELFOSABI_GNU; -/// GNU/Hurd. -pub const ELFOSABI_HURD: u8 = 4; -/// Sun Solaris. -pub const ELFOSABI_SOLARIS: u8 = 6; -/// IBM AIX. -pub const ELFOSABI_AIX: u8 = 7; -/// SGI Irix. -pub const ELFOSABI_IRIX: u8 = 8; -/// FreeBSD. -pub const ELFOSABI_FREEBSD: u8 = 9; -/// Compaq TRU64 UNIX. -pub const ELFOSABI_TRU64: u8 = 10; -/// Novell Modesto. -pub const ELFOSABI_MODESTO: u8 = 11; -/// OpenBSD. -pub const ELFOSABI_OPENBSD: u8 = 12; -/// OpenVMS. -pub const ELFOSABI_OPENVMS: u8 = 13; -/// Hewlett-Packard Non-Stop Kernel. -pub const ELFOSABI_NSK: u8 = 14; -/// AROS -pub const ELFOSABI_AROS: u8 = 15; -/// FenixOS -pub const ELFOSABI_FENIXOS: u8 = 16; -/// Nuxi CloudABI -pub const ELFOSABI_CLOUDABI: u8 = 17; -/// ARM EABI. -pub const ELFOSABI_ARM_AEABI: u8 = 64; -/// ARM. -pub const ELFOSABI_ARM: u8 = 97; -/// Standalone (embedded) application. -pub const ELFOSABI_STANDALONE: u8 = 255; - -// Values for `FileHeader*::e_type`. -constant_names!(NAMES_ET: u16 = { +newtype!( + /// Values for `Ident::class`. + #[repr(transparent)] + struct FileClass(u8); +); + +newtype_constant_names!(NAMES_CLASS: FileClass(u8) = { + /// Invalid class. + ELFCLASSNONE = 0, + /// 32-bit object. + ELFCLASS32 = 1, + /// 64-bit object. + ELFCLASS64 = 2, +}); + +newtype!( + /// Values for `Ident::data`. + #[repr(transparent)] + struct DataEncoding(u8); +); + +newtype_constant_names!(NAMES_DATA: DataEncoding(u8) = { + /// Invalid data encoding. + ELFDATANONE = 0, + /// 2's complement, little endian. + ELFDATA2LSB = 1, + /// 2's complement, big endian. + ELFDATA2MSB = 2, +}); + +newtype!( + /// Values for `Ident::os_abi`. + #[repr(transparent)] + struct OsAbi(u8); +); + +newtype_constant_names!(NAMES_ELFOSABI: OsAbi(u8) = { + /// UNIX System V ABI. + ELFOSABI_SYSV = 0, + /// UNIX System V ABI. + /// + /// Alias. + ELFOSABI_NONE = 0, + /// HP-UX. + ELFOSABI_HPUX = 1, + /// NetBSD. + ELFOSABI_NETBSD = 2, + /// Object uses GNU ELF extensions. + ELFOSABI_GNU = 3, + /// Object uses GNU ELF extensions. + /// + /// Compatibility alias. + ELFOSABI_LINUX = ELFOSABI_GNU.0, + /// GNU/Hurd. + ELFOSABI_HURD = 4, + /// Sun Solaris. + ELFOSABI_SOLARIS = 6, + /// IBM AIX. + ELFOSABI_AIX = 7, + /// SGI Irix. + ELFOSABI_IRIX = 8, + /// FreeBSD. + ELFOSABI_FREEBSD = 9, + /// Compaq TRU64 UNIX. + ELFOSABI_TRU64 = 10, + /// Novell Modesto. + ELFOSABI_MODESTO = 11, + /// OpenBSD. + ELFOSABI_OPENBSD = 12, + /// OpenVMS. + ELFOSABI_OPENVMS = 13, + /// Hewlett-Packard Non-Stop Kernel. + ELFOSABI_NSK = 14, + /// AROS + ELFOSABI_AROS = 15, + /// FenixOS + ELFOSABI_FENIXOS = 16, + /// Nuxi CloudABI + ELFOSABI_CLOUDABI = 17, + /// ARM EABI. + ELFOSABI_ARM_AEABI = 64, + /// ARM. + ELFOSABI_ARM = 97, + /// Standalone (embedded) application. + ELFOSABI_STANDALONE = 255, +}); + +newtype!( + /// Values for `FileHeader*::e_type`. + struct FileType(u16); +); + +impl FileType { + /// Return true if the type is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= ET_LOOS && self.0 <= ET_HIOS + } + /// Return true if the type is in the processor-specific range. + pub fn is_proc(self) -> bool { + debug_assert_eq!(ET_HIPROC, !0); + self.0 >= ET_LOPROC + } +} + +newtype_constant_names!(NAMES_ET: FileType(u16) = { /// No file type. ET_NONE = 0, /// Relocatable file. @@ -324,377 +361,525 @@ pub const ET_LOPROC: u16 = 0xff00; /// Processor-specific range end. pub const ET_HIPROC: u16 = 0xffff; -// Values for `FileHeader*::e_machine`. -/// No machine -pub const EM_NONE: u16 = 0; -/// AT&T WE 32100 -pub const EM_M32: u16 = 1; -/// SUN SPARC -pub const EM_SPARC: u16 = 2; -/// Intel 80386 -pub const EM_386: u16 = 3; -/// Motorola m68k family -pub const EM_68K: u16 = 4; -/// Motorola m88k family -pub const EM_88K: u16 = 5; -/// Intel MCU -pub const EM_IAMCU: u16 = 6; -/// Intel 80860 -pub const EM_860: u16 = 7; -/// MIPS R3000 big-endian -pub const EM_MIPS: u16 = 8; -/// IBM System/370 -pub const EM_S370: u16 = 9; -/// MIPS R3000 little-endian -pub const EM_MIPS_RS3_LE: u16 = 10; -/// HPPA -pub const EM_PARISC: u16 = 15; -/// Fujitsu VPP500 -pub const EM_VPP500: u16 = 17; -/// Sun's "v8plus" -pub const EM_SPARC32PLUS: u16 = 18; -/// Intel 80960 -pub const EM_960: u16 = 19; -/// PowerPC -pub const EM_PPC: u16 = 20; -/// PowerPC 64-bit -pub const EM_PPC64: u16 = 21; -/// IBM S390 -pub const EM_S390: u16 = 22; -/// IBM SPU/SPC -pub const EM_SPU: u16 = 23; -/// NEC V800 series -pub const EM_V800: u16 = 36; -/// Fujitsu FR20 -pub const EM_FR20: u16 = 37; -/// TRW RH-32 -pub const EM_RH32: u16 = 38; -/// Motorola RCE -pub const EM_RCE: u16 = 39; -/// ARM -pub const EM_ARM: u16 = 40; -/// Digital Alpha -pub const EM_FAKE_ALPHA: u16 = 41; -/// Hitachi SH -pub const EM_SH: u16 = 42; -/// SPARC v9 64-bit -pub const EM_SPARCV9: u16 = 43; -/// Siemens Tricore -pub const EM_TRICORE: u16 = 44; -/// Argonaut RISC Core -pub const EM_ARC: u16 = 45; -/// Hitachi H8/300 -pub const EM_H8_300: u16 = 46; -/// Hitachi H8/300H -pub const EM_H8_300H: u16 = 47; -/// Hitachi H8S -pub const EM_H8S: u16 = 48; -/// Hitachi H8/500 -pub const EM_H8_500: u16 = 49; -/// Intel Merced -pub const EM_IA_64: u16 = 50; -/// Stanford MIPS-X -pub const EM_MIPS_X: u16 = 51; -/// Motorola Coldfire -pub const EM_COLDFIRE: u16 = 52; -/// Motorola M68HC12 -pub const EM_68HC12: u16 = 53; -/// Fujitsu MMA Multimedia Accelerator -pub const EM_MMA: u16 = 54; -/// Siemens PCP -pub const EM_PCP: u16 = 55; -/// Sony nCPU embeeded RISC -pub const EM_NCPU: u16 = 56; -/// Denso NDR1 microprocessor -pub const EM_NDR1: u16 = 57; -/// Motorola Start*Core processor -pub const EM_STARCORE: u16 = 58; -/// Toyota ME16 processor -pub const EM_ME16: u16 = 59; -/// STMicroelectronic ST100 processor -pub const EM_ST100: u16 = 60; -/// Advanced Logic Corp. Tinyj emb.fam -pub const EM_TINYJ: u16 = 61; -/// AMD x86-64 architecture -pub const EM_X86_64: u16 = 62; -/// Sony DSP Processor -pub const EM_PDSP: u16 = 63; -/// Digital PDP-10 -pub const EM_PDP10: u16 = 64; -/// Digital PDP-11 -pub const EM_PDP11: u16 = 65; -/// Siemens FX66 microcontroller -pub const EM_FX66: u16 = 66; -/// STMicroelectronics ST9+ 8/16 mc -pub const EM_ST9PLUS: u16 = 67; -/// STmicroelectronics ST7 8 bit mc -pub const EM_ST7: u16 = 68; -/// Motorola MC68HC16 microcontroller -pub const EM_68HC16: u16 = 69; -/// Motorola MC68HC11 microcontroller -pub const EM_68HC11: u16 = 70; -/// Motorola MC68HC08 microcontroller -pub const EM_68HC08: u16 = 71; -/// Motorola MC68HC05 microcontroller -pub const EM_68HC05: u16 = 72; -/// Silicon Graphics SVx -pub const EM_SVX: u16 = 73; -/// STMicroelectronics ST19 8 bit mc -pub const EM_ST19: u16 = 74; -/// Digital VAX -pub const EM_VAX: u16 = 75; -/// Axis Communications 32-bit emb.proc -pub const EM_CRIS: u16 = 76; -/// Infineon Technologies 32-bit emb.proc -pub const EM_JAVELIN: u16 = 77; -/// Element 14 64-bit DSP Processor -pub const EM_FIREPATH: u16 = 78; -/// LSI Logic 16-bit DSP Processor -pub const EM_ZSP: u16 = 79; -/// Donald Knuth's educational 64-bit proc -pub const EM_MMIX: u16 = 80; -/// Harvard University machine-independent object files -pub const EM_HUANY: u16 = 81; -/// SiTera Prism -pub const EM_PRISM: u16 = 82; -/// Atmel AVR 8-bit microcontroller -pub const EM_AVR: u16 = 83; -/// Fujitsu FR30 -pub const EM_FR30: u16 = 84; -/// Mitsubishi D10V -pub const EM_D10V: u16 = 85; -/// Mitsubishi D30V -pub const EM_D30V: u16 = 86; -/// NEC v850 -pub const EM_V850: u16 = 87; -/// Mitsubishi M32R -pub const EM_M32R: u16 = 88; -/// Matsushita MN10300 -pub const EM_MN10300: u16 = 89; -/// Matsushita MN10200 -pub const EM_MN10200: u16 = 90; -/// picoJava -pub const EM_PJ: u16 = 91; -/// OpenRISC 32-bit embedded processor -pub const EM_OPENRISC: u16 = 92; -/// ARC International ARCompact -pub const EM_ARC_COMPACT: u16 = 93; -/// Tensilica Xtensa Architecture -pub const EM_XTENSA: u16 = 94; -/// Alphamosaic VideoCore -pub const EM_VIDEOCORE: u16 = 95; -/// Thompson Multimedia General Purpose Proc -pub const EM_TMM_GPP: u16 = 96; -/// National Semi. 32000 -pub const EM_NS32K: u16 = 97; -/// Tenor Network TPC -pub const EM_TPC: u16 = 98; -/// Trebia SNP 1000 -pub const EM_SNP1K: u16 = 99; -/// STMicroelectronics ST200 -pub const EM_ST200: u16 = 100; -/// Ubicom IP2xxx -pub const EM_IP2K: u16 = 101; -/// MAX processor -pub const EM_MAX: u16 = 102; -/// National Semi. CompactRISC -pub const EM_CR: u16 = 103; -/// Fujitsu F2MC16 -pub const EM_F2MC16: u16 = 104; -/// Texas Instruments msp430 -pub const EM_MSP430: u16 = 105; -/// Analog Devices Blackfin DSP -pub const EM_BLACKFIN: u16 = 106; -/// Seiko Epson S1C33 family -pub const EM_SE_C33: u16 = 107; -/// Sharp embedded microprocessor -pub const EM_SEP: u16 = 108; -/// Arca RISC -pub const EM_ARCA: u16 = 109; -/// PKU-Unity & MPRC Peking Uni. mc series -pub const EM_UNICORE: u16 = 110; -/// eXcess configurable cpu -pub const EM_EXCESS: u16 = 111; -/// Icera Semi. Deep Execution Processor -pub const EM_DXP: u16 = 112; -/// Altera Nios II -pub const EM_ALTERA_NIOS2: u16 = 113; -/// National Semi. CompactRISC CRX -pub const EM_CRX: u16 = 114; -/// Motorola XGATE -pub const EM_XGATE: u16 = 115; -/// Infineon C16x/XC16x -pub const EM_C166: u16 = 116; -/// Renesas M16C -pub const EM_M16C: u16 = 117; -/// Microchip Technology dsPIC30F -pub const EM_DSPIC30F: u16 = 118; -/// Freescale Communication Engine RISC -pub const EM_CE: u16 = 119; -/// Renesas M32C -pub const EM_M32C: u16 = 120; -/// Altium TSK3000 -pub const EM_TSK3000: u16 = 131; -/// Freescale RS08 -pub const EM_RS08: u16 = 132; -/// Analog Devices SHARC family -pub const EM_SHARC: u16 = 133; -/// Cyan Technology eCOG2 -pub const EM_ECOG2: u16 = 134; -/// Sunplus S+core7 RISC -pub const EM_SCORE7: u16 = 135; -/// New Japan Radio (NJR) 24-bit DSP -pub const EM_DSP24: u16 = 136; -/// Broadcom VideoCore III -pub const EM_VIDEOCORE3: u16 = 137; -/// RISC for Lattice FPGA -pub const EM_LATTICEMICO32: u16 = 138; -/// Seiko Epson C17 -pub const EM_SE_C17: u16 = 139; -/// Texas Instruments TMS320C6000 DSP -pub const EM_TI_C6000: u16 = 140; -/// Texas Instruments TMS320C2000 DSP -pub const EM_TI_C2000: u16 = 141; -/// Texas Instruments TMS320C55x DSP -pub const EM_TI_C5500: u16 = 142; -/// Texas Instruments App. Specific RISC -pub const EM_TI_ARP32: u16 = 143; -/// Texas Instruments Prog. Realtime Unit -pub const EM_TI_PRU: u16 = 144; -/// STMicroelectronics 64bit VLIW DSP -pub const EM_MMDSP_PLUS: u16 = 160; -/// Cypress M8C -pub const EM_CYPRESS_M8C: u16 = 161; -/// Renesas R32C -pub const EM_R32C: u16 = 162; -/// NXP Semi. TriMedia -pub const EM_TRIMEDIA: u16 = 163; -/// QUALCOMM Hexagon -pub const EM_HEXAGON: u16 = 164; -/// Intel 8051 and variants -pub const EM_8051: u16 = 165; -/// STMicroelectronics STxP7x -pub const EM_STXP7X: u16 = 166; -/// Andes Tech. compact code emb. RISC -pub const EM_NDS32: u16 = 167; -/// Cyan Technology eCOG1X -pub const EM_ECOG1X: u16 = 168; -/// Dallas Semi. MAXQ30 mc -pub const EM_MAXQ30: u16 = 169; -/// New Japan Radio (NJR) 16-bit DSP -pub const EM_XIMO16: u16 = 170; -/// M2000 Reconfigurable RISC -pub const EM_MANIK: u16 = 171; -/// Cray NV2 vector architecture -pub const EM_CRAYNV2: u16 = 172; -/// Renesas RX -pub const EM_RX: u16 = 173; -/// Imagination Tech. META -pub const EM_METAG: u16 = 174; -/// MCST Elbrus -pub const EM_MCST_ELBRUS: u16 = 175; -/// Cyan Technology eCOG16 -pub const EM_ECOG16: u16 = 176; -/// National Semi. CompactRISC CR16 -pub const EM_CR16: u16 = 177; -/// Freescale Extended Time Processing Unit -pub const EM_ETPU: u16 = 178; -/// Infineon Tech. SLE9X -pub const EM_SLE9X: u16 = 179; -/// Intel L10M -pub const EM_L10M: u16 = 180; -/// Intel K10M -pub const EM_K10M: u16 = 181; -/// ARM AARCH64 -pub const EM_AARCH64: u16 = 183; -/// Amtel 32-bit microprocessor -pub const EM_AVR32: u16 = 185; -/// STMicroelectronics STM8 -pub const EM_STM8: u16 = 186; -/// Tileta TILE64 -pub const EM_TILE64: u16 = 187; -/// Tilera TILEPro -pub const EM_TILEPRO: u16 = 188; -/// Xilinx MicroBlaze -pub const EM_MICROBLAZE: u16 = 189; -/// NVIDIA CUDA -pub const EM_CUDA: u16 = 190; -/// Tilera TILE-Gx -pub const EM_TILEGX: u16 = 191; -/// CloudShield -pub const EM_CLOUDSHIELD: u16 = 192; -/// KIPO-KAIST Core-A 1st gen. -pub const EM_COREA_1ST: u16 = 193; -/// KIPO-KAIST Core-A 2nd gen. -pub const EM_COREA_2ND: u16 = 194; -/// Synopsys ARCompact V2 -pub const EM_ARC_COMPACT2: u16 = 195; -/// Open8 RISC -pub const EM_OPEN8: u16 = 196; -/// Renesas RL78 -pub const EM_RL78: u16 = 197; -/// Broadcom VideoCore V -pub const EM_VIDEOCORE5: u16 = 198; -/// Renesas 78KOR -pub const EM_78KOR: u16 = 199; -/// Freescale 56800EX DSC -pub const EM_56800EX: u16 = 200; -/// Beyond BA1 -pub const EM_BA1: u16 = 201; -/// Beyond BA2 -pub const EM_BA2: u16 = 202; -/// XMOS xCORE -pub const EM_XCORE: u16 = 203; -/// Microchip 8-bit PIC(r) -pub const EM_MCHP_PIC: u16 = 204; -/// KM211 KM32 -pub const EM_KM32: u16 = 210; -/// KM211 KMX32 -pub const EM_KMX32: u16 = 211; -/// KM211 KMX16 -pub const EM_EMX16: u16 = 212; -/// KM211 KMX8 -pub const EM_EMX8: u16 = 213; -/// KM211 KVARC -pub const EM_KVARC: u16 = 214; -/// Paneve CDP -pub const EM_CDP: u16 = 215; -/// Cognitive Smart Memory Processor -pub const EM_COGE: u16 = 216; -/// Bluechip CoolEngine -pub const EM_COOL: u16 = 217; -/// Nanoradio Optimized RISC -pub const EM_NORC: u16 = 218; -/// CSR Kalimba -pub const EM_CSR_KALIMBA: u16 = 219; -/// Zilog Z80 -pub const EM_Z80: u16 = 220; -/// Controls and Data Services VISIUMcore -pub const EM_VISIUM: u16 = 221; -/// FTDI Chip FT32 -pub const EM_FT32: u16 = 222; -/// Moxie processor -pub const EM_MOXIE: u16 = 223; -/// AMD GPU -pub const EM_AMDGPU: u16 = 224; -/// RISC-V -pub const EM_RISCV: u16 = 243; -/// Linux BPF -- in-kernel virtual machine -pub const EM_BPF: u16 = 247; -/// C-SKY -pub const EM_CSKY: u16 = 252; -/// Loongson LoongArch -pub const EM_LOONGARCH: u16 = 258; -/// Solana Binary Format -pub const EM_SBF: u16 = 263; -/// Digital Alpha -pub const EM_ALPHA: u16 = 0x9026; - -// Values for `FileHeader*::e_version` and `Ident::version`. -/// Invalid ELF version. -pub const EV_NONE: u8 = 0; -/// Current ELF version. -pub const EV_CURRENT: u8 = 1; +newtype!( + /// Values for `FileHeader*::e_machine`. + struct Machine(u16); +); + +newtype_constant_names!(NAMES_EM: Machine(u16) = { + /// No machine + EM_NONE = 0, + /// AT&T WE 32100 + EM_M32 = 1, + /// SUN SPARC + EM_SPARC = 2, + /// Intel 80386 + EM_386 = 3, + /// Motorola m68k family + EM_68K = 4, + /// Motorola m88k family + EM_88K = 5, + /// Intel MCU + EM_IAMCU = 6, + /// Intel 80860 + EM_860 = 7, + /// MIPS R3000 big-endian + EM_MIPS = 8, + /// IBM System/370 + EM_S370 = 9, + /// MIPS R3000 little-endian + EM_MIPS_RS3_LE = 10, + /// HPPA + EM_PARISC = 15, + /// Fujitsu VPP500 + EM_VPP500 = 17, + /// Sun's "v8plus" + EM_SPARC32PLUS = 18, + /// Intel 80960 + EM_960 = 19, + /// PowerPC + EM_PPC = 20, + /// PowerPC 64-bit + EM_PPC64 = 21, + /// IBM S390 + EM_S390 = 22, + /// IBM SPU/SPC + EM_SPU = 23, + /// NEC V800 series + EM_V800 = 36, + /// Fujitsu FR20 + EM_FR20 = 37, + /// TRW RH-32 + EM_RH32 = 38, + /// Motorola RCE + EM_RCE = 39, + /// ARM + EM_ARM = 40, + /// Digital Alpha + EM_FAKE_ALPHA = 41, + /// Hitachi SH + EM_SH = 42, + /// SPARC v9 64-bit + EM_SPARCV9 = 43, + /// Siemens Tricore + EM_TRICORE = 44, + /// Argonaut RISC Core + EM_ARC = 45, + /// Hitachi H8/300 + EM_H8_300 = 46, + /// Hitachi H8/300H + EM_H8_300H = 47, + /// Hitachi H8S + EM_H8S = 48, + /// Hitachi H8/500 + EM_H8_500 = 49, + /// Intel Merced + EM_IA_64 = 50, + /// Stanford MIPS-X + EM_MIPS_X = 51, + /// Motorola Coldfire + EM_COLDFIRE = 52, + /// Motorola M68HC12 + EM_68HC12 = 53, + /// Fujitsu MMA Multimedia Accelerator + EM_MMA = 54, + /// Siemens PCP + EM_PCP = 55, + /// Sony nCPU embeeded RISC + EM_NCPU = 56, + /// Denso NDR1 microprocessor + EM_NDR1 = 57, + /// Motorola Start*Core processor + EM_STARCORE = 58, + /// Toyota ME16 processor + EM_ME16 = 59, + /// STMicroelectronic ST100 processor + EM_ST100 = 60, + /// Advanced Logic Corp. Tinyj emb.fam + EM_TINYJ = 61, + /// AMD x86-64 architecture + EM_X86_64 = 62, + /// Sony DSP Processor + EM_PDSP = 63, + /// Digital PDP-10 + EM_PDP10 = 64, + /// Digital PDP-11 + EM_PDP11 = 65, + /// Siemens FX66 microcontroller + EM_FX66 = 66, + /// STMicroelectronics ST9+ 8/16 mc + EM_ST9PLUS = 67, + /// STmicroelectronics ST7 8 bit mc + EM_ST7 = 68, + /// Motorola MC68HC16 microcontroller + EM_68HC16 = 69, + /// Motorola MC68HC11 microcontroller + EM_68HC11 = 70, + /// Motorola MC68HC08 microcontroller + EM_68HC08 = 71, + /// Motorola MC68HC05 microcontroller + EM_68HC05 = 72, + /// Silicon Graphics SVx + EM_SVX = 73, + /// STMicroelectronics ST19 8 bit mc + EM_ST19 = 74, + /// Digital VAX + EM_VAX = 75, + /// Axis Communications 32-bit emb.proc + EM_CRIS = 76, + /// Infineon Technologies 32-bit emb.proc + EM_JAVELIN = 77, + /// Element 14 64-bit DSP Processor + EM_FIREPATH = 78, + /// LSI Logic 16-bit DSP Processor + EM_ZSP = 79, + /// Donald Knuth's educational 64-bit proc + EM_MMIX = 80, + /// Harvard University machine-independent object files + EM_HUANY = 81, + /// SiTera Prism + EM_PRISM = 82, + /// Atmel AVR 8-bit microcontroller + EM_AVR = 83, + /// Fujitsu FR30 + EM_FR30 = 84, + /// Mitsubishi D10V + EM_D10V = 85, + /// Mitsubishi D30V + EM_D30V = 86, + /// NEC v850 + EM_V850 = 87, + /// Mitsubishi M32R + EM_M32R = 88, + /// Matsushita MN10300 + EM_MN10300 = 89, + /// Matsushita MN10200 + EM_MN10200 = 90, + /// picoJava + EM_PJ = 91, + /// OpenRISC 32-bit embedded processor + EM_OPENRISC = 92, + /// ARC International ARCompact + EM_ARC_COMPACT = 93, + /// Tensilica Xtensa Architecture + EM_XTENSA = 94, + /// Alphamosaic VideoCore + EM_VIDEOCORE = 95, + /// Thompson Multimedia General Purpose Proc + EM_TMM_GPP = 96, + /// National Semi. 32000 + EM_NS32K = 97, + /// Tenor Network TPC + EM_TPC = 98, + /// Trebia SNP 1000 + EM_SNP1K = 99, + /// STMicroelectronics ST200 + EM_ST200 = 100, + /// Ubicom IP2xxx + EM_IP2K = 101, + /// MAX processor + EM_MAX = 102, + /// National Semi. CompactRISC + EM_CR = 103, + /// Fujitsu F2MC16 + EM_F2MC16 = 104, + /// Texas Instruments msp430 + EM_MSP430 = 105, + /// Analog Devices Blackfin DSP + EM_BLACKFIN = 106, + /// Seiko Epson S1C33 family + EM_SE_C33 = 107, + /// Sharp embedded microprocessor + EM_SEP = 108, + /// Arca RISC + EM_ARCA = 109, + /// PKU-Unity & MPRC Peking Uni. mc series + EM_UNICORE = 110, + /// eXcess configurable cpu + EM_EXCESS = 111, + /// Icera Semi. Deep Execution Processor + EM_DXP = 112, + /// Altera Nios II + EM_ALTERA_NIOS2 = 113, + /// National Semi. CompactRISC CRX + EM_CRX = 114, + /// Motorola XGATE + EM_XGATE = 115, + /// Infineon C16x/XC16x + EM_C166 = 116, + /// Renesas M16C + EM_M16C = 117, + /// Microchip Technology dsPIC30F + EM_DSPIC30F = 118, + /// Freescale Communication Engine RISC + EM_CE = 119, + /// Renesas M32C + EM_M32C = 120, + /// Altium TSK3000 + EM_TSK3000 = 131, + /// Freescale RS08 + EM_RS08 = 132, + /// Analog Devices SHARC family + EM_SHARC = 133, + /// Cyan Technology eCOG2 + EM_ECOG2 = 134, + /// Sunplus S+core7 RISC + EM_SCORE7 = 135, + /// New Japan Radio (NJR) 24-bit DSP + EM_DSP24 = 136, + /// Broadcom VideoCore III + EM_VIDEOCORE3 = 137, + /// RISC for Lattice FPGA + EM_LATTICEMICO32 = 138, + /// Seiko Epson C17 + EM_SE_C17 = 139, + /// Texas Instruments TMS320C6000 DSP + EM_TI_C6000 = 140, + /// Texas Instruments TMS320C2000 DSP + EM_TI_C2000 = 141, + /// Texas Instruments TMS320C55x DSP + EM_TI_C5500 = 142, + /// Texas Instruments App. Specific RISC + EM_TI_ARP32 = 143, + /// Texas Instruments Prog. Realtime Unit + EM_TI_PRU = 144, + /// STMicroelectronics 64bit VLIW DSP + EM_MMDSP_PLUS = 160, + /// Cypress M8C + EM_CYPRESS_M8C = 161, + /// Renesas R32C + EM_R32C = 162, + /// NXP Semi. TriMedia + EM_TRIMEDIA = 163, + /// QUALCOMM Hexagon + EM_HEXAGON = 164, + /// Intel 8051 and variants + EM_8051 = 165, + /// STMicroelectronics STxP7x + EM_STXP7X = 166, + /// Andes Tech. compact code emb. RISC + EM_NDS32 = 167, + /// Cyan Technology eCOG1X + EM_ECOG1X = 168, + /// Dallas Semi. MAXQ30 mc + EM_MAXQ30 = 169, + /// New Japan Radio (NJR) 16-bit DSP + EM_XIMO16 = 170, + /// M2000 Reconfigurable RISC + EM_MANIK = 171, + /// Cray NV2 vector architecture + EM_CRAYNV2 = 172, + /// Renesas RX + EM_RX = 173, + /// Imagination Tech. META + EM_METAG = 174, + /// MCST Elbrus + EM_MCST_ELBRUS = 175, + /// Cyan Technology eCOG16 + EM_ECOG16 = 176, + /// National Semi. CompactRISC CR16 + EM_CR16 = 177, + /// Freescale Extended Time Processing Unit + EM_ETPU = 178, + /// Infineon Tech. SLE9X + EM_SLE9X = 179, + /// Intel L10M + EM_L10M = 180, + /// Intel K10M + EM_K10M = 181, + /// ARM AARCH64 + EM_AARCH64 = 183, + /// Amtel 32-bit microprocessor + EM_AVR32 = 185, + /// STMicroelectronics STM8 + EM_STM8 = 186, + /// Tileta TILE64 + EM_TILE64 = 187, + /// Tilera TILEPro + EM_TILEPRO = 188, + /// Xilinx MicroBlaze + EM_MICROBLAZE = 189, + /// NVIDIA CUDA + EM_CUDA = 190, + /// Tilera TILE-Gx + EM_TILEGX = 191, + /// CloudShield + EM_CLOUDSHIELD = 192, + /// KIPO-KAIST Core-A 1st gen. + EM_COREA_1ST = 193, + /// KIPO-KAIST Core-A 2nd gen. + EM_COREA_2ND = 194, + /// Synopsys ARCompact V2 + EM_ARC_COMPACT2 = 195, + /// Open8 RISC + EM_OPEN8 = 196, + /// Renesas RL78 + EM_RL78 = 197, + /// Broadcom VideoCore V + EM_VIDEOCORE5 = 198, + /// Renesas 78KOR + EM_78KOR = 199, + /// Freescale 56800EX DSC + EM_56800EX = 200, + /// Beyond BA1 + EM_BA1 = 201, + /// Beyond BA2 + EM_BA2 = 202, + /// XMOS xCORE + EM_XCORE = 203, + /// Microchip 8-bit PIC(r) + EM_MCHP_PIC = 204, + /// KM211 KM32 + EM_KM32 = 210, + /// KM211 KMX32 + EM_KMX32 = 211, + /// KM211 KMX16 + EM_EMX16 = 212, + /// KM211 KMX8 + EM_EMX8 = 213, + /// KM211 KVARC + EM_KVARC = 214, + /// Paneve CDP + EM_CDP = 215, + /// Cognitive Smart Memory Processor + EM_COGE = 216, + /// Bluechip CoolEngine + EM_COOL = 217, + /// Nanoradio Optimized RISC + EM_NORC = 218, + /// CSR Kalimba + EM_CSR_KALIMBA = 219, + /// Zilog Z80 + EM_Z80 = 220, + /// Controls and Data Services VISIUMcore + EM_VISIUM = 221, + /// FTDI Chip FT32 + EM_FT32 = 222, + /// Moxie processor + EM_MOXIE = 223, + /// AMD GPU + EM_AMDGPU = 224, + /// RISC-V + EM_RISCV = 243, + /// Linux BPF -- in-kernel virtual machine + EM_BPF = 247, + /// C-SKY + EM_CSKY = 252, + /// Loongson LoongArch + EM_LOONGARCH = 258, + /// Solana Binary Format + EM_SBF = 263, + /// Digital Alpha + EM_ALPHA = 0x9026, +}); + +newtype!( + /// Values for `FileHeader*::e_version` and `Ident::version`. + #[repr(transparent)] + struct FileVersion(u8); +); + +newtype_constant_names!(NAMES_VERSION: FileVersion(u8) = { + /// Invalid ELF version. + EV_NONE = 0, + /// Current ELF version. + EV_CURRENT = 1, +}); + +newtype!( + /// Values for `FileHeader*::e_flags`. + struct FileFlags(u32); +); + +newtype_flag_names!(NAMES_EF: FileFlags(u32) = {}); + +impl FileFlags { + /// Get the MIPS ABI field. + /// + /// One of the `EF_MIPS_ABI_*` constants. + pub fn mips_abi(self) -> FileFlags { + FileFlags(self.0 & EF_MIPS_ABI) + } + + /// Set the MIPS ABI field. + /// + /// One of the `EF_MIPS_ABI_*` constants. + pub fn with_mips_abi(self, abi: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_MIPS_ABI | abi.0 & EF_MIPS_ABI) + } + + /// Get the MIPS architecture field. + /// + /// One of the `EF_MIPS_ARCH_*` constants. + pub fn mips_arch(self) -> FileFlags { + FileFlags(self.0 & EF_MIPS_ARCH) + } + + /// Set the MIPS architecture field. + /// + /// One of the `EF_MIPS_ARCH_*` constants. + pub fn with_mips_arch(self, arch: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_MIPS_ARCH | arch.0 & EF_MIPS_ARCH) + } + + /// Get the PA-RISC architecture field. + /// + /// One of the `EFA_PARISC_*` constants. + pub fn parisc_arch(self) -> FileFlags { + FileFlags(self.0 & EF_PARISC_ARCH) + } + + /// Set the PA-RISC architecture field. + /// + /// One of the `EFA_PARISC_*` constants. + pub fn with_parisc_arch(self, arch: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_PARISC_ARCH | arch.0 & EF_PARISC_ARCH) + } + + /// Get the PPC64 ABI field. + /// + /// See [`EF_PPC64_ABI`] for values. + pub fn ppc64_abi(self) -> u32 { + self.0 & EF_PPC64_ABI + } + + /// Set the PPC64 ABI field. + /// + /// See [`EF_PPC64_ABI`] for values. + pub fn with_ppc64_abi(self, abi: u32) -> FileFlags { + FileFlags(self.0 & !EF_PPC64_ABI | abi & EF_PPC64_ABI) + } + + /// Get the ARM EABI field. + /// + /// One of the `EF_ARM_EABI_*` values. + pub fn arm_eabi(self) -> FileFlags { + FileFlags(self.0 & EF_ARM_EABIMASK) + } + + /// Set the ARM EABI field. + /// + /// One of the `EF_ARM_EABI_*` values. + pub fn with_arm_eabi(self, eabi: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_ARM_EABIMASK | eabi.0 & EF_ARM_EABIMASK) + } + + /// Get the AVR architecture field. + /// + /// One of the `EF_AVR_ARCH_*` values. + pub fn avr_arch(self) -> FileFlags { + FileFlags(self.0 & EF_AVR_ARCH) + } + + /// Set the AVR architecture field. + /// + /// One of the `EF_AVR_ARCH_*` values. + pub fn with_avr_arch(self, arch: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_AVR_ARCH | arch.0 & EF_AVR_ARCH) + } + + /// Get the SH machine field. + /// + /// One of the `EF_SH*` values. + pub fn sh_mach(self) -> FileFlags { + FileFlags(self.0 & EF_SH_MACH_MASK) + } + + /// Set the SH machine field. + /// + /// One of the `EF_SH*` values. + pub fn with_sh_mach(self, mach: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_SH_MACH_MASK | mach.0 & EF_SH_MACH_MASK) + } + + /// Get the RISC-V float ABI field. + /// + /// One of the `EF_RISCV_FLOAT_ABI_*` values. + pub fn riscv_float_abi(self) -> FileFlags { + FileFlags(self.0 & EF_RISCV_FLOAT_ABI) + } + + /// Set the RISC-V float ABI field. + /// + /// One of the `EF_RISCV_FLOAT_ABI_*` values. + pub fn with_riscv_float_abi(self, float_abi: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_RISCV_FLOAT_ABI | float_abi.0 & EF_RISCV_FLOAT_ABI) + } + + /// Get the LoongArch ABI modifier field. + /// + /// One of the `EF_LARCH_ABI_* ` values. + pub fn larch_abi_modifier(self) -> FileFlags { + FileFlags(self.0 & EF_LARCH_ABI_MODIFIER_MASK) + } + + /// Set the LoongArch ABI modifier field. + /// + /// One of the `EF_LARCH_ABI_* ` values. + pub fn with_larch_abi_modifier(self, modifier: FileFlags) -> FileFlags { + FileFlags(self.0 & !EF_LARCH_ABI_MODIFIER_MASK | modifier.0 & EF_LARCH_ABI_MODIFIER_MASK) + } +} /// Section header. #[derive(Debug, Clone, Copy)] @@ -705,9 +890,9 @@ pub struct SectionHeader32 { /// This is an offset into the section header string table. pub sh_name: U32, /// Section type. One of the `SHT_*` constants. - pub sh_type: U32, + pub sh_type: U32, /// Section flags. A combination of the `SHF_*` constants. - pub sh_flags: U32, + pub sh_flags: U32, /// Section virtual address at execution. pub sh_addr: U32, /// Section file offset. @@ -737,9 +922,9 @@ pub struct SectionHeader64 { /// This is an offset into the section header string table. pub sh_name: U32, /// Section type. One of the `SHT_*` constants. - pub sh_type: U32, + pub sh_type: U32, /// Section flags. A combination of the `SHF_*` constants. - pub sh_flags: U64, + pub sh_flags: U64, /// Section virtual address at execution. pub sh_addr: U64, /// Section file offset. @@ -760,8 +945,59 @@ pub struct SectionHeader64 { pub sh_entsize: U64, } -// Special values for section indices. -constant_names!(NAMES_SHN: u16 = { +newtype!( + /// Section header index. + /// + /// May be a reserved value with special meaning. + /// + /// This is primarily used for `Sym*::st_shndx`. + /// However, `FileHeader*::e_shstrndx` may be set to `SHN_UNDEF`, `SHN_XINDEX`, or an index. + struct SymbolSection(u16); +); + +impl SymbolSection { + /// Construct a `SymbolSection` from a `u32` section index. + /// + /// Returns `SHN_XINDEX` if the index is >= `SHN_LORESERVE`. The caller must write the + /// extended index separately. + pub fn new(index: u32) -> Self { + if index >= u32::from(SHN_LORESERVE) { + SHN_XINDEX + } else { + SymbolSection(index as u16) + } + } + + /// Return the section index, or `None` if this is `SHN_UNDEF` or in the reserved range. + pub fn index(self) -> Option { + if self.is_special() { + None + } else { + Some(self.0) + } + } + + /// Return true if the number is `SHN_UNDEF` or in the reserved range. + pub fn is_special(self) -> bool { + self == SHN_UNDEF || self.is_reserved() + } + + /// Return true if the number is in the reserved range. + pub fn is_reserved(self) -> bool { + debug_assert_eq!(SHN_HIRESERVE, !0); + self.0 >= SHN_LORESERVE + } + /// Return true if the number is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= SHN_LOOS && self.0 <= SHN_HIOS + } + /// Return true if the number is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= SHN_LOPROC && self.0 <= SHN_HIPROC + } +} + +newtype_constant_names!(NAMES_SHN: SymbolSection(u16) = { /// Undefined section. SHN_UNDEF = 0, /// Associated symbol is absolute. @@ -785,8 +1021,31 @@ pub const SHN_HIOS: u16 = 0xff3f; /// End of reserved section indices. pub const SHN_HIRESERVE: u16 = 0xffff; -// Values for `SectionHeader*::sh_type`. -constant_names!(NAMES_SHT: u32 = { +newtype!( + /// Values for `SectionHeader*::sh_type`. + struct SectionType(u32); +); + +impl SectionType { + /// Return true if the type is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= SHT_LOOS && self.0 <= SHT_HIOS + } + /// Return true if the type is in the Sun-specific range. + pub fn is_sun(self) -> bool { + self.0 >= SHT_LOSUNW && self.0 <= SHT_HISUNW + } + /// Return true if the type is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= SHT_LOPROC && self.0 <= SHT_HIPROC + } + /// Return true if the type is in the application-specific range. + pub fn is_user(self) -> bool { + self.0 >= SHT_LOUSER && self.0 <= SHT_HIUSER + } +} + +newtype_constant_names!(NAMES_SHT: SectionType(u32) = { /// Section header table entry is unused. SHT_NULL = 0, /// Program data. @@ -874,8 +1133,24 @@ pub const SHT_LOUSER: u32 = 0x8000_0000; /// End of application-specific section types. pub const SHT_HIUSER: u32 = 0x8fff_ffff; -// Values for `SectionHeader*::sh_flags`. -flag_names!(NAMES_SHF: u32 = { +newtype!( + /// Values for `SectionHeader*::sh_flags`. + struct SectionFlags(u64); +); + +impl SectionFlags { + /// Returns OS-specific flags. + pub fn os_bits(self) -> Self { + SectionFlags(self.0 & SHF_MASKOS) + } + + /// Returns processor-specific flags. + pub fn proc_bits(self) -> Self { + SectionFlags(self.0 & SHF_MASKPROC) + } +} + +newtype_flag_names!(NAMES_SHF: SectionFlags(u64) = { /// Section is writable. SHF_WRITE = 1 << 0, /// Section occupies memory during execution. @@ -909,9 +1184,9 @@ flag_names!(NAMES_SHF: u32 = { }); /// OS-specific section flags. -pub const SHF_MASKOS: u32 = 0x0ff0_0000; +pub const SHF_MASKOS: u64 = 0x0ff0_0000; /// Processor-specific section flags. -pub const SHF_MASKPROC: u32 = 0xf000_0000; +pub const SHF_MASKPROC: u64 = 0xf000_0000; /// Section compression header. /// @@ -923,7 +1198,7 @@ pub const SHF_MASKPROC: u32 = 0xf000_0000; #[repr(C)] pub struct CompressionHeader32 { /// Compression format. One of the `ELFCOMPRESS_*` values. - pub ch_type: U32, + pub ch_type: U32, /// Uncompressed data size. pub ch_size: U32, /// Uncompressed data alignment. @@ -940,7 +1215,7 @@ pub struct CompressionHeader32 { #[repr(C)] pub struct CompressionHeader64 { /// Compression format. One of the `ELFCOMPRESS_*` values. - pub ch_type: U32, + pub ch_type: U32, /// Reserved. pub ch_reserved: U32, /// Uncompressed data size. @@ -949,10 +1224,29 @@ pub struct CompressionHeader64 { pub ch_addralign: U64, } -/// ZLIB/DEFLATE algorithm. -pub const ELFCOMPRESS_ZLIB: u32 = 1; -/// Zstandard algorithm. -pub const ELFCOMPRESS_ZSTD: u32 = 2; +newtype!( + /// Values for `CompressionHeader*::ch_type`. + struct CompressionType(u32); +); + +impl CompressionType { + /// Return true if the type is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= ELFCOMPRESS_LOOS && self.0 <= ELFCOMPRESS_HIOS + } + /// Return true if the type is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= ELFCOMPRESS_LOPROC && self.0 <= ELFCOMPRESS_HIPROC + } +} + +newtype_constant_names!(NAMES_COMPRESS: CompressionType(u32) = { + /// ZLIB/DEFLATE algorithm. + ELFCOMPRESS_ZLIB = 1, + /// Zstandard algorithm. + ELFCOMPRESS_ZSTD = 2, +}); + /// Start of OS-specific compression types. pub const ELFCOMPRESS_LOOS: u32 = 0x6000_0000; /// End of OS-specific compression types. @@ -962,9 +1256,15 @@ pub const ELFCOMPRESS_LOPROC: u32 = 0x7000_0000; /// End of processor-specific compression types. pub const ELFCOMPRESS_HIPROC: u32 = 0x7fff_ffff; -// Values for the flag entry for section groups. -/// Mark group as COMDAT. -pub const GRP_COMDAT: u32 = 1; +newtype!( + /// Values for the flag entry for section groups. + struct GroupFlags(u32); +); + +newtype_flag_names!(NAMES_GRP: GroupFlags(u32) = { + /// Mark group as COMDAT. + GRP_COMDAT = 1, +}); /// Symbol table entry. #[derive(Debug, Default, Clone, Copy)] @@ -981,38 +1281,38 @@ pub struct Sym32 { /// Symbol type and binding. /// /// Use the `st_type` and `st_bind` methods to access this value. - pub st_info: u8, + pub st_info: SymbolInfo, /// Symbol visibility. /// /// Use the `st_visibility` method to access this value. - pub st_other: u8, + pub st_other: SymbolOther, /// Section index or one of the `SHN_*` values. - pub st_shndx: U16, + pub st_shndx: U16, } impl Sym32 { - /// Get the `st_bind` component of the `st_info` field. + /// Get the `st_bind` subfield of the `st_info` field. #[inline] - pub fn st_bind(&self) -> u8 { - self.st_info >> 4 + pub fn st_bind(&self) -> SymbolBind { + self.st_info.st_bind() } - /// Get the `st_type` component of the `st_info` field. + /// Get the `st_type` subfield of the `st_info` field. #[inline] - pub fn st_type(&self) -> u8 { - self.st_info & 0xf + pub fn st_type(&self) -> SymbolType { + self.st_info.st_type() } - /// Set the `st_info` field given the `st_bind` and `st_type` components. + /// Set the `st_info` field given the `st_bind` and `st_type` subfields. #[inline] - pub fn set_st_info(&mut self, st_bind: u8, st_type: u8) { - self.st_info = (st_bind << 4) + (st_type & 0xf); + pub fn set_st_info(&mut self, st_bind: SymbolBind, st_type: SymbolType) { + self.st_info = SymbolInfo::new(st_bind, st_type); } - /// Get the `st_visibility` component of the `st_info` field. + /// Get the `st_visibility` subfield of the `st_other` field. #[inline] - pub fn st_visibility(&self) -> u8 { - self.st_other & 0x3 + pub fn st_visibility(&self) -> SymbolVisibility { + self.st_other.visibility() } } @@ -1027,13 +1327,13 @@ pub struct Sym64 { /// Symbol type and binding. /// /// Use the `st_bind` and `st_type` methods to access this value. - pub st_info: u8, + pub st_info: SymbolInfo, /// Symbol visibility. /// /// Use the `st_visibility` method to access this value. - pub st_other: u8, + pub st_other: SymbolOther, /// Section index or one of the `SHN_*` values. - pub st_shndx: U16, + pub st_shndx: U16, /// Symbol value. pub st_value: U64, /// Symbol size. @@ -1041,28 +1341,28 @@ pub struct Sym64 { } impl Sym64 { - /// Get the `st_bind` component of the `st_info` field. + /// Get the `st_bind` subfield of the `st_info` field. #[inline] - pub fn st_bind(&self) -> u8 { - self.st_info >> 4 + pub fn st_bind(&self) -> SymbolBind { + self.st_info.st_bind() } - /// Get the `st_type` component of the `st_info` field. + /// Get the `st_type` subfield of the `st_info` field. #[inline] - pub fn st_type(&self) -> u8 { - self.st_info & 0xf + pub fn st_type(&self) -> SymbolType { + self.st_info.st_type() } - /// Set the `st_info` field given the `st_bind` and `st_type` components. + /// Set the `st_info` field given the `st_bind` and `st_type` subfields. #[inline] - pub fn set_st_info(&mut self, st_bind: u8, st_type: u8) { - self.st_info = (st_bind << 4) + (st_type & 0xf); + pub fn set_st_info(&mut self, st_bind: SymbolBind, st_type: SymbolType) { + self.st_info = SymbolInfo::new(st_bind, st_type); } - /// Get the `st_visibility` component of the `st_info` field. + /// Get the `st_visibility` subfield of the `st_other` field. #[inline] - pub fn st_visibility(&self) -> u8 { - self.st_other & 0x3 + pub fn st_visibility(&self) -> SymbolVisibility { + self.st_other.visibility() } } @@ -1071,9 +1371,9 @@ impl Sym64 { #[repr(C)] pub struct Syminfo32 { /// Direct bindings, symbol bound to. - pub si_boundto: U16, + pub si_boundto: U16, /// Per symbol flags. - pub si_flags: U16, + pub si_flags: U16, } /// Additional information about a `Sym64`. @@ -1081,36 +1381,130 @@ pub struct Syminfo32 { #[repr(C)] pub struct Syminfo64 { /// Direct bindings, symbol bound to. - pub si_boundto: U16, + pub si_boundto: U16, /// Per symbol flags. - pub si_flags: U16, + pub si_flags: U16, } -// Values for `Syminfo*::si_boundto`. -/// Symbol bound to self -pub const SYMINFO_BT_SELF: u16 = 0xffff; -/// Symbol bound to parent -pub const SYMINFO_BT_PARENT: u16 = 0xfffe; +newtype!( + /// Values for `Syminfo*::si_boundto`. + struct SyminfoBoundto(u16); +); + +impl SyminfoBoundto { + /// Return true if the value is in the reserved range. + pub fn is_reserved(self) -> bool { + self.0 >= SYMINFO_BT_LOWRESERVE + } + + /// Return the symbol index, or `None` if it is a reserved value. + pub fn index(self) -> Option { + if self.is_reserved() { + None + } else { + Some(self.0) + } + } + + /// Values for `Syminfo*::si_boundto` for the first entry. + #[cfg(feature = "names")] + pub fn version_names() -> &'static ConstantNames { + &NAMES_SYMINFO_VERSION + } +} + +newtype_constant_names!(NAMES_SYMINFO_BT: SyminfoBoundto(u16) = { + /// Symbol bound to self + SYMINFO_BT_SELF = 0xffff, + /// Symbol bound to parent + SYMINFO_BT_PARENT = 0xfffe, +}); + /// Beginning of reserved entries pub const SYMINFO_BT_LOWRESERVE: u16 = 0xff00; -// Values for `Syminfo*::si_flags`. -/// Direct bound symbol -pub const SYMINFO_FLG_DIRECT: u16 = 0x0001; -/// Pass-thru symbol for translator -pub const SYMINFO_FLG_PASSTHRU: u16 = 0x0002; -/// Symbol is a copy-reloc -pub const SYMINFO_FLG_COPY: u16 = 0x0004; -/// Symbol bound to object to be lazy loaded -pub const SYMINFO_FLG_LAZYLOAD: u16 = 0x0008; - -// Syminfo version values. -pub const SYMINFO_NONE: u16 = 0; -pub const SYMINFO_CURRENT: u16 = 1; -pub const SYMINFO_NUM: u16 = 2; - -// Values for `st_bind` field of `Sym*::st_info`. -constant_names!(NAMES_STB: u8 = { +newtype!( + /// Values for `Syminfo*::si_flags`. + struct SyminfoFlags(u16); +); + +newtype_flag_names!(NAMES_SYMINFO_FLG: SyminfoFlags(u16) = { + /// Direct bound symbol + SYMINFO_FLG_DIRECT = 0x0001, + /// Pass-thru symbol for translator + SYMINFO_FLG_PASSTHRU = 0x0002, + /// Symbol is a copy-reloc + SYMINFO_FLG_COPY = 0x0004, + /// Symbol bound to object to be lazy loaded + SYMINFO_FLG_LAZYLOAD = 0x0008, +}); + +constant_names!(NAMES_SYMINFO_VERSION: SyminfoBoundto(u16) = { + SYMINFO_NONE = 0, + SYMINFO_CURRENT = 1, + SYMINFO_NUM = 2, +}); + +newtype!( + /// Values for `Sym*::st_info`. + #[repr(transparent)] + struct SymbolInfo(u8); +); + +impl core::fmt::Debug for SymbolInfo { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?} | {:?}", self.st_bind(), self.st_type()) + } +} + +impl SymbolInfo { + /// Construct a value for the `st_info` field given the `st_bind` and `st_type` fields. + pub fn new(st_bind: SymbolBind, st_type: SymbolType) -> Self { + SymbolInfo((st_bind.0 << 4) | (st_type.0 & 0xf)) + } + + /// Get the `st_bind` field. + pub fn st_bind(self) -> SymbolBind { + SymbolBind(self.0 >> 4) + } + + /// Get the `st_type` field. + pub fn st_type(self) -> SymbolType { + SymbolType(self.0 & 0xf) + } +} + +impl core::ops::BitOr for SymbolType { + type Output = SymbolInfo; + fn bitor(self, st_bind: SymbolBind) -> Self::Output { + SymbolInfo::new(st_bind, self) + } +} + +impl core::ops::BitOr for SymbolBind { + type Output = SymbolInfo; + fn bitor(self, st_type: SymbolType) -> Self::Output { + SymbolInfo::new(self, st_type) + } +} + +newtype!( + /// Values for `st_bind` field of `Sym*::st_info`. + struct SymbolBind(u8); +); + +impl SymbolBind { + /// Return true if the binding is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= STB_LOOS && self.0 <= STB_HIOS + } + /// Return true if the binding is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= STB_LOPROC && self.0 <= STB_HIPROC + } +} + +newtype_constant_names!(NAMES_STB: SymbolBind(u8) = { /// Local symbol. STB_LOCAL = 0, /// Global symbol. @@ -1130,8 +1524,23 @@ pub const STB_LOPROC: u8 = 13; /// End of processor-specific symbol binding. pub const STB_HIPROC: u8 = 15; -// Values for `st_type` field of `Sym*::st_info`. -constant_names!(NAMES_STT: u8 = { +newtype!( + /// Values for `st_type` field of `Sym*::st_info`. + struct SymbolType(u8); +); + +impl SymbolType { + /// Return true if the type is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= STT_LOOS && self.0 <= STT_HIOS + } + /// Return true if the type is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= STT_LOPROC && self.0 <= STT_HIPROC + } +} + +newtype_constant_names!(NAMES_STT: SymbolType(u8) = { /// Symbol type is unspecified. STT_NOTYPE = 0, /// Symbol is a data object. @@ -1159,12 +1568,57 @@ pub const STT_LOPROC: u8 = 13; /// End of processor-specific symbol types. pub const STT_HIPROC: u8 = 15; -// Values for `Sym*::st_other`. -flag_names!(NAMES_STO: u8 = { +newtype!( + /// Values for `Sym*::st_other`. + #[repr(transparent)] + struct SymbolOther(u8); +); + +impl SymbolOther { + /// Get the `st_visibility` field. + pub fn visibility(self) -> SymbolVisibility { + SymbolVisibility(self.0 & STV_MASK) + } + + /// Set the `st_visibility` field. + pub fn with_visibility(self, vis: SymbolVisibility) -> Self { + SymbolOther(self.0 & !STV_MASK | vis.0 & STV_MASK) + } + + /// Get the PPC64 `local` field. + pub fn ppc64_local(self) -> u8 { + (self.0 & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT + } + + /// Set the PPC64 `local` field. + pub fn ppc64_with_local(self, local: u8) -> Self { + SymbolOther( + self.0 & !STO_PPC64_LOCAL_MASK | (local << STO_PPC64_LOCAL_BIT) & STO_PPC64_LOCAL_MASK, + ) + } +} + +newtype_flag_names!(NAMES_STO: SymbolOther(u8) = { STV_MASK = 3 => NAMES_STV, }); -constant_names!(NAMES_STV: u8 = { +newtype!( + struct SymbolVisibility(u8); +); + +impl From for SymbolOther { + fn from(value: SymbolVisibility) -> Self { + SymbolOther(value.0 & STV_MASK) + } +} + +impl From for SymbolVisibility { + fn from(value: SymbolOther) -> Self { + value.visibility() + } +} + +newtype_constant_names!(NAMES_STV: SymbolVisibility(u8) = { /// Default symbol visibility rules. STV_DEFAULT = 0, /// Processor specific hidden class. @@ -1186,24 +1640,24 @@ pub struct Rel32 { } impl Rel32 { - /// Get the `r_sym` component of the `r_info` field. + /// Get the `r_sym` subfield of the `r_info` field. #[inline] pub fn r_sym(&self, endian: E) -> u32 { self.r_info.get(endian) >> 8 } - /// Get the `r_type` component of the `r_info` field. + /// Get the `r_type` subfield of the `r_info` field. #[inline] pub fn r_type(&self, endian: E) -> u32 { self.r_info.get(endian) & 0xff } - /// Calculate the `r_info` field given the `r_sym` and `r_type` components. + /// Calculate the `r_info` field given the `r_sym` and `r_type` subfields. pub fn r_info(endian: E, r_sym: u32, r_type: u8) -> U32 { U32::new(endian, (r_sym << 8) | u32::from(r_type)) } - /// Set the `r_info` field given the `r_sym` and `r_type` components. + /// Set the `r_info` field given the `r_sym` and `r_type` subfields. pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u8) { self.r_info = Self::r_info(endian, r_sym, r_type) } @@ -1222,24 +1676,24 @@ pub struct Rela32 { } impl Rela32 { - /// Get the `r_sym` component of the `r_info` field. + /// Get the `r_sym` subfield of the `r_info` field. #[inline] pub fn r_sym(&self, endian: E) -> u32 { self.r_info.get(endian) >> 8 } - /// Get the `r_type` component of the `r_info` field. + /// Get the `r_type` subfield of the `r_info` field. #[inline] pub fn r_type(&self, endian: E) -> u32 { self.r_info.get(endian) & 0xff } - /// Calculate the `r_info` field given the `r_sym` and `r_type` components. + /// Calculate the `r_info` field given the `r_sym` and `r_type` subfields. pub fn r_info(endian: E, r_sym: u32, r_type: u8) -> U32 { U32::new(endian, (r_sym << 8) | u32::from(r_type)) } - /// Set the `r_info` field given the `r_sym` and `r_type` components. + /// Set the `r_info` field given the `r_sym` and `r_type` subfields. pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u8) { self.r_info = Self::r_info(endian, r_sym, r_type) } @@ -1266,24 +1720,24 @@ pub struct Rel64 { } impl Rel64 { - /// Get the `r_sym` component of the `r_info` field. + /// Get the `r_sym` subfield of the `r_info` field. #[inline] pub fn r_sym(&self, endian: E) -> u32 { (self.r_info.get(endian) >> 32) as u32 } - /// Get the `r_type` component of the `r_info` field. + /// Get the `r_type` subfield of the `r_info` field. #[inline] pub fn r_type(&self, endian: E) -> u32 { (self.r_info.get(endian) & 0xffff_ffff) as u32 } - /// Calculate the `r_info` field given the `r_sym` and `r_type` components. + /// Calculate the `r_info` field given the `r_sym` and `r_type` subfields. pub fn r_info(endian: E, r_sym: u32, r_type: u32) -> U64 { U64::new(endian, (u64::from(r_sym) << 32) | u64::from(r_type)) } - /// Set the `r_info` field given the `r_sym` and `r_type` components. + /// Set the `r_info` field given the `r_sym` and `r_type` subfields. pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u32) { self.r_info = Self::r_info(endian, r_sym, r_type) } @@ -1324,19 +1778,19 @@ impl Rela64 { t } - /// Get the `r_sym` component of the `r_info` field. + /// Get the `r_sym` subfield of the `r_info` field. #[inline] pub fn r_sym(&self, endian: E, is_mips64el: bool) -> u32 { (self.get_r_info(endian, is_mips64el) >> 32) as u32 } - /// Get the `r_type` component of the `r_info` field. + /// Get the `r_type` subfield of the `r_info` field. #[inline] pub fn r_type(&self, endian: E, is_mips64el: bool) -> u32 { (self.get_r_info(endian, is_mips64el) & 0xffff_ffff) as u32 } - /// Calculate the `r_info` field given the `r_sym` and `r_type` components. + /// Calculate the `r_info` field given the `r_sym` and `r_type` subfields. pub fn r_info(endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) -> U64 { let mut t = (u64::from(r_sym) << 32) | u64::from(r_type); if is_mips64el { @@ -1349,7 +1803,7 @@ impl Rela64 { U64::new(endian, t) } - /// Set the `r_info` field given the `r_sym` and `r_type` components. + /// Set the `r_info` field given the `r_sym` and `r_type` subfields. pub fn set_r_info(&mut self, endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) { self.r_info = Self::r_info(endian, is_mips64el, r_sym, r_type); } @@ -1370,7 +1824,7 @@ pub struct Relr64(pub U64); #[repr(C)] pub struct ProgramHeader32 { /// Segment type. One of the `PT_*` constants. - pub p_type: U32, + pub p_type: U32, /// Segment file offset. pub p_offset: U32, /// Segment virtual address. @@ -1382,7 +1836,7 @@ pub struct ProgramHeader32 { /// Segment size in memory. pub p_memsz: U32, /// Segment flags. A combination of the `PF_*` constants. - pub p_flags: U32, + pub p_flags: U32, /// Segment alignment. pub p_align: U32, } @@ -1392,9 +1846,9 @@ pub struct ProgramHeader32 { #[repr(C)] pub struct ProgramHeader64 { /// Segment type. One of the `PT_*` constants. - pub p_type: U32, + pub p_type: U32, /// Segment flags. A combination of the `PF_*` constants. - pub p_flags: U32, + pub p_flags: U32, /// Segment file offset. pub p_offset: U64, /// Segment virtual address. @@ -1415,8 +1869,23 @@ pub struct ProgramHeader64 { /// Instead the real value is in the field `sh_info` of section 0. pub const PN_XNUM: u16 = 0xffff; -// Values for `ProgramHeader*::p_type`. -constant_names!(NAMES_PT: u32 = { +newtype!( + /// Values for `ProgramHeader*::p_type`. + struct ProgramType(u32); +); + +impl ProgramType { + /// Return true if the type is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= PT_LOOS && self.0 <= PT_HIOS + } + /// Return true if the type is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= PT_LOPROC && self.0 <= PT_HIPROC + } +} + +newtype_constant_names!(NAMES_PT: ProgramType(u32) = { /// Program header table entry is unused. PT_NULL = 0, /// Loadable program segment. @@ -1454,8 +1923,12 @@ pub const PT_LOPROC: u32 = 0x7000_0000; /// End of processor-specific segment types. pub const PT_HIPROC: u32 = 0x7fff_ffff; -// Values for `ProgramHeader*::p_flags`. -flag_names!(NAMES_PF: u32 = { +newtype!( + /// Values for `ProgramHeader*::p_flags`. + struct ProgramFlags(u32); +); + +newtype_flag_names!(NAMES_PF: ProgramFlags(u32) = { /// Segment is executable. PF_X = 1 << 0, /// Segment is writable. @@ -1619,7 +2092,7 @@ pub const NT_VERSION: u32 = 1; #[repr(C)] pub struct Dyn32 { /// Dynamic entry type. - pub d_tag: I32, + pub d_tag: I32, /// Value (integer or address). pub d_val: U32, } @@ -1629,13 +2102,40 @@ pub struct Dyn32 { #[repr(C)] pub struct Dyn64 { /// Dynamic entry type. - pub d_tag: I64, + pub d_tag: I64, /// Value (integer or address). pub d_val: U64, } -// Values for `Dyn*::d_tag`. -constant_names!(NAMES_DT: i64 = { +newtype!( + /// Values for `Dyn*::d_tag`. + struct DynamicTag(i64); +); + +impl DynamicTag { + /// Return true if the tag is in the range for values. + /// + /// Note that some tags outside of this range are also used for values. + pub fn is_value(self) -> bool { + self.0 >= DT_VALRNGLO && self.0 <= DT_VALRNGHI + } + /// Return true if the tag is in the range for addresses. + /// + /// Note that some tags outside of this range are also used for addresses. + pub fn is_address(self) -> bool { + self.0 >= DT_ADDRRNGLO && self.0 <= DT_ADDRRNGHI + } + /// Return true if the tag is in the OS-specific range. + pub fn is_os(self) -> bool { + self.0 >= DT_LOOS && self.0 <= DT_HIOS + } + /// Return true if the tag is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= DT_LOPROC && self.0 <= DT_HIPROC + } +} + +newtype_constant_names!(NAMES_DT: DynamicTag(i64) = { /// Marks end of dynamic section DT_NULL = 0, /// Name of needed library @@ -1811,78 +2311,142 @@ pub const DT_VALRNGHI: i64 = 0x6fff_fdff; pub const DT_ADDRRNGLO: i64 = 0x6fff_fe00; pub const DT_ADDRRNGHI: i64 = 0x6fff_feff; -// Values of `Dyn*::d_val` in the `DT_FLAGS` entry. -/// Object may use DF_ORIGIN -pub const DF_ORIGIN: u32 = 0x0000_0001; -/// Symbol resolutions starts here -pub const DF_SYMBOLIC: u32 = 0x0000_0002; -/// Object contains text relocations -pub const DF_TEXTREL: u32 = 0x0000_0004; -/// No lazy binding for this object -pub const DF_BIND_NOW: u32 = 0x0000_0008; -/// Module uses the static TLS model -pub const DF_STATIC_TLS: u32 = 0x0000_0010; - -// Values of `Dyn*::d_val` in the `DT_FLAGS_1` entry. -/// Set RTLD_NOW for this object. -pub const DF_1_NOW: u32 = 0x0000_0001; -/// Set RTLD_GLOBAL for this object. -pub const DF_1_GLOBAL: u32 = 0x0000_0002; -/// Set RTLD_GROUP for this object. -pub const DF_1_GROUP: u32 = 0x0000_0004; -/// Set RTLD_NODELETE for this object. -pub const DF_1_NODELETE: u32 = 0x0000_0008; -/// Trigger filtee loading at runtime. -pub const DF_1_LOADFLTR: u32 = 0x0000_0010; -/// Set RTLD_INITFIRST for this object. -pub const DF_1_INITFIRST: u32 = 0x0000_0020; -/// Set RTLD_NOOPEN for this object. -pub const DF_1_NOOPEN: u32 = 0x0000_0040; -/// $ORIGIN must be handled. -pub const DF_1_ORIGIN: u32 = 0x0000_0080; -/// Direct binding enabled. -pub const DF_1_DIRECT: u32 = 0x0000_0100; -pub const DF_1_TRANS: u32 = 0x0000_0200; -/// Object is used to interpose. -pub const DF_1_INTERPOSE: u32 = 0x0000_0400; -/// Ignore default lib search path. -pub const DF_1_NODEFLIB: u32 = 0x0000_0800; -/// Object can't be dldump'ed. -pub const DF_1_NODUMP: u32 = 0x0000_1000; -/// Configuration alternative created. -pub const DF_1_CONFALT: u32 = 0x0000_2000; -/// Filtee terminates filters search. -pub const DF_1_ENDFILTEE: u32 = 0x0000_4000; -/// Disp reloc applied at build time. -pub const DF_1_DISPRELDNE: u32 = 0x0000_8000; -/// Disp reloc applied at run-time. -pub const DF_1_DISPRELPND: u32 = 0x0001_0000; -/// Object has no-direct binding. -pub const DF_1_NODIRECT: u32 = 0x0002_0000; -pub const DF_1_IGNMULDEF: u32 = 0x0004_0000; -pub const DF_1_NOKSYMS: u32 = 0x0008_0000; -pub const DF_1_NOHDR: u32 = 0x0010_0000; -/// Object is modified after built. -pub const DF_1_EDITED: u32 = 0x0020_0000; -pub const DF_1_NORELOC: u32 = 0x0040_0000; -/// Object has individual interposers. -pub const DF_1_SYMINTPOSE: u32 = 0x0080_0000; -/// Global auditing required. -pub const DF_1_GLOBAUDIT: u32 = 0x0100_0000; -/// Singleton symbols are used. -pub const DF_1_SINGLETON: u32 = 0x0200_0000; -pub const DF_1_STUB: u32 = 0x0400_0000; -pub const DF_1_PIE: u32 = 0x0800_0000; +newtype!( + /// Values of `Dyn*::d_val` in the `DT_FLAGS` entry. + struct DynamicFlags(u64); +); + +newtype_flag_names!(NAMES_DF: DynamicFlags(u64) = { + /// Object may use DF_ORIGIN + DF_ORIGIN = 0x0000_0001, + /// Symbol resolutions starts here + DF_SYMBOLIC = 0x0000_0002, + /// Object contains text relocations + DF_TEXTREL = 0x0000_0004, + /// No lazy binding for this object + DF_BIND_NOW = 0x0000_0008, + /// Module uses the static TLS model + DF_STATIC_TLS = 0x0000_0010, +}); + +newtype!( + /// Values of `Dyn*::d_val` in the `DT_FLAGS_1` entry. + struct DynamicFlags1(u64); +); + +newtype_flag_names!(NAMES_DF_1: DynamicFlags1(u64) = { + /// Set RTLD_NOW for this object. + DF_1_NOW = 0x0000_0001, + /// Set RTLD_GLOBAL for this object. + DF_1_GLOBAL = 0x0000_0002, + /// Set RTLD_GROUP for this object. + DF_1_GROUP = 0x0000_0004, + /// Set RTLD_NODELETE for this object. + DF_1_NODELETE = 0x0000_0008, + /// Trigger filtee loading at runtime. + DF_1_LOADFLTR = 0x0000_0010, + /// Set RTLD_INITFIRST for this object. + DF_1_INITFIRST = 0x0000_0020, + /// Set RTLD_NOOPEN for this object. + DF_1_NOOPEN = 0x0000_0040, + /// $ORIGIN must be handled. + DF_1_ORIGIN = 0x0000_0080, + /// Direct binding enabled. + DF_1_DIRECT = 0x0000_0100, + DF_1_TRANS = 0x0000_0200, + /// Object is used to interpose. + DF_1_INTERPOSE = 0x0000_0400, + /// Ignore default lib search path. + DF_1_NODEFLIB = 0x0000_0800, + /// Object can't be dldump'ed. + DF_1_NODUMP = 0x0000_1000, + /// Configuration alternative created. + DF_1_CONFALT = 0x0000_2000, + /// Filtee terminates filters search. + DF_1_ENDFILTEE = 0x0000_4000, + /// Disp reloc applied at build time. + DF_1_DISPRELDNE = 0x0000_8000, + /// Disp reloc applied at run-time. + DF_1_DISPRELPND = 0x0001_0000, + /// Object has no-direct binding. + DF_1_NODIRECT = 0x0002_0000, + DF_1_IGNMULDEF = 0x0004_0000, + DF_1_NOKSYMS = 0x0008_0000, + DF_1_NOHDR = 0x0010_0000, + /// Object is modified after built. + DF_1_EDITED = 0x0020_0000, + DF_1_NORELOC = 0x0040_0000, + /// Object has individual interposers. + DF_1_SYMINTPOSE = 0x0080_0000, + /// Global auditing required. + DF_1_GLOBAUDIT = 0x0100_0000, + /// Singleton symbols are used. + DF_1_SINGLETON = 0x0200_0000, + DF_1_STUB = 0x0400_0000, + DF_1_PIE = 0x0800_0000, +}); /// Version symbol information #[derive(Debug, Clone, Copy)] #[repr(C)] -pub struct Versym(pub U16); +pub struct Versym(pub U16); + +newtype!( + /// Version index for a symbol. + /// + /// This is a `VersionIndex` plus the `VERSYM_HIDDEN` flag. + struct VersymIndex(u16); +); + +impl VersymIndex { + /// Construct a `VersymIndex` from an index and a hidden flag. + pub fn new(index: VersionIndex, hidden: bool) -> Self { + if hidden { + Self(index.0).with(VERSYM_HIDDEN) + } else { + Self(index.0) + } + } + + /// Return the version index. + pub fn index(&self) -> VersionIndex { + VersionIndex(self.0 & VERSYM_VERSION) + } + + /// Return true if it is the local index. + pub fn is_local(&self) -> bool { + self.index() == VER_NDX_LOCAL + } + + /// Return true if it is the global index. + pub fn is_global(&self) -> bool { + self.index() == VER_NDX_GLOBAL + } + + /// Return the hidden flag. + pub fn is_hidden(&self) -> bool { + self.contains(VERSYM_HIDDEN) + } +} + +impl From for VersymIndex { + fn from(value: VersionIndex) -> Self { + VersymIndex(value.0) + } +} + +impl From for VersionIndex { + fn from(value: VersymIndex) -> Self { + value.index() + } +} -/// Symbol is hidden. -pub const VERSYM_HIDDEN: u16 = 0x8000; -/// Symbol version index. -pub const VERSYM_VERSION: u16 = 0x7fff; +newtype_flag_names!(NAMES_VERSYM: VersymIndex(u16) = { + /// Symbol is hidden. + VERSYM_HIDDEN = 0x8000, + /// Symbol version index. + VERSYM_VERSION = 0x7fff => NAMES_VER_NDX, +}); /// Version definition sections #[derive(Debug, Clone, Copy)] @@ -1891,9 +2455,9 @@ pub struct Verdef { /// Version revision pub vd_version: U16, /// Version information - pub vd_flags: U16, + pub vd_flags: U16, /// Version Index - pub vd_ndx: U16, + pub vd_ndx: U16, /// Number of associated aux entries pub vd_cnt: U16, /// Version name hash value @@ -1910,18 +2474,51 @@ pub const VER_DEF_NONE: u16 = 0; /// Current version pub const VER_DEF_CURRENT: u16 = 1; -// Legal values for vd_flags (version information flags). -/// Version definition of file itself -pub const VER_FLG_BASE: u16 = 0x1; -// Legal values for vd_flags and vna_flags (version information flags). -/// Weak version identifier -pub const VER_FLG_WEAK: u16 = 0x2; +newtype!( + /// Legal values for vd_flags and vna_flags (version information flags). + struct VersionFlags(u16); +); + +newtype_flag_names!(NAMES_VER_FLG: VersionFlags(u16) = { + // Legal values for vd_flags (version information flags). + /// Version definition of file itself + VER_FLG_BASE = 0x1, + // Legal values for vd_flags and vna_flags (version information flags). + /// Weak version identifier + VER_FLG_WEAK = 0x2, +}); + +newtype!( + /// Version index. + /// + /// This is the index value stored in [`VersymIndex`], [`Verdef::vd_ndx`] or + /// [`Vernaux::vna_other`]. + struct VersionIndex(u16); +); + +impl VersionIndex { + /// Return true if it is the local index. + pub fn is_local(&self) -> bool { + *self == VER_NDX_LOCAL + } + + /// Return true if it is the global index. + pub fn is_global(&self) -> bool { + *self == VER_NDX_GLOBAL + } + + /// Return true if it is the local or global index. + pub fn is_special(&self) -> bool { + self.0 <= VER_NDX_GLOBAL.0 + } +} -// Versym symbol index values. -/// Symbol is local. -pub const VER_NDX_LOCAL: u16 = 0; -/// Symbol is global. -pub const VER_NDX_GLOBAL: u16 = 1; +newtype_constant_names!(NAMES_VER_NDX: VersionIndex(u16) = { + /// Symbol is local. + VER_NDX_LOCAL = 0, + /// Symbol is global. + VER_NDX_GLOBAL = 1, +}); /// Auxiliary version information. #[derive(Debug, Clone, Copy)] @@ -1962,9 +2559,9 @@ pub struct Vernaux { /// Hash value of dependency name pub vna_hash: U32, /// Dependency specific information - pub vna_flags: U16, + pub vna_flags: U16, /// Version Index - pub vna_other: U16, + pub vna_other: U16, /// Dependency name string offset pub vna_name: U32, /// Offset in bytes to next vernaux entry @@ -2085,12 +2682,104 @@ pub const ELF_NOTE_OS_SOLARIS2: u32 = 2; /// OS descriptor for `NT_GNU_ABI_TAG`. pub const ELF_NOTE_OS_FREEBSD: u32 = 3; -// Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). +newtype!( + /// Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). + struct GnuPropertyType(u32); +); + +impl GnuPropertyType { + /// A 4-byte unsigned integer property: A bit is set if it is set in all + /// relocatable inputs. + pub fn is_uint32_and(self) -> bool { + self.0 >= GNU_PROPERTY_UINT32_AND_LO && self.0 <= GNU_PROPERTY_UINT32_AND_HI + } + /// A 4-byte unsigned integer property: A bit is set if it is set in any + /// relocatable inputs. + pub fn is_uint32_or(self) -> bool { + self.0 >= GNU_PROPERTY_UINT32_OR_LO && self.0 <= GNU_PROPERTY_UINT32_OR_HI + } + /// Return true if the property is in the processor-specific range. + pub fn is_proc(self) -> bool { + self.0 >= GNU_PROPERTY_LOPROC && self.0 <= GNU_PROPERTY_HIPROC + } + /// Return true if the property is in the application-specific range. + pub fn is_user(self) -> bool { + debug_assert_eq!(GNU_PROPERTY_HIUSER, !0); + self.0 >= GNU_PROPERTY_LOUSER + } + /// A 4-byte unsigned integer property: A bit is set if it is set in all + /// relocatable inputs. + pub fn is_x86_uint32_and(self) -> bool { + self.0 >= GNU_PROPERTY_X86_UINT32_AND_LO && self.0 <= GNU_PROPERTY_X86_UINT32_AND_HI + } + /// A 4-byte unsigned integer property: A bit is set if it is set in any + /// relocatable inputs. + pub fn is_x86_uint32_or(self) -> bool { + self.0 >= GNU_PROPERTY_X86_UINT32_OR_LO && self.0 <= GNU_PROPERTY_X86_UINT32_OR_HI + } + /// A 4-byte unsigned integer property: A bit is set if it is set in any + /// relocatable inputs and the property is present in all relocatable + /// inputs. + pub fn is_x86_uint32_or_and(self) -> bool { + self.0 >= GNU_PROPERTY_X86_UINT32_OR_AND_LO && self.0 <= GNU_PROPERTY_X86_UINT32_OR_AND_HI + } + + /// Return the property type names for the given machine. + #[cfg(feature = "names")] + pub fn type_names(machine: Machine) -> &'static ConstantNames { + match machine { + EM_386 | EM_X86_64 => &NAMES_GNU_PROPERTY_X86, + EM_AARCH64 => &NAMES_GNU_PROPERTY_AARCH64, + _ => &NAMES_GNU_PROPERTY, + } + } + + /// Return the property values names for the given machine if the property + /// data is a u32. + #[cfg(feature = "names")] + pub fn u32_value_names(self, machine: Machine) -> Option<&'static FlagNames> { + match self { + GNU_PROPERTY_1_NEEDED => { + return Some(&NAMES_GNU_PROPERTY_1_NEEDED); + } + _ => {} + } + match machine { + EM_386 | EM_X86_64 => match self { + GNU_PROPERTY_X86_ISA_1_USED | GNU_PROPERTY_X86_ISA_1_NEEDED => { + return Some(&NAMES_GNU_PROPERTY_X86_ISA_1); + } + GNU_PROPERTY_X86_FEATURE_1_AND => { + return Some(&NAMES_GNU_PROPERTY_X86_FEATURE_1); + } + _ => {} + }, + EM_AARCH64 => match self { + GNU_PROPERTY_AARCH64_FEATURE_1_AND => { + return Some(&NAMES_GNU_PROPERTY_AARCH64_FEATURE_1); + } + _ => {} + }, + _ => {} + } + None + } +} + +newtype_constant_names!(NAMES_GNU_PROPERTY: GnuPropertyType(u32) = { + /// Stack size. + GNU_PROPERTY_STACK_SIZE = 1, + /// No copy relocation on protected data symbol. + GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2, + /// The needed properties by the object file. */ + GNU_PROPERTY_1_NEEDED = GNU_PROPERTY_UINT32_OR_LO, +}); -/// Stack size. -pub const GNU_PROPERTY_STACK_SIZE: u32 = 1; -/// No copy relocation on protected data symbol. -pub const GNU_PROPERTY_NO_COPY_ON_PROTECTED: u32 = 2; +flag_names!(NAMES_GNU_PROPERTY_1_NEEDED: u32 = { + /// Set if the object file requires canonical function pointers and + /// cannot be used with copy relocation. + GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS = 1 << 0, +}); // A 4-byte unsigned integer property: A bit is set if it is set in all // relocatable inputs. @@ -2102,13 +2791,6 @@ pub const GNU_PROPERTY_UINT32_AND_HI: u32 = 0xb0007fff; pub const GNU_PROPERTY_UINT32_OR_LO: u32 = 0xb0008000; pub const GNU_PROPERTY_UINT32_OR_HI: u32 = 0xb000ffff; -/// The needed properties by the object file. */ -pub const GNU_PROPERTY_1_NEEDED: u32 = GNU_PROPERTY_UINT32_OR_LO; - -/// Set if the object file requires canonical function pointers and -/// cannot be used with copy relocation. -pub const GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS: u32 = 1 << 0; - /// Processor-specific semantics, lo pub const GNU_PROPERTY_LOPROC: u32 = 0xc0000000; /// Processor-specific semantics, hi @@ -2118,12 +2800,15 @@ pub const GNU_PROPERTY_LOUSER: u32 = 0xe0000000; /// Application-specific semantics, hi pub const GNU_PROPERTY_HIUSER: u32 = 0xffffffff; -/// AArch64 specific GNU properties. -pub const GNU_PROPERTY_AARCH64_FEATURE_1_AND: u32 = 0xc0000000; -pub const GNU_PROPERTY_AARCH64_FEATURE_PAUTH: u32 = 0xc0000001; +constant_names!(NAMES_GNU_PROPERTY_AARCH64: GnuPropertyType(u32) = NAMES_GNU_PROPERTY + { + GNU_PROPERTY_AARCH64_FEATURE_1_AND = 0xc0000000, + GNU_PROPERTY_AARCH64_FEATURE_PAUTH = 0xc0000001, +}); -pub const GNU_PROPERTY_AARCH64_FEATURE_1_BTI: u32 = 1 << 0; -pub const GNU_PROPERTY_AARCH64_FEATURE_1_PAC: u32 = 1 << 1; +flag_names!(NAMES_GNU_PROPERTY_AARCH64_FEATURE_1: u32 = { + GNU_PROPERTY_AARCH64_FEATURE_1_BTI = 1 << 0, + GNU_PROPERTY_AARCH64_FEATURE_1_PAC = 1 << 1, +}); // A 4-byte unsigned integer property: A bit is set if it is set in all // relocatable inputs. @@ -2141,33 +2826,39 @@ pub const GNU_PROPERTY_X86_UINT32_OR_HI: u32 = 0xc000ffff; pub const GNU_PROPERTY_X86_UINT32_OR_AND_LO: u32 = 0xc0010000; pub const GNU_PROPERTY_X86_UINT32_OR_AND_HI: u32 = 0xc0017fff; -/// The x86 instruction sets indicated by the corresponding bits are -/// used in program. Their support in the hardware is optional. -pub const GNU_PROPERTY_X86_ISA_1_USED: u32 = 0xc0010002; -/// The x86 instruction sets indicated by the corresponding bits are -/// used in program and they must be supported by the hardware. -pub const GNU_PROPERTY_X86_ISA_1_NEEDED: u32 = 0xc0008002; -/// X86 processor-specific features used in program. -pub const GNU_PROPERTY_X86_FEATURE_1_AND: u32 = 0xc0000002; - -/// GNU_PROPERTY_X86_ISA_1_BASELINE: CMOV, CX8 (cmpxchg8b), FPU (fld), -/// MMX, OSFXSR (fxsave), SCE (syscall), SSE and SSE2. -pub const GNU_PROPERTY_X86_ISA_1_BASELINE: u32 = 1 << 0; -/// GNU_PROPERTY_X86_ISA_1_V2: GNU_PROPERTY_X86_ISA_1_BASELINE, -/// CMPXCHG16B (cmpxchg16b), LAHF-SAHF (lahf), POPCNT (popcnt), SSE3, -/// SSSE3, SSE4.1 and SSE4.2. -pub const GNU_PROPERTY_X86_ISA_1_V2: u32 = 1 << 1; -/// GNU_PROPERTY_X86_ISA_1_V3: GNU_PROPERTY_X86_ISA_1_V2, AVX, AVX2, BMI1, -/// BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE. -pub const GNU_PROPERTY_X86_ISA_1_V3: u32 = 1 << 2; -/// GNU_PROPERTY_X86_ISA_1_V4: GNU_PROPERTY_X86_ISA_1_V3, AVX512F, -/// AVX512BW, AVX512CD, AVX512DQ and AVX512VL. -pub const GNU_PROPERTY_X86_ISA_1_V4: u32 = 1 << 3; - -/// This indicates that all executable sections are compatible with IBT. -pub const GNU_PROPERTY_X86_FEATURE_1_IBT: u32 = 1 << 0; -/// This indicates that all executable sections are compatible with SHSTK. -pub const GNU_PROPERTY_X86_FEATURE_1_SHSTK: u32 = 1 << 1; +constant_names!(NAMES_GNU_PROPERTY_X86: GnuPropertyType(u32) = NAMES_GNU_PROPERTY + { + /// The x86 instruction sets indicated by the corresponding bits are + /// used in program. Their support in the hardware is optional. + GNU_PROPERTY_X86_ISA_1_USED = 0xc0010002, + /// The x86 instruction sets indicated by the corresponding bits are + /// used in program and they must be supported by the hardware. + GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0008002, + /// X86 processor-specific features used in program. + GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002, +}); + +flag_names!(NAMES_GNU_PROPERTY_X86_ISA_1: u32 = { + /// GNU_PROPERTY_X86_ISA_1_BASELINE: CMOV, CX8 (cmpxchg8b), FPU (fld), + /// MMX, OSFXSR (fxsave), SCE (syscall), SSE and SSE2. + GNU_PROPERTY_X86_ISA_1_BASELINE = 1 << 0, + /// GNU_PROPERTY_X86_ISA_1_V2: GNU_PROPERTY_X86_ISA_1_BASELINE, + /// CMPXCHG16B (cmpxchg16b), LAHF-SAHF (lahf), POPCNT (popcnt), SSE3, + /// SSSE3, SSE4.1 and SSE4.2. + GNU_PROPERTY_X86_ISA_1_V2 = 1 << 1, + /// GNU_PROPERTY_X86_ISA_1_V3: GNU_PROPERTY_X86_ISA_1_V2, AVX, AVX2, BMI1, + /// BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE. + GNU_PROPERTY_X86_ISA_1_V3 = 1 << 2, + /// GNU_PROPERTY_X86_ISA_1_V4: GNU_PROPERTY_X86_ISA_1_V3, AVX512F, + /// AVX512BW, AVX512CD, AVX512DQ and AVX512VL. + GNU_PROPERTY_X86_ISA_1_V4 = 1 << 3, +}); + +flag_names!(NAMES_GNU_PROPERTY_X86_FEATURE_1: u32 = { + /// This indicates that all executable sections are compatible with IBT. + GNU_PROPERTY_X86_FEATURE_1_IBT = 1 << 0, + /// This indicates that all executable sections are compatible with SHSTK. + GNU_PROPERTY_X86_FEATURE_1_SHSTK = 1 << 1, +}); // Note types for `ELF_NOTE_GO`. constant_names!(NAMES_NT_GO: u32 = { @@ -2525,7 +3216,7 @@ constants! { R_SHARC_CALC_PUSH_LEN = 0xec, R_SHARC_CALC_NOT = 0xf6, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// .adi.attributes SHT_SHARC_ADI_ATTRIBUTES = SHT_LOPROC + 0x2, }; @@ -2535,11 +3226,11 @@ constants! { constants! { struct Sparc(Base); - consts stt: u8 = { + consts stt: SymbolType(u8) = { /// Global register reserved to app. STT_SPARC_REGISTER = 13, }; - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// little endian data EF_SPARC_LEDATA = 0x80_0000, /// generic V8+ features @@ -2704,7 +3395,7 @@ constants! { R_SPARC_GNU_VTENTRY = 251, R_SPARC_REV32 = 252, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_SPARC_REGISTER = 0x7000_0001, }; } @@ -2713,12 +3404,12 @@ pub const EF_SPARC_EXT_MASK: u32 = 0xFF_FF00; constants! { struct SparcV9(Sparc); - flags ef: u32 = { + flags ef: FileFlags(u32) = { EF_SPARCV9_MM = 3 => NAMES_EF_SPARC_MM, }; } -constant_names!(NAMES_EF_SPARC_MM: u32 = { +constant_names!(NAMES_EF_SPARC_MM: FileFlags(u32) = { EF_SPARCV9_TSO = 0, EF_SPARCV9_PSO = 1, EF_SPARCV9_RMO = 2, @@ -2728,7 +3419,7 @@ constant_names!(NAMES_EF_SPARC_MM: u32 = { constants! { struct Mips(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// A .noreorder directive was used. EF_MIPS_NOREORDER = 1, /// Contains PIC code. @@ -2748,7 +3439,7 @@ constants! { /// MIPS architecture level. EF_MIPS_ARCH = 0xf000_0000 => NAMES_EF_MIPS_ARCH, }; - consts shn: u16 = { + consts shn: SymbolSection(u16) = { /// Allocated common symbols. SHN_MIPS_ACOMMON = 0xff00, /// Allocated test symbols. @@ -2760,7 +3451,7 @@ constants! { /// Small undefined symbols. SHN_MIPS_SUNDEFINED = 0xff04, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// Shared objects used in link. SHT_MIPS_LIBLIST = 0x7000_0000, SHT_MIPS_MSYM = 0x7000_0001, @@ -2810,7 +3501,7 @@ constants! { SHT_MIPS_XLATE_OLD = 0x7000_0028, SHT_MIPS_PDR_EXCEPTION = 0x7000_0029, }; - flags shf: u32 = { + flags shf: SectionFlags(u64) = { /// Must be in global data area. SHF_MIPS_GPREL = 0x1000_0000, SHF_MIPS_MERGE = 0x2000_0000, @@ -2821,10 +3512,10 @@ constants! { SHF_MIPS_NAMES = 0x0200_0000, SHF_MIPS_NODUPE = 0x0100_0000, }; - flags sto: u8 = { + flags sto: SymbolOther(u8) = { STO_MIPS_PLT = 0x8, }; - consts stb: u8 = { + consts stb: SymbolBind(u8) = { STB_MIPS_SPLIT_COMMON = 13, }; consts r: u32 = { @@ -2907,7 +3598,7 @@ constants! { R_MIPS_COPY = 126, R_MIPS_JUMP_SLOT = 127, }; - consts pt: u32 = { + consts pt: ProgramType(u32) = { /// Register usage information. PT_MIPS_REGINFO = 0x7000_0000, /// Runtime procedure table. @@ -2916,10 +3607,10 @@ constants! { /// FP mode requirement. PT_MIPS_ABIFLAGS = 0x7000_0003, }; - flags pf: u32 = { + flags pf: ProgramFlags(u32) = { PF_MIPS_LOCAL = 0x1000_0000, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { /// Runtime linker interface version DT_MIPS_RLD_VERSION = 0x7000_0001, /// Timestamp @@ -3007,7 +3698,7 @@ constants! { }; } -constant_names!(NAMES_EF_MIPS_ABI: u32 = { +constant_names!(NAMES_EF_MIPS_ABI: FileFlags(u32) = { /// The first MIPS 32 bit ABI EF_MIPS_ABI_O32 = 0x0000_1000, /// O32 ABI extended for 64-bit architectures @@ -3018,7 +3709,7 @@ constant_names!(NAMES_EF_MIPS_ABI: u32 = { EF_MIPS_ABI_EABI64 = 0x0000_4000, }); -constant_names!(NAMES_EF_MIPS_ARCH: u32 = { +constant_names!(NAMES_EF_MIPS_ARCH: FileFlags(u32) = { /// -mips1 code. EF_MIPS_ARCH_1 = 0x0000_0000, /// -mips2 code. @@ -3163,7 +3854,7 @@ pub const LL_DELTA: u32 = 1 << 5; constants! { struct Parisc(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// Trap nil pointer dereference. EF_PARISC_TRAPNIL = 0x0001_0000, /// Program uses arch. extensions. @@ -3179,13 +3870,13 @@ constants! { /// Architecture version. EF_PARISC_ARCH = 0x0000_ffff => NAMES_EFA_PARISC, }; - consts shn: u16 = { + consts shn: SymbolSection(u16) = { /// Section for tentatively declared symbols in ANSI C. SHN_PARISC_ANSI_COMMON = 0xff00, /// Common blocks in huge model. SHN_PARISC_HUGE_COMMON = 0xff01, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// Contains product specific ext. SHT_PARISC_EXT = 0x7000_0000, /// Unwind information. @@ -3193,7 +3884,7 @@ constants! { /// Debug info for optimized code. SHT_PARISC_DOC = 0x7000_0002, }; - flags shf: u32 = { + flags shf: SectionFlags(u64) = { /// Section with short addressing. SHF_PARISC_SHORT = 0x2000_0000, /// Section far from gp. @@ -3201,7 +3892,7 @@ constants! { /// Static branch prediction code. SHF_PARISC_SBP = 0x8000_0000, }; - consts stt: u8 = { + consts stt: SymbolType(u8) = { /// Millicode function entry point. STT_PARISC_MILLICODE = 13, STT_HP_OPAQUE = STT_LOOS + 0x1, @@ -3419,7 +4110,7 @@ constants! { R_PARISC_TLS_TPREL64 = R_PARISC_TPREL64, R_PARISC_HIRESERVE = 255, }; - consts pt: u32 = { + consts pt: ProgramType(u32) = { PT_HP_TLS = PT_LOOS + 0x0, PT_HP_CORE_NONE = PT_LOOS + 0x1, PT_HP_CORE_VERSION = PT_LOOS + 0x2, @@ -3439,7 +4130,7 @@ constants! { PT_PARISC_ARCHEXT = 0x7000_0000, PT_PARISC_UNWIND = 0x7000_0001, }; - flags pf: u32 = { + flags pf: ProgramFlags(u32) = { PF_PARISC_SBP = 0x0800_0000, PF_HP_PAGE_SIZE = 0x0010_0000, @@ -3452,7 +4143,7 @@ constants! { }; } -constant_names!(NAMES_EFA_PARISC: u32 = { +constant_names!(NAMES_EFA_PARISC: FileFlags(u32) = { /// PA-RISC 1.0 big-endian. EFA_PARISC_1_0 = 0x020b, /// PA-RISC 1.1 big-endian. @@ -3465,21 +4156,21 @@ constant_names!(NAMES_EFA_PARISC: u32 = { constants! { struct Alpha(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// All addresses must be < 2GB. EF_ALPHA_32BIT = 1, /// Relocations for relaxing exist. EF_ALPHA_CANRELAX = 2, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { // These two are primarily concerned with ECOFF debugging info. SHT_ALPHA_DEBUG = 0x7000_0001, SHT_ALPHA_REGINFO = 0x7000_0002, }; - flags shf: u32 = { + flags shf: SectionFlags(u64) = { SHF_ALPHA_GPREL = 0x1000_0000, }; - flags sto: u8 = { + flags sto: SymbolOther(u8) = { /// No PV required. STO_ALPHA_NOPV = 0x80, /// PV only used for initial ldgp. @@ -3539,7 +4230,7 @@ constants! { R_ALPHA_TPRELLO = 40, R_ALPHA_TPREL16 = 41, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_ALPHA_PLTRO = DT_LOPROC + 0, }; } @@ -3556,7 +4247,7 @@ pub const LITUSE_ALPHA_TLS_LDM: u32 = 5; constants! { struct Ppc(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// PowerPC embedded flag EF_PPC_EMB = 0x8000_0000, @@ -3728,7 +4419,7 @@ constants! { /// still be in object files. R_PPC_TOC16 = 255, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_PPC_GOT = DT_LOPROC + 0, DT_PPC_OPT = DT_LOPROC + 1, }; @@ -3958,7 +4649,7 @@ constants! { /// half16 (sym+add-.)@ha R_PPC64_REL16_HA = 252, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_PPC64_GLINK = DT_LOPROC + 0, DT_PPC64_OPD = DT_LOPROC + 1, DT_PPC64_OPDSZ = DT_LOPROC + 2, @@ -3986,7 +4677,7 @@ pub const STO_PPC64_LOCAL_MASK: u8 = 7 << STO_PPC64_LOCAL_BIT; constants! { struct Arm(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { EF_ARM_RELEXEC = 0x01, EF_ARM_HASENTRY = 0x02, EF_ARM_INTERWORK = 0x04, @@ -4007,19 +4698,19 @@ constants! { EF_ARM_EABIMASK = 0xff00_0000 => NAMES_EF_ARM_EABI, }; - consts stt: u8 = { + consts stt: SymbolType(u8) = { /// A Thumb function. STT_ARM_TFUNC = STT_LOPROC, /// A Thumb label. STT_ARM_16BIT = STT_HIPROC, }; - flags shf: u32 = { + flags shf: SectionFlags(u64) = { /// Section contains an entry point SHF_ARM_ENTRYSECT = 0x1000_0000, /// Section may be multiply defined in the input to a link step. SHF_ARM_COMDEF = 0x8000_0000, }; - flags pf: u32 = { + flags pf: ProgramFlags(u32) = { /// Segment contains the location addressed by the static base. PF_ARM_SB = 0x1000_0000, /// Position-independent segment. @@ -4027,11 +4718,11 @@ constants! { /// Absolute segment. PF_ARM_ABS = 0x4000_0000, }; - consts pt: u32 = { + consts pt: ProgramType(u32) = { /// ARM unwind segment. PT_ARM_EXIDX = PT_LOPROC + 1, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// ARM unwind section. SHT_ARM_EXIDX = SHT_LOPROC + 1, /// Preemption details. @@ -4271,7 +4962,7 @@ constants! { }; } -constant_names!(NAMES_EF_ARM_EABI: u32 = { +constant_names!(NAMES_EF_ARM_EABI: FileFlags(u32) = { EF_ARM_EABI_UNKNOWN = 0x0000_0000, EF_ARM_EABI_VER1 = 0x0100_0000, EF_ARM_EABI_VER2 = 0x0200_0000, @@ -4293,15 +4984,15 @@ pub const EF_ARM_MAPSYMSFIRST: u32 = 0x10; constants! { struct Aarch64(Base); - consts sht: u32 = { + consts sht: SectionType(u32) = { /// AArch64 attributes section. SHT_AARCH64_ATTRIBUTES = SHT_LOPROC + 3, }; - flags sto: u8 = { + flags sto: SymbolOther(u8) = { // AArch64 values for `Sym64::st_other`. STO_AARCH64_VARIANT_PCS = 0x80, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_AARCH64_BTI_PLT = DT_LOPROC + 1, DT_AARCH64_PAC_PLT = DT_LOPROC + 3, DT_AARCH64_VARIANT_PCS = DT_LOPROC + 5, @@ -4588,7 +5279,7 @@ pub const DT_AARCH64_NUM: i64 = 6; constants! { struct Avr(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// If set, it is assumed that the elf file uses local symbols as reference /// for the relocations so that linker relaxation is possible. EF_AVR_LINKRELAX_PREPARED = 0x80, @@ -4639,7 +5330,7 @@ constants! { }; } -constant_names!(NAMES_EF_AVR_ARCH: u32 = { +constant_names!(NAMES_EF_AVR_ARCH: FileFlags(u32) = { EF_AVR_ARCH_AVR1 = 1, EF_AVR_ARCH_AVR2 = 2, EF_AVR_ARCH_AVR25 = 25, @@ -4789,10 +5480,10 @@ constants! { R_CKCORE_TLS_DTPOFF32 = 57, R_CKCORE_TLS_TPOFF32 = 58, }; - flags ef: u32 = { + flags ef: FileFlags(u32) = { _ = EF_CSKY_ABIMASK => NAMES_EF_CSKY_ABI, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// C-SKY attributes section. SHT_CSKY_ATTRIBUTES = SHT_LOPROC + 1, }; @@ -4802,7 +5493,7 @@ pub const EF_CSKY_ABIMASK: u32 = 0xF000_0000; pub const EF_CSKY_OTHER: u32 = 0x0FFF_0000; pub const EF_CSKY_PROCESSOR: u32 = 0x0000_FFFF; -constant_names!(NAMES_EF_CSKY_ABI: u32 = { +constant_names!(NAMES_EF_CSKY_ABI: FileFlags(u32) = { EF_CSKY_ABIV1 = 0x1000_0000, EF_CSKY_ABIV2 = 0x2000_0000, }); @@ -4811,11 +5502,11 @@ constant_names!(NAMES_EF_CSKY_ABI: u32 = { constants! { struct Ia64(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// 64-bit ABI EF_IA_64_ABI64 = 0x0000_0010, }; - consts pt: u32 = { + consts pt: ProgramType(u32) = { /// arch extension bits PT_IA_64_ARCHEXT = PT_LOPROC + 0, /// ia64 unwind bits @@ -4824,23 +5515,23 @@ constants! { PT_IA_64_HP_HSL_ANOT = PT_LOOS + 0x13, PT_IA_64_HP_STACK = PT_LOOS + 0x14, }; - flags pf: u32 = { + flags pf: ProgramFlags(u32) = { /// spec insns w/o recovery PF_IA_64_NORECOV = 0x8000_0000, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// extension bits SHT_IA_64_EXT = SHT_LOPROC + 0, /// unwind bits SHT_IA_64_UNWIND = SHT_LOPROC + 1, }; - flags shf: u32 = { + flags shf: SectionFlags(u64) = { /// section near gp SHF_IA_64_SHORT = 0x1000_0000, /// spec insns w/o recovery SHF_IA_64_NORECOV = 0x2000_0000, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_IA_64_PLT_RESERVE = DT_LOPROC + 0, }; consts r: u32 = { @@ -5018,7 +5709,7 @@ pub const EF_IA_64_ARCH: u32 = 0xff00_0000; constants! { struct Sh(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { EF_SH_MACH_MASK = 0x1f => NAMES_EF_SH_MACH, }; consts r: u32 = { @@ -5066,7 +5757,7 @@ constants! { constants! { struct S390(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// High GPRs kernel facility needed. EF_S390_HIGH_GPRS = 0x0000_0001, }; @@ -5198,7 +5889,7 @@ constants! { }; } -constant_names!(NAMES_EF_SH_MACH: u32 = { +constant_names!(NAMES_EF_SH_MACH: FileFlags(u32) = { EF_SH_UNKNOWN = 0x0, EF_SH1 = 0x1, EF_SH2 = 0x2, @@ -5354,7 +6045,7 @@ constants! { /// 32-bit PC relative to TLS descriptor in GOT if the instruction starts at 6 bytes before the relocation offset. R_X86_64_CODE_6_GOTPC32_TLSDESC = 51, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// Unwind information. SHT_X86_64_UNWIND = 0x7000_0001, }; @@ -5597,7 +6288,7 @@ constants! { // Nios II constants! { struct Nios2(Base); - consts dt: i64 = { + consts dt: DynamicTag(i64) = { /// Address of _gp. DT_NIOS2_GP = 0x7000_0002, }; @@ -6140,25 +6831,25 @@ constants! { constants! { struct Riscv(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { EF_RISCV_RVC = 0x0001, EF_RISCV_FLOAT_ABI = 0x0006 => NAMES_EF_RISCV_FLOAT_ABI, EF_RISCV_RVE = 0x0008, EF_RISCV_TSO = 0x0010, EF_RISCV_RV64ILP32 = 0x0020, }; - flags sto: u8 = { + flags sto: SymbolOther(u8) = { /// Function uses variant calling convention. STO_RISCV_VARIANT_CC = 0x80, }; - consts sht: u32 = { + consts sht: SectionType(u32) = { /// RISC-V attributes section. SHT_RISCV_ATTRIBUTES = SHT_LOPROC + 3, }; - consts pt: u32 = { + consts pt: ProgramType(u32) = { PT_RISCV_ATTRIBUTES = PT_LOPROC + 3, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_RISCV_VARIANT_CC = DT_LOPROC + 1, }; consts r: u32 = { @@ -6228,7 +6919,7 @@ constants! { }; } -constant_names!(NAMES_EF_RISCV_FLOAT_ABI: u32 = { +constant_names!(NAMES_EF_RISCV_FLOAT_ABI: FileFlags(u32) = { EF_RISCV_FLOAT_ABI_SOFT = 0x0000, EF_RISCV_FLOAT_ABI_SINGLE = 0x0002, EF_RISCV_FLOAT_ABI_DOUBLE = 0x0004, @@ -6339,7 +7030,7 @@ constants! { constants! { struct Larch(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { /// Additional properties of the base ABI type, including the FP calling /// convention. EF_LARCH_ABI_MODIFIER_MASK = 0x7 => NAMES_EF_LARCH_ABI, @@ -6671,7 +7362,7 @@ constants! { }; } -constant_names!(NAMES_EF_LARCH_ABI: u32 = { +constant_names!(NAMES_EF_LARCH_ABI: FileFlags(u32) = { /// Uses GPRs and the stack for parameter passing EF_LARCH_ABI_SOFT_FLOAT = 0x1, /// Uses GPRs, 32-bit FPRs and the stack for parameter passing @@ -6796,7 +7487,7 @@ pub const E_E2K_MACH_8V7: u32 = 25; constants! { struct E2k(Base); - flags ef: u32 = { + flags ef: FileFlags(u32) = { EF_E2K_IPD = 3, EF_E2K_X86APP = 4, EF_E2K_4MB_PAGES = 8, @@ -6901,7 +7592,7 @@ constants! { /// PC relative 64 bit in data. R_E2K_64_PC = 258, }; - consts dt: i64 = { + consts dt: DynamicTag(i64) = { DT_E2K_LAZY = DT_LOPROC + 1, DT_E2K_LAZY_GOT = DT_LOPROC + 3, @@ -6915,12 +7606,19 @@ constants! { pub const DT_E2K_NUM: i64 = 0x1021; -#[allow(non_upper_case_globals)] -pub const Tag_File: u8 = 1; -#[allow(non_upper_case_globals)] -pub const Tag_Section: u8 = 2; -#[allow(non_upper_case_globals)] -pub const Tag_Symbol: u8 = 3; +newtype!( + /// Value for the subsubsection tag in an attributes section. + struct AttributeTag(u8); +); + +newtype_constant_names!(NAMES_TAG: AttributeTag(u8) = { + #[allow(non_upper_case_globals)] + Tag_File = 1, + #[allow(non_upper_case_globals)] + Tag_Section = 2, + #[allow(non_upper_case_globals)] + Tag_Symbol = 3, +}); unsafe_impl_endian_pod!( FileHeader32, diff --git a/src/endian.rs b/src/endian.rs index 8a66f86f..d4359c09 100644 --- a/src/endian.rs +++ b/src/endian.rs @@ -370,6 +370,11 @@ impl> U32 { Ok(Self(e.write_u32(n.into_inner().try_into()?), PhantomData)) } + /// Construct a new value given a native endian `u64` value, truncating to `u32`. + pub fn new_u64_truncate(e: E, n: T) -> Self { + Self(e.write_u32(n.into_inner() as u32), PhantomData) + } + /// Return the value as a native endian `u64` value. pub fn get_u64(self, e: E) -> T { T::from_inner(u64::from(e.read_u32(self.0))) @@ -380,6 +385,11 @@ impl> U32 { self.0 = e.write_u32(n.into_inner().try_into()?); Ok(()) } + + /// Set the value given a native endian `u64` value, truncating to `u32`. + pub fn set_u64_truncate(&mut self, e: E, n: T) { + self.0 = e.write_u32(n.into_inner() as u32); + } } /// An unaligned `u64` value with an externally specified endianness of type `E`. @@ -475,6 +485,11 @@ impl> I32 { Ok(Self(e.write_i32(n.into_inner().try_into()?), PhantomData)) } + /// Construct a new value given a native endian `i64` value, truncating to `i32`. + pub fn new_i64_truncate(e: E, n: T) -> Self { + Self(e.write_i32(n.into_inner() as i32), PhantomData) + } + /// Return the value as a native endian `i64` value. pub fn get_i64(self, e: E) -> T { T::from_inner(i64::from(e.read_i32(self.0))) @@ -485,6 +500,11 @@ impl> I32 { self.0 = e.write_i32(n.into_inner().try_into()?); Ok(()) } + + /// Set the value given a native endian `i64` value, truncating to `i32`. + pub fn set_i64_truncate(&mut self, e: E, n: T) { + self.0 = e.write_i32(n.into_inner() as i32); + } } /// An unaligned `i64` value with an externally specified endianness of type `E`. diff --git a/src/read/elf/attributes.rs b/src/read/elf/attributes.rs index aa3ad22b..46a256f3 100644 --- a/src/read/elf/attributes.rs +++ b/src/read/elf/attributes.rs @@ -176,8 +176,10 @@ impl<'data, Elf: FileHeader> AttributesSubsubsectionIterator<'data, Elf> { // | * 0 * // | * 0 * let mut data = self.data; - let tag = *data + let tag = data .read::() + .copied() + .map(elf::AttributeTag) .read_error("ELF attributes subsection is too short")?; let length = data .read::>() @@ -227,7 +229,7 @@ impl<'data, Elf: FileHeader> Iterator for AttributesSubsubsectionIterator<'data, /// followed by a series of attributes. #[derive(Debug, Clone)] pub struct AttributesSubsubsection<'data> { - tag: u8, + tag: elf::AttributeTag, length: u32, indices: Bytes<'data>, data: Bytes<'data>, @@ -235,7 +237,7 @@ pub struct AttributesSubsubsection<'data> { impl<'data> AttributesSubsubsection<'data> { /// Return the tag of the attributes sub-subsection. - pub fn tag(&self) -> u8 { + pub fn tag(&self) -> elf::AttributeTag { self.tag } diff --git a/src/read/elf/comdat.rs b/src/read/elf/comdat.rs index 832b93b9..e44ed8ee 100644 --- a/src/read/elf/comdat.rs +++ b/src/read/elf/comdat.rs @@ -87,7 +87,7 @@ where section: &'data Elf::SectionHeader, ) -> Option> { let (flag, sections) = section.group(file.endian, file.data.0).ok()??; - if flag != elf::GRP_COMDAT { + if !flag.contains(elf::GRP_COMDAT) { return None; } Some(ElfComdat { diff --git a/src/read/elf/compression.rs b/src/read/elf/compression.rs index de2533f2..17623144 100644 --- a/src/read/elf/compression.rs +++ b/src/read/elf/compression.rs @@ -10,7 +10,7 @@ pub trait CompressionHeader: Debug + Pod { type Word: Into; type Endian: endian::Endian; - fn ch_type(&self, endian: Self::Endian) -> u32; + fn ch_type(&self, endian: Self::Endian) -> elf::CompressionType; fn ch_size(&self, endian: Self::Endian) -> Self::Word; fn ch_addralign(&self, endian: Self::Endian) -> Self::Word; } @@ -20,7 +20,7 @@ impl CompressionHeader for elf::CompressionHeader32 u32 { + fn ch_type(&self, endian: Self::Endian) -> elf::CompressionType { self.ch_type.get(endian) } @@ -40,7 +40,7 @@ impl CompressionHeader for elf::CompressionHeader64 u32 { + fn ch_type(&self, endian: Self::Endian) -> elf::CompressionType { self.ch_type.get(endian) } diff --git a/src/read/elf/dynamic.rs b/src/read/elf/dynamic.rs index c4f1cc4c..c59b832a 100644 --- a/src/read/elf/dynamic.rs +++ b/src/read/elf/dynamic.rs @@ -138,7 +138,7 @@ impl<'data, Elf: FileHeader> Iterator for DynamicIterator<'data, Elf> { fn next(&mut self) -> Option { let d = self.dynamics.next()?; - let tag = d.d_tag(self.endian).into(); + let tag = d.d_tag(self.endian); if tag == elf::DT_NULL { self.dynamics = [].iter(); return None; @@ -154,7 +154,7 @@ pub struct Dynamic { /// The entry tag. /// /// One of the `DT_*` constants. - pub tag: i64, + pub tag: elf::DynamicTag, /// The entry value. /// @@ -192,17 +192,16 @@ impl Dynamic { #[allow(missing_docs)] pub trait Dyn: Debug + Pod { type Word: Into; - type Sword: Into; type Endian: endian::Endian; - fn d_tag(&self, endian: Self::Endian) -> Self::Sword; + fn d_tag(&self, endian: Self::Endian) -> elf::DynamicTag; fn d_val(&self, endian: Self::Endian) -> Self::Word; - /// Get the tag as an `i64`. + /// Get the tag as a `DynamicTag`. /// /// This will sign-extend for 32-bit ELF. - fn tag(&self, endian: Self::Endian) -> i64 { - self.d_tag(endian).into() + fn tag(&self, endian: Self::Endian) -> elf::DynamicTag { + self.d_tag(endian) } /// Get the value as a `u64`. @@ -214,7 +213,7 @@ pub trait Dyn: Debug + Pod { /// Try to convert the tag to an `i32`. fn tag32(&self, endian: Self::Endian) -> Option { - self.d_tag(endian).into().try_into().ok() + self.d_tag(endian).0.try_into().ok() } /// Try to convert the value to a `u32`. @@ -248,12 +247,11 @@ pub trait Dyn: Debug + Pod { impl Dyn for elf::Dyn32 { type Word = u32; - type Sword = i32; type Endian = Endian; #[inline] - fn d_tag(&self, endian: Self::Endian) -> Self::Sword { - self.d_tag.get(endian) + fn d_tag(&self, endian: Self::Endian) -> elf::DynamicTag { + self.d_tag.get_i64(endian) } #[inline] @@ -264,11 +262,10 @@ impl Dyn for elf::Dyn32 { impl Dyn for elf::Dyn64 { type Word = u64; - type Sword = i64; type Endian = Endian; #[inline] - fn d_tag(&self, endian: Self::Endian) -> Self::Sword { + fn d_tag(&self, endian: Self::Endian) -> elf::DynamicTag { self.d_tag.get(endian) } @@ -278,7 +275,7 @@ impl Dyn for elf::Dyn64 { } } -fn tag_is_string(tag: i64) -> bool { +fn tag_is_string(tag: elf::DynamicTag) -> bool { match tag { elf::DT_NEEDED | elf::DT_SONAME @@ -290,7 +287,7 @@ fn tag_is_string(tag: i64) -> bool { } } -fn tag_is_address(tag: i64) -> bool { +fn tag_is_address(tag: elf::DynamicTag) -> bool { // TODO: check architecture specific values. This requires the e_machine value. match tag { elf::DT_PLTGOT @@ -309,8 +306,7 @@ fn tag_is_address(tag: i64) -> bool { | elf::DT_SYMTAB_SHNDX | elf::DT_VERDEF | elf::DT_VERNEED - | elf::DT_VERSYM - | elf::DT_ADDRRNGLO..=elf::DT_ADDRRNGHI => true, - _ => false, + | elf::DT_VERSYM => true, + _ => tag.is_address(), } } diff --git a/src/read/elf/file.rs b/src/read/elf/file.rs index beeac1c8..f9a112e7 100644 --- a/src/read/elf/file.rs +++ b/src/read/elf/file.rs @@ -276,7 +276,7 @@ where (elf::EM_LOONGARCH, true) => Architecture::LoongArch64, (elf::EM_68K, false) => Architecture::M68k, (elf::EM_MIPS, false) => { - if (self.header.e_flags(self.endian) & elf::EF_MIPS_ABI2) != 0 { + if self.header.e_flags(self.endian).contains(elf::EF_MIPS_ABI2) { Architecture::Mips64_N32 } else { Architecture::Mips @@ -573,19 +573,19 @@ pub trait FileHeader: Debug + Pod { Self: Sized; fn e_ident(&self) -> &elf::Ident; - fn e_type(&self, endian: Self::Endian) -> u16; - fn e_machine(&self, endian: Self::Endian) -> u16; + fn e_type(&self, endian: Self::Endian) -> elf::FileType; + fn e_machine(&self, endian: Self::Endian) -> elf::Machine; fn e_version(&self, endian: Self::Endian) -> u32; fn e_entry(&self, endian: Self::Endian) -> Self::Word; fn e_phoff(&self, endian: Self::Endian) -> Self::Word; fn e_shoff(&self, endian: Self::Endian) -> Self::Word; - fn e_flags(&self, endian: Self::Endian) -> u32; + fn e_flags(&self, endian: Self::Endian) -> elf::FileFlags; fn e_ehsize(&self, endian: Self::Endian) -> u16; fn e_phentsize(&self, endian: Self::Endian) -> u16; fn e_phnum(&self, endian: Self::Endian) -> u16; fn e_shentsize(&self, endian: Self::Endian) -> u16; fn e_shnum(&self, endian: Self::Endian) -> u16; - fn e_shstrndx(&self, endian: Self::Endian) -> u16; + fn e_shstrndx(&self, endian: Self::Endian) -> elf::SymbolSection; // Provided methods. @@ -712,18 +712,20 @@ pub trait FileHeader: Debug + Pod { data: R, ) -> read::Result { let e_shstrndx = self.e_shstrndx(endian); - let index = if e_shstrndx != elf::SHN_XINDEX { - e_shstrndx.into() - } else if let Some(section_0) = self.section_0(endian, data)? { - section_0.sh_link(endian) - } else { + if let Some(index) = e_shstrndx.index() { + Ok(u32::from(index)) + } else if e_shstrndx == elf::SHN_XINDEX { // Section 0 must exist if we're trying to read e_shstrndx. - return Err(Error("Missing ELF section headers for e_shstrndx overflow")); - }; - if index == 0 { - return Err(Error("Missing ELF e_shstrndx")); + let section_0 = self + .section_0(endian, data)? + .read_error("Missing ELF section headers for e_shstrndx overflow")?; + Ok(section_0.sh_link(endian)) + } else if e_shstrndx == elf::SHN_UNDEF { + // Valid, but we're only called if we expect a section index. + Err(Error("Missing ELF e_shstrndx")) + } else { + Err(Error("Invalid ELF e_shstrndx")) } - Ok(index) } /// Return the slice of program headers. @@ -867,12 +869,12 @@ impl FileHeader for elf::FileHeader32 { } #[inline] - fn e_type(&self, endian: Self::Endian) -> u16 { + fn e_type(&self, endian: Self::Endian) -> elf::FileType { self.e_type.get(endian) } #[inline] - fn e_machine(&self, endian: Self::Endian) -> u16 { + fn e_machine(&self, endian: Self::Endian) -> elf::Machine { self.e_machine.get(endian) } @@ -897,7 +899,7 @@ impl FileHeader for elf::FileHeader32 { } #[inline] - fn e_flags(&self, endian: Self::Endian) -> u32 { + fn e_flags(&self, endian: Self::Endian) -> elf::FileFlags { self.e_flags.get(endian) } @@ -927,7 +929,7 @@ impl FileHeader for elf::FileHeader32 { } #[inline] - fn e_shstrndx(&self, endian: Self::Endian) -> u16 { + fn e_shstrndx(&self, endian: Self::Endian) -> elf::SymbolSection { self.e_shstrndx.get(endian) } } @@ -965,12 +967,12 @@ impl FileHeader for elf::FileHeader64 { } #[inline] - fn e_type(&self, endian: Self::Endian) -> u16 { + fn e_type(&self, endian: Self::Endian) -> elf::FileType { self.e_type.get(endian) } #[inline] - fn e_machine(&self, endian: Self::Endian) -> u16 { + fn e_machine(&self, endian: Self::Endian) -> elf::Machine { self.e_machine.get(endian) } @@ -995,7 +997,7 @@ impl FileHeader for elf::FileHeader64 { } #[inline] - fn e_flags(&self, endian: Self::Endian) -> u32 { + fn e_flags(&self, endian: Self::Endian) -> elf::FileFlags { self.e_flags.get(endian) } @@ -1025,7 +1027,7 @@ impl FileHeader for elf::FileHeader64 { } #[inline] - fn e_shstrndx(&self, endian: Self::Endian) -> u16 { + fn e_shstrndx(&self, endian: Self::Endian) -> elf::SymbolSection { self.e_shstrndx.get(endian) } } diff --git a/src/read/elf/note.rs b/src/read/elf/note.rs index bf4a3aed..0987dd6a 100644 --- a/src/read/elf/note.rs +++ b/src/read/elf/note.rs @@ -254,7 +254,7 @@ impl<'data, Endian: endian::Endian> GnuPropertyIterator<'data, Endian> { fn parse(&mut self) -> read::Result> { (|| -> Result<_, ()> { - let pr_type = self.data.read_at::>(0)?.get(self.endian); + let pr_type = self.data.read_at::>(0)?.get(self.endian); let pr_datasz = self.data.read_at::>(4)?.get(self.endian) as usize; let pr_data = self.data.read_bytes_at(8, pr_datasz)?.0; self.data.skip(util::align(8 + pr_datasz, self.align))?; @@ -275,7 +275,7 @@ impl<'data, Endian: endian::Endian> Iterator for GnuPropertyIterator<'data, Endi /// A property in a [`elf::NT_GNU_PROPERTY_TYPE_0`] note. #[derive(Debug)] pub struct GnuProperty<'data> { - pr_type: u32, + pr_type: elf::GnuPropertyType, pr_data: &'data [u8], } @@ -283,7 +283,7 @@ impl<'data> GnuProperty<'data> { /// Return the property type. /// /// This is one of the `GNU_PROPERTY_*` constants. - pub fn pr_type(&self) -> u32 { + pub fn pr_type(&self) -> elf::GnuPropertyType { self.pr_type } diff --git a/src/read/elf/section.rs b/src/read/elf/section.rs index 915c24fb..6990723f 100644 --- a/src/read/elf/section.rs +++ b/src/read/elf/section.rs @@ -138,7 +138,7 @@ impl<'data, Elf: FileHeader, R: ReadRef<'data>> SectionTable<'data, Elf, R> { &self, endian: Elf::Endian, data: R, - sh_type: u32, + sh_type: elf::SectionType, ) -> read::Result> { debug_assert!(sh_type == elf::SHT_DYNSYM || sh_type == elf::SHT_SYMTAB); @@ -629,30 +629,30 @@ where } fn kind(&self) -> SectionKind { - let flags = self.section.sh_flags(self.file.endian).into(); + let flags = self.section.sh_flags(self.file.endian); let sh_type = self.section.sh_type(self.file.endian); match sh_type { elf::SHT_PROGBITS => { - if flags & u64::from(elf::SHF_ALLOC) != 0 { - if flags & u64::from(elf::SHF_EXECINSTR) != 0 { + if flags.contains(elf::SHF_ALLOC) { + if flags.contains(elf::SHF_EXECINSTR) { SectionKind::Text - } else if flags & u64::from(elf::SHF_TLS) != 0 { + } else if flags.contains(elf::SHF_TLS) { SectionKind::Tls - } else if flags & u64::from(elf::SHF_WRITE) != 0 { + } else if flags.contains(elf::SHF_WRITE) { SectionKind::Data - } else if flags & u64::from(elf::SHF_STRINGS) != 0 { + } else if flags.contains(elf::SHF_STRINGS) { SectionKind::ReadOnlyString } else { SectionKind::ReadOnlyData } - } else if flags & u64::from(elf::SHF_STRINGS) != 0 { + } else if flags.contains(elf::SHF_STRINGS) { SectionKind::OtherString } else { SectionKind::Other } } elf::SHT_NOBITS => { - if flags & u64::from(elf::SHF_TLS) != 0 { + if flags.contains(elf::SHF_TLS) { SectionKind::UninitializedTls } else { SectionKind::UninitializedData @@ -690,7 +690,7 @@ where fn flags(&self) -> SectionFlags { SectionFlags::Elf { sh_type: self.section.sh_type(self.file.endian), - sh_flags: self.section.sh_flags(self.file.endian).into(), + sh_flags: self.section.sh_flags(self.file.endian), } } } @@ -703,8 +703,8 @@ pub trait SectionHeader: Debug + Pod { type Endian: endian::Endian; fn sh_name(&self, endian: Self::Endian) -> u32; - fn sh_type(&self, endian: Self::Endian) -> u32; - fn sh_flags(&self, endian: Self::Endian) -> Self::Word; + fn sh_type(&self, endian: Self::Endian) -> elf::SectionType; + fn sh_flags(&self, endian: Self::Endian) -> elf::SectionFlags; fn sh_addr(&self, endian: Self::Endian) -> Self::Word; fn sh_offset(&self, endian: Self::Endian) -> Self::Word; fn sh_size(&self, endian: Self::Endian) -> Self::Word; @@ -733,7 +733,7 @@ pub trait SectionHeader: Debug + Pod { /// Return true if the `SHF_INFO_LINK` flag is set. fn has_info_link(&self, endian: Self::Endian) -> bool { - self.sh_flags(endian).into() & u64::from(elf::SHF_INFO_LINK) != 0 + self.sh_flags(endian).contains(elf::SHF_INFO_LINK) } /// Get the `sh_info` field as a section index. @@ -975,13 +975,13 @@ pub trait SectionHeader: Debug + Pod { &self, endian: Self::Endian, data: R, - ) -> read::Result])>> { + ) -> read::Result])>> { if self.sh_type(endian) != elf::SHT_GROUP { return Ok(None); } let msg = "Invalid ELF group section offset or size"; let data = self.data(endian, data).read_error(msg)?; - let (flag, data) = pod::from_bytes::>(data).read_error(msg)?; + let (flag, data) = pod::from_bytes::>(data).read_error(msg)?; let sections = pod::slice_from_all_bytes(data).read_error(msg)?; Ok(Some((flag.get(endian), sections))) } @@ -1184,7 +1184,7 @@ pub trait SectionHeader: Debug + Pod { u64, )>, > { - if (self.sh_flags(endian).into() & u64::from(elf::SHF_COMPRESSED)) == 0 { + if !self.sh_flags(endian).contains(elf::SHF_COMPRESSED) { return Ok(None); } let (section_offset, section_size) = self @@ -1212,13 +1212,13 @@ impl SectionHeader for elf::SectionHeader32 { } #[inline] - fn sh_type(&self, endian: Self::Endian) -> u32 { + fn sh_type(&self, endian: Self::Endian) -> elf::SectionType { self.sh_type.get(endian) } #[inline] - fn sh_flags(&self, endian: Self::Endian) -> Self::Word { - self.sh_flags.get(endian) + fn sh_flags(&self, endian: Self::Endian) -> elf::SectionFlags { + self.sh_flags.get_u64(endian) } #[inline] @@ -1268,12 +1268,12 @@ impl SectionHeader for elf::SectionHeader64 { } #[inline] - fn sh_type(&self, endian: Self::Endian) -> u32 { + fn sh_type(&self, endian: Self::Endian) -> elf::SectionType { self.sh_type.get(endian) } #[inline] - fn sh_flags(&self, endian: Self::Endian) -> Self::Word { + fn sh_flags(&self, endian: Self::Endian) -> elf::SectionFlags { self.sh_flags.get(endian) } diff --git a/src/read/elf/segment.rs b/src/read/elf/segment.rs index 92545fc7..7b6b52d6 100644 --- a/src/read/elf/segment.rs +++ b/src/read/elf/segment.rs @@ -151,9 +151,9 @@ where fn permissions(&self) -> Permissions { let p_flags = self.segment.p_flags(self.file.endian); Permissions::new( - p_flags & elf::PF_R != 0, - p_flags & elf::PF_W != 0, - p_flags & elf::PF_X != 0, + p_flags.contains(elf::PF_R), + p_flags.contains(elf::PF_W), + p_flags.contains(elf::PF_X), ) } } @@ -165,8 +165,8 @@ pub trait ProgramHeader: Debug + Pod { type Word: Into; type Endian: endian::Endian; - fn p_type(&self, endian: Self::Endian) -> u32; - fn p_flags(&self, endian: Self::Endian) -> u32; + fn p_type(&self, endian: Self::Endian) -> elf::ProgramType; + fn p_flags(&self, endian: Self::Endian) -> elf::ProgramFlags; fn p_offset(&self, endian: Self::Endian) -> Self::Word; fn p_vaddr(&self, endian: Self::Endian) -> Self::Word; fn p_paddr(&self, endian: Self::Endian) -> Self::Word; @@ -289,12 +289,12 @@ impl ProgramHeader for elf::ProgramHeader32 { type Elf = elf::FileHeader32; #[inline] - fn p_type(&self, endian: Self::Endian) -> u32 { + fn p_type(&self, endian: Self::Endian) -> elf::ProgramType { self.p_type.get(endian) } #[inline] - fn p_flags(&self, endian: Self::Endian) -> u32 { + fn p_flags(&self, endian: Self::Endian) -> elf::ProgramFlags { self.p_flags.get(endian) } @@ -335,12 +335,12 @@ impl ProgramHeader for elf::ProgramHeader64 { type Elf = elf::FileHeader64; #[inline] - fn p_type(&self, endian: Self::Endian) -> u32 { + fn p_type(&self, endian: Self::Endian) -> elf::ProgramType { self.p_type.get(endian) } #[inline] - fn p_flags(&self, endian: Self::Endian) -> u32 { + fn p_flags(&self, endian: Self::Endian) -> elf::ProgramFlags { self.p_flags.get(endian) } diff --git a/src/read/elf/symbol.rs b/src/read/elf/symbol.rs index ac438b6f..aea550e5 100644 --- a/src/read/elf/symbol.rs +++ b/src/read/elf/symbol.rs @@ -178,20 +178,20 @@ impl<'data, Elf: FileHeader, R: ReadRef<'data>> SymbolTable<'data, Elf, R> { symbol: &Elf::Sym, index: SymbolIndex, ) -> read::Result> { - match symbol.st_shndx(endian) { - elf::SHN_UNDEF => Ok(None), - elf::SHN_XINDEX => { - let shndx = self - .shndx(endian, index) - .read_error("Missing ELF symbol extended index")?; - if shndx == 0 { - Ok(None) - } else { - Ok(Some(SectionIndex(shndx as usize))) - } + let shndx = symbol.st_shndx(endian); + if let Some(index) = shndx.index() { + Ok(Some(SectionIndex(index.into()))) + } else if shndx == elf::SHN_XINDEX { + let shndx = self + .shndx(endian, index) + .read_error("Missing ELF symbol extended index")?; + if shndx == 0 { + Ok(None) + } else { + Ok(Some(SectionIndex(shndx as usize))) } - shndx if shndx < elf::SHN_LORESERVE => Ok(Some(SectionIndex(shndx.into()))), - _ => Ok(None), + } else { + Ok(None) } } @@ -424,10 +424,13 @@ impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> ObjectSymbol<'data> Some(index) => SymbolSection::Section(SectionIndex(index as usize)), None => SymbolSection::Unknown, }, - index if index < elf::SHN_LORESERVE => { - SymbolSection::Section(SectionIndex(index as usize)) + shndx => { + if let Some(index) = shndx.index() { + SymbolSection::Section(SectionIndex(index.into())) + } else { + SymbolSection::Unknown + } } - _ => SymbolSection::Unknown, } } @@ -496,12 +499,12 @@ pub trait Sym: Debug + Pod { type Endian: endian::Endian; fn st_name(&self, endian: Self::Endian) -> u32; - fn st_info(&self) -> u8; - fn st_bind(&self) -> u8; - fn st_type(&self) -> u8; - fn st_other(&self) -> u8; - fn st_visibility(&self) -> u8; - fn st_shndx(&self, endian: Self::Endian) -> u16; + fn st_info(&self) -> elf::SymbolInfo; + fn st_bind(&self) -> elf::SymbolBind; + fn st_type(&self) -> elf::SymbolType; + fn st_other(&self) -> elf::SymbolOther; + fn st_visibility(&self) -> elf::SymbolVisibility; + fn st_shndx(&self, endian: Self::Endian) -> elf::SymbolSection; fn st_value(&self, endian: Self::Endian) -> Self::Word; fn st_size(&self, endian: Self::Endian) -> Self::Word; @@ -529,7 +532,7 @@ pub trait Sym: Debug + Pod { strings: StringTable<'data, R>, ) -> bool { let shndx = self.st_shndx(endian); - if shndx == elf::SHN_UNDEF || (shndx >= elf::SHN_LORESERVE && shndx != elf::SHN_XINDEX) { + if shndx.is_special() && shndx != elf::SHN_XINDEX { return false; } match self.st_type() { @@ -578,32 +581,32 @@ impl Sym for elf::Sym32 { } #[inline] - fn st_info(&self) -> u8 { + fn st_info(&self) -> elf::SymbolInfo { self.st_info } #[inline] - fn st_bind(&self) -> u8 { + fn st_bind(&self) -> elf::SymbolBind { self.st_bind() } #[inline] - fn st_type(&self) -> u8 { + fn st_type(&self) -> elf::SymbolType { self.st_type() } #[inline] - fn st_other(&self) -> u8 { + fn st_other(&self) -> elf::SymbolOther { self.st_other } #[inline] - fn st_visibility(&self) -> u8 { + fn st_visibility(&self) -> elf::SymbolVisibility { self.st_visibility() } #[inline] - fn st_shndx(&self, endian: Self::Endian) -> u16 { + fn st_shndx(&self, endian: Self::Endian) -> elf::SymbolSection { self.st_shndx.get(endian) } @@ -628,32 +631,32 @@ impl Sym for elf::Sym64 { } #[inline] - fn st_info(&self) -> u8 { + fn st_info(&self) -> elf::SymbolInfo { self.st_info } #[inline] - fn st_bind(&self) -> u8 { + fn st_bind(&self) -> elf::SymbolBind { self.st_bind() } #[inline] - fn st_type(&self) -> u8 { + fn st_type(&self) -> elf::SymbolType { self.st_type() } #[inline] - fn st_other(&self) -> u8 { + fn st_other(&self) -> elf::SymbolOther { self.st_other } #[inline] - fn st_visibility(&self) -> u8 { + fn st_visibility(&self) -> elf::SymbolVisibility { self.st_visibility() } #[inline] - fn st_shndx(&self, endian: Self::Endian) -> u16 { + fn st_shndx(&self, endian: Self::Endian) -> elf::SymbolSection { self.st_shndx.get(endian) } diff --git a/src/read/elf/version.rs b/src/read/elf/version.rs index 2e350a8b..6ad33e1d 100644 --- a/src/read/elf/version.rs +++ b/src/read/elf/version.rs @@ -5,32 +5,6 @@ use crate::{elf, endian}; use super::FileHeader; -/// A version index. -#[derive(Debug, Default, Clone, Copy)] -pub struct VersionIndex(pub u16); - -impl VersionIndex { - /// Return the version index. - pub fn index(&self) -> u16 { - self.0 & elf::VERSYM_VERSION - } - - /// Return true if it is the local index. - pub fn is_local(&self) -> bool { - self.index() == elf::VER_NDX_LOCAL - } - - /// Return true if it is the global index. - pub fn is_global(&self) -> bool { - self.index() == elf::VER_NDX_GLOBAL - } - - /// Return the hidden flag. - pub fn is_hidden(&self) -> bool { - self.0 & elf::VERSYM_HIDDEN != 0 - } -} - /// A version definition or requirement. /// /// This is derived from entries in the [`elf::SHT_GNU_VERDEF`] and [`elf::SHT_GNU_VERNEED`] sections. @@ -98,21 +72,21 @@ impl<'data, Elf: FileHeader> VersionTable<'data, Elf> { let mut max_index = 0; if let Some(mut verdefs) = verdefs.clone() { while let Some((verdef, _)) = verdefs.next()? { - if verdef.vd_flags.get(endian) & elf::VER_FLG_BASE != 0 { + if verdef.vd_flags.get(endian).contains(elf::VER_FLG_BASE) { continue; } - let index = verdef.vd_ndx.get(endian) & elf::VERSYM_VERSION; - if max_index < index { - max_index = index; + let index = verdef.vd_ndx.get(endian); + if max_index < index.0 { + max_index = index.0; } } } if let Some(mut verneeds) = verneeds.clone() { while let Some((_, mut vernauxs)) = verneeds.next()? { while let Some(vernaux) = vernauxs.next()? { - let index = vernaux.vna_other.get(endian) & elf::VERSYM_VERSION; - if max_index < index { - max_index = index; + let index = vernaux.vna_other.get(endian); + if max_index < index.0 { + max_index = index.0; } } } @@ -124,16 +98,16 @@ impl<'data, Elf: FileHeader> VersionTable<'data, Elf> { if let Some(mut verdefs) = verdefs { while let Some((verdef, mut verdauxs)) = verdefs.next()? { - if verdef.vd_flags.get(endian) & elf::VER_FLG_BASE != 0 { + if verdef.vd_flags.get(endian).contains(elf::VER_FLG_BASE) { continue; } - let index = verdef.vd_ndx.get(endian) & elf::VERSYM_VERSION; - if index <= elf::VER_NDX_GLOBAL { + let index = verdef.vd_ndx.get(endian); + if index.is_special() { // TODO: return error? continue; } if let Some(verdaux) = verdauxs.next()? { - versions[usize::from(index)] = Version { + versions[usize::from(index.0)] = Version { name: verdaux.name(endian, strings)?, hash: verdef.vd_hash.get(endian), valid: true, @@ -145,12 +119,12 @@ impl<'data, Elf: FileHeader> VersionTable<'data, Elf> { if let Some(mut verneeds) = verneeds { while let Some((verneed, mut vernauxs)) = verneeds.next()? { while let Some(vernaux) = vernauxs.next()? { - let index = vernaux.vna_other.get(endian) & elf::VERSYM_VERSION; - if index <= elf::VER_NDX_GLOBAL { + let index = vernaux.vna_other.get(endian); + if index.is_special() { // TODO: return error? continue; } - versions[usize::from(index)] = Version { + versions[usize::from(index.0)] = Version { name: vernaux.name(endian, strings)?, hash: vernaux.vna_hash.get(endian), valid: true, @@ -172,26 +146,26 @@ impl<'data, Elf: FileHeader> VersionTable<'data, Elf> { } /// Return version index for a given symbol index. - pub fn version_index(&self, endian: Elf::Endian, index: SymbolIndex) -> VersionIndex { - let version_index = match self.symbols.get(index.0) { - Some(x) => x.0.get(endian), + pub fn version_index(&self, endian: Elf::Endian, index: SymbolIndex) -> elf::VersymIndex { + match self.symbols.get(index.0) { + Some(versym) => versym.0.get(endian), // Ideally this would be VER_NDX_LOCAL for undefined symbols, // but currently there are no checks that need this distinction. - None => elf::VER_NDX_GLOBAL, - }; - VersionIndex(version_index) + None => elf::VER_NDX_GLOBAL.into(), + } } /// Return version information for a given symbol version index. /// /// Returns `Ok(None)` for local and global versions. /// Returns `Err(_)` if index is invalid. - pub fn version(&self, index: VersionIndex) -> Result>> { - if index.index() <= elf::VER_NDX_GLOBAL { + pub fn version(&self, index: elf::VersymIndex) -> Result>> { + let index = index.index(); + if index.is_special() { return Ok(None); } self.versions - .get(usize::from(index.index())) + .get(usize::from(index.0)) .filter(|version| version.valid) .read_error("Invalid ELF symbol version index") .map(Some) diff --git a/src/write/elf/object.rs b/src/write/elf/object.rs index b246c307..a5b8b9c3 100644 --- a/src/write/elf/object.rs +++ b/src/write/elf/object.rs @@ -31,7 +31,7 @@ impl<'a> Object<'a> { /// Add a property with a u32 value to the ELF ".note.gnu.property" section. /// /// Requires `feature = "elf"`. - pub fn add_elf_gnu_property_u32(&mut self, property: u32, value: u32) { + pub fn add_elf_gnu_property_u32(&mut self, property: elf::GnuPropertyType, value: u32) { if self.format != BinaryFormat::Elf { return; } @@ -106,7 +106,7 @@ impl<'a> Object<'a> { SectionKind::Note, SectionFlags::Elf { sh_type: elf::SHT_NOTE, - sh_flags: u64::from(elf::SHF_ALLOC), + sh_flags: elf::SHF_ALLOC, }, ), StandardSection::EhFrame => ( @@ -122,7 +122,7 @@ impl<'a> Object<'a> { } else { elf::SHT_PROGBITS }, - sh_flags: u64::from(elf::SHF_ALLOC), + sh_flags: elf::SHF_ALLOC, }, ), } @@ -158,9 +158,8 @@ impl<'a> Object<'a> { SectionKind::OtherString | SectionKind::DebugString => { elf::SHF_STRINGS | elf::SHF_MERGE } - _ => 0, - } - .into(); + _ => elf::SectionFlags(0), + }; SectionFlags::Elf { sh_type, sh_flags } } @@ -203,13 +202,16 @@ impl<'a> Object<'a> { } else { elf::STB_GLOBAL }; - let st_info = (st_bind << 4) + st_type; - let st_other = if symbol.scope == SymbolScope::Linkage { + let st_info = st_bind | st_type; + let vis = if symbol.scope == SymbolScope::Linkage { elf::STV_HIDDEN } else { elf::STV_DEFAULT }; - SymbolFlags::Elf { st_info, st_other } + SymbolFlags::Elf { + st_info, + st_other: vis.into(), + } } fn elf_has_relocation_addend(&self) -> Result { @@ -749,7 +751,7 @@ impl<'a> Object<'a> { { (os_abi, abi_version, e_flags) } else { - (elf::ELFOSABI_NONE, 0, 0) + (elf::ELFOSABI_NONE, 0, elf::FileFlags(0)) }; if self.architecture == Architecture::Mips64_N32 { @@ -796,7 +798,9 @@ impl<'a> Object<'a> { SymbolSection::Undefined => (elf::SHN_UNDEF, None), SymbolSection::Absolute => (elf::SHN_ABS, None), SymbolSection::Common => (elf::SHN_COMMON, None), - SymbolSection::Section(id) => (0, Some(section_offsets[id.0].index)), + SymbolSection::Section(id) => { + (elf::SymbolSection(0), Some(section_offsets[id.0].index)) + } }; writer.write_symbol(&Sym { name: symbol_offsets[index].str_id, diff --git a/src/write/elf/writer.rs b/src/write/elf/writer.rs index 71578f06..5dda6506 100644 --- a/src/write/elf/writer.rs +++ b/src/write/elf/writer.rs @@ -338,11 +338,7 @@ impl<'a> Writer<'a> { } else { self.section_num as u16 }; - let e_shstrndx = if self.shstrtab_index.0 >= elf::SHN_LORESERVE.into() { - elf::SHN_XINDEX - } else { - self.shstrtab_index.0 as u16 - }; + let e_shstrndx = elf::SymbolSection::new(self.shstrtab_index.0); let endian = self.endian; if self.is_64 { @@ -350,7 +346,7 @@ impl<'a> Writer<'a> { e_ident, e_type: U16::new(endian, header.e_type), e_machine: U16::new(endian, header.e_machine), - e_version: U32::new(endian, elf::EV_CURRENT.into()), + e_version: U32::new(endian, elf::EV_CURRENT.0.into()), e_entry: U64::new(endian, header.e_entry), e_phoff: U64::new(endian, e_phoff), e_shoff: U64::new(endian, e_shoff), @@ -368,7 +364,7 @@ impl<'a> Writer<'a> { e_ident, e_type: U16::new(endian, header.e_type), e_machine: U16::new(endian, header.e_machine), - e_version: U32::new(endian, elf::EV_CURRENT.into()), + e_version: U32::new(endian, elf::EV_CURRENT.0.into()), e_entry: U32::new(endian, header.e_entry as u32), e_phoff: U32::new(endian, e_phoff as u32), e_shoff: U32::new(endian, e_shoff as u32), @@ -495,8 +491,8 @@ impl<'a> Writer<'a> { debug_assert_eq!(self.section_offset, self.buffer.len()); self.write_section_header(&SectionHeader { name: None, - sh_type: 0, - sh_flags: 0, + sh_type: elf::SHT_NULL, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: 0, sh_size: if self.section_num >= elf::SHN_LORESERVE.into() { @@ -542,7 +538,7 @@ impl<'a> Writer<'a> { let section = elf::SectionHeader32 { sh_name: U32::new(endian, sh_name), sh_type: U32::new(endian, section.sh_type), - sh_flags: U32::new(endian, section.sh_flags as u32), + sh_flags: U32::new_u64_truncate(endian, section.sh_flags), sh_addr: U32::new(endian, section.sh_addr as u32), sh_offset: U32::new(endian, section.sh_offset as u32), sh_size: U32::new(endian, section.sh_size as u32), @@ -623,7 +619,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.shstrtab_str_id, sh_type: elf::SHT_STRTAB, - sh_flags: 0, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: self.shstrtab_offset as u64, sh_size: self.shstrtab_data.len() as u64, @@ -716,7 +712,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.strtab_str_id, sh_type: elf::SHT_STRTAB, - sh_flags: 0, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: self.strtab_offset as u64, sh_size: self.strtab_data.len() as u64, @@ -827,11 +823,7 @@ impl<'a> Writer<'a> { 0 }; let st_shndx = if let Some(section) = sym.section { - if section.0 >= elf::SHN_LORESERVE as u32 { - elf::SHN_XINDEX - } else { - section.0 as u16 - } + elf::SymbolSection::new(section.0) } else { sym.st_shndx }; @@ -898,7 +890,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.symtab_str_id, sh_type: elf::SHT_SYMTAB, - sh_flags: 0, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: self.symtab_offset as u64, sh_size: self.symtab_num as u64 * self.class().sym_size() as u64, @@ -986,7 +978,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.symtab_shndx_str_id, sh_type: elf::SHT_SYMTAB_SHNDX, - sh_flags: 0, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: self.symtab_shndx_offset as u64, sh_size, @@ -1100,7 +1092,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.dynstr_str_id, sh_type: elf::SHT_STRTAB, - sh_flags: elf::SHF_ALLOC.into(), + sh_flags: elf::SHF_ALLOC, sh_addr, sh_offset: self.dynstr_offset as u64, sh_size: self.dynstr_data.len() as u64, @@ -1196,13 +1188,9 @@ impl<'a> Writer<'a> { }; let st_shndx = if let Some(section) = sym.section { - if section.0 >= elf::SHN_LORESERVE as u32 { - // TODO: we don't actually write out .dynsym_shndx yet. - // This is unlikely to be needed though. - elf::SHN_XINDEX - } else { - section.0 as u16 - } + // TODO: we don't write out .dynsym_shndx yet. + // This is unlikely to be needed though. + elf::SymbolSection::new(section.0) } else { sym.st_shndx }; @@ -1263,7 +1251,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.dynsym_str_id, sh_type: elf::SHT_DYNSYM, - sh_flags: elf::SHF_ALLOC.into(), + sh_flags: elf::SHF_ALLOC, sh_addr, sh_offset: self.dynsym_offset as u64, sh_size: self.dynsym_num as u64 * self.class().sym_size() as u64, @@ -1306,12 +1294,12 @@ impl<'a> Writer<'a> { } /// Write a dynamic string entry. - pub fn write_dynamic_string(&mut self, tag: i64, id: StringId) -> Result<()> { + pub fn write_dynamic_string(&mut self, tag: elf::DynamicTag, id: StringId) -> Result<()> { self.write_dynamic(tag, self.dynstr.get_offset(id) as u64) } /// Write a dynamic value entry. - pub fn write_dynamic(&mut self, d_tag: i64, d_val: u64) -> Result<()> { + pub fn write_dynamic(&mut self, d_tag: elf::DynamicTag, d_val: u64) -> Result<()> { let endian = self.endian; if self.is_64 { let d = elf::Dyn64 { @@ -1320,14 +1308,13 @@ impl<'a> Writer<'a> { }; self.buffer.write(&d); } else { - let d_tag = d_tag - .try_into() + let d_tag = I32::new_i64(endian, d_tag) .map_err(|_| Error(format!("d_tag overflow: 0x{:x}", d_tag)))?; let d_val = d_val .try_into() .map_err(|_| Error(format!("d_val overflow: 0x{:x}", d_val)))?; let d = elf::Dyn32 { - d_tag: I32::new(endian, d_tag), + d_tag, d_val: U32::new(endian, d_val), }; self.buffer.write(&d); @@ -1352,7 +1339,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.dynamic_str_id, sh_type: elf::SHT_DYNAMIC, - sh_flags: (elf::SHF_WRITE | elf::SHF_ALLOC).into(), + sh_flags: elf::SHF_WRITE | elf::SHF_ALLOC, sh_addr, sh_offset: self.dynamic_offset as u64, sh_size: (self.dynamic_num * self.class().dyn_size()) as u64, @@ -1423,7 +1410,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.hash_str_id, sh_type: elf::SHT_HASH, - sh_flags: elf::SHF_ALLOC.into(), + sh_flags: elf::SHF_ALLOC, sh_addr, sh_offset: self.hash_offset as u64, sh_size: self.hash_size as u64, @@ -1554,7 +1541,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.gnu_hash_str_id, sh_type: elf::SHT_GNU_HASH, - sh_flags: elf::SHF_ALLOC.into(), + sh_flags: elf::SHF_ALLOC, sh_addr, sh_offset: self.gnu_hash_offset as u64, sh_size: self.gnu_hash_size as u64, @@ -1587,11 +1574,11 @@ impl<'a> Writer<'a> { } util::write_align(self.buffer, ALIGN_GNU_VERSYM); debug_assert_eq!(self.gnu_versym_offset, self.buffer.len()); - self.write_gnu_versym(0); + self.write_gnu_versym(elf::VER_NDX_LOCAL.into()); } /// Write a symbol version entry. - pub fn write_gnu_versym(&mut self, versym: u16) { + pub fn write_gnu_versym(&mut self, versym: elf::VersymIndex) { self.buffer.write(&U16::new(self.endian, versym)); } @@ -1617,7 +1604,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.gnu_versym_str_id, sh_type: elf::SHT_GNU_VERSYM, - sh_flags: elf::SHF_ALLOC.into(), + sh_flags: elf::SHF_ALLOC, sh_addr, sh_offset: self.gnu_versym_offset as u64, sh_size: self.class().gnu_versym_size(self.dynsym_num as usize) as u64, @@ -1739,7 +1726,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.gnu_verdef_str_id, sh_type: elf::SHT_GNU_VERDEF, - sh_flags: elf::SHF_ALLOC.into(), + sh_flags: elf::SHF_ALLOC, sh_addr, sh_offset: self.gnu_verdef_offset as u64, sh_size: self.gnu_verdef_size as u64, @@ -1839,7 +1826,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.gnu_verneed_str_id, sh_type: elf::SHT_GNU_VERNEED, - sh_flags: elf::SHF_ALLOC.into(), + sh_flags: elf::SHF_ALLOC, sh_addr, sh_offset: self.gnu_verneed_offset as u64, sh_size: self.gnu_verneed_size as u64, @@ -1886,7 +1873,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: self.gnu_attributes_str_id, sh_type: elf::SHT_GNU_ATTRIBUTES, - sh_flags: 0, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: self.gnu_attributes_offset as u64, sh_size: self.gnu_attributes_size as u64, @@ -1976,7 +1963,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: Some(name), sh_type: if is_rela { elf::SHT_RELA } else { elf::SHT_REL }, - sh_flags: elf::SHF_INFO_LINK.into(), + sh_flags: elf::SHF_INFO_LINK, sh_addr: 0, sh_offset: offset as u64, sh_size: (count * self.class().rel_size(is_rela)) as u64, @@ -2000,7 +1987,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: Some(name), sh_type: elf::SHT_RELA, - sh_flags: 0, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: offset as u64, sh_size: size as u64, @@ -2043,7 +2030,7 @@ impl<'a> Writer<'a> { self.write_section_header(&SectionHeader { name: Some(name), sh_type: elf::SHT_GROUP, - sh_flags: 0, + sh_flags: elf::SectionFlags(0), sh_addr: 0, sh_offset: offset as u64, sh_size: ((count + 1) * 4) as u64, @@ -2107,11 +2094,11 @@ impl AttributesWriter { } /// Start a new sub-subsection with the given tag. - pub fn start_subsubsection(&mut self, tag: u8) { + pub fn start_subsubsection(&mut self, tag: elf::AttributeTag) { debug_assert_ne!(self.subsection_offset, 0); debug_assert_eq!(self.subsubsection_offset, 0); self.subsubsection_offset = self.data.len(); - self.data.push(tag); + self.data.push(tag.0); self.data.extend_from_slice(&[0; 4]); } @@ -2307,20 +2294,20 @@ impl Class { #[allow(missing_docs)] #[derive(Debug, Clone)] pub struct FileHeader { - pub os_abi: u8, + pub os_abi: elf::OsAbi, pub abi_version: u8, - pub e_type: u16, - pub e_machine: u16, + pub e_type: elf::FileType, + pub e_machine: elf::Machine, pub e_entry: u64, - pub e_flags: u32, + pub e_flags: elf::FileFlags, } /// Native endian version of [`elf::ProgramHeader64`]. #[allow(missing_docs)] #[derive(Debug, Clone)] pub struct ProgramHeader { - pub p_type: u32, - pub p_flags: u32, + pub p_type: elf::ProgramType, + pub p_flags: elf::ProgramFlags, pub p_offset: u64, pub p_vaddr: u64, pub p_paddr: u64, @@ -2334,8 +2321,8 @@ pub struct ProgramHeader { #[derive(Debug, Clone)] pub struct SectionHeader { pub name: Option, - pub sh_type: u32, - pub sh_flags: u64, + pub sh_type: elf::SectionType, + pub sh_flags: elf::SectionFlags, pub sh_addr: u64, pub sh_offset: u64, pub sh_size: u64, @@ -2351,9 +2338,9 @@ pub struct SectionHeader { pub struct Sym { pub name: Option, pub section: Option, - pub st_info: u8, - pub st_other: u8, - pub st_shndx: u16, + pub st_info: elf::SymbolInfo, + pub st_other: elf::SymbolOther, + pub st_shndx: elf::SymbolSection, pub st_value: u64, pub st_size: u64, } @@ -2373,8 +2360,8 @@ pub struct Rel { #[derive(Debug, Clone)] pub struct Verdef { pub version: u16, - pub flags: u16, - pub index: u16, + pub flags: elf::VersionFlags, + pub index: elf::VersionIndex, pub aux_count: u16, /// The name for the first [`elf::Verdaux`] entry. pub name: StringId, @@ -2393,7 +2380,7 @@ pub struct Verneed { #[allow(missing_docs)] #[derive(Debug, Clone)] pub struct Vernaux { - pub flags: u16, - pub index: u16, + pub flags: elf::VersionFlags, + pub index: elf::VersionIndex, pub name: StringId, } diff --git a/tests/build/elf.rs b/tests/build/elf.rs index 53979ee1..ed2c5192 100644 --- a/tests/build/elf.rs +++ b/tests/build/elf.rs @@ -15,7 +15,7 @@ fn test_nobits_offset() { let section = builder.sections.add(); section.name = b".bss"[..].into(); section.sh_type = elf::SHT_NOBITS; - section.sh_flags = (elf::SHF_ALLOC | elf::SHF_WRITE) as u64; + section.sh_flags = elf::SHF_ALLOC | elf::SHF_WRITE; section.sh_addr = 0x1000; section.sh_offset = 0; section.sh_size = 0x1000; @@ -54,7 +54,7 @@ fn test_no_dynstr() { let section = builder.sections.add(); section.name = b".dynsym"[..].into(); section.sh_type = elf::SHT_DYNSYM; - section.sh_flags = elf::SHF_ALLOC as u64; + section.sh_flags = elf::SHF_ALLOC; section.sh_addralign = 8; section.data = build::elf::SectionData::DynamicSymbol; let dynsym_id = section.id(); @@ -62,7 +62,7 @@ fn test_no_dynstr() { let section = builder.sections.add(); section.name = b".rela.dyn"[..].into(); section.sh_type = elf::SHT_RELA; - section.sh_flags = elf::SHF_ALLOC as u64; + section.sh_flags = elf::SHF_ALLOC; section.sh_addralign = 8; section.data = build::elf::SectionData::DynamicRelocation(vec![build::elf::DynamicRelocation { @@ -121,7 +121,7 @@ fn test_attribute() { vendor: b"GNU"[..].into(), subsubsections: vec![ (build::elf::AttributesSubsubsection { - tag: build::elf::AttributeTag::File, + scope: build::elf::AttributeScope::File, data: b"123"[..].into(), }), ], @@ -144,8 +144,8 @@ fn test_attribute() { assert_eq!(attributes.subsections[0].vendor.as_slice(), b"GNU"); assert_eq!(attributes.subsections[0].subsubsections.len(), 1); assert_eq!( - attributes.subsections[0].subsubsections[0].tag, - build::elf::AttributeTag::File + attributes.subsections[0].subsubsections[0].scope, + build::elf::AttributeScope::File ); assert_eq!( attributes.subsections[0].subsubsections[0].data.as_slice(), @@ -170,7 +170,7 @@ fn test_dynsym() { let section = builder.sections.add(); section.name = b".text"[..].into(); section.sh_type = elf::SHT_PROGBITS; - section.sh_flags = (elf::SHF_ALLOC | elf::SHF_EXECINSTR) as u64; + section.sh_flags = elf::SHF_ALLOC | elf::SHF_EXECINSTR; section.sh_addralign = 16; section.data = build::elf::SectionData::Data(vec![0xcc; 100].into()); let text_id = section.id(); @@ -178,7 +178,7 @@ fn test_dynsym() { let section = builder.sections.add(); section.name = b".dynsym"[..].into(); section.sh_type = elf::SHT_DYNSYM; - section.sh_flags = elf::SHF_ALLOC as u64; + section.sh_flags = elf::SHF_ALLOC; section.sh_addralign = 8; section.data = build::elf::SectionData::DynamicSymbol; let dynsym_id = section.id(); @@ -186,7 +186,7 @@ fn test_dynsym() { let section = builder.sections.add(); section.name = b".dynstr"[..].into(); section.sh_type = elf::SHT_STRTAB; - section.sh_flags = elf::SHF_ALLOC as u64; + section.sh_flags = elf::SHF_ALLOC; section.sh_addralign = 1; section.data = build::elf::SectionData::DynamicString; let dynstr_id = section.id(); @@ -194,7 +194,7 @@ fn test_dynsym() { let section = builder.sections.add(); section.name = b".gnu.hash"[..].into(); section.sh_type = elf::SHT_GNU_HASH; - section.sh_flags = elf::SHF_ALLOC as u64; + section.sh_flags = elf::SHF_ALLOC; section.sh_addralign = 8; section.data = build::elf::SectionData::GnuHash; let gnu_hash_id = section.id(); diff --git a/tests/round_trip/elf.rs b/tests/round_trip/elf.rs index bebcbe16..c8ef5674 100644 --- a/tests/round_trip/elf.rs +++ b/tests/round_trip/elf.rs @@ -117,7 +117,7 @@ fn compression_zlib() { let object::SectionFlags::Elf { sh_flags, .. } = object.section_flags_mut(section) else { unreachable!(); }; - *sh_flags = object::elf::SHF_COMPRESSED.into(); + *sh_flags = object::elf::SHF_COMPRESSED; let bytes = object.write().unwrap(); @@ -289,7 +289,7 @@ fn gnu_property_inner>(architecture: Archit sections.section_name(endian, section).unwrap(), b".note.gnu.property" ); - assert_eq!(section.sh_flags(endian).into(), u64::from(elf::SHF_ALLOC)); + assert_eq!(section.sh_flags(endian), elf::SHF_ALLOC); let mut notes = section.notes(endian, bytes).unwrap().unwrap(); let note = notes.next().unwrap().unwrap(); let mut props = note.gnu_properties(endian).unwrap(); diff --git a/tests/round_trip/mod.rs b/tests/round_trip/mod.rs index 20e7d39c..09e37597 100644 --- a/tests/round_trip/mod.rs +++ b/tests/round_trip/mod.rs @@ -218,7 +218,7 @@ fn elf_x86_64() { text.flags(), SectionFlags::Elf { sh_type: object::elf::SHT_PROGBITS, - sh_flags: (object::elf::SHF_ALLOC | object::elf::SHF_EXECINSTR).into() + sh_flags: object::elf::SHF_ALLOC | object::elf::SHF_EXECINSTR, } ); assert_eq!(&text.data().unwrap()[..30], &[1; 30]); @@ -237,7 +237,7 @@ fn elf_x86_64() { section.flags(), SectionFlags::Elf { sh_type: object::elf::SHT_X86_64_UNWIND, - sh_flags: object::elf::SHF_ALLOC.into() + sh_flags: object::elf::SHF_ALLOC, } ); diff --git a/tests/round_trip/section_flags.rs b/tests/round_trip/section_flags.rs index 7799219e..a51abd9f 100644 --- a/tests/round_trip/section_flags.rs +++ b/tests/round_trip/section_flags.rs @@ -40,7 +40,7 @@ fn elf_x86_64_section_flags() { let SectionFlags::Elf { sh_flags, .. } = object.section_flags_mut(section) else { unreachable!(); }; - *sh_flags = object::elf::SHF_WRITE.into(); + *sh_flags = object::elf::SHF_WRITE; let bytes = object.write().unwrap(); @@ -55,7 +55,7 @@ fn elf_x86_64_section_flags() { section.flags(), SectionFlags::Elf { sh_type: object::elf::SHT_PROGBITS, - sh_flags: object::elf::SHF_WRITE.into(), + sh_flags: object::elf::SHF_WRITE, } ); }