John-Titor/py68k

-fPIC must be added to CFLAGS to get musashi to compile

Closed this issue · 7 comments

When I try to compile musashi on Fedora 27, it fails
`[tingo@localhost py68k]$ cd musashi/
[tingo@localhost musashi]$ make
mkdir BUILD
gcc -g -O3 -c -o BUILD/m68kmake.o m68kmake.c
gcc -g -O3 -o m68kmake BUILD/m68kmake.o
./m68kmake

	Musashi v3.3 68000, 68010, 68EC020, 68020 emulator
	Copyright 1998-2000 Karl Stenerud (karl@mame.net)

Generated 1962 opcode handlers from 513 primitives
gcc -g -O3 -c -o BUILD/mem.o mem.c
gcc -g -O3 -c -o BUILD/m68kcpu.o m68kcpu.c
gcc -g -O3 -c -o BUILD/m68kdasm.o m68kdasm.c
gcc -g -O3 -c -o BUILD/m68kopac.o m68kopac.c
gcc -g -O3 -c -o BUILD/m68kopdm.o m68kopdm.c
gcc -g -O3 -c -o BUILD/m68kopnz.o m68kopnz.c
gcc -g -O3 -c -o BUILD/m68kops.o m68kops.c
gcc -shared -o libmusashi.so BUILD/mem.o BUILD/m68kcpu.o BUILD/m68kdasm.o BUILD/m68kopac.o BUILD/m68kopdm.o BUILD/m68kopnz.o BUILD/m68kops.o
/usr/bin/ld: BUILD/mem.o: relocation R_X86_64_32 against .bss' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kcpu.o: relocation R_X86_64_32 against symbol m68ki_cpu' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: BUILD/m68kdasm.o: relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kopac.o: relocation R_X86_64_32S against symbol m68ki_cpu' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: BUILD/m68kopdm.o: relocation R_X86_64_32S against symbol m68ki_cpu' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kopnz.o: relocation R_X86_64_32S against symbol m68ki_cpu' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: BUILD/m68kops.o: relocation R_X86_64_32 against undefined symbol m68ki_instruction_jump_table' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status make: *** [Makefile:53: libmusashi.so] Error 1
so I add -fPIC to CFLAGS, like so
[tingo@localhost musashi]$ grep ^CFLAGS Makefile CFLAGS = -g -O3 -fPIC

Question is this the correct fix?

Well, I really don't know. It works good enough that I can do this
[tingo@localhost py68k]$ ./py68k.py
usage: py68k.py [-h] [--target TARGET] [--trace-file TRACE_FILE]
[--cycle-limit CYCLES] [--trace-everything] [--trace-memory]
[--trace-read-trigger ADDRESS-or-NAME]
[--trace-write-trigger ADDRESS-or-NAME] [--trace-instructions]
[--trace-instruction-trigger ADDRESS-or-NAME] [--trace-jumps]
[--trace-exceptions] [--trace-exception EXCEPTION]
[--trace-io] [--trace-cycle-limit CYCLES]
[--trace-check-PC-in-text] [--debug-device DEBUG_DEVICE]
[--diskfile DISKFILE]
image
py68k.py: error: too few arguments
and I can start the emulator like this:
[tingo@localhost py68k]$ ./py68k.py --target tiny68k ~/work/emul/tiny68k/tinybios.bin
Exit due to user interrupt.
the emulator quits as described. Unfortunately, all I get is a black screen.

If you add '--trace-everything', do you get anything in the trace file?

What's the md5 of 'tinybios.bin'?

Yes, the trace file contains what looks to me like real 68k instructions.
md5 of the bios
tingo@kg-core1$ md5 ~/work/emul/tiny68k/tinybios.bin
MD5 (/home/tingo/work/emul/tiny68k/tinybios.bin) = 136ba1e7ee8c62a5f9ac1222ea167ea7

I couldn't actually find anything on the Tiny68K wiki with that MD5 - is it possible that you're trying to boot the CP/M BIOS file due to my poor instructions?

To emulate the normal board startup you want the monitor/debugger; current version is at https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=boards:sbc:tiny68k:tiny68k_rev2:t68kbug_r07.zip

MD5 (T68kbug_r07.BIN) = b4da657ba3090327a6a458711764e55e

Indeed, I was trying to use the BIOS file. Using the monitor/debugger works. Thanks!

Thanks for the confirmation.