Skip to content

Commit 2dce787

Browse files
authored
Merge pull request #42 from staticfloat/sf/platform_extraction
Add FreeBSD ELF detection
2 parents 68cb7f5 + 4e37745 commit 2dce787

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ELF/ELFHandle.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,16 @@ end
7272

7373
## Format-specific properties:
7474
header(oh::ELFHandle) = oh.header
75-
Platform(oh::ELFHandle) = strip_libc_tag(Platform(elf_machine_to_arch(oh.header.e_machine), "linux"))
75+
function Platform(oh::ELFHandle)
76+
arch = elf_machine_to_arch(oh.header.e_machine)
77+
if oh.ei.osabi == ELFOSABI_LINUX || oh.ei.osabi == ELFOSABI_NONE
78+
return strip_libc_tag(Platform(arch, "linux"))
79+
elseif oh.ei.osabi == ELFOSABI_FREEBSD
80+
return Platform(arch, "freebsd")
81+
else
82+
throw(ArgumentError("Unknown ELF OSABI $(oh.ei.osabi)"))
83+
end
84+
end
7685
endianness(oh::ELFHandle) = elf_internal_endianness(oh.ei)
7786
is64bit(oh::ELFHandle) = elf_internal_is64bit(oh.ei)
7887
isrelocatable(oh::ELFHandle) = header(oh).e_type == ET_REL

0 commit comments

Comments
 (0)