IMPORT |Image$$RO$$Limit| ; End of ROM code (=start of ROM data) IMPORT |Image$$RW$$Base| ; Base of RAM to initialise IMPORT |Image$$ZI$$Base| ; Base and limit of area IMPORT |Image$$ZI$$Limit| ; to zero initialise
……………………
LDR r0, =|Image$$RO$$Limit| ; Get pointer to ROM data LDR r1, =|Image$$RW$$Base| ; and RAM copy LDR r3, =|Image$$ZI$$Base| ;Zero init base => top of initialised data CMP r0, r1 ; Check that they are different BEQ %F1 0 CMP r1, r3 ; Copy init data LDRCC r2, [r0], #4 ;--> LDRCC r2, [r0] + ADD r0, r0, #4 STRCC r2, [r1], #4 ;--> STRCC r2, [r1] + ADD r1, r1, #4 BCC %B0 1 LDR r1, =|Image$$ZI$$Limit| ; Top of zero init segment MOV r2, #0 2 CMP r3, r1 ; Zero init STRCC r2, [r3], #4 BCC %B2
这段程序是ARM编译器下的语句,我在GNU编译下改为如下的程序
.extern Image_RO_Limit .extern Image_RW_Base .extern Image_BSS_Base .extern Image_BSS_Limit
……………………
LDR r0, =Image_RO_Limit // Get pointer to ROM data LDR r1, =Image_RW_Base //and RAM copy LDR r3, =Image_BSS_Base CMP r0, r1 //Check that they are different BEQ FF1 FF0: CMP r1, r3 //Copy init data LDRCC r2, [r0], #4 //LDRCC r2, [r0] + ADD r0, r0, #4 STRCC r2, [r1], #4 //STRCC r2, [r1] + ADD r1, r1, #4 BCC FF0 FF1: LDR r1, =Image_BSS_Limit //Top of zero init segment MOV r2, #0 F2: CMP r3, r1 //Zero init STRCC r2, [r3], #4 BCC F2
可是编译的时候出现如下的错误提示:
init.../kb_self_1/init.s:185: undefined reference to `Image_RO_Limit' init.../kb_self_1/init.s:185: undefined reference to `Image_RW_Base' init.../kb_self_1/init.s:185: undefined reference to `Image_BSS_Base' init.../kb_self_1/init.s:185: undefined reference to `Image_BSS_Limit'
说是没有定义的符号,那么在ARM编译器下,他们不是也没有定义吗?问题出现在什么地方呢?
各位大侠请指教。当我没有这部分把DATA段拷贝到SDRAM中去的这些语句时,程序运行正常,并且在flash里面运行正常,那么难道这些拷贝语句是多余的吗?请教各位高手了。另外我使用的是GNU的编译器,是不是是GNU的编译器能够自动生成这样的拷贝代码吗?有点糊涂,还情各位高手指教。