GAS:jmp 到标签会导致错误的跳转?
我正在尝试汇编以下程序:
.text
.globl _search2
_search2:
pushq %rbp
movq %rsp, %rbp
movq %rax, -8(%rbp)
go_again:
cmpl $0x90909090, (%rax)
je go_out
addq $0x8, %rax
jmp go_again
go_out:
leave
ret
通过执行以下操作:“gcc -o test test.s main.c”,我得到:
otool -v -t test
_search2:
0000000100000d0c pushq %rbp
0000000100000d0d movq %rsp,%rbp
0000000100000d10 movq %rax,0xf8(%rbp)
go_again:
0000000100000d14 cmpl $0x90909090,(%rax)
0000000100000d1a je 0x100000d29
0000000100000d20 addq $0x08,%rax
0000000100000d24 jmp 0x200000d14
go_out:
0000000100000d29 leave
0000000100000d2a ret
jmp 试图跳转到地址 0x200000d14,这是完全错误的而不是0x100000d29,标有 go_out 标签。
请帮忙。
I am trying to assembly following program:
.text
.globl _search2
_search2:
pushq %rbp
movq %rsp, %rbp
movq %rax, -8(%rbp)
go_again:
cmpl $0x90909090, (%rax)
je go_out
addq $0x8, %rax
jmp go_again
go_out:
leave
ret
by doing this: "gcc -o test test.s main.c" and I get this:
otool -v -t test
_search2:
0000000100000d0c pushq %rbp
0000000100000d0d movq %rsp,%rbp
0000000100000d10 movq %rax,0xf8(%rbp)
go_again:
0000000100000d14 cmpl $0x90909090,(%rax)
0000000100000d1a je 0x100000d29
0000000100000d20 addq $0x08,%rax
0000000100000d24 jmp 0x200000d14
go_out:
0000000100000d29 leave
0000000100000d2a ret
The jmp is trying to jump to address 0x200000d14 which is totally wrong instead of 0x100000d29 which is marked with go_out label.
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 objdump -D test > test.list
查看您使用的工具是否可以显示指令,如果指令(有些)相同,则相对地址是正确的,您可以忽略该工具正在显示的地址,或者干脆不使用该工具。
如果分支是直接的并且与目标不匹配,则存在 gcc/gnu 工具问题。
Try objdump -D test > test.list
See if the tool you are using can display the instructions, if the instructions are the (somewhat the) same then the relative address is correct and you can ignore the address the tool is displaying, or just not use that tool.
If the branches are direct and dont match the target, then there is a gcc/gnu tools problem.