Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
361abbed
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
361abbed
编写于
3月 12, 2018
作者:
B
Bucky Kittinger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issues with unresolvable intrinsic
上级
748f75da
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
13 deletion
+47
-13
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
+25
-5
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+20
-7
libraries/chain/webassembly/wavm.cpp
libraries/chain/webassembly/wavm.cpp
+2
-1
未找到文件。
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
浏览文件 @
361abbed
...
...
@@ -28,12 +28,18 @@ namespace eosio { namespace chain { namespace wasm_injections {
}
}
static
int
last_imported_index
(
Module
&
module
)
{
return
module
.
functions
.
imports
.
size
()
-
1
;
}
template
<
ResultType
Result
,
ValueType
...
Params
>
static
void
add_import
(
Module
&
module
,
const
char
*
scope
,
const
char
*
func_name
,
int32_t
&
index
)
{
if
(
module
.
functions
.
imports
.
size
()
==
0
||
module
.
functions
.
imports
.
back
().
exportName
.
compare
(
func_name
)
!=
0
)
{
add_type_slot
<
Result
,
Params
...
>
(
module
);
const
uint32_t
func_type_index
=
type_slots
[{
FromResultType
<
Result
>::
value
,
FromValueType
<
Params
>::
value
...
}];
for
(
auto
e
:
{
FromValueType
<
Params
>::
value
...}
)
std
::
cout
<<
"
\n
"
;
module
.
functions
.
imports
.
push_back
({{
func_type_index
},
std
::
move
(
scope
),
std
::
move
(
func_name
)});
index
=
module
.
functions
.
imports
.
size
()
-
1
;
// shift all exported functions by 1
...
...
@@ -132,14 +138,29 @@ namespace eosio { namespace chain { namespace wasm_injections {
}
static
int32_t
checktime_idx
;
};
struct
increment_call_index
{
static
constexpr
bool
kills
=
false
;
static
void
init
()
{}
static
void
accept
(
wasm_ops
::
instr
*
inst
,
wasm_ops
::
visitor_arg
&
arg
)
{
// TODO this is hardcoded for various injections, refactor to allow the system to deduce this
wasm_ops
::
op_types
<>::
call_t
*
call_inst
=
reinterpret_cast
<
wasm_ops
::
op_types
<>::
call_t
*>
(
inst
);
const
int
offset
=
1
;
if
(
call_inst
->
field
>=
injector_utils
::
last_imported_index
(
*
(
arg
.
module
)
)
)
call_inst
->
field
+=
offset
;
}
};
// add opcode specific constraints here
// so far we only black list
struct
op_injectors
:
wasm_ops
::
op_types
<
pass_injector
>
{
using
block_t
=
wasm_ops
::
block
<
debug_printer
,
instruction_counter
,
checktime_injector
>
;
using
loop_t
=
wasm_ops
::
loop
<
debug_printer
,
instruction_counter
,
checktime_injector
>
;
using
if__t
=
wasm_ops
::
if_
<
debug_printer
,
instruction_counter
,
checktime_injector
>
;
using
else__t
=
wasm_ops
::
else_
<
debug_printer
,
instruction_counter
,
checktime_injector
>
;
using
if__t
=
wasm_ops
::
if_
<
debug_printer
,
instruction_counter
>
;
using
else__t
=
wasm_ops
::
else_
<
debug_printer
,
instruction_counter
>
;
//using if__t = wasm_ops::if_ <debug_printer, instruction_counter, checktime_injector>;
//using else__t = wasm_ops::else_ <debug_printer, instruction_counter, checktime_injector>;
using
end_t
=
wasm_ops
::
end
<
debug_printer
,
instruction_counter
>
;
using
unreachable_t
=
wasm_ops
::
unreachable
<
debug_printer
,
instruction_counter
>
;
...
...
@@ -147,7 +168,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
using
br_if_t
=
wasm_ops
::
br_if
<
debug_printer
,
instruction_counter
>
;
using
br_table_t
=
wasm_ops
::
br_table
<
debug_printer
,
instruction_counter
>
;
using
return__t
=
wasm_ops
::
return_
<
debug_printer
,
instruction_counter
>
;
using
call_t
=
wasm_ops
::
call
<
debug_printer
,
instruction_counter
>
;
using
call_t
=
wasm_ops
::
call
<
debug_printer
,
instruction_counter
,
increment_call_index
>
;
using
call_indirect_t
=
wasm_ops
::
call_indirect
<
debug_printer
,
instruction_counter
>
;
using
drop_t
=
wasm_ops
::
drop
<
debug_printer
,
instruction_counter
>
;
using
select_t
=
wasm_ops
::
select
<
debug_printer
,
instruction_counter
>
;
...
...
@@ -286,7 +307,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
wasm_binary_injection
()
{
_module_injectors
.
init
();
// initialize static fields of injectors
//
injector_utils::init();
injector_utils
::
init
();
instruction_counter
::
init
();
checktime_injector
::
init
();
}
...
...
@@ -300,7 +321,6 @@ namespace eosio { namespace chain { namespace wasm_injections {
auto
op
=
decoder
.
decodeOp
();
op
->
visit
(
{
&
mod
,
&
new_code
,
&
fd
,
decoder
.
index
()
}
);
}
fd
.
code
=
new_code
;
}
}
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
361abbed
...
...
@@ -195,8 +195,9 @@ namespace eosio { namespace chain {
WASM
::
serializeWithInjection
(
stream2
,
*
module2
);
wasm_constraints
::
wasm_binary_validation
::
validate
(
*
module
);
#if 0
wasm_injections::wasm_binary_injection::inject( *module );
/*
std::cout << "INJECTED\n";
wasm_injections::wasm_binary_injection::inject( *module );
std::cout << "INJECTEDSS\n";
...
...
@@ -236,12 +237,12 @@ namespace eosio { namespace chain {
std::cout << "\n";
std::cout << "FUNCTION_Import A \n";
for (
auto e : module->functions.imports
)
std::cout <<
e.exportName
<< "\n";
for (
int i=0; i < module->functions.imports.size(); i++
)
std::cout <<
module->functions.imports[i].exportName << " : " << i
<< "\n";
std::cout << "\n";
std::cout << "FUNCTION_Import B \n";
for (
auto e : module2->functions.imports
)
std::cout <<
e.exportName
<< "\n";
for (
int i=0; i < module->functions.imports.size(); i++
)
std::cout <<
module->functions.imports[i].exportName << " : " << i
<< "\n";
std::cout << "\n";
std::cout << "TABLES_Import A \n";
...
...
@@ -283,7 +284,20 @@ namespace eosio { namespace chain {
for (auto e : module2->exports)
std::cout << e.name << " " << uint32_t(e.index) << "\n";
std::cout << "\n";
*/
std::cout << "DATASEG A \n";
for (auto e : module->dataSegments)
std::cout << e.memoryIndex << "\n";
std::cout << "\n";
std::cout << "DATSEG B \n";
for (auto e : module2->dataSegments)
std::cout << e.memoryIndex << "\n";
std::cout << "\n";
std::cout << "start index A " << module->startFunctionIndex << "\n";
std::cout << "start index B " << module2->startFunctionIndex << "\n";
#endif
Serialization
::
ArrayOutputStream
outstream
;
WASM
::
serialize
(
outstream
,
*
module
);
...
...
@@ -595,7 +609,6 @@ public:
using
context_aware_api
::
context_aware_api
;
void
checktime
(
uint32_t
instruction_count
)
{
std
::
cout
<<
"CHECKTIME
\n
"
;
context
.
checktime
(
instruction_count
);
}
};
...
...
libraries/chain/webassembly/wavm.cpp
浏览文件 @
361abbed
#include <eosio/chain/webassembly/wavm.hpp>
#include <eosio/chain/wasm_eosio_constraints.hpp>
#include <eosio/chain/wasm_eosio_injection.hpp>
#include <eosio/chain/apply_context.hpp>
#include "IR/Module.h"
...
...
@@ -121,7 +122,7 @@ entry entry::build(const char* wasm_binary, size_t wasm_binary_size) {
Module
*
module
=
new
Module
();
Serialization
::
MemoryInputStream
stream
((
const
U8
*
)
wasm_binary
,
wasm_binary_size
);
WASM
::
serialize
(
stream
,
*
module
);
wasm_injections
::
wasm_binary_injection
::
inject
(
*
module
);
root_resolver
resolver
;
LinkResult
link_result
=
linkModule
(
*
module
,
resolver
);
ModuleInstance
*
instance
=
instantiateModule
(
*
module
,
std
::
move
(
link_result
.
resolvedImports
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录