Closed s-macke closed 9 years ago
The crash happens in libc.so in __libc_start_main at 0x17540
00017444 <__libc_start_main>:
17444: f1010113 addi sp,sp,-240
17448: fffe9717 auipc a4,0xfffe9
1744c: bb870713 addi a4,a4,-1096 # 0 <GLIBC_2.20>
17450: 0e812423 sw s0,232(sp)
17454: 0e112623 sw ra,236(sp)
17458: 0e912223 sw s1,228(sp)
1745c: 0f212023 sw s2,224(sp)
17460: 0d312e23 sw s3,220(sp)
17464: 0d412c23 sw s4,216(sp)
17468: 00a12623 sw a0,12(sp)
1746c: 00b12423 sw a1,8(sp)
17470: 00c12223 sw a2,4(sp)
17474: 00068413 mv s0,a3
17478: 10070863 beqz a4,17588 <__libc_start_main+0x144>
1747c: 00072703 lw a4,0(a4)
17480: 00173713 seqz a4,a4
17484: 00129697 auipc a3,0x129
17488: b7c68693 addi a3,a3,-1156 # 140000 <__libc_multiple_libcs>
1748c: 00e6a023 sw a4,0(a3)
17490: 00078a63 beqz a5,174a4 <__libc_start_main+0x60>
17494: 00000613 li a2,0
17498: 00000593 li a1,0
1749c: 00078513 mv a0,a5
174a0: 235150ef jal 2ced4 <__cxa_atexit>
174a4: 00000797 auipc a5,0x0
174a8: b5c78793 addi a5,a5,-1188 # 17000 <set_regs+0x2b4>
174ac: 0007a483 lw s1,0(a5)
174b0: 0024f493 andi s1,s1,2
174b4: 06049c63 bnez s1,1752c <__libc_start_main+0xe8>
174b8: 00040e63 beqz s0,174d4 <__libc_start_main+0x90>
174bc: 0012a797 auipc a5,0x12a
174c0: 57878793 addi a5,a5,1400 # 141a34 <__environ>
174c4: 0007a603 lw a2,0(a5)
174c8: 00412583 lw a1,4(sp)
174cc: 00812503 lw a0,8(sp)
174d0: 000400e7 jalr s0
174d4: 00000797 auipc a5,0x0
174d8: b2c78793 addi a5,a5,-1236 # 17000 <set_regs+0x2b4>
174dc: 0b47aa03 lw s4,180(a5)
174e0: 060a1663 bnez s4,1754c <__libc_start_main+0x108>
174e4: 0e049263 bnez s1,175c8 <__libc_start_main+0x184>
174e8: 01810513 addi a0,sp,24
174ec: 335120ef jal 2a020 <_setjmp>
174f0: 0a051063 bnez a0,17590 <__libc_start_main+0x14c>
174f4: be022703 lw a4,-1056(tp) # fffffbe0 <_end+0xffebc7f0>
174f8: 0012a697 auipc a3,0x12a
174fc: 53c68693 addi a3,a3,1340 # 141a34 <__environ>
17500: 0006a603 lw a2,0(a3)
17504: 0ce12023 sw a4,192(sp)
17508: bdc22703 lw a4,-1060(tp) # fffffbdc <_end+0xffebc7ec>
1750c: 00412583 lw a1,4(sp)
17510: 00812503 lw a0,8(sp)
17514: 00c12783 lw a5,12(sp)
17518: 0ce12223 sw a4,196(sp)
1751c: 01810713 addi a4,sp,24
17520: bee22023 sw a4,-1056(tp) # fffffbe0 <_end+0xffebc7f0>
17524: 000780e7 jalr a5
17528: 718150ef jal 2cc40 <exit>
1752c: 00412703 lw a4,4(sp)
17530: 0887a783 lw a5,136(a5)
17534: 000fb517 auipc a0,0xfb
17538: b5450513 addi a0,a0,-1196 # 112088 <xdr_zero+0x24>
1753c: 00072583 lw a1,0(a4)
17540: 000780e7 jalr a5 <------ crash
17544: f6041ce3 bnez s0,174bc <__libc_start_main+0x78>
17548: f8dff06f j 174d4 <__libc_start_main+0x90>
1754c: 00000717 auipc a4,0x0
17550: ab470713 addi a4,a4,-1356 # 17000 <set_regs+0x2b4>
17554: 00072403 lw s0,0(a4)
17558: 0b07a983 lw s3,176(a5)
1755c: 00000913 li s2,0
17560: 25840413 addi s0,s0,600
17564: 00c9a783 lw a5,12(s3)
17568: 00078663 beqz a5,17574 <__libc_start_main+0x130>
1756c: 00040513 mv a0,s0
17570: 000780e7 jalr a5 174fc: 53c68693 addi a3,a3,1340 # 141a34 <__environ>
We haven't debugged dynamic linking on RV32 yet because we didn't have a working Linux distribution. Aside from the issue Palmer recently helped with, what did you have to do to get RV32 Linux working?
On Tue, Jul 14, 2015 at 9:04 AM, Sebastian Macke notifications@github.com wrote:
The crash happens in libc.so in __libc_start_main at 0x17540
00017444 <__libc_start_main>: 17444: f1010113 addi sp,sp,-240 17448: fffe9717 auipc a4,0xfffe9 1744c: bb870713 addi a4,a4,-1096 # 0
17450: 0e812423 sw s0,232(sp) 17454: 0e112623 sw ra,236(sp) 17458: 0e912223 sw s1,228(sp) 1745c: 0f212023 sw s2,224(sp) 17460: 0d312e23 sw s3,220(sp) 17464: 0d412c23 sw s4,216(sp) 17468: 00a12623 sw a0,12(sp) 1746c: 00b12423 sw a1,8(sp) 17470: 00c12223 sw a2,4(sp) 17474: 00068413 mv s0,a3 17478: 10070863 beqz a4,17588 <libc_start_main+0x144> 1747c: 00072703 lw a4,0(a4) 17480: 00173713 seqz a4,a4 17484: 00129697 auipc a3,0x129 17488: b7c68693 addi a3,a3,-1156 # 140000 <libc_multiple_libcs> 1748c: 00e6a023 sw a4,0(a3) 17490: 00078a63 beqz a5,174a4 <libc_start_main+0x60> 17494: 00000613 li a2,0 17498: 00000593 li a1,0 1749c: 00078513 mv a0,a5 174a0: 235150ef jal 2ced4 <cxa_atexit> 174a4: 00000797 auipc a5,0x0 174a8: b5c78793 addi a5,a5,-1188 # 17000 <set_regs+0x2b4> 174ac: 0007a483 lw s1,0(a5) 174b0: 0024f493 andi s1,s1,2 174b4: 06049c63 bnez s1,1752c <libc_start_main+0xe8> 174b8: 00040e63 beqz s0,174d4 <libc_start_main+0x90> 174bc: 0012a797 auipc a5,0x12a 174c0: 57878793 addi a5,a5,1400 # 141a34 <__environ> 174c4: 0007a603 lw a2,0(a5) 174c8: 00412583 lw a1,4(sp) 174cc: 00812503 lw a0,8(sp) 174d0: 000400e7 jalr s0 174d4: 00000797 auipc a5,0x0 174d8: b2c78793 addi a5,a5,-1236 # 17000 <set_regs+0x2b4> 174dc: 0b47aa03 lw s4,180(a5) 174e0: 060a1663 bnez s4,1754c <libc_start_main+0x108> 174e4: 0e049263 bnez s1,175c8 <libc_start_main+0x184> 174e8: 01810513 addi a0,sp,24 174ec: 335120ef jal 2a020 <_setjmp> 174f0: 0a051063 bnez a0,17590 <libc_start_main+0x14c> 174f4: be022703 lw a4,-1056(tp) # fffffbe0 <_end+0xffebc7f0> 174f8: 0012a697 auipc a3,0x12a 174fc: 53c68693 addi a3,a3,1340 # 141a34 <__environ> 17500: 0006a603 lw a2,0(a3) 17504: 0ce12023 sw a4,192(sp) 17508: bdc22703 lw a4,-1060(tp) # fffffbdc <_end+0xffebc7ec> 1750c: 00412583 lw a1,4(sp) 17510: 00812503 lw a0,8(sp) 17514: 00c12783 lw a5,12(sp) 17518: 0ce12223 sw a4,196(sp) 1751c: 01810713 addi a4,sp,24 17520: bee22023 sw a4,-1056(tp) # fffffbe0 <_end+0xffebc7f0> 17524: 000780e7 jalr a5 17528: 718150ef jal 2cc40 1752c: 00412703 lw a4,4(sp) 17530: 0887a783 lw a5,136(a5) 17534: 000fb517 auipc a0,0xfb 17538: b5450513 addi a0,a0,-1196 # 112088 <xdr_zero+0x24> 1753c: 00072583 lw a1,0(a4) 17540: 000780e7 jalr a5 <------ crash 17544: f6041ce3 bnez s0,174bc < libc_start_main+0x78> 17548: f8dff06f j 174d4 <__libc_start_main+0x90> 1754c: 00000717 auipc a4,0x0 17550: ab470713 addi a4,a4,-1356 # 17000 <set_regs+0x2b4> 17554: 00072403 lw s0,0(a4) 17558: 0b07a983 lw s3,176(a5) 1755c: 00000913 li s2,0 17560: 25840413 addi s0,s0,600 17564: 00c9a783 lw a5,12(s3) 17568: 00078663 beqz a5,17574 <libc_start_main+0x130> 1756c: 00040513 mv a0,s0 17570: 000780e7 jalr a5 174fc: 53c68693 addi a3,a3,1340 # 141a34 <environ>— Reply to this email directly or view it on GitHub https://github.com/riscv/riscv-gnu-toolchain/issues/63#issuecomment-121291727 .
You can find my current hacks for pk and linux here: http://pastie.org/10273402 http://pastie.org/10273399 I changed the htif interface to use two registers. But the diffs also contain patches to support Linux 4.1 and add a few debug messages.
You can test yourself by using the link http://jor1k.com/jor1k/demos/riscv.html Wait until you can see the first output in the terminal. During that time it loads the block device image. Then you choose bbl in the dropdown menu and see the (slow but safe) version of the emulator booting Linux.
Unfortunately someone abandoned the support for mmio devices :) . So I can't give you access to download/upload files to test yourself via virtio/9p.
This problem is not exclusive to RV32. See issue #66.
Good to know. I am glad, that the problem is reproducible for you and more recent. My test of the 64-Bit toolchain was prior to the patch.
Resolved by 0f680c80ddaddaff24b2af85e78fa069d040f5f2
This specific problem is solved. However it still doesn't start. It just hangs somewhere forever or I get an unaligned memory access.
Hi,
I managed after some time and patches to run Linux on the RV32 architecture. However, shared libraries don't seem to work. They all crash with the same segmentation fault at the same address. The same code compiled with --static works without problems.
Several month ago I have tried the 64-Bit toolchain with success.
Debug output: