执行二进制包 [英] executing wrapped binary
问题描述
我想执行包裹着我自己的组装code里面的二进制,有理由像我想要做一些init和查看二进制的行为,但我无法执行二进制即使没有任何这样的init上UART无输出,LCD(我运行一个基于ARM cortexa-8 qsd8250b芯片组供电的MDP [移动开发平台])我知道我的船上包装的二进制完美运行,因为我已经用它早期(不到一天前)。
I am trying to execute a binary wrapped inside my own assembly code, there are reasons like i want to do some init and see how the binary behaves, however i am unable to execute the binary even without any such init, no output on uart, lcd (I am running an arm cortexa-8 based qsd8250b chipset powering a mdp[mobile development platform]) I know the wrapped binary runs perfectly on my board since i have used it earlier (less than a day ago).
问题是,我不确定/信息不可用有关,其中二进制加载到内存中。
Problem is, i am unsure/info is not available regarding where the binary is loaded in memory.
这是我的code到目前为止
This is my code so far
.org 0
.type _start,#function
.globl _start
_start:
b main
@@ Snipped headers @@
.org 0x1000
main:
mov r9, pc @r9= address of loadlk in memory
ldr r2, =loadlk @r2= address of loadlk in objfile
loadlk:
sub r0, r9, r2 @r0= r9-r2 = address of _start in memory
add r0, r0, #0x1200 @r0= r0 + 0x1200 = lkbin_start (src)
add r3, r0, #0xD000 @r3= r0 + 0xd000 = lkbin_start + ~sz(lk.bin) = lkbin_end (end)
cpy:
ldr r1, =0x28000000 @r1= destination (dst)
ldr r2, [r0],#4
str r2, [r1],#4
cmp r0, r3 @current read address ?= end, r0 < r3 -> branch back
blo cpy
ldr r9, =0x28000000
ldr r4, =0xa9000864 @Flashlight
ldr r5, =0xa9000814
ldr r4, [r4, #0]
orr r6, r4, #0x200000
str r6, [r5, #0]
dsb sy
isb sy
bx r9
b .
.ltorg
.org 0x1200
lkbin_start:
.incbin "lk.bin"
lkbin_end:
.align 8
这是我的编译脚本
and this is my compile script
arm-none-eabi-as bootwrapper.S -o bootwrapper.o
arm-none-eabi-objcopy -O binary bootwrapper.o binary
这肯定不会达到手电筒code,因为我看到我的手电筒闪烁,但没有任何反应,从我能想到它会将垃圾code到目标,并试图执行它。
It sure does reach the flashlight code as i see my flashlight blink, but then nothing happens, from what i can think it copies trash code to the target and tries to execute it.
任何帮助吗?
推荐答案
好吧,我不知道我可能是这个愚蠢的夜晚...
Okay, i didn't know i could be this silly at night...
cpy:
ldr r1, =0x28000000 @r1= destination (dst)
ldr r2, [r0],#4
str r2, [r1],#4
cmp r0, r3 @current read address ?= end, r0 < r3 -> branch back
blo cpy
随着循环继续,R1总是覆盖previous内容的值0x28000000,因此所有的数据在内存中写入一个单一的位置......多么的愚蠢。
As the loop went on, r1 always had the value 0x28000000, so all data was written to one single location in memory overwriting the previous contents... how stupid.
这篇关于执行二进制包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!