重定位中,从加载地址一次复制4个字节到运行地址的问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39642794/article/details/83662754

代码:

 ldr r1,=bss_start
     ldr r2,=bss_end
   mov r3,#0

 clean:
   str r3,[r1]
   add r1,r1,#4
   cmp r1,r2
   ble clean
 

在代码中 r1=0x3000 0002;

因为要4字节对齐,所以从0x3000 0000清零。故把data段也清零了。

e59f1038        ldr     r1, [pc, #56]   ; c4 <.text+0xc4>
e59f2038        ldr     r2, [pc, #56]   ; c8 <.text+0xc8>


 c4:   30000002        andcc   r0, r0, r2
  c8:   3000000c        andcc   r0, r0, ip

Disassembly of section .data:

355 30000000 <data_start>:
356 30000000:       Address 0x30000000 is out of bounds.
357 
358 
359 30000001 <g_Char3>:
360 30000001:       Address 0x30000001 is out of bounds.
 

r1=0x3000 0002 是接着数据段0x3000 0001后面开始的,但是因为4字节对齐的问题,r1=0x3000 0000开始清零

猜你喜欢

转载自blog.csdn.net/qq_39642794/article/details/83662754
今日推荐