lib/pwnlib/shellcraft/generators/amd64/common/ret.rb
# encoding: ASCII-8BIT
# frozen_string_literal: true
require 'pwnlib/shellcraft/generators/amd64/common/common'
require 'pwnlib/shellcraft/generators/amd64/common/mov'
module Pwnlib
module Shellcraft
module Generators
module Amd64
module Common
# Instruction return.
#
# @param [String, Symbol, Integer] return_value
# Set the return value.
# Can be name of a register or an immediate value.
# +nil+ for not set return value.
#
# @example
# context.arch = 'amd64'
# shellcraft.ret
# #=> " ret"
# shellcraft.ret(:rdi)
# #=> " mov rax, rdi\n ret\n"
def ret(return_value = nil)
cat Common.mov('rax', return_value) if return_value
cat 'ret'
end
end
end
end
end
end