|
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
View previous topic :: View next topic |
Author |
Message |
tweakoz
Joined: 17 Feb 2004 Posts: 21 Location: Santa Cruz, CA
|
Posted: Tue Feb 17, 2004 10:58 am Post subject: global constructors not working in gcc 3.2.2EE |
|
|
my toolchain is hosted on cygwin.
program compiles and links fine, but _init() doesnt seem to do anything
top of main and entire linkfile listed below.
any help would be appreciated
thank,
mtm
Code: |
class testclass
{ public:
int testval;
testclass()
: testval( 300 )
{
}
int getval( void ) { return testval; }
};
testclass testinstance;
int main( int argc, char **argv )
{
MagCheckPoint( "Testval %d\n", testinstance.getval() ); // prints 0
gdb_stub_main( 0, 0 );
_init(); // call global / static constructors
MagCheckPoint( "Testval %d\n", testinstance.getval() ); // prints 0
... blah blah .....
}
|
my link file looks like this
Code: |
ENTRY(_start);
INPUT( /usr/local/ps2dev/ee/lib/gcc-lib/ee/3.2.2/crtbegin.o )
INPUT( /usr/local/ps2dev/ee/lib/gcc-lib/ee/3.2.2/crtend.o )
INPUT( /usr/local/ps2dev/ee/lib/gcc-lib/ee/3.2.2/crti.o )
INPUT( /usr/local/ps2dev/ee/lib/gcc-lib/ee/3.2.2/crtn.o )
SECTIONS
{
.init 0x00100000:
{ /* USE GCC's _init() */
*(.init)
}
.fini :
{ /* USE GCC's _init() */
*(.fini)
}
.text :
{ /* USE PS2LIBS's _start */
/usr/local/ps2dev/ps2lib/ee/startup/crt0.o(.text)
*(.text)
*(.text.*)
*(.gnu.linkonce.t*)
}
.ctors :
{
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{ KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.reginfo ALIGN(128): { KEEP(*(.reginfo)) }
/***************************************/
/* Static data. */
.rodata ALIGN(128): { *(.rodata) }
.data ALIGN(128):
{
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
}
.rdata ALIGN(128):
{
*(.rdata)
}
.rodata ALIGN(128):
{
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
}
_gp = ALIGN(128) + 0x7ff0;
.lit4 ALIGN(128): { *(.lit4) }
.lit8 ALIGN(128): { *(.lit8) }
.sdata ALIGN(128):
{
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s*)
}
/***************************************/
/* Uninitialized data. */
.sbss ALIGN(128) (NOLOAD): {
_fbss = . ;
*(.scommon)
*(.sbss)
}
.bss ALIGN(128) (NOLOAD): { *(.bss) }
.COMMON ALIGN(128) (NOLOAD): { *(COMMON) }
_end_bss = .;
/***************************************/
_end = . ;
PROVIDE(end = .);
/***************************************/
/* Symbols needed by crt0.s. */
PROVIDE(_heap_size = -1);
PROVIDE(_stack = -1);
PROVIDE(_stack_size = 128 * 1024);
/***************************************/
}
|
|
|
Back to top |
|
|
MrHTFord
Joined: 10 Feb 2004 Posts: 35 Location: England
|
Posted: Tue Feb 17, 2004 10:24 pm Post subject: |
|
|
What you've got there seems ok to me, have you got this before your main function?
Code: | extern "C" {
extern void _init(void);
};
|
I'd assume you have as otherwise you'd get linking errors.
My linkfile doesn't explicitly list the crt files as yours does, instead, when linking, I don't specify -nostdlib to gcc (at least, I think that's what I don't do). Posting a disassembly with debugging (-g) would be useful.
Also, does it fail with -O0?
Cheers. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|