Page 1 of 1
linking with calloc
Posted: Sat Mar 05, 2005 4:24 pm
by cheriff
I just was playing around a bit with some IOP code that needed calloc (using the iop Makefile that ahz.irx used).
So I added to the top of imports.1st:
Code: Select all
alloc_IMPORTS_start
I_alloc
I_calloc
I_malloc
I_free
alloc_IMPORTS_end
and #include <alloc.h> in irx_imports.x
this died with an error:
tmp/cc791Krm.s:332: Error: expected comma after symbol-name
after manually compiling build-imports.c to a .s file, line 332 is:
seems my iop toolchain doesn't like the .comm directive?? If i remove that and manually compile the 'fixed' .s to a .o the make process completes as normal.
SO. My question to you, it what is this .comm mean, and is it important? If so, why does it cause errors, and if not, why is it being emitted in the first place? I looked around a little, but I cant find where these lines of code come from....
Thanks!
- cheriff
Posted: Fri Oct 30, 2009 8:43 am
by protomank
I am having this exact same error when trying to compile ps2sdk in ps2toolchain/build/ps2sdk/iop/debug/iop_sbusdbg:
root@satellite:/arquivos/programas/devel/ps2/ps2toolchain/build/ps2sdk/iop/debug/iop_sbusdbg# make
echo "#include \"irx_imports.h\"" > src/build-imports.c
cat src/imports.lst >> src/build-imports.c
iop-gcc -miop -O2 -G0 -I/arquivos/programas/devel/ps2/ps2toolchain/build/ps2sdk//iop/include -I/arquivos/programas/devel/ps2/ps2toolchain/build/ps2sdk//iop/kernel/include/ -I/arquivos/programas/devel/ps2/ps2toolchain/build/ps2sdk//common/include -I/arquivos/programas/devel/ps2/ps2toolchain/build/ps2sdk//iop/debug/iopdebug/include/ -I/arquivos/programas/devel/ps2/ps2toolchain/build/ps2sdk//common/sbus/include -I./include -I./src -Wall -fno-builtin-printf -DIRX_NAME=iop_sbusdbg -c src/build-imports.c -o obj/imports.o
/tmp/cc80l5eh.s: Assembler messages:
/tmp/cc80l5eh.s:295: Erro: expected comma after symbol-name
/tmp/cc80l5eh.s:295: Aviso: rest of line ignored; first ignored character is `.'
make: ** [iop_sbusdbg.irx] Erro 1
Anyone knows a fix?
Posted: Sat Oct 31, 2009 4:41 am
by ragnarok2040
It's because the imports.lst has I_iop_dbg_get_reg_frames listed as an imported symbol which isn't prepared as an imported symbol in "iopdebug.h" using DECLARE_IMPORT. Instead the name is treated as a variable definition with no type which wrecks the import table.
Code: Select all
static struct irx_import_table _imp_iopdebug __attribute__((section(".text\n\t#"), unused))= { magic: 0x41e00000, version: ((((1) & 0xff) << 8) + ((1) & 0xff)), name: "iopdebug", };
__asm__ (".section\t.text\n\t" ".globl\t""iop_dbg_set_handler""\n\t""iop_dbg_set_handler"":\n\t" ".word 0x3e00008\n\t" ".word ""0x24000000|8");
I_iop_dbg_get_reg_frames
__asm__ (".section\t.text\n\t.word\t0, 0");
which produces
Code: Select all
.comm .section .text
.word 0, 0,4,4
The END_IMPORT_TABLE macro is inserted within the variable's definition, though.
Here's what it kind of should come out as. I left the symbol name blank, but the .comm directive's attributes are name,size,alignment. A single integer is 4 bytes with a 4 byte alignment.
Code: Select all
.comm 4,4
.section .text
.word 0, 0
The last two statements are inserted by END_IMPORT_TABLE.
I'm not sure why cheriff had his original problem, though. Perhaps a whitespace problem or something specific with his code.