[gccsdk] [GCCSDK commit] lee - r2510 - trunk/gcc4/recipe/files/gcc/config/arm

Nick Burrett nick at sqrt.co.uk
Fri Jan 19 01:22:33 PST 2007


svnuser at riscos.info wrote:
> Author: lee
> Date: 2007-01-18 22:30:44 +0000 (Thu, 18 Jan 2007)
> New Revision: 2510
> 
> Modified:
>    trunk/gcc4/recipe/files/gcc/config/arm/crti-riscos.asm
> Log:
> Add call to UnixLib initialisation function (__unixlib_main).
> Add call to run user's program (_main)
> Add call to terminate after user's program (exit).
> Add ARM code version of _main. To reproduce _main in C would require
> more than one file creating added complexity.
> Although some, if not all, of the above changes are only required when
> dynamic linking, it is easier to make both static and dynamic use the
> same system files.
> 
> 
> Modified: trunk/gcc4/recipe/files/gcc/config/arm/crti-riscos.asm
> ===================================================================
> --- trunk/gcc4/recipe/files/gcc/config/arm/crti-riscos.asm	2007-01-18 22:04:36 UTC (rev 2509)
> +++ trunk/gcc4/recipe/files/gcc/config/arm/crti-riscos.asm	2007-01-18 22:30:44 UTC (rev 2510)
> @@ -48,18 +48,43 @@
>  	.global	_start
>  	.type	_start, %function
>  _start:
> -	@ On RISC OS the main entry point to the run-time library is
> -	@ always called __main.
> -	B	__main
> +	@ UnixLib must be initialised before any constructors can be called.
> +	@ a1 is set by the dynamic loader. In a static executable, a2 & a3, as
> +	@ set below, are ignored.
> +	LDR	a2, =__executable_start
> +	LDR	a3, =__data_start
> +	BL	__unixlib_main
>  
> -	@ This never gets executed, but it tells the linker to
> -	@ pull in a definition of 'main' from somewhere, so that if an
> -	@ application is linking when 'main' is in a static library,
> -	@ it ensures that 'main' actually gets pulled in.
> -	.type	main, %function
> -	B	main
> +	@ Run global object constructors in shared libraries
> +@	BL	__unixlib_call_ctors
> +

Any calls to specific UnixLib functions in this file could be considered 
incorrect.


> +	@ Run global object constructors in executable
> +@	BL	_init
> +
> +	@; Run the users program.
> +	BL	_main
> +	@; C programs always terminate by calling exit.
> +	B	exit
> +	.type	_start, %function
>  	.size	_start, . - _start
>  
> +	@ _main used to be in unix.c, however, as it calls main() in the executable,
> +	@ it can't remain in the shared library. This is the ARM code equivalent as
> +	@ produced by GCC 4. To make things easier, this applies to static executables
> +	@ as well. Note that if the positions of the argc or argv members of __u change
> +	@ then this code will have to be updated.
> +_main:
> +	LDR	a4, =__u
> +	LDR	ip, [a4, #0]
> +	LDR	a4, =environ
> +	LDR	a2, [ip, #4]
> +	LDR	a3, [a4, #0]
> +	LDR	a1, [ip, #0]
> +	B	main
> +	.type	_main, %function
> +	.size	_main, . - _main

And this definitely shouldn't be in here as we shouldn't hold knowledge 
of internal UnixLib structures externally to UnixLib -- GCC has no 
connection with UnixLib.

Please try to find an alternative to this.

Regards,

Nick.






More information about the gcc mailing list