From 4e37745873c790af4cfef5c3afc2e817aa4dd40d Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Fri, 25 Aug 2023 15:18:00 -0700 Subject: [PATCH] Add FreeBSD ELF detection --- src/ELF/ELFHandle.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ELF/ELFHandle.jl b/src/ELF/ELFHandle.jl index 2bebde6..1b34e0c 100644 --- a/src/ELF/ELFHandle.jl +++ b/src/ELF/ELFHandle.jl @@ -72,7 +72,16 @@ end ## Format-specific properties: header(oh::ELFHandle) = oh.header -Platform(oh::ELFHandle) = strip_libc_tag(Platform(elf_machine_to_arch(oh.header.e_machine), "linux")) +function Platform(oh::ELFHandle) + arch = elf_machine_to_arch(oh.header.e_machine) + if oh.ei.osabi == ELFOSABI_LINUX || oh.ei.osabi == ELFOSABI_NONE + return strip_libc_tag(Platform(arch, "linux")) + elseif oh.ei.osabi == ELFOSABI_FREEBSD + return Platform(arch, "freebsd") + else + throw(ArgumentError("Unknown ELF OSABI $(oh.ei.osabi)")) + end +end endianness(oh::ELFHandle) = elf_internal_endianness(oh.ei) is64bit(oh::ELFHandle) = elf_internal_is64bit(oh.ei) isrelocatable(oh::ELFHandle) = header(oh).e_type == ET_REL