#![allow(clippy::type_complexity)]
#![warn(
clippy::unnecessary_lazy_evaluations,
clippy::collapsible_if,
clippy::explicit_iter_loop,
clippy::manual_assert,
clippy::needless_question_mark,
clippy::needless_return,
clippy::needless_update,
clippy::redundant_clone,
clippy::redundant_else,
clippy::redundant_static_lifetimes
)]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(all(feature = "std", feature = "use-syscall"))]
compile_error!("feature \"std\" and feature \"use-syscall\" cannot be enabled at the same time");
pub mod api;
mod core_impl;
mod error;
mod os;
mod utils;
use bitflags::bitflags;
pub use crate::api::dlsym::{dlsym_default, dlsym_next};
pub use crate::core_impl::loader::ElfLibrary;
pub use crate::core_impl::traits::AsFilename;
pub use crate::error::Error;
pub use elf_loader::image::Symbol;
#[cfg(not(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
)))]
compile_error!("unsupport arch");
bitflags! {
#[derive(Clone, Copy, Debug)]
pub struct OpenFlags:u32{
const RTLD_LOCAL = 0;
const RTLD_LAZY = 1;
const RTLD_NOW = 2;
const RTLD_NOLOAD = 4;
const RTLD_DEEPBIND = 8;
const RTLD_GLOBAL = 256;
const RTLD_NODELETE = 4096;
}
}
impl OpenFlags {
pub(crate) fn is_global(&self) -> bool {
self.contains(OpenFlags::RTLD_GLOBAL)
}
pub(crate) fn is_nodelete(&self) -> bool {
self.contains(OpenFlags::RTLD_NODELETE)
}
pub(crate) fn is_now(&self) -> bool {
self.contains(OpenFlags::RTLD_NOW)
}
pub(crate) fn is_noload(&self) -> bool {
self.contains(OpenFlags::RTLD_NOLOAD)
}
pub(crate) fn is_lazy(&self) -> bool {
self.contains(OpenFlags::RTLD_LAZY)
}
pub(crate) fn is_deepbind(&self) -> bool {
self.contains(OpenFlags::RTLD_DEEPBIND)
}
pub(crate) fn promotable(&self) -> OpenFlags {
*self & (OpenFlags::RTLD_GLOBAL | OpenFlags::RTLD_NODELETE)
}
}
pub type Result<T> = core::result::Result<T, Error>;