[英]Can llvm emit code that jumps to a given address within a function?
Following up on this question, is it possible for llvm to generate code that may jump to an arbitrary address within a function in the same address space? 关注这个问题,llvm是否有可能生成可能跳转到同一地址空间中函数内任意地址的代码? ie 即
void func1() {
...
<code that jumps to addr2>
...
}
void func2() {
...
addr2:
<some code in func2()>
...
}
Yes,No,Yes,No,(yes) - It depends on the level you look at and what you mean with possible
: 是的,不,是,否,(是) -这取决于你看水平,你的意思,与possible
:
goto
) 不,因为C和C ++不允许这样的跳转到ARBITRARY位置,所以clang不会编译任何尝试这样做的程序(例如通过goto
) longjmp
macro jumps back to a place in the control flow that you have already visited (where you called setjmp
) but also restores (most) of the system state. (是)c longjmp
宏跳回到您已访问过的控制流中的某个位置(您调用setjmp
),但也恢复(大部分)系统状态。 EDIT: However, this is UB if func2 isn't somewhere up in the current callstack from where you jump. 编辑:但是,如果func2不在你跳转的当前callstack的某个地方,这就是UB。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.