vowstar / k210-linux-nommu

K210 run linux nommu (From Damien Le Moal's patch)
154 stars 34 forks source link

TCC failed to compile main.c #17

Open Pengfei-Lee opened 2 years ago

Pengfei-Lee commented 2 years ago

Hi, Thanks for this tutorial! I followed this tutorial and successfully ported Linux to k210. But when I compile the main.c example using TCC, I get the following error. As a beginner, I don't know how to solve it. Any help will be greatly appreciated!


/ # cat main.c
#include <stdio.h>
int fib(int n){
    if(n < 2){
        return 1;
    }
    return fib(n-1) + fib(n-2);
}

int main(int argc, char* argv[]) {
    int i;
    for (i = 0; i < 15; i++)
        printf("%d ", fib(i));
    printf("Hello world from K210!!!\n");
    return 0;
}
/ #
/ # tcc -run main.c
[  245.559805] tcc[31]: unhandled signal 11 code 0x2 at 0x000000008013e124
[  245.565664] CPU: 1 PID: 31 Comm: tcc Not tainted 5.6.0-rc1vowstar #1
[  245.571995] epc: 000000008013e124 ra : 000000008012584c sp : 0000000080173cf0
[  245.579113]  gp : 0000000080143d80 tp : 0000000000000000 t0 : 0000000000000002
[  245.586320]  t1 : 00000000803e4640 t2 : 0000000000000008 s0 : 0000000080173d30
[  245.593527]  s1 : 00000000801f0010 a0 : 0000000000048ff0 a1 : 8080808080808080
[  245.600732]  a2 : fefefefefefefeff a3 : 0000000000000006 a4 : 0000000000000000
[  245.607939]  a5 : 0000000000048ff0 a6 : 0000000000000050 a7 : 00000000803e4640
[  245.615146]  s2 : 00000000801728a0 s3 : 0000000000000003 s4 : 00000000801012e0
[  245.622352]  s5 : 0000000080173e20 s6 : 000000000000000e s7 : 00000000805e19ec
[  245.629557]  s8 : 0000000000000008 s9 : 000000000000002f s10: 000000000000002f
[  245.636764]  s11: 0000000000000000 t3 : ffffffffffffffff t4 : 0000000000000008
[  245.643968]  t5 : 0000000000000038 t6 : 6e00000000000000
[  245.649268] status: 8000000000006000 badaddr: 0000000000048ff0 cause: 0000000000000005
SEGV
/ # tcc -run -nostdlib main.c
[  258.819830] tcc[32]: unhandled signal 11 code 0x2 at 0x000000008013e124
[  258.825689] CPU: 1 PID: 32 Comm: tcc Not tainted 5.6.0-rc1vowstar #1
[  258.832021] epc: 000000008013e124 ra : 000000008012584c sp : 0000000080173ce0
[  258.839139]  gp : 0000000080143d80 tp : 0000000000000000 t0 : 0000000000000003
[  258.846345]  t1 : 00000000803e4640 t2 : 0000000000000008 s0 : 0000000080173d20
[  258.853552]  s1 : 0000000080173ff8 a0 : 0000000000048ff0 a1 : 8080808080808080
[  258.860757]  a2 : fefefefefefefeff a3 : 0000000000000006 a4 : 0000000000000000
[  258.867964]  a5 : 0000000000048ff0 a6 : 0000000000000050 a7 : 00000000803e4640
[  258.875171]  s2 : 00000000801728a0 s3 : 0000000000000004 s4 : 00000000801012e0
[  258.882376]  s5 : 0000000080173e10 s6 : 000000000000000e s7 : 00000000805e19ec
[  258.889583]  s8 : 0000000000000008 s9 : 000000000000002f s10: 000000000000002f
[  258.896790]  s11: 0000000000000000 t3 : ffffffffffffffff t4 : 0000000000000008
[  258.903993]  t5 : 0000000000000038 t6 : 6c00000000000000
[  258.909293] status: 8000000000006000 badaddr: 0000000000048ff0 cause: 0000000000000005
SEGV