關於arm-none-linux-gnueabi-4.4.3編譯環境下,lib1funs.S編譯報錯的處理

原始報錯信息:

Krj@VM:~/soc_workspace/1stQuarter_BarBoard/15_NandFlash/NandFlash_codeTest$ make cleanDepend && make
delete all module files succeed!
delete all depend files succeed!
start.s compile running...
start.s compile succeed!
src/memCtrl/memCtrl.c compile running...
src/memCtrl/memCtrl.c compile succeed!
src/nand_flash/nand_flash.c compile running...
src/nand_flash/nand_flash.c compile succeed!
src/soc_s3c2440_init.c compile running...
src/soc_s3c2440_init.c compile succeed!
src/uart/uart.c compile running...
src/uart/uart.c compile succeed!
src/exception/interrupt.c compile running...
src/exception/interrupt.c compile succeed!
src/led/led.c compile running...
src/led/led.c compile succeed!
src/tools/tools.c compile running...
src/tools/tools.c compile succeed!
src/log/syslog.c compile running...
src/log/syslog.c compile succeed!
src/test/test.c compile running...
src/test/test.c compile succeed!
src/exception/exception.c compile running...
src/exception/exception.c compile succeed!
src/timer/timer.c compile running...
src/timer/timer.c compile succeed!
src/nor_flash/nor_flash.c compile running...
src/nor_flash/nor_flash.c compile succeed!
soc_s3c2440.c compile running...
soc_s3c2440.c compile succeed!
lib1funcs.s compile running...
lib1funcs.s: Assembler messages:
lib1funcs.s:44: Error: junk at end of line, first unrecognized character is `\'
lib1funcs.s:45: Error: bad instruction `align'
lib1funcs.s:45: Error: junk at end of line, first unrecognized character is `\'
lib1funcs.s:216: Error: bad instruction `entry(__udivsi3)'
lib1funcs.s:226: Error: selected processor does not support `clz r3,r1'
lib1funcs.s:226: Error: selected processor does not support `clz r2,r0'
lib1funcs.s:235: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:241: Error: bad instruction `entry(__umodsi3)'
lib1funcs.s:251: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:251: Error: selected processor does not support `clz r3,r0'
lib1funcs.s:256: Error: bad instruction `entry(__divsi3)'
lib1funcs.s:271: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:271: Error: selected processor does not support `clz r0,r3'
lib1funcs.s:286: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:294: Error: bad instruction `entry(__modsi3)'
lib1funcs.s:308: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:308: Error: selected processor does not support `clz r3,r0'
lib1funcs.s compile failure!
commpile project S3C2440 is running...
./src/nand_flash/nand_flash.o: In function `nand_flash_get_mem_info':
nand_flash.c:(.text+0x374): undefined reference to `__aeabi_uidiv'
nand_flash.c:(.text+0x3a0): undefined reference to `__aeabi_uidiv'
link all files to target file S3C2440.bin failure!
Krj@VM:~/soc_workspace/1stQuarter_BarBoard/15_NandFlash/NandFlash_codeTest$ 

是在編譯lib1funs.S時報的錯誤。

1、先處理兩個宏定義引起的報錯:

lib1funcs.s: Assembler messages:
lib1funcs.s:44: Error: junk at end of line, first unrecognized character is `\'
lib1funcs.s:45: Error: bad instruction `align'
lib1funcs.s:45: Error: junk at end of line, first unrecognized character is `\'

直接將源有宏定義全部去掉,用到宏定義的地方直接一個個定義就行,對於換行符編譯器不是別的問題,暫時也沒有搜索到好的方式解決,反正文件中用到該宏就只有幾處,怎麼修改快速怎麼來。

2、處理剩餘的報錯(指令不支持):

lib1funcs.s: Assembler messages:
lib1funcs.s:221: Error: selected processor does not support `clz r3,r1'
lib1funcs.s:221: Error: selected processor does not support `clz r2,r0'
lib1funcs.s:230: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:248: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:248: Error: selected processor does not support `clz r3,r0'
lib1funcs.s:269: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:269: Error: selected processor does not support `clz r0,r3'
lib1funcs.s:284: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:307: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:307: Error: selected processor does not support `clz r3,r0'
lib1funcs.s compile failure!

經過百度,搜索到解決方案,將原有的:

CC += -march=armv4

替換爲:

CC += -march=armv5te

即可解決。

3、但是又報了新的錯誤,除法不支持:

commpile project S3C2440 is running...
./src/nand_flash/nand_flash.o: In function `nand_flash_get_mem_info':
nand_flash.c:(.text+0x370): undefined reference to `__aeabi_uidiv'
nand_flash.c:(.text+0x39c): undefined reference to `__aeabi_uidiv'
link all files to target file S3C2440.bin failure!

按照網上解決方案,使用libgcc自帶除法運算庫函(需要確認本地編譯環境庫的實際路徑):

Krj@VM:/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3$ grep "__aeabi_uidiv" * -Rn              
匹配到二進制文件 libgcc.a
匹配到二進制文件 libgcov.a
Krj@VM:/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3$ 
#指定連接庫文
LIBPATH :=
LIBPATH +=-lgcc -L/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3/

#連接時使用鏈接庫即可
$(TARGETP_ROJECT):$(ALLOBJS)
	@echo "commpile project $(TARGETP_ROJECT) is running..." && \
	$(LD) $(START) $(OBJS) $(LIBPATH) -o [email protected] && \
	$(OBJCOPY) -O binary -S [email protected] [email protected] && \
	$(OBJDUMP) -D [email protected] > [email protected] && \
	echo "link all files to target file $(TARGETP_ROJECT).bin succeed!" || \
	echo "link all files to target file $(TARGETP_ROJECT).bin failure!"

4、解決了除法運算不支持的問題,又有新的報錯,未定義的raise:

commpile project S3C2440 is running...
/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3//libgcc.a(_dvmd_lnx.o): In function `__div0':
/opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/libgcc/../gcc/config/arm/lib1funcs.asm:1093: undefined reference to `raise'
link all files to target file S3C2440.bin failure!

按照博客博主lock1501的解決方案,進行修改:

/*
 * 2020-2-16 15:44:27
 * 解決編譯問題:
 * /opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3//libgcc.a(_dvmd_lnx.o): In function `__div0':
 * /opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/libgcc/../gcc/config/arm/lib1funcs.asm:1093: undefined reference to `raise'
 * 代碼參考u-boot-2012.04.01
 */
int raise (int signum)
{
	print_screen("raise: Signal # %d caught\n", signum);
	return 0;
}

最終編譯成功,撒花:

lib1funcs.s compile succeed!
commpile project S3C2440 is running...
link all files to target file S3C2440.bin succeed!
Krj@VM:~/soc_workspace/1stQuarter_BarBoard/15_NandFlash/NandFlash_codeTest$ 

從解決llib1funcs.s編譯不過到最後,發現除法可以直接再編譯器自帶庫裏取,而不再需要lib1funcs.s文件了。這樣的話,不再編譯lib1funcs.s,恢復CC += -march=armv5teCC += -march=armv4,不恢復的話,對於S3C2440來講,可能會產生未定義指令異常(2020年2月21日23:01:04),在使用armv5te的時候,發現過多條未定義指令異常:blx指令(函數指針可能會用到該指令)、ldrd、strd指令等

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章