Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use crate::common::FromFFI;
4 :
5 : use super::Operand;
6 :
7 : /// This structure represents a RIP/EIP-relative operand.
8 : ///
9 : /// For instance:
10 : ///
11 : /// ```text
12 : /// jmp 67633;
13 : /// |
14 : /// +----------> PCRelative(67633)
15 : /// ```
16 : pub struct PCRelative {
17 : ptr: cxx::UniquePtr<ffi::asm_x86_operands_PCRelative>,
18 : }
19 :
20 : impl FromFFI<ffi::asm_x86_operands_PCRelative> for PCRelative {
21 0 : fn from_ffi(ptr: cxx::UniquePtr<ffi::asm_x86_operands_PCRelative>) -> Self {
22 0 : Self { ptr }
23 0 : }
24 : }
25 :
26 : impl Operand for PCRelative {
27 : #[doc(hidden)]
28 0 : fn as_generic(&self) -> &ffi::asm_x86_Operand {
29 0 : self.ptr.as_ref().unwrap().as_ref()
30 0 : }
31 : }
32 :
33 : impl PCRelative {
34 : /// The effective value that is relative to the current `rip/eip` register
35 0 : pub fn value(&self) -> i64 {
36 0 : self.ptr.value()
37 0 : }
38 : }
|