gpt4 book ai didi

.net - 为什么这个 .Net IL 无法验证?

转载 作者:行者123 更新时间:2023-12-04 03:49:40 24 4
gpt4 key购买 nike

我编写了一些自定义 IL,它不会通过 PEVerify。我得到的错误是

$ peverify foo.exeMicrosoft (R) .NET Framework PE Verifier.  Version  4.0.30319.17929Copyright (c) Microsoft Corporation.  All rights reserved.[IL]: Error: [Z:\virtualbox_shared\foo.exe : HelloWorld.Program::Main][offset 0x00000021] Stack height at all points must be determinable in a single forward scan of IL.1 Error(s) Verifying foo.exe

The program however will run fine without any exceptions. Here is the IL of the relevant method:

.method private static hidebysig
default void Main (string[] args) cil managed
{
// Method begins at RVA 0x2050
.entrypoint
// Code size 54 (0x36)
.maxstack 2

//custom IL
ldc.i4 1
ldc.i4 1
ceq
switch(first, second)

first:
ldc.i4 1
br.s temp
popit: pop
br.s second

temp: ldc.i4 1
brfalse temp2
temp2: br.s popit

second:
ldc.i4 2
pop

ret

} // end of method Program::Main

完整源代码位于 pastebin

为什么我收到这个错误?

最佳答案

must be determinable in a single forward scan of IL



这是验证失败的关键部分。验证器不会尝试验证每个分支路径,这需要解决停机问题。它对 POP 不满意,它无法在单次前向扫描中看到该操作码是由具有非空堆栈的后向分支到达的,因此是有效的。

关于.net - 为什么这个 .Net IL 无法验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13274384/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com