链接地址:程序运行时应当处于的地址
1,当Makefile为
[root@localhost
sdram]# vi Makefile
sdram.bin :
head.S leds.c
arm-linux-gcc -c -o head.o head.S
arm-linux-gcc -c -o leds.o leds.c
arm-linux-ld -Ttext 0x00000000 head.o leds.o -o sdram_elf
arm-linux-objcopy -O binary -S
sdram_elf sdram.bin
arm-linux-objdump -D -m arm sdram_elf > sdram.dis
clean:
rm -f sdram.dis sdram.bin sdram_elf *.o
====================================================
程序在sram中的4kb中运行,地址从0x00000000开始
sdram_elf: file format elf32-littlearm
Disassembly of
section .text:
00000000
<_start>:
0: eb000005
bl 1c <disable_watch_dog>
4: eb000010
bl 4c <memsetup>
8: eb000007
bl 2c <copy_steppingstone_to_sdram>
c: e59ff090
ldr pc,
[pc, #144] ; a4 <mem_cfg_val+0x34>
PC=0x0000000c+8+144=0xa4=0x00000010
00000010 <on_sdram>:仍然在sram中运行
10: e3a0d30d mov sp, #872415232 ; 0x34000000
14: eb000033
bl e8
<main>
00000018
<halt_loop>:
18: eafffffe
b 18
<halt_loop>
0000001c <disable_watch_dog>:
1c: e3a01453
mov r1,
#1392508928 ; 0x53000000
20: e3a02000 mov r2, #0 ;
0x0
24: e5812000
str r2,
[r1]
28: e1a0f00e
mov pc,
lr
0000002c <copy_steppingstone_to_sdram>:
2c: e3a01000
mov r1,
#0 ; 0x0
30: e3a02203 mov r2, #805306368 ; 0x30000000
34: e3a03a01
mov r3,
#4096 ; 0x1000
38: e4914004
ldr r4,
[r1], #4
3c: e4824004 str r4, [r2], #4
40: e1510003
cmp r1,
r3
44: 1afffffb
bne 38
<copy_steppingstone_to_sdram+0xc>
48: e1a0f00e
mov pc,
lr
0000004c <memsetup>:
4c: e3a01312
mov r1,
#1207959552 ; 0x48000000
50: e28f2018 add r2, pc, #24 ; 0x18
54: e1a00000 nop (mov r0,r0)
58: e2813034
add r3,
r1, #52 ; 0x34
5c: e4924004 ldr r4, [r2], #4
60: e4814004
str r4,
[r1], #4
64: e1510003
cmp r1,
r3
68: 1afffffb
bne 5c <memsetup+0x10>
6c: e1a0f00e mov pc, lr
00000070
<mem_cfg_val>:
70: 22011110
.word 0x22011110
74: 00000700
.word 0x00000700
78: 00000700
.word 0x00000700
7c: 00000700 .word 0x00000700
80: 00000700
.word 0x00000700
84: 00000700
.word 0x00000700
88: 00000700
.word 0x00000700
8c: 00018005 .word 0x00018005
90: 00018005
.word 0x00018005
94: 008c07a3
.word 0x008c07a3
98: 000000b1
.word 0x000000b1
9c: 00000030 .word 0x00000030
a0: 00000030
.word 0x00000030
a4: 00000010
.word 0x00000010
a8: e1a00000 .word 0xe1a00000
ac: e1a00000 .word 0xe1a00000
2,当Makefile为
sdram.bin :
head.S leds.c
arm-linux-gcc -c -o head.o head.S
arm-linux-gcc -c -o leds.o leds.c
arm-linux-ld -Ttext 0x30000000 head.o leds.o -o
sdram_elf
arm-linux-objcopy -O binary -S sdram_elf
sdram.bin
arm-linux-objdump -D -m arm sdram_elf > sdram.dis
clean:
rm -f
sdram.dis sdram.bin sdram_elf *.o
============================================
程序在sram中的4kb中运行,地址从0x00000000开始
直到ldr pc, [pc, #144] ;这一句,跳转到了sdram中运行
sdram_elf: file format elf32-littlearm
Disassembly of
section .text:
30000000
<_start>:
30000000: eb000005 bl 3000001c <disable_watch_dog>
30000004: eb000010 bl 3000004c <memsetup>
30000008: eb000007 bl 3000002c <copy_steppingstone_to_sdram>
3000000c: e59ff090
ldr pc,
[pc, #144] ;
//300000a4
<mem_cfg_val+0x34>
PC=当前地址+8+offset
PC=0x0000000c+8+144=0x000000a4=0x30000010
这就是引入的链接地址
30000010
<on_sdram>://程序跳到了sdram中运行
30000010: e3a0d30d
mov sp,
#872415232 ; 0x34000000
30000014: eb000033 bl 300000e8 <main>
30000018
<halt_loop>:
30000018: eafffffe b 30000018 <halt_loop>
3000001c <disable_watch_dog>:
3000001c: e3a01453 mov r1, #1392508928 ; 0x53000000
30000020: e3a02000
mov r2,
#0 ; 0x0
30000024: e5812000 str r2, [r1]
30000028: e1a0f00e mov pc, lr
3000002c <copy_steppingstone_to_sdram>:
3000002c: e3a01000 mov r1, #0 ;
0x0
30000030: e3a02203
mov r2,
#805306368 ; 0x30000000
30000034: e3a03a01 mov r3, #4096 ;
0x1000
30000038: e4914004 ldr r4, [r1], #4
3000003c: e4824004
str r4,
[r2], #4
30000040: e1510003 cmp r1, r3
30000044: 1afffffb bne 30000038 <copy_steppingstone_to_sdram+0xc>
30000048: e1a0f00e mov pc, lr
3000004c <memsetup>:
3000004c: e3a01312 mov r1, #1207959552 ; 0x48000000
30000050: e28f2018
add r2,
pc, #24 ; 0x18
30000054: e1a00000
nop (mov
r0,r0)
30000058: e2813034 add r3, r1, #52 ; 0x34
3000005c: e4924004
ldr r4,
[r2], #4
30000060: e4814004 str r4, [r1], #4
30000064: e1510003 cmp r1, r3
30000068: 1afffffb bne 3000005c <memsetup+0x10>
3000006c: e1a0f00e
mov pc,
lr
30000070
<mem_cfg_val>:
30000070: 22011110 .word 0x22011110
30000074: 00000700 .word 0x00000700
30000078: 00000700 .word 0x00000700
3000007c: 00000700
.word 0x00000700
30000080: 00000700 .word 0x00000700
30000084: 00000700 .word 0x00000700
30000088: 00000700 .word 0x00000700
3000008c: 00018005
.word 0x00018005
30000090: 00018005 .word 0x00018005
30000094: 008c07a3 .word 0x008c07a3
30000098: 000000b1 .word 0x000000b1
3000009c: 00000030
.word 0x00000030
300000a0: 00000030
.word 0x00000030
300000a4: 30000010 .word 0x30000010
300000a8: e1a00000 .word 0xe1a00000
300000ac: e1a00000 .word 0xe1a00000