linking with calloc

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
cheriff
Regular
Posts: 258
Joined: Wed Jun 23, 2004 5:35 pm
Location: Sydney.au

linking with calloc

Post 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:

Code: Select all

.comm	.section	.text
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
Damn, I need a decent signature!
protomank
Posts: 59
Joined: Thu Dec 18, 2008 1:41 am
Location: Porto Alegre, RS, Brazil
Contact:

Post 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?
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post 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__&#40;&#40;section&#40;".text\n\t#"&#41;, unused&#41;&#41;= &#123; magic&#58; 0x41e00000, version&#58; &#40;&#40;&#40;&#40;1&#41; & 0xff&#41; << 8&#41; + &#40;&#40;1&#41; & 0xff&#41;&#41;, name&#58; "iopdebug", &#125;;
__asm__ &#40;".section\t.text\n\t" ".globl\t""iop_dbg_set_handler""\n\t""iop_dbg_set_handler""&#58;\n\t" ".word 0x3e00008\n\t" ".word ""0x24000000|8"&#41;;
I_iop_dbg_get_reg_frames
__asm__ &#40;".section\t.text\n\t.word\t0, 0"&#41;;
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.
Post Reply