Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
a23e3dbe
O
openssl
项目概览
btwise
/
openssl
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a23e3dbe
编写于
2月 13, 2008
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for NASM>=2 in Win64/x64 build.
上级
400ca0e4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
41 deletion
+76
-41
crypto/perlasm/x86_64-xlate.pl
crypto/perlasm/x86_64-xlate.pl
+66
-38
util/pl/VC-32.pl
util/pl/VC-32.pl
+10
-3
未找到文件。
crypto/perlasm/x86_64-xlate.pl
浏览文件 @
a23e3dbe
...
...
@@ -65,10 +65,20 @@ my $output = shift;
if
(
$stddev
!=
$outdev
||
$stdino
!=
$outino
);
}
my
$win64
=
1
if
(
$output
=~
/\.asm/
);
my
$masmref
=
8
+
50727
*
2
**-
32
;
# 8.00.50727 shipped with VS2005
my
$masm
=
$masmref
if
(
$output
=~
/\.asm/
);
if
(
$masm
&&
`
ml64 2>&1
`
=~
m/Version ([0-9]+)\.([0-9]+)(\.([0-9]+))?/
)
{
$masm
=
$
1
+
$
2
*
2
**-
16
+
$
4
*
2
**-
32
;
}
my
$masm
=
$masmref
;
my
$PTR
=
"
PTR
";
my
$nasm
=
0
;
if
(
$win64
)
{
if
(
$ENV
{
ASM
}
=~
m/nasm/
)
{
$nasm
=
1
;
$PTR
=
"";
}
elsif
(`
ml64 2>&1
`
=~
m/Version ([0-9]+)\.([0-9]+)(\.([0-9]+))?/
)
{
$masm
=
$
1
+
$
2
*
2
**-
16
+
$
4
*
2
**-
32
;
}
}
my
$current_segment
;
my
$current_function
;
...
...
@@ -105,7 +115,7 @@ my $current_function;
}
sub
out
{
my
$self
=
shift
;
if
(
!
$
masm
)
{
if
(
!
$
win64
)
{
if
(
$self
->
{
op
}
eq
"
movz
")
{
# movz is pain...
sprintf
"
%s%s%s
",
$self
->
{
op
},
$self
->
{
sz
},
shift
;
}
elsif
(
$self
->
{
op
}
=~
/^set/
)
{
...
...
@@ -120,14 +130,17 @@ my $current_function;
if
(
$self
->
{
op
}
eq
"
ret
")
{
$self
->
{
op
}
=
"";
if
(
$current_function
->
{
abi
}
eq
"
svr4
")
{
$self
->
{
op
}
=
"
mov rdi,QWORD
PTR 8[
rsp]
\t
;WIN64 epilogue
\n\t
"
.
"
mov rsi,QWORD
PTR 16[
rsp]
\n\t
";
$self
->
{
op
}
=
"
mov rdi,QWORD
${PTR}
[8+
rsp]
\t
;WIN64 epilogue
\n\t
"
.
"
mov rsi,QWORD
${PTR}
[16+
rsp]
\n\t
";
}
$self
->
{
op
}
.=
"
DB
\t
0F3h,0C3h
\t\t
;repret
";
}
elsif
(
$self
->
{
op
}
=~
/^j/
&&
$nasm
)
{
$self
->
{
op
}
.=
"
NEAR
";
}
$self
->
{
op
};
}
}
sub
mnemonic
{
shift
->
{
op
};
}
}
{
package
const
;
# pick up constants, which start with $
sub
re
{
...
...
@@ -145,7 +158,7 @@ my $current_function;
sub
out
{
my
$self
=
shift
;
if
(
!
$
masm
)
{
if
(
!
$
win64
)
{
# Solaris /usr/ccs/bin/as can't handle multiplications
# in $self->{value}
$self
->
{
value
}
=~
s/(?<![0-9a-f])(0[x0-9a-f]+)/oct($1)/
egi
;
...
...
@@ -186,7 +199,7 @@ my $current_function;
$self
->
{
index
}
=~
s/^[er](.?[0-9xpi])[d]?$/r\1/
;
$self
->
{
base
}
=~
s/^[er](.?[0-9xpi])[d]?$/r\1/
;
if
(
!
$
masm
)
{
if
(
!
$
win64
)
{
# Solaris /usr/ccs/bin/as can't handle multiplications
# in $self->{label}
$self
->
{
label
}
=~
s/(?<![0-9a-f])(0[x0-9a-f]+)/oct($1)/
egi
;
...
...
@@ -200,22 +213,23 @@ my $current_function;
sprintf
"
%s(%%%s)
",
$self
->
{
label
},
$self
->
{
base
};
}
}
else
{
%szmap
=
(
b
=>
"
BYTE
",
w
=>
"
WORD
",
l
=>
"
DWORD
",
q
=>
"
QWORD
"
);
%szmap
=
(
b
=>
"
BYTE
$PTR
",
w
=>
"
WORD
$PTR
",
l
=>
"
DWORD
$PTR
",
q
=>
"
QWORD
$PTR
"
);
$self
->
{
label
}
=~
s/\./\$/g
;
$self
->
{
label
}
=~
s/0x([0-9a-f]+)/0$1h/ig
;
$self
->
{
label
}
=
"
(
$self
->{label})
"
if
(
$self
->
{
label
}
=~
/[\*\+\-\/]/
);
if
(
defined
(
$self
->
{
index
}))
{
sprintf
"
%s
PTR %s[
%s*%d+%s]
",
$szmap
{
$sz
},
$self
->
{
label
},
sprintf
"
%s
[%s
%s*%d+%s]
",
$szmap
{
$sz
},
$self
->
{
label
}
?"
$self
->{label}+
":""
,
$self
->
{
index
},
$self
->
{
scale
},
$self
->
{
base
};
}
elsif
(
$self
->
{
base
}
eq
"
rip
")
{
sprintf
"
%s
PTR %s
",
$szmap
{
$sz
},
$self
->
{
label
};
sprintf
"
%s
[%s]
",
$szmap
{
$sz
},
$self
->
{
label
};
}
else
{
sprintf
"
%s PTR %s[%s]
",
$szmap
{
$sz
},
$self
->
{
label
},
$self
->
{
base
};
sprintf
"
%s[%s%s]
",
$szmap
{
$sz
},
$self
->
{
label
}?"
$self
->{label}+
":"",
$self
->
{
base
};
}
}
}
...
...
@@ -252,7 +266,7 @@ my $current_function;
}
sub
out
{
my
$self
=
shift
;
sprintf
$
masm
?"
%s
":"
%%%s
",
$self
->
{
value
};
sprintf
$
win64
?"
%s
":"
%%%s
",
$self
->
{
value
};
}
}
{
package
label
;
# pick up labels, which end with :
...
...
@@ -266,32 +280,32 @@ my $current_function;
$ret
=
$self
;
$line
=
substr
(
$line
,
@
+
[
0
]);
$line
=~
s/^\s+//
;
$self
->
{
value
}
=~
s/\.L/\$L/
if
(
$
masm
);
$self
->
{
value
}
=~
s/\.L/\$L/
if
(
$
win64
);
}
$ret
;
}
sub
out
{
my
$self
=
shift
;
if
(
!
$
masm
)
{
if
(
!
$
win64
)
{
$self
->
{
value
};
}
elsif
(
$self
->
{
value
}
ne
"
$current_function
->{name}:
")
{
$self
->
{
value
};
}
elsif
(
$current_function
->
{
abi
}
eq
"
svr4
")
{
my
$func
=
"
$current_function
->{name}
PROC
\n
"
.
"
mov QWORD
PTR 8[
rsp],rdi
\t
;WIN64 prologue
\n
"
.
"
mov QWORD
PTR 16[
rsp],rsi
\n
";
my
$func
=
"
$current_function
->{name}
"
.
(
$nasm
?"
:
":"
\t
PROC
")
.
"
\n
"
.
"
mov QWORD
${PTR}
[8+
rsp],rdi
\t
;WIN64 prologue
\n
"
.
"
mov QWORD
${PTR}
[16+
rsp],rsi
\n
";
my
$narg
=
$current_function
->
{
narg
};
$narg
=
6
if
(
!
defined
(
$narg
));
$func
.=
"
mov rdi,rcx
\n
"
if
(
$narg
>
0
);
$func
.=
"
mov rsi,rdx
\n
"
if
(
$narg
>
1
);
$func
.=
"
mov rdx,r8
\n
"
if
(
$narg
>
2
);
$func
.=
"
mov rcx,r9
\n
"
if
(
$narg
>
3
);
$func
.=
"
mov r8,QWORD
PTR 40[
rsp]
\n
"
if
(
$narg
>
4
);
$func
.=
"
mov r9,QWORD
PTR 48[
rsp]
\n
"
if
(
$narg
>
5
);
$func
.=
"
mov r8,QWORD
${PTR}
[40+
rsp]
\n
"
if
(
$narg
>
4
);
$func
.=
"
mov r9,QWORD
${PTR}
[48+
rsp]
\n
"
if
(
$narg
>
5
);
$func
.=
"
\n
";
}
else
{
"
$current_function
->{name}
PROC
"
;
"
$current_function
->{name}
"
.
(
$nasm
?"
:
":"
\t
PROC
")
;
}
}
}
...
...
@@ -306,7 +320,7 @@ my $current_function;
$ret
=
$self
;
$line
=
substr
(
$line
,
@
+
[
0
]);
$line
=~
s/^\s+//
;
$self
->
{
value
}
=~
s/\.L/\$L/g
if
(
$
masm
);
$self
->
{
value
}
=~
s/\.L/\$L/g
if
(
$
win64
);
}
$ret
;
}
...
...
@@ -332,7 +346,7 @@ my $current_function;
"
%r14
"
=>
0x01358d4c
,
"
%r15
"
=>
0x013d8d4c
);
if
(
$line
=~
/^\s*(\.\w+)/
)
{
if
(
!
$
masm
)
{
if
(
!
$
win64
)
{
$self
->
{
value
}
=
$
1
;
$line
=~
s/\@abi\-omnipotent/\@function/
;
$line
=~
s/\@function.*/\@function/
;
...
...
@@ -356,16 +370,25 @@ my $current_function;
SWITCH:
for
(
$dir
)
{
/\.(text)/
&&
do
{
my
$v
=
undef
;
$v
=
"
$current_segment
\t
ENDS
\n
"
if
(
$current_segment
);
$current_segment
=
"
_$1
\$
";
$current_segment
=~
tr/[a-z]/[A-Z]/
;
$v
.=
"
$current_segment
\t
SEGMENT
";
$v
.=
$masm
>=
$masmref
?
"
ALIGN(64)
"
:
"
PAGE
";
$v
.=
"
'CODE'
";
if
(
$nasm
)
{
$v
=
"
section .$1 code align=64
\n
";
$v
.=
"
default rel
\n
";
$v
.=
"
%define PUBLIC global
";
}
else
{
$v
=
"
$current_segment
\t
ENDS
\n
"
if
(
$current_segment
);
$current_segment
=
"
_$1
\$
";
$current_segment
=~
tr/[a-z]/[A-Z]/
;
$v
.=
"
$current_segment
\t
SEGMENT
";
$v
.=
$masm
>=
$masmref
?
"
ALIGN(64)
"
:
"
PAGE
";
$v
.=
"
'CODE'
";
}
$self
->
{
value
}
=
$v
;
last
;
};
/\.extern/
&&
do
{
$self
->
{
value
}
=
"
EXTRN
\t
"
.
$line
.
"
:BYTE
";
last
;
};
/\.extern/
&&
do
{
$self
->
{
value
}
=
"
EXTERN
\t
"
.
$line
;
$self
->
{
value
}
.=
"
:BYTE
"
if
(
!
$nasm
);
last
;
};
/\.globl/
&&
do
{
$self
->
{
value
}
=
"
PUBLIC
\t
"
.
$line
;
last
;
};
/\.type/
&&
do
{
(
$sym
,
$type
,
$narg
)
=
split
('
,
',
$line
);
if
(
$type
eq
"
\@
function
")
{
...
...
@@ -380,7 +403,7 @@ my $current_function;
last
;
};
/\.size/
&&
do
{
if
(
defined
(
$current_function
))
{
$self
->
{
value
}
=
"
$current_function
->{name}
\t
ENDP
";
$self
->
{
value
}
=
"
$current_function
->{name}
\t
ENDP
"
if
(
!
$nasm
)
;
undef
$current_function
;
}
last
;
...
...
@@ -390,14 +413,18 @@ my $current_function;
&&
do
{
my
@arr
=
split
('
,
',
$line
);
my
$sz
=
substr
(
$
1
,
0
,
1
);
my
$last
=
pop
(
@arr
);
my
$conv
=
sub
{
my
$var
=
shift
;
if
(
$var
=~
s/0x([0-9a-f]+)/0$1h/i
)
{
$var
;
}
else
{
sprintf
"
0%Xh
",
$var
;
}
};
$sz
=~
tr/bvlq/BWDQ/
;
$self
->
{
value
}
=
"
\t
D
$sz
\t
";
for
(
@arr
)
{
$self
->
{
value
}
.=
sprintf
"
0%Xh,
",
oct
;
}
$self
->
{
value
}
.=
sprintf
"
0%Xh
",
oct
(
$last
);
for
(
@arr
)
{
$self
->
{
value
}
.=
&$conv
(
$_
)
.
"
,
"
;
}
$self
->
{
value
}
.=
&$conv
(
$last
);
last
;
};
/\.picmeup/
&&
do
{
$self
->
{
value
}
=
sprintf
"
\t
DD
\t
0%Xh,090000000h
",
$opcode
{
$line
};
/\.picmeup/
&&
do
{
$self
->
{
value
}
=
sprintf
"
\t
DD
\t
0%Xh,090000000h
",
$opcode
{
$line
};
last
;
};
/\.asciz/
&&
do
{
if
(
$line
=~
/^"(.*)"$/
)
{
...
...
@@ -463,10 +490,11 @@ while($line=<>) {
$sz
=
opcode
->
size
();
if
(
defined
(
$dst
))
{
if
(
!
$
masm
)
{
if
(
!
$
win64
)
{
printf
"
\t
%s
\t
%s,%s
",
$opcode
->
out
(
$dst
->
size
()),
$src
->
out
(
$sz
),
$dst
->
out
(
$sz
);
}
else
{
undef
$sz
if
(
$nasm
&&
$opcode
->
mnemonic
()
eq
"
lea
");
printf
"
\t
%s
\t
%s,%s
",
$opcode
->
out
(),
$dst
->
out
(
$sz
),
$src
->
out
(
$sz
);
}
...
...
@@ -480,7 +508,7 @@ while($line=<>) {
print
$line
,"
\n
";
}
print
"
\n
$current_segment
\t
ENDS
\n
END
\n
"
if
(
$
masm
);
print
"
\n
$current_segment
\t
ENDS
\n
END
\n
"
if
(
$
current_segment
);
close
STDOUT
;
...
...
util/pl/VC-32.pl
浏览文件 @
a23e3dbe
...
...
@@ -42,6 +42,7 @@ if ($FLAVOR =~ /WIN64/)
$bname
=~
s/(.*)\.[^\.]$/$1/
;
$ret
=
<<___;
\$(TMP_D)$o$bname.asm: $source
set ASM=\$(ASM)
\$(PERL) $source \$\@
$target: \$(TMP_D)$o$bname.asm
...
...
@@ -171,9 +172,15 @@ $lfile='/out:';
$shlib_ex_obj
=
"";
$app_ex_obj
=
"
setargv.obj
"
if
(
$FLAVOR
!~
/CE/
);
if
(
$FLAVOR
=~
/WIN64A/
)
{
$asm
=
'
ml64 /c /Cp /Cx
';
$asm
.=
"
/Zi
"
if
$debug
;
$afile
=
'
/Fo
';
if
(`
nasm -v
`
=~
/NASM version ([0-9]+\.[0-9]+)/
&&
$
1
>=
2.0
)
{
$asm
=
'
nasm -f win64
';
$asm
.=
'
-g
'
if
$debug
;
$afile
=
'
-o
';
}
else
{
$asm
=
'
ml64 /c /Cp /Cx
';
$asm
.=
"
/Zi
"
if
$debug
;
$afile
=
'
/Fo
';
}
}
elsif
(
$FLAVOR
=~
/WIN64I/
)
{
$asm
=
'
ias
';
$asm
.=
"
-d debug
"
if
$debug
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录