aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser/lua-scripts/demo1.lua
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-01-12 15:06:46 +0000
committerbloodstalker <thabogre@gmail.com>2018-01-12 15:06:46 +0000
commit575615c5a41592f3701853f90e1762c6dce4abe4 (patch)
treefca52890bb597c587441db1a99a1d16c63f98694 /bruiser/lua-scripts/demo1.lua
parentupdate (diff)
downloadmutator-575615c5a41592f3701853f90e1762c6dce4abe4.tar.gz
mutator-575615c5a41592f3701853f90e1762c6dce4abe4.zip
you can now run objects that are loaded into bruiser from a shared library from lua. right now very simple examples work. i have to figure out how to handles runtime pointer recasts.
Diffstat (limited to 'bruiser/lua-scripts/demo1.lua')
-rw-r--r--bruiser/lua-scripts/demo1.lua36
1 files changed, 35 insertions, 1 deletions
diff --git a/bruiser/lua-scripts/demo1.lua b/bruiser/lua-scripts/demo1.lua
index de83431..eb55acb 100644
--- a/bruiser/lua-scripts/demo1.lua
+++ b/bruiser/lua-scripts/demo1.lua
@@ -81,8 +81,34 @@ function codeTableByName(name)
return nil
end
+function codeTableByName_number(name)
+ local return_table = {}
+ local func_name_table = objload("elf_get_func_names", "../bfd/test/test.so", "symbol_list")
+ local code_table = objload("elf_get_func_code", "../bfd/test/test.so", "code_list")
+ for k,v in ipairs(func_name_table) do
+ if v == name then
+ for k1, v1 in ipairs(code_table[k]) do
+ table.insert(return_table, v1)
+ end
+ return return_table
+ end
+ end
+ return nil
+end
+
+function printFuncSizes()
+ local func_name_table = objload("elf_get_func_names", "../bfd/test/test.so", "symbol_list")
+ local code_table = objload("elf_get_func_code", "../bfd/test/test.so", "code_list")
+ local counter = 1
+ print("function sizes:")
+ for k, v in ipairs(code_table) do
+ print("code size for "..func_name_table[counter].." is".." "..#v)
+ counter = counter + 1
+ end
+end
+
-- start of @placeholder
-function XobjRegister(code_table, registration_name)
+function xobjRegister(code_table, registration_name)
-- lightuserdata
local Xobjpointer
return Xobjpointer
@@ -110,6 +136,14 @@ function main()
io.write(v, " ")
end
io.write("\n")
+
+ local add2_code = codeTableByName_number("'add2'")
+ local sub2_code = codeTableByName_number("'sub2'")
+
+ printFuncSizes()
+
+ xobjregister(add2_code, "add2")
+ xobjregister(sub2_code, "sub2")
end
main()