Skip to content

Commit

Permalink
Add abi_version to FileFlags::Elf (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Jun 6, 2022
1 parent 7bf9f8e commit 6f39788
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/examples/testfiles/elf/base-strip.objdump
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Format: Elf Little-endian 64-bit
Kind: Dynamic
Architecture: X86_64
Flags: Elf { os_abi: 0, e_flags: 0 }
Flags: Elf { os_abi: 0, 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]
Expand Down
2 changes: 1 addition & 1 deletion crates/examples/testfiles/elf/base.o.objdump
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Format: Elf Little-endian 64-bit
Kind: Relocatable
Architecture: X86_64
Flags: Elf { os_abi: 0, e_flags: 0 }
Flags: Elf { os_abi: 0, abi_version: 0, e_flags: 0 }
Relative Address Base: 0
Entry Address: 0
0: Section { name: "", address: 0, size: 0, align: 0, kind: Metadata, flags: Elf { sh_flags: 0 } }
Expand Down
2 changes: 1 addition & 1 deletion crates/examples/testfiles/elf/base.objdump
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Format: Elf Little-endian 64-bit
Kind: Dynamic
Architecture: X86_64
Flags: Elf { os_abi: 0, e_flags: 0 }
Flags: Elf { os_abi: 0, 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]
Expand Down
2 changes: 2 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ pub enum FileFlags {
Elf {
/// `os_abi` field in the ELF file header.
os_abi: u8,
/// `abi_version` field in the ELF file header.
abi_version: u8,
/// `e_flags` field in the ELF file header.
e_flags: u32,
},
Expand Down
1 change: 1 addition & 0 deletions src/read/elf/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ where
fn flags(&self) -> FileFlags {
FileFlags::Elf {
os_abi: self.header.e_ident().os_abi,
abi_version: self.header.e_ident().abi_version,
e_flags: self.header.e_flags(self.endian),
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/write/elf/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,19 @@ impl<'a> Object<'a> {
)));
}
};
let (os_abi, e_flags) = if let FileFlags::Elf { os_abi, e_flags } = self.flags {
(os_abi, e_flags)
let (os_abi, abi_version, e_flags) = if let FileFlags::Elf {
os_abi,
abi_version,
e_flags,
} = self.flags
{
(os_abi, abi_version, e_flags)
} else {
(elf::ELFOSABI_NONE, 0)
(elf::ELFOSABI_NONE, 0, 0)
};
writer.write_file_header(&FileHeader {
os_abi,
abi_version: 0,
abi_version,
e_type,
e_machine,
e_entry: 0,
Expand Down

0 comments on commit 6f39788

Please sign in to comment.