Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
42a5b54b
Commit
42a5b54b
authored
Sep 10, 2017
by
Felix Lange
Committed by
GitHub
Sep 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: improve bitvec comments
parent
d6681ed3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
analysis.go
core/vm/analysis.go
+7
-7
No files found.
core/vm/analysis.go
View file @
42a5b54b
...
@@ -44,8 +44,9 @@ func (d destinations) has(codehash common.Hash, code []byte, dest *big.Int) bool
...
@@ -44,8 +44,9 @@ func (d destinations) has(codehash common.Hash, code []byte, dest *big.Int) bool
return
OpCode
(
code
[
udest
])
==
JUMPDEST
&&
m
.
codeSegment
(
udest
)
return
OpCode
(
code
[
udest
])
==
JUMPDEST
&&
m
.
codeSegment
(
udest
)
}
}
// bitvec is a bit vector which maps bytes in a program
// bitvec is a bit vector which maps bytes in a program.
// An unset bit means the byte is a code-segemnt, a set bit means it's data-segment
// An unset bit means the byte is an opcode, a set bit means
// it's data (i.e. argument of PUSHxx).
type
bitvec
[]
byte
type
bitvec
[]
byte
func
(
bits
*
bitvec
)
set
(
pos
uint64
)
{
func
(
bits
*
bitvec
)
set
(
pos
uint64
)
{
...
@@ -56,15 +57,14 @@ func (bits *bitvec) set8(pos uint64) {
...
@@ -56,15 +57,14 @@ func (bits *bitvec) set8(pos uint64) {
(
*
bits
)[
pos
/
8
+
1
]
|=
^
(
0xFF
>>
(
pos
%
8
))
(
*
bits
)[
pos
/
8
+
1
]
|=
^
(
0xFF
>>
(
pos
%
8
))
}
}
// codeSegment checks if the position is in a code segment
// codeSegment checks if the position is in a code segment
.
func
(
bits
*
bitvec
)
codeSegment
(
pos
uint64
)
bool
{
func
(
bits
*
bitvec
)
codeSegment
(
pos
uint64
)
bool
{
return
((
*
bits
)[
pos
/
8
]
&
(
0x80
>>
(
pos
%
8
)))
==
0
return
((
*
bits
)[
pos
/
8
]
&
(
0x80
>>
(
pos
%
8
)))
==
0
}
}
// jumpdests creates a bitmap of the code, where 1 represents a DATA-segment,
// codeBitmap collects data locations in code.
// and 0 represents code-segment
func
codeBitmap
(
code
[]
byte
)
bitvec
{
func
codeBitmap
(
code
[]
byte
)
[]
byte
{
// The bitmap is 4 bytes longer than necessary, in case the code
//The map is 4 bytes longer than necessary, in case the code
// ends with a PUSH32, the algorithm will push zeroes onto the
// ends with a PUSH32, the algorithm will push zeroes onto the
// bitvector outside the bounds of the actual code.
// bitvector outside the bounds of the actual code.
bits
:=
make
(
bitvec
,
len
(
code
)
/
8
+
1
+
4
)
bits
:=
make
(
bitvec
,
len
(
code
)
/
8
+
1
+
4
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment