简体   繁体   English

arm64 程序集:向前分支 n 个字节

[英]arm64 assembly: branch forward n bytes

Hey so I'm trying to get into lower level systems programming in 64 bit arm, and I'm trying to branch forward 64 bytes, specifically to skip the Image header .嘿,所以我正在尝试使用 64 位 arm 进入较低级别的系统编程,并且我正在尝试向前分支 64 个字节,特别是跳过图像 header I noticed that under arm64, PC is no longer an accessible register.我注意到在 arm64 下,PC 不再是可访问的寄存器。 How would I branch forward 64 bytes relative to the current position in arm64 assembly?我将如何在 arm64 程序集中相对于当前 position 向前分支 64 个字节? I need it to fit in two or less instructions (code0 and code1).我需要它来适应两个或更少的指令(code0 和 code1)。 Thanks谢谢

something like this (give or take a word/byte to fine tune it)像这样的东西(给或取一个字/字节来微调它)

b hello
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
hello:

Disassembly of section .text:

0000000000000000 <hello-0x84>:
   0:   14000021    b   84 <hello>
    ...

which then leads to然后导致

b hello
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0
hello:
.inst 0x14000021

Disassembly of section .text:

0000000000000000 <hello-0x84>:
   0:   14000021    b   84 <hello>
    ...

0000000000000084 <hello>:
  84:   14000021    b   108 <hello+0x84>

okay so I cant count to 64 correctly...But you get the idea, I think I meant to use.byte not.word...好的,所以我不能正确数到 64...但是您明白了,我想我的意思是使用.byte not.word...

You either use labels or if you want to have a fixed offset use the machine code.您可以使用标签,或者如果您想要一个固定的偏移量,请使用机器代码。

Some assemblers (assembly is defined by the assembler not the target) might support something like this:一些汇编器(汇编是由汇编器而不是目标定义的)可能支持这样的东西:

hello:
b .+64

Disassembly of section .text:

0000000000000000 <hello>:
   0:   14000010    b   40 <hello+0x40>

But I would expect that to be extremely assembler (assembly language) specific and not port across aarch64 assemblers.但我希望它是非常特定于汇编程序(汇编语言)的,而不是跨 aarch64 汇编程序的移植。 (where some flavor of.word 0x14000010 would port) (其中一些风味的.word 0x14000010 会移植)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM