x86_64 call & ret
This commit is contained in:
@@ -106,6 +106,15 @@ impl Encoder {
|
||||
self.data.extend([0x0f, 0x05])
|
||||
}
|
||||
|
||||
pub fn call(&mut self, sym: Symbol) {
|
||||
self.data.push(0xe8);
|
||||
self.sym_offset4(sym);
|
||||
}
|
||||
|
||||
pub fn ret(&mut self) {
|
||||
self.data.push(0xc3);
|
||||
}
|
||||
|
||||
/// inserts a 32 bit offset from a symbol
|
||||
pub fn sym_offset4(&mut self, sym: Symbol) {
|
||||
let Some(addr) = self.sym_tab.get(sym) else {
|
||||
@@ -123,6 +132,8 @@ impl Encoder {
|
||||
Instr::Int { code } => self.int(code),
|
||||
Instr::Syscall => self.syscall(),
|
||||
Instr::Lea { dst, sym } => self.lea(dst, sym),
|
||||
Instr::Call(sym) => self.call(sym),
|
||||
Instr::Ret => self.ret(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user