Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
e09b6216
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e09b6216
编写于
2月 04, 2017
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perlasm/x86_64-xlate.pl: minor readability updates.
Reviewed-by:
N
Rich Salz
<
rsalz@openssl.org
>
上级
53b33100
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
37 deletion
+52
-37
crypto/perlasm/x86_64-xlate.pl
crypto/perlasm/x86_64-xlate.pl
+52
-37
未找到文件。
crypto/perlasm/x86_64-xlate.pl
浏览文件 @
e09b6216
...
...
@@ -100,7 +100,7 @@ elsif (!$gas)
{
$nasm
=
$
1
+
$
2
*
0.01
;
$PTR
=
"";
}
elsif
(`
ml64 2>&1
`
=~
m/Version ([0-9]+)\.([0-9]+)(\.([0-9]+))?/
)
{
$masm
=
$
1
+
$
2
*
2
**-
16
+
$
4
*
2
**-
32
;
}
die
"
no assembler found on %PATH
"
if
(
!
(
$nasm
||
$masm
));
die
"
no assembler found on %PATH
%
"
if
(
!
(
$nasm
||
$masm
));
$win64
=
1
;
$elf
=
0
;
$decor
=
"
\$
L
\$
";
...
...
@@ -223,6 +223,13 @@ my %globals;
}
}
{
package
ea
;
# pick up effective addresses: expr(%reg,%reg,scale)
my
%szmap
=
(
b
=>
"
BYTE
$PTR
",
w
=>
"
WORD
$PTR
",
l
=>
"
DWORD
$PTR
",
d
=>
"
DWORD
$PTR
",
q
=>
"
QWORD
$PTR
",
o
=>
"
OWORD
$PTR
",
x
=>
"
XMMWORD
$PTR
",
y=>"YMMWORD$PTR",
z=>"ZMMWORD$PTR" ) if (!$gas);
sub re {
my ($class, $line, $opcode) =
@_
;
my
$self
=
{};
...
...
@@ -235,7 +242,7 @@ my %globals;
$self
->
{
label
}
=
$
2
;
(
$self
->
{
base
},
$self
->
{
index
},
$self
->
{
scale
})
=
split
(
/,/
,
$
3
);
$self
->
{
scale
}
=
1
if
(
!
defined
(
$self
->
{
scale
}));
$self
->
{
pred
}
=
$
4
;
$self
->
{
opmask
}
=
$
4
;
$ret
=
$self
;
$$line
=
substr
(
$$line
,
@
+
[
0
]);
$$line
=~
s/^\s+//
;
...
...
@@ -276,6 +283,8 @@ my %globals;
$self
->
{
label
}
=~
s/\b([0-9]+)\b/$1>>0/
eg
;
}
# if base register is %rbp or %r13, see if it's possible to
# flip base and ingex registers [for better performance]
if
(
!
$self
->
{
label
}
&&
$self
->
{
index
}
&&
$self
->
{
scale
}
==
1
&&
$self
->
{
base
}
=~
/(rbp|r13)/
)
{
$self
->
{
base
}
=
$self
->
{
index
};
$self
->
{
index
}
=
$
1
;
...
...
@@ -289,17 +298,12 @@ my %globals;
$self
->
{
asterisk
},
$self
->
{
label
},
$self
->
{
base
}?"
%
$self
->{base}
":"",
$self
->
{
index
},
$self
->
{
scale
},
$self
->
{
pred
};
$self
->
{
opmask
};
}
else
{
sprintf
"
%s%s(%%%s)%s
",
$self
->
{
asterisk
},
$self
->
{
label
},
$self
->
{
base
},
$self
->
{
pred
};
$self
->
{
base
},
$self
->
{
opmask
};
}
}
else
{
my
%szmap
=
(
b
=>
"
BYTE
$PTR
",
w
=>
"
WORD
$PTR
",
l
=>
"
DWORD
$PTR
",
d
=>
"
DWORD
$PTR
",
q
=>
"
QWORD
$PTR
",
o
=>
"
OWORD
$PTR
",
x
=>
"
XMMWORD
$PTR
",
y=>"YMMWORD$PTR", z=>"ZMMWORD$PTR" );
$self
->
{
label
}
=~
s/\./\$/g
;
$self
->
{
label
}
=~
s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/ig
;
$self
->
{
label
}
=
"
(
$self
->{label})
"
if
(
$self
->
{
label
}
=~
/[\*\+\-\/]/
);
...
...
@@ -311,20 +315,20 @@ my %globals;
(
$mnemonic
=~
/^vpbroadcast([qdwb])$/
)
&&
(
$sz
=
$
1
)
||
(
$mnemonic
=~
/^v(?!perm)[a-z]+[fi]128$/
)
&&
(
$sz
=
"
x
");
$self
->
{
pred
}
=~
s/%(k[0-7])/$1/
;
$self
->
{
opmask
}
=~
s/%(k[0-7])/$1/
;
if
(
defined
(
$self
->
{
index
}))
{
sprintf
"
%s[%s%s*%d%s]%s
",
$szmap
{
$sz
},
$self
->
{
label
}?"
$self
->{label}+
":"",
$self
->
{
index
},
$self
->
{
scale
},
$self
->
{
base
}?"
+
$self
->{base}
":"",
$self
->
{
pred
};
$self
->
{
opmask
};
}
elsif
(
$self
->
{
base
}
eq
"
rip
")
{
sprintf
"
%s[%s]
",
$szmap
{
$sz
},
$self
->
{
label
};
}
else
{
sprintf
"
%s[%s%s]%s
",
$szmap
{
$sz
},
$self
->
{
label
}?"
$self
->{label}+
":"",
$self
->
{
base
},
$self
->
{
pred
};
$self
->
{
base
},
$self
->
{
opmask
};
}
}
}
...
...
@@ -340,7 +344,7 @@ my %globals;
bless
$self
,
$class
;
$self
->
{
asterisk
}
=
$
1
;
$self
->
{
value
}
=
$
2
;
$self
->
{
pred
}
=
$
3
;
$self
->
{
opmask
}
=
$
3
;
$opcode
->
size
(
$self
->
size
());
$ret
=
$self
;
$$line
=
substr
(
$$line
,
@
+
[
0
]);
$$line
=~
s/^\s+//
;
...
...
@@ -366,9 +370,9 @@ my %globals;
my
$self
=
shift
;
if
(
$gas
)
{
sprintf
"
%s%%%s%s
",
$self
->
{
asterisk
},
$self
->
{
value
},
$self
->
{
pred
};
}
else
{
$self
->
{
pred
}
=~
s/%(k[0-7])/$1/
;
$self
->
{
value
}
.
$self
->
{
pred
};
}
$self
->
{
opmask
};
}
else
{
$self
->
{
opmask
}
=~
s/%(k[0-7])/$1/
;
$self
->
{
value
}
.
$self
->
{
opmask
};
}
}
}
{
package
label
;
# pick up labels, which end with :
...
...
@@ -392,9 +396,8 @@ my %globals;
if
(
$gas
)
{
my
$func
=
(
$globals
{
$self
->
{
value
}}
or
$self
->
{
value
})
.
"
:
";
if
(
$win64
&&
$current_function
->
{
name
}
eq
$self
->
{
value
}
&&
$current_function
->
{
abi
}
eq
"
svr4
")
{
if
(
$win64
&&
$current_function
->
{
name
}
eq
$self
->
{
value
}
&&
$current_function
->
{
abi
}
eq
"
svr4
")
{
$func
.=
"
\n
";
$func
.=
"
movq %rdi,8(%rsp)
\n
";
$func
.=
"
movq %rsi,16(%rsp)
\n
";
...
...
@@ -473,15 +476,6 @@ my %globals;
my
$self
=
{};
my
$ret
;
my
$dir
;
my
%opcode
=
# lea 2f-1f(%rip),%dst; 1: nop; 2:
(
"
%rax
"
=>
0x01058d48
,
"
%rcx
"
=>
0x010d8d48
,
"
%rdx
"
=>
0x01158d48
,
"
%rbx
"
=>
0x011d8d48
,
"
%rsp
"
=>
0x01258d48
,
"
%rbp
"
=>
0x012d8d48
,
"
%rsi
"
=>
0x01358d48
,
"
%rdi
"
=>
0x013d8d48
,
"
%r8
"
=>
0x01058d4c
,
"
%r9
"
=>
0x010d8d4c
,
"
%r10
"
=>
0x01158d4c
,
"
%r11
"
=>
0x011d8d4c
,
"
%r12
"
=>
0x01258d4c
,
"
%r13
"
=>
0x012d8d4c
,
"
%r14
"
=>
0x01358d4c
,
"
%r15
"
=>
0x013d8d4c
);
if
(
$$line
=~
/^\s*(\.\w+)/
)
{
bless
$self
,
$class
;
...
...
@@ -491,7 +485,19 @@ my %globals;
$$line
=
substr
(
$$line
,
@
+
[
0
]);
$$line
=~
s/^\s+//
;
SWITCH:
for
(
$dir
)
{
# obsolete, to be removed
/\.picmeup/
&&
do
{
if
(
$$line
=~
/(%r[\w]+)/i
)
{
my
%opcode
=
# lea 2f-1f(%rip),%dst; 1: nop; 2:
(
"
%rax
"
=>
0x01058d48
,
"
%rcx
"
=>
0x010d8d48
,
"
%rdx
"
=>
0x01158d48
,
"
%rbx
"
=>
0x011d8d48
,
"
%rsp
"
=>
0x01258d48
,
"
%rbp
"
=>
0x012d8d48
,
"
%rsi
"
=>
0x01358d48
,
"
%rdi
"
=>
0x013d8d48
,
"
%r8
"
=>
0x01058d4c
,
"
%r9
"
=>
0x010d8d4c
,
"
%r10
"
=>
0x01158d4c
,
"
%r11
"
=>
0x011d8d4c
,
"
%r12
"
=>
0x01258d4c
,
"
%r13
"
=>
0x012d8d4c
,
"
%r14
"
=>
0x01358d4c
,
"
%r15
"
=>
0x013d8d4c
);
$dir
=
"
\t
.long
";
$$line
=
sprintf
"
0x%x,0x90000000
",
$opcode
{
$
1
};
}
...
...
@@ -701,15 +707,6 @@ my %globals;
}
}
sub
rex
{
my
$opcode
=
shift
;
my
(
$dst
,
$src
,
$rex
)
=
@_
;
$rex
|=
0x04
if
(
$dst
>=
8
);
$rex
|=
0x01
if
(
$src
>=
8
);
push
@$opcode
,(
$rex
|
0x40
)
if
(
$rex
);
}
# Upon initial x86_64 introduction SSE>2 extensions were not introduced
# yet. In order not to be bothered by tracing exact assembler versions,
# but at the same time to provide a bare security minimum of AES-NI, we
...
...
@@ -720,6 +717,15 @@ sub rex {
my
%regrm
=
(
"
%eax
"
=>
0
,
"
%ecx
"
=>
1
,
"
%edx
"
=>
2
,
"
%ebx
"
=>
3
,
"
%esp
"
=>
4
,
"
%ebp
"
=>
5
,
"
%esi
"
=>
6
,
"
%edi
"
=>
7
);
sub
rex
{
my
$opcode
=
shift
;
my
(
$dst
,
$src
,
$rex
)
=
@_
;
$rex
|=
0x04
if
(
$dst
>=
8
);
$rex
|=
0x01
if
(
$src
>=
8
);
push
@$opcode
,(
$rex
|
0x40
)
if
(
$rex
);
}
my
$movq
=
sub
{
# elderly gas can't handle inter-register movq
my
$arg
=
shift
;
my
@opcode
=
(
0x66
);
...
...
@@ -843,6 +849,10 @@ my $rdseed = sub {
}
};
# Not all AVX-capable assemblers recognize AMD XOP extension. Since we
# are using only two instructions hand-code them in order to be excused
# from chasing assembler versions...
sub
rxb
{
my
$opcode
=
shift
;
my
(
$dst
,
$src1
,
$src2
,
$rxb
)
=
@_
;
...
...
@@ -882,10 +892,15 @@ my $vprotq = sub {
}
};
# Intel Control-flow Enforcement Technology extension. All functions and
# indirect branch targets will have to start with this instruction...
my
$endbranch
=
sub
{
(
0xf3
,
0x0f
,
0x1e
,
0xfa
);
};
########################################################################
if
(
$nasm
)
{
print
<<___;
default rel
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录