Skip to content

Commit

Permalink
FileFlags::Elf: Add os_abi (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening authored Jun 6, 2022
1 parent b706982 commit 7bf9f8e
Show file tree
Hide file tree
Showing 6 changed files with 10 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 { e_flags: 0 }
Flags: Elf { os_abi: 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 { e_flags: 0 }
Flags: Elf { os_abi: 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 { e_flags: 0 }
Flags: Elf { os_abi: 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 @@ -353,6 +353,8 @@ pub enum FileFlags {
None,
/// ELF file flags.
Elf {
/// `os_abi` field in the ELF file header.
os_abi: 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 @@ -419,6 +419,7 @@ where

fn flags(&self) -> FileFlags {
FileFlags::Elf {
os_abi: self.header.e_ident().os_abi,
e_flags: self.header.e_flags(self.endian),
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/write/elf/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ impl<'a> Object<'a> {
)));
}
};
let e_flags = if let FileFlags::Elf { e_flags } = self.flags {
e_flags
let (os_abi, e_flags) = if let FileFlags::Elf { os_abi, e_flags } = self.flags {
(os_abi, e_flags)
} else {
0
(elf::ELFOSABI_NONE, 0)
};
writer.write_file_header(&FileHeader {
os_abi: elf::ELFOSABI_NONE,
os_abi,
abi_version: 0,
e_type,
e_machine,
Expand Down

0 comments on commit 7bf9f8e

Please sign in to comment.