A PHP Error was encountered

Severity: Warning

Message: mkdir(): File exists

Filename: libraries/menu.php

Line Number: 500

A PHP Error was encountered

Severity: Warning

Message: file_put_contents(/var/www/html/contents/menus/h_blogs/b_purenode/views/introduction to tpo binary module_0): failed to open stream: No such file or directory

Filename: libraries/menu.php

Line Number: 505

iadix blockchain platform - blogs introduction aux modules tpo fr

Iadix HTML 5.0 multichain technologie
Blockchain, solutions économiques et commerce en ligne
Une blockchain pour les relier toutes

blogs purenode article fr

tags


translate en to fr

introduction aux modules tpo

autheur:BitAdmin (Enregistré)
articles:9
inscription:15/01/16 22:18


TPO BINARY MODULES

 

1. Why tpo modules ?

 

The motivation for developping my own dynamically linked position independant binary module was in the course of developping an operating system project, and i wanted to avoid dependency on a particular compiler or systeme architecture but still being able to compile and link binary executable and dynamically loaded binary libraries able to be loaded and executed by simplistic micro kernel architecture.

 

The main issue with both dll and elf (.so) files is that they are both tightly related to an operating system, and C or C++ code using standard c library and runtime depend on a particular compiler runtime, which depend on the host system kernel api, it's the case for both gcc whose major requirement is to be able to compile linux kernel, and linux or unix binaries, with gcc runtime using syscall and kernel calls specific to unix, or visual studio producing dll also dependent on their own runtime, it's a problem well known that it's often very hard to link a binary library produced with one compiler environment with an executable compiled with another compiler and runtime version, even when the ABI used is the same, and it become even more complex if a binary .so compiled under linux would have to be loaded and linked with a binary dll produced with visual studio on windows.

 

Tpo module are an effort to work around the tight relation between operating system, compiler, and binary code, to have binary code that can be loaded without having the need of a particular runtime or kernel.

 

 

2. How to create tpo modules ?

 

The only tool needed to produce tpo module is "modmaker", which is a command line tools that convert a dll or a .so into a binary module. It read all the sections, the imported and exported symbol, as well as rellocation table, and write it into a binary format that can be loaded by the libcon runtime on any intel x86 32 bit system (or x64 with x32 emulation, no support for x64 yet).

 

 

To create a tpo from a .so or dll, just run the command 'modmaker myfile.so/dll [output directory]' and it will output a tpo file. The only restriction is the dynamic loader doesn't handle non initialized section, because code reference to non initialized data point to location that are not in the binary, and it had to be loaded 'in place' as position independant code without any allocation (the allocator is in a tpo module).

 

 

The output should look like this for example for the rpc module that handle the request for the javascript wallet :

 

using file : C:/bitstream/serv/export/rpc_wallet.dll -> C:/bitstream/serv/export/modz/ 

 

PE HEADER Symbols : 0 , 0 flag : 2102

import table : 68b8 - 80

function name : _tree_manager_get_child_value_i64@12
reloc addr : 00000080@00006000 => 6ec2
function name : _tree_manager_get_node_hash@12
reloc addr : 00000084@00006000 => 6ea0
function name : _tree_manager_write_node_btcaddr@12
reloc addr : 00000088@00006000 => 6e7a
function name : _tree_manager_set_child_value_float@16
reloc addr : 0000008c@00006000 => 6e50
function name : _tree_manager_node_add_child@8
reloc addr : 00000090@00006000 => 6e2e
function name : _tree_manager_create_node@12
reloc addr : 00000094@00006000 => 6e0e
function name : _tree_manager_set_child_value_hash@12
reloc addr : 00000098@00006000 => 6de6
function name : _tree_manager_get_node_istr@16
reloc addr : 0000009c@00006000 => 6dc4
function name : _tree_manager_get_child_value_i16@12
reloc addr : 000000a0@00006000 => 6d9c
function name : _tree_manager_add_child_node@16
reloc addr : 000000a4@00006000 => 6d7a
function name : _tree_manager_write_node_sig@16
reloc addr : 000000a8@00006000 => 6d58
function name : _tree_manager_set_child_value_btcaddr@12
reloc addr : 000000ac@00006000 => 6d2c
function name : _tree_manager_get_child_value_i32@12
reloc addr : 000000b0@00006000 => 6d04
function name : _tree_manager_set_child_value_bhash@12
reloc addr : 000000b4@00006000 => 6a74
function name : _tree_mamanger_get_node_dword@12
reloc addr : 000000b8@00006000 => 6ce0
function name : _tree_manager_set_child_value_i32@12
reloc addr : 000000bc@00006000 => 6cb8
function name : _tree_find_child_node_by_member_name_hash@20
reloc addr : 000000c0@00006000 => 6c88
function name : _tree_manager_set_child_value_str@12
reloc addr : 000000c4@00006000 => 6c60
function name : _tree_manager_get_node_num_children@4
reloc addr : 000000c8@00006000 => 6c38
function name : _tree_manager_get_child_value_str@20
reloc addr : 000000cc@00006000 => 6c10
function name : _tree_manager_find_child_node@16
reloc addr : 000000d0@00006000 => 6bec
function name : _tree_manager_set_child_value_i64@16
reloc addr : 000000d4@00006000 => 6bc4
function name : _tree_manager_get_child_value_btcaddr@12
reloc addr : 000000d8@00006000 => 6b98
function name : _tree_manager_get_child_at@12
reloc addr : 000000dc@00006000 => 6b78
function name : _tree_manager_get_child_value_istr@16
reloc addr : 000000e0@00006000 => 6b50
function name : _tree_manager_get_next_child@8
reloc addr : 000000e4@00006000 => 6b2e
function name : _tree_manager_get_first_child@12
reloc addr : 000000e8@00006000 => 6b0a
function name : _tree_manager_get_node_btcaddr@12
reloc addr : 000000ec@00006000 => 6ae6
function name : _tree_manager_get_node_str@20
reloc addr : 000000f0@00006000 => 6ac6
function name : _tree_manager_get_child_value_hash@12
reloc addr : 000000f4@00006000 => 6a9e
function name : _rm_dir@4
reloc addr : 000000fc@00006000 => 70c0
function name : _malloc_c@4
reloc addr : 00000100@00006000 => 70b2
function name : _strncmp_c@12
reloc addr : 00000104@00006000 => 70a2
function name : _free_c@4
reloc addr : 00000108@00006000 => 7096
function name : _cat_cstring_p@8
reloc addr : 0000010c@00006000 => 7082
function name : _memchr_c@12
reloc addr : 00000110@00006000 => 7072
function name : _get_sub_files@8
reloc addr : 00000114@00006000 => 705e
function name : _get_tpo_mod_exp_addr_name@12
reloc addr : 00000118@00006000 => 703e
function name : _create_dir@4
reloc addr : 0000011c@00006000 => 702e
function name : _clone_string@8
reloc addr : 00000120@00006000 => 701c
function name : _get_time_c@0
reloc addr : 00000124@00006000 => 700c
function name : calc_crc32_c
reloc addr : 00000128@00006000 => 6ffc
function name : _get_sub_dirs@8
reloc addr : 0000012c@00006000 => 6fda
function name : _del_file@4
reloc addr : 00000130@00006000 => 6fcc
function name : _memcmp_c@12
reloc addr : 00000134@00006000 => 6fbc
function name : _strtoul_c@12
reloc addr : 00000138@00006000 => 6fac
function name : _cat_ncstring_p@12
reloc addr : 0000013c@00006000 => 6f96
function name : _free_string@4
reloc addr : 00000140@00006000 => 6f84
function name : _memset_c@12
reloc addr : 00000144@00006000 => 6f74
function name : _memcpy_c@12
reloc addr : 00000148@00006000 => 6f64
function name : _copy_zone_ref@8
reloc addr : 0000014c@00006000 => 6f50
function name : _stat_file@4
reloc addr : 00000150@00006000 => 6f40
function name : _make_string@8
reloc addr : 00000154@00006000 => 6f2e
function name : _append_file@12
reloc addr : 00000158@00006000 => 6f1c
function name : _muldiv64@24
reloc addr : 0000015c@00006000 => 6f0c
function name : _release_zone_ref@4
reloc addr : 00000160@00006000 => 6ef6
function name : _get_file@12
reloc addr : 00000164@00006000 => 6fec
function name : _get_block_size@8
reloc addr : 00000000@00006000 => 7108
function name : _compute_tx_sign_hash@20
reloc addr : 00000004@00006000 => 70ec
function name : _tx_add_input@16
reloc addr : 00000008@00006000 => 70d8
function name : _get_blk_height@8
reloc addr : 0000000c@00006000 => 7134
function name : _is_vout_null@8
reloc addr : 00000010@00006000 => 7148
function name : _mul_compact@16
reloc addr : 00000014@00006000 => 715a
function name : _cmp_hashle@8
reloc addr : 00000018@00006000 => 716c
function name : _compute_block_hash@8
reloc addr : 0000001c@00006000 => 717c
function name : _get_tx_output@12
reloc addr : 00000020@00006000 => 7194
function name : _new_transaction@12
reloc addr : 00000024@00006000 => 71a8
function name : _get_tx_output_amount@12
reloc addr : 00000028@00006000 => 71be
function name : _add_unspent@28
reloc addr : 0000002c@00006000 => 71da
function name : _parse_sig_seq@16
reloc addr : 00000030@00006000 => 71ec
function name : _get_out_script_address@12
reloc addr : 00000034@00006000 => 7200
function name : _is_pow_block@4
reloc addr : 00000038@00006000 => 721e
function name : _get_last_block_height@0
reloc addr : 0000003c@00006000 => 7230
function name : _load_tx_addresses@8
reloc addr : 00000040@00006000 => 724c
function name : _get_pow_block@8
reloc addr : 00000044@00006000 => 7264
function name : _is_tx_null@4
reloc addr : 00000048@00006000 => 7278
function name : _get_tx_input@12
reloc addr : 0000004c@00006000 => 7288
function name : _key_to_addr@8
reloc addr : 00000050@00006000 => 729c
function name : _get_moneysupply@4
reloc addr : 00000054@00006000 => 72ae
function name : _load_tx@12
reloc addr : 00000058@00006000 => 72c4
function name : _spend_tx_addr@28
reloc addr : 0000005c@00006000 => 72d2
function name : _tx_sign@16
reloc addr : 00000060@00006000 => 72e6
function name : _get_blk_txs@8
reloc addr : 00000064@00006000 => 72f4
function name : _tx_add_output@16
reloc addr : 00000068@00006000 => 7306
function name : _blk_check_sign@12
reloc addr : 0000006c@00006000 => 731a
function name : _SetCompact@8
reloc addr : 00000070@00006000 => 7330
function name : _get_tx_output_addr@12
reloc addr : 00000074@00006000 => 7340
function name : _get_tx_blk_height@16
reloc addr : 00000078@00006000 => 711c

export table : 6630 - 647

export table name : rpc_wallet - functions : 22 - names : 22 

name : _getaddressscanstatus@12@rpc_wallet - func addr: 0x00001e80 0x00001000 - ordinal : 1
name : _getblockcount@12@rpc_wallet - func addr: 0x000026a0 0x00001000 - ordinal : 2
name : _getinfo@12@rpc_wallet - func addr: 0x00002380 0x00001000 - ordinal : 3
name : _getlastblock@12@rpc_wallet - func addr: 0x00002070 0x00001000 - ordinal : 4
name : _getprivaddr@12@rpc_wallet - func addr: 0x00005580 0x00001000 - ordinal : 5
name : _getpubaddrs@12@rpc_wallet - func addr: 0x00005710 0x00001000 - ordinal : 6
name : _getstaketx@12@rpc_wallet - func addr: 0x00004ac0 0x00001000 - ordinal : 7
name : _getstaking@12@rpc_wallet - func addr: 0x00004f60 0x00001000 - ordinal : 8
name : _importaddress@12@rpc_wallet - func addr: 0x000026d0 0x00001000 - ordinal : 9
name : _importkeypair@12@rpc_wallet - func addr: 0x00005150 0x00001000 - ordinal : 10
name : _listreceived@12@rpc_wallet - func addr: 0x00002ee0 0x00001000 - ordinal : 11
name : _listreceivedbyaddress@12@rpc_wallet - func addr: 0x00003650 0x00001000 - ordinal : 12
name : _listspent@12@rpc_wallet - func addr: 0x00003000 0x00001000 - ordinal : 13
name : _liststaking@12@rpc_wallet - func addr: 0x000042d0 0x00001000 - ordinal : 14
name : _listtransactions@12@rpc_wallet - func addr: 0x00002840 0x00001000 - ordinal : 15
name : _listunspent@12@rpc_wallet - func addr: 0x00003520 0x00001000 - ordinal : 16
name : _pubkeytoaddr@12@rpc_wallet - func addr: 0x000037a0 0x00001000 - ordinal : 18
name : _set_node@8@rpc_wallet - func addr: 0x00001010 0x00001000 - ordinal : 19
name : _signstakeblock@12@rpc_wallet - func addr: 0x000044d0 0x00001000 - ordinal : 20
name : _signstaketx@12@rpc_wallet - func addr: 0x000047c0 0x00001000 - ordinal : 21
name : mod_name_deco_type@rpc_wallet - func addr: 0x00008000 0x00008000 - ordinal : 17


text section :
name : .text
section header flags : 60000020
relocations : 0
relocations ptr: 0
vaddr : 00001000
paddr : 000048cd
size : 18944
externs : 0
syms : 0
imports : 0

 

rdata section :

name : .rdata
section header flags : 40000040
relocations : 0
relocations ptr: 0
vaddr : 00006000
paddr : 00001368
size : 5120
externs : 0
syms : 0

symboles :

imports : 88 
module : libbase - function : _tree_manager_get_child_value_i64@12 - reloc addr : 0x00000080
module : libbase - function : _tree_manager_get_node_hash@12 - reloc addr : 0x00000084
module : libbase - function : _tree_manager_write_node_btcaddr@12 - reloc addr : 0x00000088
module : libbase - function : _tree_manager_set_child_value_float@16 - reloc addr : 0x0000008c
module : libbase - function : _tree_manager_node_add_child@8 - reloc addr : 0x00000090
module : libbase - function : _tree_manager_create_node@12 - reloc addr : 0x00000094
module : libbase - function : _tree_manager_set_child_value_hash@12 - reloc addr : 0x00000098
module : libbase - function : _tree_manager_get_node_istr@16 - reloc addr : 0x0000009c
module : libbase - function : _tree_manager_get_child_value_i16@12 - reloc addr : 0x000000a0
module : libbase - function : _tree_manager_add_child_node@16 - reloc addr : 0x000000a4
module : libbase - function : _tree_manager_write_node_sig@16 - reloc addr : 0x000000a8
module : libbase - function : _tree_manager_set_child_value_btcaddr@12 - reloc addr : 0x000000ac
module : libbase - function : _tree_manager_get_child_value_i32@12 - reloc addr : 0x000000b0
module : libbase - function : _tree_manager_set_child_value_bhash@12 - reloc addr : 0x000000b4
module : libbase - function : _tree_mamanger_get_node_dword@12 - reloc addr : 0x000000b8
module : libbase - function : _tree_manager_set_child_value_i32@12 - reloc addr : 0x000000bc
module : libbase - function : _tree_find_child_node_by_member_name_hash@20 - reloc addr : 0x000000c0
module : libbase - function : _tree_manager_set_child_value_str@12 - reloc addr : 0x000000c4
module : libbase - function : _tree_manager_get_node_num_children@4 - reloc addr : 0x000000c8
module : libbase - function : _tree_manager_get_child_value_str@20 - reloc addr : 0x000000cc
module : libbase - function : _tree_manager_find_child_node@16 - reloc addr : 0x000000d0
module : libbase - function : _tree_manager_set_child_value_i64@16 - reloc addr : 0x000000d4
module : libbase - function : _tree_manager_get_child_value_btcaddr@12 - reloc addr : 0x000000d8
module : libbase - function : _tree_manager_get_child_at@12 - reloc addr : 0x000000dc
module : libbase - function : _tree_manager_get_child_value_istr@16 - reloc addr : 0x000000e0
module : libbase - function : _tree_manager_get_next_child@8 - reloc addr : 0x000000e4
module : libbase - function : _tree_manager_get_first_child@12 - reloc addr : 0x000000e8
module : libbase - function : _tree_manager_get_node_btcaddr@12 - reloc addr : 0x000000ec
module : libbase - function : _tree_manager_get_node_str@20 - reloc addr : 0x000000f0
module : libbase - function : _tree_manager_get_child_value_hash@12 - reloc addr : 0x000000f4
module : libcon - function : _rm_dir@4 - reloc addr : 0x000000fc
module : libcon - function : _malloc_c@4 - reloc addr : 0x00000100
module : libcon - function : _strncmp_c@12 - reloc addr : 0x00000104
module : libcon - function : _free_c@4 - reloc addr : 0x00000108
module : libcon - function : _cat_cstring_p@8 - reloc addr : 0x0000010c
module : libcon - function : _memchr_c@12 - reloc addr : 0x00000110
module : libcon - function : _get_sub_files@8 - reloc addr : 0x00000114
module : libcon - function : _get_tpo_mod_exp_addr_name@12 - reloc addr : 0x00000118
module : libcon - function : _create_dir@4 - reloc addr : 0x0000011c
module : libcon - function : _clone_string@8 - reloc addr : 0x00000120
module : libcon - function : _get_time_c@0 - reloc addr : 0x00000124
module : libcon - function : calc_crc32_c - reloc addr : 0x00000128
module : libcon - function : _get_sub_dirs@8 - reloc addr : 0x0000012c
module : libcon - function : _del_file@4 - reloc addr : 0x00000130
module : libcon - function : _memcmp_c@12 - reloc addr : 0x00000134
module : libcon - function : _strtoul_c@12 - reloc addr : 0x00000138
module : libcon - function : _cat_ncstring_p@12 - reloc addr : 0x0000013c
module : libcon - function : _free_string@4 - reloc addr : 0x00000140
module : libcon - function : _memset_c@12 - reloc addr : 0x00000144
module : libcon - function : _memcpy_c@12 - reloc addr : 0x00000148
module : libcon - function : _copy_zone_ref@8 - reloc addr : 0x0000014c
module : libcon - function : _stat_file@4 - reloc addr : 0x00000150
module : libcon - function : _make_string@8 - reloc addr : 0x00000154
module : libcon - function : _append_file@12 - reloc addr : 0x00000158
module : libcon - function : _muldiv64@24 - reloc addr : 0x0000015c
module : libcon - function : _release_zone_ref@4 - reloc addr : 0x00000160
module : libcon - function : _get_file@12 - reloc addr : 0x00000164
module : block_adx - function : _get_block_size@8 - reloc addr : 0x00000000
module : block_adx - function : _compute_tx_sign_hash@20 - reloc addr : 0x00000004
module : block_adx - function : _tx_add_input@16 - reloc addr : 0x00000008
module : block_adx - function : _get_blk_height@8 - reloc addr : 0x0000000c
module : block_adx - function : _is_vout_null@8 - reloc addr : 0x00000010
module : block_adx - function : _mul_compact@16 - reloc addr : 0x00000014
module : block_adx - function : _cmp_hashle@8 - reloc addr : 0x00000018
module : block_adx - function : _compute_block_hash@8 - reloc addr : 0x0000001c
module : block_adx - function : _get_tx_output@12 - reloc addr : 0x00000020
module : block_adx - function : _new_transaction@12 - reloc addr : 0x00000024
module : block_adx - function : _get_tx_output_amount@12 - reloc addr : 0x00000028
module : block_adx - function : _add_unspent@28 - reloc addr : 0x0000002c
module : block_adx - function : _parse_sig_seq@16 - reloc addr : 0x00000030
module : block_adx - function : _get_out_script_address@12 - reloc addr : 0x00000034
module : block_adx - function : _is_pow_block@4 - reloc addr : 0x00000038
module : block_adx - function : _get_last_block_height@0 - reloc addr : 0x0000003c
module : block_adx - function : _load_tx_addresses@8 - reloc addr : 0x00000040
module : block_adx - function : _get_pow_block@8 - reloc addr : 0x00000044
module : block_adx - function : _is_tx_null@4 - reloc addr : 0x00000048
module : block_adx - function : _get_tx_input@12 - reloc addr : 0x0000004c
module : block_adx - function : _key_to_addr@8 - reloc addr : 0x00000050
module : block_adx - function : _get_moneysupply@4 - reloc addr : 0x00000054
module : block_adx - function : _load_tx@12 - reloc addr : 0x00000058
module : block_adx - function : _spend_tx_addr@28 - reloc addr : 0x0000005c
module : block_adx - function : _tx_sign@16 - reloc addr : 0x00000060
module : block_adx - function : _get_blk_txs@8 - reloc addr : 0x00000064
module : block_adx - function : _tx_add_output@16 - reloc addr : 0x00000068
module : block_adx - function : _blk_check_sign@12 - reloc addr : 0x0000006c
module : block_adx - function : _SetCompact@8 - reloc addr : 0x00000070
module : block_adx - function : _get_tx_output_addr@12 - reloc addr : 0x00000074
module : block_adx - function : _get_tx_blk_height@16 - reloc addr : 0x00000078


data section :
name : .data
section header flags : c0000040
relocations : 0
relocations ptr: 0
vaddr : 00008000
paddr : 00008830
size : 35328
externs : 0
syms : 0

symboles :

imports : 0


init section :


res section :


ew section :


bss section :


check relocs :
section idx: '0' mem ofset 0 total ofset 26
section : '.text' (0x00001000) [0x004204e0 + 26] = 10010828 (10000000)
section idx: '0' mem ofset 0 total ofset 35
section : '.text' (0x00001000) [0x004204e0 + 35] = 10010828 (10000000)
section idx: '0' mem ofset 0 total ofset 41
section : '.text' (0x00001000) [0x004204e0 + 41] = 1000614c (10000000)
section idx: '0' mem ofset 0 total ofset 50
section : '.text' (0x00001000) [0x004204e0 + 50] = 10006118 (10000000)
section idx: '0' mem ofset 0 total ofset 57
section : '.text' (0x00001000) [0x004204e0 + 57] = 10006170 (10000000)
section idx: '0' mem ofset 0 total ofset 67
section : '.text' (0x00001000) [0x004204e0 + 67] = 10006188 (10000000)

[...]

num remaps : 824 1000 5a00
relocation, section addr 1a 00008000 addr final 00010828
relocation, section addr 23 00008000 addr final 00010828
relocation, section addr 29 00006000 addr final 0000614c
relocation, section addr 32 00006000 addr final 00006118
relocation, section addr 39 00006000 addr final 00006170

[...]

num remaps : 0 6000 7400
num remaps : 0 8000 10a00
module decoration type found 1
data pos : 2625
data padding : 15
write import 0 name
write export 21 name
name : _getaddressscanstatus@12[9986323a]@rpc_wallet[41102b07] - func addr: 0x00000e80
name : _getblockcount@12[31547d5d]@rpc_wallet[41102b07] - func addr: 0x000016a0
name : _getinfo@12[8ccb68f3]@rpc_wallet[41102b07] - func addr: 0x00001380
name : _getlastblock@12[a4bdff2e]@rpc_wallet[41102b07] - func addr: 0x00001070
name : _getprivaddr@12[8d60e8ea]@rpc_wallet[41102b07] - func addr: 0x00004580
name : _getpubaddrs@12[ac4c14f7]@rpc_wallet[41102b07] - func addr: 0x00004710
name : _getstaketx@12[dbfb0731]@rpc_wallet[41102b07] - func addr: 0x00003ac0
name : _getstaking@12[c2894f46]@rpc_wallet[41102b07] - func addr: 0x00003f60
name : _importaddress@12[b28731f3]@rpc_wallet[41102b07] - func addr: 0x000016d0
name : _importkeypair@12[8b75b915]@rpc_wallet[41102b07] - func addr: 0x00004150
name : _listreceived@12[fffe0fe9]@rpc_wallet[41102b07] - func addr: 0x00001ee0
name : _listreceivedbyaddress@12[89a400f3]@rpc_wallet[41102b07] - func addr: 0x00002650
name : _listspent@12[5b33c934]@rpc_wallet[41102b07] - func addr: 0x00002000
name : _liststaking@12[61658631]@rpc_wallet[41102b07] - func addr: 0x000032d0
name : _listtransactions@12[21d5fb75]@rpc_wallet[41102b07] - func addr: 0x00001840
name : _listunspent@12[d844ae77]@rpc_wallet[41102b07] - func addr: 0x00002520
name : _pubkeytoaddr@12[966f22b2]@rpc_wallet[41102b07] - func addr: 0x000027a0
name : _set_node@8[db61c4e6]@rpc_wallet[41102b07] - func addr: 0x00000010
name : _signstakeblock@12[c823a9de]@rpc_wallet[41102b07] - func addr: 0x000034d0
name : _signstaketx@12[2cffe441]@rpc_wallet[41102b07] - func addr: 0x000037c0
name : EntryPoint[04ca6e53]@rpc_wallet[41102b07] - func addr: 0x00000000
data pos : 28476
data padding : 4

write import 88 name
string index 1768 => '_make_string@8'
name : _make_string@8[bfb939a5]@libcon[3ddf3671] - func addr: 0x00000154 => 6f2e
string index 1436 => 'libcon'
string index 1783 => '_append_file@12'
name : _append_file@12[99a0ed2a]@libcon[3ddf3671] - func addr: 0x00000158 => 6f1c
string index 1436 => 'libcon'
string index 1799 => '_muldiv64@24'
name : _muldiv64@24[82da4eeb]@libcon[3ddf3671] - func addr: 0x0000015c => 6f0c
string index 1436 => 'libcon'
string index 1812 => '_release_zone_ref@4'
name : _release_zone_ref@4[2b7f522a]@libcon[3ddf3671] - func addr: 0x00000160 => 6ef6
string index 1436 => 'libcon'
string index 1832 => '_get_file@12'
name : _get_file@12[5c6fa1d3]@libcon[3ddf3671] - func addr: 0x00000164 => 6fec
string index 1845 => 'block_adx'
string index 1855 => '_get_block_size@8'
name : _get_block_size@8[94664944]@block_adx[fe093354] - func addr: 0x00000000 => 7108
string index 1845 => 'block_adx'
string index 1873 => '_compute_tx_sign_hash@20'
name : _compute_tx_sign_hash@20[0643e4d7]@block_adx[fe093354] - func addr: 0x00000004 => 70ec
string index 1845 => 'block_adx'
string index 1898 => '_tx_add_input@16'
name : _tx_add_input@16[7704f87e]@block_adx[fe093354] - func addr: 0x00000008 => 70d8
string index 1845 => 'block_adx'
string index 1915 => '_get_blk_height@8'
name : _get_blk_height@8[3f57daea]@block_adx[fe093354] - func addr: 0x0000000c => 7134
string index 1845 => 'block_adx'
string index 1933 => '_is_vout_null@8'
name : _is_vout_null@8[acd95b77]@block_adx[fe093354] - func addr: 0x00000010 => 7148
string index 1845 => 'block_adx'
string index 1949 => '_mul_compact@16'
name : _mul_compact@16[f45be4d8]@block_adx[fe093354] - func addr: 0x00000014 => 715a
string index 1845 => 'block_adx'
string index 1965 => '_cmp_hashle@8'
name : _cmp_hashle@8[8fa59d06]@block_adx[fe093354] - func addr: 0x00000018 => 716c
string index 1845 => 'block_adx'
string index 1979 => '_compute_block_hash@8'
name : _compute_block_hash@8[8cd5acb0]@block_adx[fe093354] - func addr: 0x0000001c => 717c
string index 1845 => 'block_adx'
string index 2001 => '_get_tx_output@12'
name : _get_tx_output@12[29b67459]@block_adx[fe093354] - func addr: 0x00000020 => 7194
string index 1845 => 'block_adx'
string index 2019 => '_new_transaction@12'
name : _new_transaction@12[64fdada7]@block_adx[fe093354] - func addr: 0x00000024 => 71a8
string index 1845 => 'block_adx'
string index 2039 => '_get_tx_output_amount@12'
name : _get_tx_output_amount@12[bda11d89]@block_adx[fe093354] - func addr: 0x00000028 => 71be
string index 1845 => 'block_adx'
string index 2064 => '_add_unspent@28'
name : _add_unspent@28[2256835b]@block_adx[fe093354] - func addr: 0x0000002c => 71da
string index 1845 => 'block_adx'
string index 2080 => '_parse_sig_seq@16'
name : _parse_sig_seq@16[eeae2d45]@block_adx[fe093354] - func addr: 0x00000030 => 71ec
string index 1845 => 'block_adx'
string index 2098 => '_get_out_script_address@12'
name : _get_out_script_address@12[1d8359db]@block_adx[fe093354] - func addr: 0x00000034 => 7200
string index 1845 => 'block_adx'
string index 2125 => '_is_pow_block@4'
name : _is_pow_block@4[e61b937a]@block_adx[fe093354] - func addr: 0x00000038 => 721e
string index 1845 => 'block_adx'
string index 2141 => '_get_last_block_height@0'
name : _get_last_block_height@0[9109c8c9]@block_adx[fe093354] - func addr: 0x0000003c => 7230
string index 1845 => 'block_adx'
string index 2166 => '_load_tx_addresses@8'
name : _load_tx_addresses@8[d66f2f62]@block_adx[fe093354] - func addr: 0x00000040 => 724c
string index 1845 => 'block_adx'
string index 2187 => '_get_pow_block@8'
name : _get_pow_block@8[f900d7a8]@block_adx[fe093354] - func addr: 0x00000044 => 7264
string index 1845 => 'block_adx'
string index 2204 => '_is_tx_null@4'
name : _is_tx_null@4[8db0f4c6]@block_adx[fe093354] - func addr: 0x00000048 => 7278
string index 1845 => 'block_adx'
string index 2218 => '_get_tx_input@12'
name : _get_tx_input@12[3e9f0c9f]@block_adx[fe093354] - func addr: 0x0000004c => 7288
string index 1845 => 'block_adx'
string index 2235 => '_key_to_addr@8'
name : _key_to_addr@8[7d5d3ed2]@block_adx[fe093354] - func addr: 0x00000050 => 729c
string index 1845 => 'block_adx'
string index 2250 => '_get_moneysupply@4'
name : _get_moneysupply@4[174bd4c4]@block_adx[fe093354] - func addr: 0x00000054 => 72ae
string index 1845 => 'block_adx'
string index 2269 => '_load_tx@12'
name : _load_tx@12[4c0c7578]@block_adx[fe093354] - func addr: 0x00000058 => 72c4
string index 1845 => 'block_adx'
string index 2281 => '_spend_tx_addr@28'
name : _spend_tx_addr@28[b53bfd6b]@block_adx[fe093354] - func addr: 0x0000005c => 72d2
string index 1845 => 'block_adx'
string index 2299 => '_tx_sign@16'
name : _tx_sign@16[b6fefac9]@block_adx[fe093354] - func addr: 0x00000060 => 72e6
string index 1845 => 'block_adx'
string index 2311 => '_get_blk_txs@8'
name : _get_blk_txs@8[e870b593]@block_adx[fe093354] - func addr: 0x00000064 => 72f4
string index 1845 => 'block_adx'
string index 2326 => '_tx_add_output@16'
name : _tx_add_output@16[40476bf9]@block_adx[fe093354] - func addr: 0x00000068 => 7306
string index 1845 => 'block_adx'
string index 2344 => '_blk_check_sign@12'
name : _blk_check_sign@12[dddd9195]@block_adx[fe093354] - func addr: 0x0000006c => 731a
string index 1845 => 'block_adx'
string index 2363 => '_SetCompact@8'
name : _SetCompact@8[ab7e0101]@block_adx[fe093354] - func addr: 0x00000070 => 7330
string index 1845 => 'block_adx'
string index 2377 => '_get_tx_output_addr@12'
name : _get_tx_output_addr@12[53b0f5ce]@block_adx[fe093354] - func addr: 0x00000074 => 7340
string index 1845 => 'block_adx'
string index 2400 => '_get_tx_blk_height@16'
name : _get_tx_blk_height@16[a517fd67]@block_adx[fe093354] - func addr: 0x00000078 => 711c
write export 0 name
data pos : 34704
write import 0 name
write export 2 name
name : _fltused[618381b1]@rpc_wallet[41102b07] - func addr: 0x0000882c
name : mod_name_deco_type[30d5d717]@rpc_wallet[41102b07] - func addr: 0x00000000

 

3. How to use tpo modules ?

 

To load and execute a tpo module in C, need to link with the libcon library, then it can be loaded with this code :

 

#include <base/std_def.h>
#include <base/std_mem.h>
#include <base/mem_base.h>
#include <base/std_str.h>
#include <fsio.h>
#include <mem_stream.h>
#include <tpo_mod.h>

 

 

int load_module(const char *file, const char *mod_name, tpo_mod_file *mod)

{


mem_stream mod_file;
mem_zone_ref tpo_file_data = { PTR_NULL };
unsigned char *data;
size_t data_len;

 //read tpo mod file data

if (get_file(file, &data, &data_len) <= 0)return 0;

//initialize memory stream with the data

allocate_new_zone(0, data_len, &tpo_file_data);
memcpy_c(get_zone_ptr(&tpo_file_data, 0), data, data_len);
memset_c(&mod_file, 0, sizeof(mem_stream));
mem_stream_init(&mod_file, &tpo_file_data, 0);

//initialize tpo module
tpo_mod_init(mod);
tpo_mod_load_tpo(&mod_file, mod, 0);

//register global export if others module's imports depend on this module

register_tpo_exports(mod, mod_name);

//free the memory

release_zone_ref(&tpo_file_data);
free_c(data);

}

 

int main(int argc, char **argv)

{

int done = 0;

//base initialization
init_mem_system ();

//init 8Mo of memory
init_default_mem_area (8 * 1024 * 1024);

 

//init network
network_init ();

//set home dir
set_exe_path ();
set_home_path ("purenode");

 

//load node modules

load_module("modz/libbase.tpo", "libbase", &libbase_mod);
load_module("modz/protocol_adx.tpo", "protocol_adx", &protocol_mod);
load_module("modz/block_adx.tpo", "block_adx", &block_mod);
load_module("modz/iadixcoin.tpo", "iadixcoin", &iadix_mod);

 

//load application entry points

app_init = get_tpo_mod_exp_addr_name(&iadix_mod, "app_init", 0);

app_start = get_tpo_mod_exp_addr_name(&iadix_mod, "app_start", 0);
app_loop = get_tpo_mod_exp_addr_name(&iadix_mod, "app_loop", 0);
app_stop = get_tpo_mod_exp_addr_name(&iadix_mod, "app_stop", 0);

if (!app_init(PTR_NULL))
{

console_print("could not initialize app ");
console_print(iadix_mod.name);
console_print("\n");
return 0;

}

//initialize application context

daemonize ("purenode");

 

//start application
app_start (PTR_NULL);

while (isRunning())
{

app_loop(PTR_NULL);

}

app_stop(PTR_NULL);

}

 

 

 

 

The dynamic loader take care of registering export, and matching import symbol decoration between compilers as long as the calling convention is identical. and relocate data reference to the dynamically allocated area. The same binary module can be loaded and executed from any operating system host, provided it can execute x86 machine code from memory.

commentaires
HTML 5 DOC