Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileFlags::Elf: Add os_abi #438

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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