微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何为arm64裸机实施printf?

如何解决如何为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 举报,一经查实,本站将立刻删除。