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 {
23 0 : ptr,
24 0 : }
25 0 : }
26 : }
27 :
28 : impl Operand for PCRelative {
29 : #[doc(hidden)]
30 0 : fn as_generic(&self) -> &ffi::asm_x86_Operand {
31 0 : self.ptr.as_ref().unwrap().as_ref()
32 0 : }
33 : }
34 :
35 : impl PCRelative {
36 : /// The effective value that is relative to the current `rip/eip` register
37 0 : pub fn value(&self) -> i64 {
38 0 : self.ptr.value()
39 0 : }
40 : }
|