- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我构建了 golang 代码并输出了汇编代码。代码和输出在上面。JMP 指令是否正确:0x000f 00015 (math.go:17) JMP 23
指向0x0017(十进制23)?在 JMP 指令后看到十进制值让我有点困惑。
代码:
(math.go:15) func multiplyLoop(a, b int) int {
(math.go:16) var res int
(math.go:17) for i := 0; i < b; i++ {
(math.go:18) res += a
(math.go:19) }
(math.go:20) return res
(math.go:21) }
构建:
go tool compile -S -m math.go
程序集:
"".multiplyLoop STEXT nosplit size=34 args=0x18 locals=0x0
0x0000 00000 (math.go:15) TEXT "".multiplyLoop(SB), NOSPLIT, $0-24
0x0000 00000 (math.go:15) FUNCDATA $0, gclocals·54241e171da8af6ae173d69da0236748(SB)
0x0000 00000 (math.go:15) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (math.go:15) MOVQ "".a+8(SP), AX
0x0005 00005 (math.go:15) MOVQ "".b+16(SP), CX
0x000a 00010 (math.go:15) MOVL $0, DX
0x000c 00012 (math.go:15) MOVQ DX, BX
0x000f 00015 (math.go:17) JMP 23
0x0011 00017 (math.go:17) INCQ DX
0x0014 00020 (math.go:18) ADDQ AX, BX
0x0017 00023 (math.go:17) CMPQ DX, CX
0x001a 00026 (math.go:17) JLT 17
0x001c 00028 (math.go:20) MOVQ BX, "".~r2+24(SP)
0x0021 00033 (math.go:20) RET
最佳答案
JMP 23
到线 0x0017 00023
对于 i < b
, CMPQ DX, CX
. JLT 17
到线 0x0011 00017
对于 i++
, INCQ DX
.例如,
package multiply
func multiplyLoop(a, b int) int {
var res int
for i := 0; i < b; i++ {
res += a
}
return res
}
$ go tool compile -S multiply.go
"".multiplyLoop STEXT nosplit size=34 args=0x18 locals=0x0
0x0000 00000 (multiply.go:3) TEXT "".multiplyLoop(SB), NOSPLIT, $0-24
0x0000 00000 (multiply.go:3) FUNCDATA $0, gclocals·54241e171da8af6ae173d69da0236748(SB)
0x0000 00000 (multiply.go:3) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (multiply.go:3) MOVQ "".a+8(SP), AX
0x0005 00005 (multiply.go:3) MOVQ "".b+16(SP), CX
0x000a 00010 (multiply.go:3) XORL DX, DX
0x000c 00012 (multiply.go:3) MOVQ DX, BX
0x000f 00015 (multiply.go:5) JMP 23
0x0011 00017 (multiply.go:5) INCQ DX
0x0014 00020 (multiply.go:6) ADDQ AX, BX
0x0017 00023 (multiply.go:5) CMPQ DX, CX
0x001a 00026 (multiply.go:5) JLT 17
0x001c 00028 (multiply.go:8) MOVQ BX, "".~r2+24(SP)
0x0021 00033 (multiply.go:8) RET
0x0000 48 8b 44 24 08 48 8b 4c 24 10 31 d2 48 89 d3 eb H.D$.H.L$.1.H...
0x0010 06 48 ff c2 48 01 c3 48 39 ca 7c f5 48 89 5c 24 .H..H..H9.|.H.\$
0x0020 18 c3 ..
go.info."".multiplyLoop SDWARFINFO size=78
0x0000 02 22 22 2e 6d 75 6c 74 69 70 6c 79 4c 6f 6f 70 ."".multiplyLoop
0x0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0020 00 01 9c 00 00 00 00 01 0e 61 00 00 03 00 00 00 .........a......
0x0030 00 01 9c 0e 62 00 00 03 00 00 00 00 02 91 08 0e ....b...........
0x0040 7e 72 32 00 01 03 00 00 00 00 02 91 10 00 ~r2...........
rel 17+8 t=1 "".multiplyLoop+0
rel 25+8 t=1 "".multiplyLoop+34
rel 35+4 t=29 gofile../home/peter/Dropbox/gopath/src/so/multiply.go+0
rel 45+4 t=28 go.info.int+0
rel 56+4 t=28 go.info.int+0
rel 70+4 t=28 go.info.int+0
go.range."".multiplyLoop SDWARFRANGE size=0
gclocals·54241e171da8af6ae173d69da0236748 SRODATA dupok size=9
0x0000 01 00 00 00 03 00 00 00 00 .........
gclocals·33cdeccccebe80329f1fdbee7f5874cb SRODATA dupok size=8
0x0000 01 00 00 00 00 00 00 00
$
关于go - golang汇编中的jmp指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49103204/
我正在 C 中的一些 asm 代码中执行相对跳转。我已经让跳转按预期工作,但它会在跳转发生并完成运行代码后立即返回。 #include void function() { asm("jmp
我需要为漏洞利用演示制作一个跳转操作码。 我需要在跳转指令之后跳转到大约 200 个字节。这对于 jmp short 来说太多了。 如果我生成一个带有常规跳转的操作码,jmp $200 我得到这个:
在 AT&T 汇编语法中,文字值必须以 $ 符号为前缀 但是,在内存寻址中,文字值没有$ 符号 例如: mov %eax, -100(%eax) 和 jmp 100 jmp $100, $100 不同
尽管这两个程序都遵守 shellcode 执行所需的相对寻址指令,并且都在执行时打印所需的消息,但当用作 shellcode 时,2nd Sample 失败了。谁能解释这种行为?奇怪的是,与第一个相同
我听说使用 jmp -2 我们可以进行无限循环。这听起来很奇怪,但是在解释了相对跳转需要一个字节之后,下一条指令地址(eip)将比 jmp 地址少 2 个字节。所以,我决定实现它,但我无法让它发挥作用
我偶尔会使用汇编。因此,我需要更专家的帮助来解码我必须处理的一小段代码。 0000: 48 ff 25 61 57 07 00 rex.W jmp QWORD PTR [rip+0x75761
当程序集有像 jmp f 这样的指令时,堆栈和帧指针会发生什么? 我的意思是 - f 是内存中的标签,对吗?我们如何跳转到内存中的不同地址而不更新我们的帧和堆栈指针... 编辑:我说的是 Intel
好的,所以我一直在尝试在汇编/C 中制作一个两步引导加载程序,但我无法让 JMP 工作。起初我以为读取失败了,但是经过以下测试我排除了这种可能性: __asm__ __volatile__(
我正在尝试计算跳转的正确操作码,我在其他线程中看过这个,但我仍然不明白: 我以为公式是desination - (from+5)但它只是不工作,它很远,这是我想跳转到/从的地址: FROM: 6259
我正在尝试编写一个 exe 打包程序/保护程序,作为了解有关汇编程序、C++ 以及 PE 文件工作原理的更多信息的一种方式。我目前已经让它工作了,所以包含 EP 的部分与一个 key 进行异或,并创建
我只是在看我用 C 编写的一个简单 exe 的 .text 部分,我只是想弄清楚一些 x86 操作码的结构。 从我一直在阅读的内容来看,0xe9 似乎是相对跳转 (JMP) 的单字节操作码,但是我不确
所以我在 %eax 有一个地址我想 jmp 到但代码无法编译,有没有办法解决这个问题? movl 0xdeadbeef, %eax jmp %eax ; <--- compile error: typ
对JMP机器指令的十六进制代码转换有疑问。我有我想跳转到的绝对地址,比如“JMP 0x400835”。 首先,这是允许的吗?如果是,相应的十六进制代码是什么? 如果没有,我可以先将地址存储在某个寄存器
在 Google Native Client 的论文中,作者定义了一个 nacljmp如这两条指令: and $0xffffffe0, %eax # Clears the 5 least si
我试图从 Bootloader 编写引导加载程序。编写的代码是 BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after
我被告知尝试使用“jmp”而不是“call”,但是“jmp”不喜欢我..当我跳跃时它不会返回(所以它永远不会退出并且不快乐的日子),但是调用会返回并正常退出。 我很高兴使用“call”,但实际上我应该
我正在尝试用 java 分析一个简单的应用程序,它基本上只打开一个 RMI 接口(interface)并等待消息。当我通过 TIJMP 打开应用程序时,它从头开始报告: 堆:init - 0,已用 -
如何使用jump family指令? 这就是他们所拥有的: JL label "It" jumps if it is less than or if it is not larger than or
在为 x86 平台构建汇编器时,我在编码 JMP 指令时遇到了一些问题: OPCODE INSTRUCTION SIZE EB cb JMP rel8 2 E9 cw
我正在查看 IDA 中的一个程序,试图弄清楚某个函数是如何工作的,这时我遇到了这样的事情: ; C_TestClass::Foo(void) __text:00000000 __ZN14C_TestC
我是一名优秀的程序员,十分优秀!