Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libn64 Segmentation fault error #18

Open
cdlt opened this issue Jul 11, 2020 · 4 comments
Open

Libn64 Segmentation fault error #18

cdlt opened this issue Jul 11, 2020 · 4 comments

Comments

@cdlt
Copy link

cdlt commented Jul 11, 2020

Hi all!
I have a problem with n64chain specific libn64 compiling from Ubuntu 18.04.
The libn64/header.bin is present (this is copied from libdragon header file).
Compilation tools is successfully from tools/build-posix64-toolchain.sh
Libn64 compiling error logs:
cd libn64
make
Compiling: libn64/io/init.c
Compiling: libn64/io/filesystem.c
Compiling: libn64/io/pi_thread.c
Compiling: libn64/io/si_thread.c
Compiling: libn64/os/fbtext.c
Compiling: libn64/os/main.c
os/main.c: In function 'libn64_main':
os/main.c:25:47: warning: unused parameter 'bss_end' [-Wunused-parameter]
void libn64_main(uint32_t kernel_sp, uint32_t bss_end) {
Compiling: libn64/os/mm.c
Compiling: libn64/os/panic.c
Compiling: libn64/os/thread.c
Compiling: libn64/os/time.c
Compiling: libn64/rcp/vi.c
Compiling: libn64/sp/init.c
Compiling: libn64/sp/sp_thread.c
Assembling: libn64/os/asm/boot.s
Assembling: libn64/os/asm/context.s
Assembling: libn64/os/asm/exception.s
Assembling: libn64/os/asm/idle_thread.s
Assembling: libn64/os/asm/message.s
Assembling: libn64/os/asm/syscall.s
Assembling: /ucodes/init.o
Makefile:87: recipe for target 'ucodes/init.o' failed
make: *** [ucodes/init.o] Segmentation fault

Thank you very much

@cdlt cdlt changed the title Libn64 compiling errors Libn64 compiling Segmentation fault error Jul 11, 2020
@cdlt cdlt changed the title Libn64 compiling Segmentation fault error Libn64 Segmentation fault error Jul 11, 2020
@ijacquez
Copy link

What if you manually assemble the file, but through gdb? Would you be able to provide a back trace?

@cdlt
Copy link
Author

cdlt commented Jul 14, 2020

Hi Israel Jacquez

Thank you and I'm sorry my poor english

make libn64:

Compiling: libn64/io/init.c
Compiling: libn64/io/filesystem.c
Compiling: libn64/io/pi_thread.c
Compiling: libn64/io/si_thread.c
Compiling: libn64/os/fbtext.c
Compiling: libn64/os/main.c
Compiling: libn64/os/mm.c
Compiling: libn64/os/panic.c
Compiling: libn64/os/thread.c
Compiling: libn64/os/time.c
Compiling: libn64/rcp/vi.c
Compiling: libn64/sp/init.c
Compiling: libn64/sp/sp_thread.c
Assembling: libn64/os/asm/boot.s
Assembling: libn64/os/asm/context.s
Assembling: libn64/os/asm/exception.s
Assembling: libn64/os/asm/idle_thread.s
Assembling: libn64/os/asm/message.s
Assembling: libn64/os/asm/syscall.s

.... without errors
Assembling: /ucodes/init.o:

/tmp/ramdisk/n64chain/libn64/../tools/bin/mips64-elf-cpp -E -Iucodes ucodes/init.rsp > ucodes/init.rsppch

ok without errors

/tmp/ramdisk/n64chain/libn64/../tools/bin/rspasm ucodes/init.rsppch -o ucodes/init.bin

Segmentation fault error on all lines of init.rsppch containing addiu instructions. There is not error when removing these lines and continue....

/tmp/ramdisk/n64chain/libn64/../tools/bin/mips64-elf-gcc -x assembler-with-cpp -Wall -Wextra -pedantic -std=c99 -I. -Iinclude -Ipriv_include -Os -march=vr4300 -mtune=vr4300 -mabi=eabi -mgp32 -mlong32 -flto -ffat-lto-objects -ffunction-sections -fdata-sections -G4 -mno-extern-sdata -mgpopt -mfix4300 -mbranch-likely -mno-check-zero-division -MMD -c ucodes/init.rsps -o ucodes/init.o

ok building libn64/libn64.a

make libgfx:

Compiling: libgfx/src/init.c
Compiling: libgfx/src/rspbuf.c

.... without errors

Assembling: /ucodes/gfx.o:

/tmp/ramdisk/n64chain/libgfx/../tools/bin/mips64-elf-cpp -E -I../libn64/ucodes -Iucodes ucodes/gfx.rsp > ucodes/gfx.rsppch

ok without errors

/tmp/ramdisk/n64chain/libgfx/../tools/bin/rspasm ucodes/gfx.rsppch -o ucodes/gfx.bin

Segmentation fault error on all lines of gfx.rsppch containing addiu instructions. There is not error when removing these lines and continue....

/tmp/ramdisk/n64chain/libgfx/../tools/bin/mips64-elf-gcc -x assembler-with-cpp -Wall -Wextra -pedantic -std=c99 -I. -Iinclude -I../libn64/include -Os -march=vr4300 -mtune=vr4300 -mabi=eabi -mgp32 -mlong32 -flto -ffat-lto-objects -ffunction-sections -fdata-sections -G4 -mno-extern-sdata -mgpopt -mfix4300 -mbranch-likely -mno-check-zero-division -mno-memcpy -MMD -c ucodes/gfx.rsps -o ucodes/gfx.o

ok building: libgfx/libgfx.a

I don't believe the libraries work well without the removed instructions.

Thanks very much for your support.
P.S:
I attach the files with problems:
files.zip

@ijacquez
Copy link

Thanks for the information.

Could you do: gdb /tmp/ramdisk/n64chain/libn64/../tools/bin/rspasm, and within GDB, type run ucodes/init.rsppch -o ucodes/init.bin?

And see what's happening? Assuming that rspasm is compiled with -g.

This all may be of help to @tj90241.

@cdlt
Copy link
Author

cdlt commented Jul 14, 2020

Hi @ijacquez:

Starting program: /tmp/ramdisk/n64chain/tools/bin/rspasm ucodes/init.rsppch -o ucodes/init.bin

Program received signal SIGSEGV, Segmentation fault.
__strcmp_sse4_2 () at ../sysdeps/i386/i686/multiarch/strcmp-sse4.S:229
229 ../sysdeps/i386/i686/multiarch/strcmp-sse4.S: No such file or directory.
(gdb) backtrace
#0 __strcmp_sse4_2 () at ../sysdeps/i386/i686/multiarch/strcmp-sse4.S:229
#1 0x0040dcf9 in rspasm_symbol_binary_search ()
#2 0x0040dd26 in rspasm_symbol_binary_search ()
#3 0x0040dc43 in rspasm_get_symbol_address ()
#4 0x0040d051 in rspasmparse ()
#5 0x0040b42a in assemble ()
#6 0x0040b839 in main ()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants