From 531670d6c5804cad90673b0e7daecf603fd8e275 Mon Sep 17 00:00:00 2001 From: occheung Date: Mon, 8 Nov 2021 13:03:17 +0800 Subject: [PATCH] dyld: check ABI --- artiq/firmware/libdyld/elf.rs | 6 ++++++ artiq/firmware/libdyld/lib.rs | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/artiq/firmware/libdyld/elf.rs b/artiq/firmware/libdyld/elf.rs index d8712b9fd..a10d9b4c3 100644 --- a/artiq/firmware/libdyld/elf.rs +++ b/artiq/firmware/libdyld/elf.rs @@ -2230,6 +2230,12 @@ pub const R_OR1K_TLS_TPOFF: u8 = 32; pub const R_OR1K_TLS_DTPOFF: u8 = 33; pub const R_OR1K_TLS_DTPMOD: u8 = 34; pub const R_OR1K_NUM: u8 = 35; +pub const EF_RISCV_RVC: u32 = 1; +pub const EF_RISCV_FLOAT_ABI: u32 = 6; +pub const EF_RISCV_FLOAT_ABI_SOFT: u32 = 0; +pub const EF_RISCV_FLOAT_ABI_SINGLE: u32 = 2; +pub const EF_RISCV_FLOAT_ABI_DOUBLE: u32 = 4; +pub const EF_RISCV_FLOAT_ABI_QUAD: u32 = 6; pub const R_RISCV_NONE: u8 = 0; pub const R_RISCV_32: u8 = 1; pub const R_RISCV_64: u8 = 2; diff --git a/artiq/firmware/libdyld/lib.rs b/artiq/firmware/libdyld/lib.rs index 1fec38959..1d89edaee 100644 --- a/artiq/firmware/libdyld/lib.rs +++ b/artiq/firmware/libdyld/lib.rs @@ -219,7 +219,13 @@ impl<'a> Library<'a> { #[cfg(not(target_arch = "riscv32"))] const ARCH: u16 = EM_NONE; - if ehdr.e_ident != IDENT || ehdr.e_type != ET_DYN || ehdr.e_machine != ARCH { + #[cfg(all(target_feature = "f", target_feature = "d"))] + const FLAGS: u32 = EF_RISCV_FLOAT_ABI_DOUBLE; + + #[cfg(not(all(target_feature = "f", target_feature = "d")))] + const FLAGS: u32 = EF_RISCV_FLOAT_ABI_SOFT; + + if ehdr.e_ident != IDENT || ehdr.e_type != ET_DYN || ehdr.e_machine != ARCH || ehdr.e_flags != FLAGS { return Err("not a shared library for current architecture")? }