[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Binutils 2.18 + GCC 4.2.3



MiKRO wrote:
Actually, I maybe, just maybe, discovered the source of problem. Shame on me, it's my patch -- look in the startup code of mintlib, I changed our premilitary stack to 1 KB, to be sure we know what's going on in case of some problems (ehm, it does work really well ;-).

Hmmmmm (again)...

Here is the current startup code (including your patch) :

	movel	sp@(4), a0	| get basepage
	movel	a0, Base	| save it
	movel	a0@(0x18), d0	| get address of BSS segment
	addl	a0@(0x1c), d0	| add length of BSS segment
	addl	#1024, d0	| add length of early stack
	andb	#0b11111100, d0	| align on long boundary
	movel	d0, sp		| set stack (temporarily)
	jmp	__crtinit	| in crtinit.c


I think it is not correct for accessories, because the space after the .bss segment does not belong to us.

It is not correct if there is not enough space for the initial stack after the .bss segment (base->p_hitpa should be checked).

However, in the usual case, it should not cause any problem...

I've just looked quickly at mintlib/crtinit.c, in the function parseargs (which is run with the early stack).

 * parseargs(bp): parse the environment and arguments pointed to by the
 * basepage. Return the number of bytes of environment and arguments
 * that have been appended to the bss area (the environ and argv arrays
 * are put here, as is a temporary buffer for the command line, if
 * necessary).

In our problematic case, the arguments are more than 2 Kb long... and the early stack size is 1Kb... all of them using the space just after the .bss segment...

Clearly, we should have a closer look to that !

--
Vincent Rivière