Posted: Sat Aug 03, 2013 9:51 am
I got some more time to play with this and finally got it to work! Grabbed SGDK "windows only" makefile and started modifying it to work with GNU/Linux. At first, object files were built, but failed when linking:
It couldn't find _bend symbol. I browsed libmd.a to see if it was there, and it is, but undefined (prefixed with 'U' character):
Then I grep the sources, and the only reference to "bend" I found was (as expected) in memory.c:
It is defined as an external symbol, and as it is not defined in any other source file, I suspected it could be defined in the linker file. But it was not in the one installed by the script. So I opened the one inside SGDK package and bingo!:
Replaced installed md.ld with latest SGDK md.ld, and the ROM was built. And it works!
If anyone wants to test the Makefile, you can find it here. You will also have to overwrite the md.ld linker file using the one from SGDK sources, and copy the src directory from SGDK to $GDK/src. I have also used $GDK variable to point to the toolchain instead of the one the build script initially set up ($GENDEV).
Code: Select all
m68k-elf-gcc -n -T /opt/toolchains/gen/ldscripts/md.ld -nostdlib out/sega.o @out/cmd_ /opt/toolchains/gen/m68k-elf/lib/libmd.a /opt/toolchains/gen/m68k-elf/lib/gcc/m68k-elf/4.5.2/libgcc.a -o out/rom.out
/opt/toolchains/gen/m68k-elf/lib/libmd.a(memory.o): In function `MEM_init':
memory.c:(.text+0x2): undefined reference to `_bend'
collect2: ld returned 1 exit status
make: *** [out/rom.out] Error 1
Code: Select all
$ m68k-elf-nm $GDK/m68k-elf/lib/libmd.a
[...]
memory.o:
00000064 T MEM_alloc
00000052 T MEM_free
00000028 T MEM_getFree
00000000 T MEM_init
U _bend
000001b0 T fastMemcpy
000001cc T fastMemcpyU16
000001ea T fastMemcpyU32
00000154 T fastMemset
00000174 T fastMemsetU16
00000194 T fastMemsetU32
00000000 b free
00000004 b heap
U memcpy
00000116 T memcpyU16
00000134 T memcpyU32
U memset
U memsetU16
U memsetU32
[...]
Code: Select all
// end of bss segment --> start of heap
extern u32 _bend;
Code: Select all
.bss 0xFF0000 + SIZEOF (.data) :
{
_start = . ;
*(.shbss)
*(.bss .bss.*)
*(COMMON)
_bend = . ;
} > ram
If anyone wants to test the Makefile, you can find it here. You will also have to overwrite the md.ld linker file using the one from SGDK sources, and copy the src directory from SGDK to $GDK/src. I have also used $GDK variable to point to the toolchain instead of the one the build script initially set up ($GENDEV).