赞
踩
笔者有幸参加了平头哥RISCV开发者大赛,体验了一下基于玄铁C910内核的矽速开发板。
LicheePi 4A 是基于 Lichee Module 4A 核心板的 高性能 RISC-V Linux 开发板。
GCC的工具链安装,参考Licheepi GCC工具链安装。
root@lpi4a:~# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-linux-gnu/10/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.4.0-8revyos2.4' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gcv0p7_zfh_xtheadc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.4.0 (Debian 10.4.0-8revyos2.4)
gcc hello.c
Assembler messages:
Error: x ISA extension `xtheadc' must be set with the versions
gcc hello.c -march=rv64imc
In file included from /usr/include/features.h:513,
from /usr/include/riscv64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/stdio.h:27,
from hello.c:1:
/usr/include/riscv64-linux-gnu/gnu/stubs.h:14:11: fatal error: gnu/stubs-lp64.h: No such file or directory
14 | # include <gnu/stubs-lp64.h>
root@lpi4a:~# ls /usr/include/riscv64-linux-gnu/gnu/stubs.h /usr/include/riscv64-linux-gnu/gnu/stubs.h root@lpi4a:~# cat /usr/include/riscv64-linux-gnu/gnu/stubs.h /* This file is automatically generated. This file selects the right generated file of `__stub_FUNCTION' macros based on the architecture being compiled for. */ #include <bits/wordsize.h> #if __WORDSIZE == 32 && defined __riscv_float_abi_soft # include <gnu/stubs-ilp32.h> #endif #if __WORDSIZE == 32 && defined __riscv_float_abi_double # include <gnu/stubs-ilp32d.h> #endif #if __WORDSIZE == 64 && defined __riscv_float_abi_soft # include <gnu/stubs-lp64.h> #endif #if __WORDSIZE == 64 && defined __riscv_float_abi_double # include <gnu/stubs-lp64d.h> #endif
ls /usr/include/riscv64-linux-gnu/gnu/
lib-names-lp64d.h lib-names.h libc-version.h stubs-lp64d.h stubs.h
gcc hello.c -march=rv64imc -mabi=lp64d
cc1: error: requested ABI requires '-march' to subsume the 'D' extension
gcc hello.c -march=rv64dimc -mabi=lp64d
gcc: error: '-march=rv64dimc': first ISA subset must be 'e', 'i' or 'g'
gcc hello.c -march=rv64imc -mabi=lp64e
gcc: error: unrecognized argument in option '-mabi=lp64e'
gcc: note: valid arguments to '-mabi=' are: ilp32 ilp32d ilp32e ilp32f lp64 lp64d lp64dv lp64f lp64v; did you mean 'lp64'?
root@lpi4a:~# gcc hello.c -march=rv64imafd -mabi=lp64d
root@lpi4a:~#
root@lpi4a:~# readelf -a a.out ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Position-Independent Executable file) Machine: RISC-V Version: 0x1 Entry point address: 0x5b0 Start of program headers: 64 (bytes into file) Start of section headers: 7168 (bytes into file) Flags: 0x5, RVC, double-float ABI Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 10 Size of section headers: 64 (bytes) Number of section headers: 28 Section header string table index: 27
Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .interp PROGBITS 0000000000000270 00000270 0000000000000021 0000000000000000 A 0 0 1 [ 2] .note.gnu.bu[...] NOTE 0000000000000294 00000294 0000000000000024 0000000000000000 A 0 0 4 [ 3] .note.ABI-tag NOTE 00000000000002b8 000002b8 0000000000000020 0000000000000000 A 0 0 4 [ 4] .gnu.hash GNU_HASH 00000000000002d8 000002d8 0000000000000024 0000000000000000 A 5 0 8 [ 5] .dynsym DYNSYM 0000000000000300 00000300 00000000000000c0 0000000000000018 A 6 2 8 [ 6] .dynstr STRTAB 00000000000003c0 000003c0 000000000000007d 0000000000000000 A 0 0 1 [ 7] .gnu.version VERSYM 000000000000043e 0000043e 0000000000000010 0000000000000002 A 5 0 2 [ 8] .gnu.version_r VERNEED 0000000000000450 00000450 0000000000000030 0000000000000000 A 6 1 8 [ 9] .rela.dyn RELA 0000000000000480 00000480 00000000000000c0 0000000000000018 A 5 0 8 [10] .rela.plt RELA 0000000000000540 00000540 0000000000000030 0000000000000018 AI 5 21 8 [11] .plt PROGBITS 0000000000000570 00000570 0000000000000040 0000000000000010 AX 0 0 16 [12] .text PROGBITS 00000000000005b0 000005b0 0000000000000108 0000000000000000 AX 0 0 16 [13] .rodata PROGBITS 00000000000006b8 000006b8 0000000000000015 0000000000000000 A 0 0 8 [14] .eh_frame_hdr PROGBITS 00000000000006d0 000006d0 0000000000000014 0000000000000000 A 0 0 4 [15] .eh_frame PROGBITS 00000000000006e8 000006e8 000000000000002c 0000000000000000 A 0 0 8 [16] .preinit_array PREINIT_ARRAY 0000000000001e08 00000e08 0000000000000008 0000000000000008 WA 0 0 1 [17] .init_array INIT_ARRAY 0000000000001e10 00000e10 0000000000000008 0000000000000008 WA 0 0 8 [18] .fini_array FINI_ARRAY 0000000000001e18 00000e18 0000000000000008 0000000000000008 WA 0 0 8 [19] .dynamic DYNAMIC 0000000000001e20 00000e20 00000000000001e0 0000000000000010 WA 6 0 8 [20] .data PROGBITS 0000000000002000 00001000 0000000000000008 0000000000000000 WA 0 0 8 [21] .got PROGBITS 0000000000002008 00001008 0000000000000048 0000000000000008 WA 0 0 8 [22] .bss NOBITS 0000000000002050 00001050 0000000000000008 0000000000000000 WA 0 0 1 [23] .comment PROGBITS 0000000000000000 00001050 0000000000000027 0000000000000001 MS 0 0 1 [24] .riscv.attributes RISCV_ATTRIBUTE 0000000000000000 00001077 0000000000000106 0000000000000000 0 0 1 [25] .symtab SYMTAB 0000000000000000 00001180 0000000000000630 0000000000000018 26 47 8 [26] .strtab STRTAB 0000000000000000 000017b0 000000000000033c 0000000000000000 0 0 1 [27] .shstrtab STRTAB 0000000000000000 00001aec 000000000000010f 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), D (mbind), p (processor specific) There are no section groups in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040 0x0000000000000230 0x0000000000000230 R 0x8 INTERP 0x0000000000000270 0x0000000000000270 0x0000000000000270 0x0000000000000021 0x0000000000000021 R 0x1 [Requesting program interpreter: /lib/ld-linux-riscv64-lp64d.so.1] RISCV_ATTRIBUT 0x0000000000001077 0x0000000000000000 0x0000000000000000 0x0000000000000106 0x0000000000000000 R 0x1 LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000714 0x0000000000000714 R E 0x1000 LOAD 0x0000000000000e08 0x0000000000001e08 0x0000000000001e08 0x0000000000000248 0x0000000000000250 RW 0x1000 DYNAMIC 0x0000000000000e20 0x0000000000001e20 0x0000000000001e20 0x00000000000001e0 0x00000000000001e0 RW 0x8 NOTE 0x0000000000000294 0x0000000000000294 0x0000000000000294 0x0000000000000044 0x0000000000000044 R 0x4 GNU_EH_FRAME 0x00000000000006d0 0x00000000000006d0 0x00000000000006d0 0x0000000000000014 0x0000000000000014 R 0x4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 0x10 GNU_RELRO 0x0000000000000e08 0x0000000000001e08 0x0000000000001e08 0x00000000000001f8 0x00000000000001f8 R 0x1 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .riscv.attributes 03 .interp .note.gnu.build-id .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .plt .text .rodata .eh_frame_hdr .eh_frame 04 .preinit_array .init_array .fini_array .dynamic .data .got .bss 05 .dynamic 06 .note.gnu.build-id .note.ABI-tag 07 .eh_frame_hdr 08 09 .preinit_array .init_array .fini_array .dynamic Dynamic section at offset 0xe20 contains 26 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x0000000000000020 (PREINIT_ARRAY) 0x1e08 0x0000000000000021 (PREINIT_ARRAYSZ) 8 (bytes) 0x0000000000000019 (INIT_ARRAY) 0x1e10 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) 0x000000000000001a (FINI_ARRAY) 0x1e18 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) 0x000000006ffffef5 (GNU_HASH) 0x2d8 0x0000000000000005 (STRTAB) 0x3c0 0x0000000000000006 (SYMTAB) 0x300 0x000000000000000a (STRSZ) 125 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000015 (DEBUG) 0x0 0x0000000000000003 (PLTGOT) 0x2008 0x0000000000000002 (PLTRELSZ) 48 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x540 0x0000000000000007 (RELA) 0x480 0x0000000000000008 (RELASZ) 240 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000006ffffffb (FLAGS_1) Flags: PIE 0x000000006ffffffe (VERNEED) 0x450 0x000000006fffffff (VERNEEDNUM) 1 0x000000006ffffff0 (VERSYM) 0x43e 0x000000006ffffff9 (RELACOUNT) 5 0x0000000000000000 (NULL) 0x0 Relocation section '.rela.dyn' at offset 0x480 contains 8 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000001e08 000000000003 R_RISCV_RELATIVE 5d2 000000001e10 000000000003 R_RISCV_RELATIVE 680 000000001e18 000000000003 R_RISCV_RELATIVE 640 000000002000 000000000003 R_RISCV_RELATIVE 2000 000000002038 000000000003 R_RISCV_RELATIVE 684 000000002030 000300000002 R_RISCV_64 0000000000000000 _ITM_deregisterTM[...] + 0 000000002040 000500000002 R_RISCV_64 0000000000000000 __cxa_finalize@GLIBC_2.27 + 0 000000002048 000600000002 R_RISCV_64 0000000000000000 _ITM_registerTMCl[...] + 0 Relocation section '.rela.plt' at offset 0x540 contains 2 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000002018 000200000005 R_RISCV_JUMP_SLOT 0000000000000000 __libc_start_main@GLIBC_2.34 + 0 000000002020 000400000005 R_RISCV_JUMP_SLOT 0000000000000000 puts@GLIBC_2.27 + 0 The decoding of unwind sections for machine type RISC-V is not currently supported. Symbol table '.dynsym' contains 8 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000000005b0 0 SECTION LOCAL DEFAULT 12 .text 2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _[...]@GLIBC_2.34 (2) 3: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterT[...] 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.27 (3) 5: 0000000000000000 0 FUNC WEAK DEFAULT UND _[...]@GLIBC_2.27 (3) 6: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMC[...] 7: 0000000000000684 52 FUNC GLOBAL DEFAULT 12 main Symbol table '.symtab' contains 66 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000270 0 SECTION LOCAL DEFAULT 1 .interp 2: 0000000000000294 0 SECTION LOCAL DEFAULT 2 .note.gnu.build-id 3: 00000000000002b8 0 SECTION LOCAL DEFAULT 3 .note.ABI-tag 4: 00000000000002d8 0 SECTION LOCAL DEFAULT 4 .gnu.hash 5: 0000000000000300 0 SECTION LOCAL DEFAULT 5 .dynsym 6: 00000000000003c0 0 SECTION LOCAL DEFAULT 6 .dynstr 7: 000000000000043e 0 SECTION LOCAL DEFAULT 7 .gnu.version 8: 0000000000000450 0 SECTION LOCAL DEFAULT 8 .gnu.version_r 9: 0000000000000480 0 SECTION LOCAL DEFAULT 9 .rela.dyn 10: 0000000000000540 0 SECTION LOCAL DEFAULT 10 .rela.plt 11: 0000000000000570 0 SECTION LOCAL DEFAULT 11 .plt 12: 00000000000005b0 0 SECTION LOCAL DEFAULT 12 .text 13: 00000000000006b8 0 SECTION LOCAL DEFAULT 13 .rodata 14: 00000000000006d0 0 SECTION LOCAL DEFAULT 14 .eh_frame_hdr 15: 00000000000006e8 0 SECTION LOCAL DEFAULT 15 .eh_frame 16: 0000000000001e08 0 SECTION LOCAL DEFAULT 16 .preinit_array 17: 0000000000001e10 0 SECTION LOCAL DEFAULT 17 .init_array 18: 0000000000001e18 0 SECTION LOCAL DEFAULT 18 .fini_array 19: 0000000000001e20 0 SECTION LOCAL DEFAULT 19 .dynamic 20: 0000000000002000 0 SECTION LOCAL DEFAULT 20 .data 21: 0000000000002008 0 SECTION LOCAL DEFAULT 21 .got 22: 0000000000002050 0 SECTION LOCAL DEFAULT 22 .bss 23: 0000000000000000 0 SECTION LOCAL DEFAULT 23 .comment 24: 0000000000000000 0 SECTION LOCAL DEFAULT 24 .riscv.attributes 25: 0000000000000000 0 FILE LOCAL DEFAULT ABS Scrt1.o 26: 00000000000002b8 32 OBJECT LOCAL DEFAULT 3 __abi_tag 27: 00000000000005b0 0 NOTYPE LOCAL DEFAULT 12 $xrv64i2p0_m2p0_[...] 28: 00000000000005d2 0 NOTYPE LOCAL DEFAULT 12 load_gp 29: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c 30: 00000000000005e0 0 NOTYPE LOCAL DEFAULT 12 $xrv64i2p0_m2p0_[...] 31: 00000000000005e0 0 FUNC LOCAL DEFAULT 12 deregister_tm_clones 32: 0000000000000610 0 FUNC LOCAL DEFAULT 12 register_tm_clones 33: 0000000000000640 0 FUNC LOCAL DEFAULT 12 __do_global_dtors_aux 34: 0000000000002050 1 OBJECT LOCAL DEFAULT 22 completed.0 35: 0000000000001e18 0 OBJECT LOCAL DEFAULT 18 __do_global_dtor[...] 36: 0000000000000680 0 FUNC LOCAL DEFAULT 12 frame_dummy 37: 0000000000001e10 0 OBJECT LOCAL DEFAULT 17 __frame_dummy_in[...] 38: 0000000000000000 0 FILE LOCAL DEFAULT ABS hello.c 39: 0000000000000684 0 NOTYPE LOCAL DEFAULT 12 $xrv64i2p0_m2p0_[...] 40: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c 41: 0000000000000710 0 OBJECT LOCAL DEFAULT 15 __FRAME_END__ 42: 0000000000000000 0 FILE LOCAL DEFAULT ABS 43: 0000000000000570 0 OBJECT LOCAL DEFAULT ABS _PROCEDURE_LINKA[...] 44: 0000000000001e20 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC 45: 00000000000006d0 0 NOTYPE LOCAL DEFAULT 14 __GNU_EH_FRAME_HDR 46: 0000000000002028 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ 47: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_mai[...] 48: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterT[...] 49: 0000000000002000 0 NOTYPE WEAK DEFAULT 20 data_start 50: 0000000000002058 0 NOTYPE GLOBAL DEFAULT 22 __BSS_END__ 51: 0000000000002050 0 NOTYPE GLOBAL DEFAULT 21 _edata 52: 0000000000002050 0 NOTYPE GLOBAL DEFAULT 21 __SDATA_BEGIN__ 53: 0000000000002000 0 NOTYPE GLOBAL DEFAULT 20 __DATA_BEGIN__ 54: 0000000000002000 0 NOTYPE GLOBAL DEFAULT 20 __data_start 55: 0000000000002000 0 OBJECT GLOBAL HIDDEN 20 __dso_handle 56: 00000000000006b8 4 OBJECT GLOBAL DEFAULT 13 _IO_stdin_used 57: 0000000000002058 0 NOTYPE GLOBAL DEFAULT 22 _end 58: 00000000000005b0 34 FUNC GLOBAL DEFAULT 12 _start 59: 0000000000002800 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$ 60: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.27 61: 0000000000002050 0 NOTYPE GLOBAL DEFAULT 22 __bss_start 62: 0000000000000684 52 FUNC GLOBAL DEFAULT 12 main 63: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@G[...] 64: 0000000000002008 0 OBJECT GLOBAL HIDDEN 21 __TMC_END__ 65: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMC[...] Histogram for `.gnu.hash' bucket list length (total of 2 buckets): Length Number % of total Coverage 0 1 ( 50.0%) 1 1 ( 50.0%) 100.0% Version symbols section '.gnu.version' contains 8 entries: Addr: 0x000000000000043e Offset: 0x0000043e Link: 5 (.dynsym) 000: 0 (*local*) 0 (*local*) 2 (GLIBC_2.34) 1 (*global*) 004: 3 (GLIBC_2.27) 3 (GLIBC_2.27) 1 (*global*) 1 (*global*) Version needs section '.gnu.version_r' contains 1 entry: Addr: 0x0000000000000450 Offset: 0x00000450 Link: 6 (.dynstr) 000000: Version: 1 File: libc.so.6 Cnt: 2 0x0010: Name: GLIBC_2.27 Flags: none Version: 3 0x0020: Name: GLIBC_2.34 Flags: none Version: 2 Displaying notes found in: .note.gnu.build-id Owner Data size Description GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring) Build ID: 04af9f13e57b18e206a946570b7a6c8f6a078c86 Displaying notes found in: .note.ABI-tag Owner Data size Description GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag) OS: Linux, ABI: 4.15.0 Attribute Section: riscv File Attributes
Tag_RISCV_arch: "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_v0p7_zmmul1p0_zfh1p0_zfhmin1p0_xtheadba1p0_xtheadbb1p0_xtheadbs1p0_xtheadc1p0_xtheadcmo1p0_xtheadcondmov1p0_xtheadfmemidx1p0_xtheadfmv1p0_xtheadint1p0_xtheadmac1p0_xtheadmemidx1p0_xtheadmempair1p0_xtheadsync1p0"
注意事项:
1、安装是需要后面添加参数 --fix-missing(根据提示)
2、安装时系统可能会卡死,这时候安装包可能损坏,需要修复这个问题,dpkg --configure -a,
3、继续安装的时候,又会发现没有依赖或者依赖关系不对,需要apt --fix-broken install
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。