执行打包的二进制文件 [英] executing wrapped binary

查看:39
本文介绍了执行打包的二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行包含在我自己的汇编代码中的二进制文件,有一些原因,例如我想做一些初始化并查看二进制文件的行为,但是即使没有任何此类初始化,我也无法执行二进制文件,没有输出在 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.

这是我目前的代码

.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

这是我的编译脚本

arm-none-eabi-as bootwrapper.S -o bootwrapper.o
arm-none-eabi-objcopy -O binary bootwrapper.o binary

当我看到手电筒闪烁时,它确实到达了手电筒代码,但随后什么也没发生,据我所知,它会将垃圾代码复制到目标并尝试执行它.

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 的值始终为 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆