retour\pic/mod.rs
1pub use self::emitter::CodeEmitter;
2pub use self::thunk::{FixedThunk, UnsafeThunk};
3
4mod emitter;
5mod thunk;
6
7/// An interface for generating PIC thunks.
8pub trait Thunkable {
9 /// Generates the code at the specified address.
10 fn generate(&self, address: usize) -> Vec<u8>;
11
12 /// Returns the size of a generated thunk.
13 fn len(&self) -> usize;
14}
15
16/// Thunkable implementation for static data
17impl Thunkable for Vec<u8> {
18 /// Generates a static thunk assumed to be PIC
19 fn generate(&self, _address: usize) -> Vec<u8> {
20 self.clone()
21 }
22
23 /// Returns the size of a generated thunk
24 fn len(&self) -> usize {
25 self.len()
26 }
27}