Skip to content

[Bug] 最新的 riscv musl 工具链编译生成的 helloworld 无法工作 #10028

Open
@unicornx

Description

@unicornx

RT-Thread Version

latest

Hardware Type/Architectures

bsp/cvitek 或者 bsp/qemu-virt64-riscv

Develop Toolchain

Other

Describe the bug

参考 https://github.com/RT-Thread/rt-thread/issues/9812#issuecomment-2664977960,

https://download.rt-thread.org/download/rt-smart/toolchains/riscv64gc-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 这个工具链做了一个 helloworld 运行后报错

#include "stdio.h"

void main()
{
	printf("Hello world!\n");
}

静态链接:

~/ws/bin/rtt-tools-smart/riscv64gc-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc -static ./hello.c -o ./hello

bsp/cvitek 下制作 smart 版本或者 bsp/qemu-virt64-riscv 制作 smart 版本,启动后运行 hello,报错类似如下:

/ # ./hello 
[I/mm.fault] rt_aspace_fault_try_fix: varea not found at 0x0
[E/libcpu.trap] [FATAL ERROR] Exception 12:Instruction Page Fault

[E/libcpu.trap] scause:0x000000000000000c,stval:(nil),sepc:(nil)

--------------Dump Registers-----------------
Function Registers:
        ra(x1) = 0xffffffc000222710     user_sp = 0x0000000300000000
        gp(x3) = 0xffffffc0002d9760     tp(x4) = 0x0000000000107728
Temporary Registers:
        t0(x5) = 0x0000000000000020     t1(x6) = 0xffffffc00415f158
        t2(x7) = 0x000000000000003a
        t3(x28) = 0xffffffc00415f150    t4(x29) = 0x000000000000001f
        t5(x30) = 0x0000000000000002    t6(x31) = 0x0000000000000002
Saved Registers:
        s0/fp(x8) = 0xffffffc00047bdc0  s1(x9) = 0x00000003000023f0
        s2(x18) = 0x0000000300002400    s3(x19) = 0x00000003000023f0
        s4(x20) = 0xffffffffffffffff    s5(x21) = 0x00000003000023f0
        s6(x22) = 0x00000003000023d0    s7(x23) = 0x00000000000feab2
        s8(x24) = 0x00000000000dcda8    s9(x25) = 0x0000000000105aa8
        s10(x26) = 0x0000000000000008   s11(x27) = 0x0000000000000001
Function Arguments Registers:
        a0(x10) = 0x0000000300000000    a1(x11) = (nil)
        a2(x12) = 0x0000000300000000    a3(x13) = 0xffffffc00047c000
        a4(x14) = 0xffffffc000478000    a5(x15) = 0x0000000000000003
        a6(x16) = 0x0000000000000018    a7(x17) = (nil)
sstatus = 0x0000000200044020
        Supervisor Interrupt Disabled
        Last Time Supervisor Interrupt Enabled
        Last Privilege is User Mode
        Permit to Access User Page
        Not Permit to Read Executable-only Page
satp = 0x800000000008414a
        Current Page Table(Physical) = 0x000000008414a000
        Current ASID = (nil)
        Mode = Page-based 39-bit Virtual Addressing Mode
-----------------Dump OK---------------------
fp = 0xffffffc00047bdc0
please use: addr2line -e ./hello -a -f
 0x0 0xffffffc00024f9c2 0xffffffc0002002c8 0xffffffc00024f9c2 0xffffffc0002002c8 0xffffffc00024f9c2 0xffffffc0002002c8 0xffffffc00024f9c2
[E/libcpu.trap] User Fault, killing thread: hello

Other additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: RISC-VBSP related with risc-vRT-SmartRT-Thread Smart related PR or issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions