如何为arm64裸机实施printf?

问题描述

我正在尝试使打印可用于arm64平台(裸机,编译器是aarch64-none-elf-gcc)。 如果我天真地编译了一个简单的包含printf的hello_world.c程序,那么我将得到预期的错误错误如下。

ckim@chan-ubuntu:~/prj/abdsn/ab21u/ab21zeus/simoob$ arm-none-elf-gcc tt.c
....aarch64-none-elf/lib/libc.a(lib_a-exit.o): in function `exit':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'
....aarch64-none-elf/lib/libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/sbrkr.c:51: undefined reference to `_sbrk'
....aarch64-none-elf/lib/libc.a(lib_a-writer.o): in function `_write_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/writer.c:49: undefined reference to `_write'
....aarch64-none-elf/lib/libc.a(lib_a-closer.o): in function `_close_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/closer.c:47: undefined reference to `_close'
....aarch64-none-elf/lib/libc.a(lib_a-lseekr.o): in function `_lseek_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/lseekr.c:49: undefined reference to `_lseek'
....aarch64-none-elf/lib/libc.a(lib_a-readr.o): in function `_read_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/readr.c:49: undefined reference to `_read'
....aarch64-none-elf/lib/libc.a(lib_a-fstatr.o): in function `_fstat_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/fstatr.c:55: undefined reference to `_fstat'
....aarch64-none-elf/lib/libc.a(lib_a-isattyr.o): in function `_isatty_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/isattyr.c:52: undefined reference to `_isatty'
collect2: error: ld returned 1 exit status

工具链正在寻找_exit,_sbrk,_write,_close,_lseek,_lread,_fstat,_isatty,我可能应该为链接程序提供这些链接。但是我想是因为arm64被广泛使用,所以应该有一些代码我可以参考/下载并为我们的UART IP和使用进行一些修复。谁能给我一些指导?
过去,我们团队中的某个人似乎借用了Linux代码和使用我们的uart IP(使用sparc架构)的单独printf。我不确定在这种情况下是否也应该做类似的事情。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)