问题描述
我一直在为简单表达式编写JIT ARM编译器。为我的即时编译器提供了将在表达式以及表达式本身中使用的函数和变量的地址。并生成用于计算表达式的ARM代码。
这是我的编译器针对表达式inc(1) + 1
的输出:
start:
push {r4} //saving r4
ldr r0,[pc] //writing the constant into r0
b skip0 //skipping data line
.word 0x1
skip0:
push {r0} //saving the constant
pop {r0} //fucntion time. Let's pop the argument
ldr r4,[pc] //Let's get function address
b skip1 //skipping data line
.word 0x13050
skip1:
bx r4 //jumping to function
push {r0} //saving the output of it
ldr r0,[pc] //writing the constant into r0
b skip2 //skipping data line
.word 0x1
skip2:
push {r0} //saving the constant
pop {r0-r1} //getting function result and the constant
add r0,r1,r0 //adding them to each other
push {r0} //saving the result
pop {r0} //work done,popping the result to r0 in order to return it
pop {r4} //placing r4 back
bx lr
inc(x)
是仅返回++x
的外部函数。 0x13050
是函数在执行时的地址。
有趣的事实:如果我将bx
更改为blx
,则会遇到段错误
解决方法
答案在最后一行:@RequestHeader("the-header-name") TheHeaderType theHeader
覆盖@RequestHeader MultiValueMap<String,String> headers
并且由于您没有在开始时保留blx
,因此在结尾的lr
会导致分支返回到lr
之后的行bx lr
,从而导致无限循环。 br />
而且由于您弹出的时间比每次迭代的弹出时间多,所以堆栈指针将在某个时间指向无效地址=> segfault
使用push {r0}
子函数blx r4
不会返回到您的函数,而是返回到返回值2(除了INCORRECT堆栈指针之外)的调用者函数。
bx r4