使用ldr加载指令(not ldr伪指令)实现绝对地址跳转
hander标号依赖于链接脚本地址的设定,将hander地址放在标号为step3标号的内存中,从而达到实现绝对地址跳转的目的。
+++++++++++link2.s+++++++++
.text
.global _start
_start: b step1
step1: ldr pc,=step2
step2: ldr pc,step3
step3: .long hander
hander: b step4
step4: b step4 | |
+++++++++++Makefile++++++++++++++
link2: link2.s
arm-linux-gcc -c -o link2.o link2.s
arm-linux-ld -Ttext 0x00000000 link2.o -o link2_elf_0x00000000
arm-linux-ld -Ttext 0x30000000 link2.o -o link2_elf_0x30000000
arm-linux-objdump -D link2_elf_0x00000000 > link2_0x00000000_dis
arm-linux-objdump -D link2_elf_0x30000000 > link2_0x30000000_dis
clean :
rm -f *.o | |
link2_elf_0x30000000: file format elf32-littlearm
Disassembly of section .text:
30000000 <_start>:
30000000: eaffffff b 30000004 <step1>
30000004 <step1>:
30000004: e59ff00c ldr pc, [pc, #12]; 30000018 <step4+0x4>
30000008 <step2>:
30000008: e51ff004 ldr pc, [pc, #-4] ; 3000000c <step3>
3000000c <step3>:
3000000c: 30000010 .word 0x30000010
30000010 <hander>:
30000010: eaffffff b 30000014 <step4>
30000014 <step4>:
30000014: eafffffe b 30000014 <step4>
30000018: 30000008 .word 0x30000008 | |
link2_elf_0x00000000: file format elf32-littlearm
Disassembly of section .text:
00000000 <_start>:
0: eaffffff b 4 <step1>
00000004 <step1>:
4: e59ff00c ldr pc, [pc, #12] ; 18 <step4+0x4>
00000008 <step2>:
8: e51ff004 ldr pc, [pc, #-4] ; c <step3>
0000000c <step3>:
c: 00000010 .word 0x00000010
00000010 <hander>:
10: eaffffff b 14 <step4>
00000014 <step4>:
14: eafffffe b 14 <step4>
18: 00000008 .word 0x00000008 | |
