* m32c/crt0.S: Add support for preinit, init, and fini arrays, and
.init and .fini processing. * m32c/crtn.S: Likewise. * m32c/exit.S: Likewise.
This commit is contained in:
		| @@ -1,3 +1,10 @@ | |||||||
|  | 2005-12-13  DJ Delorie  <dj@redhat.com> | ||||||
|  |  | ||||||
|  | 	* m32c/crt0.S: Add support for preinit, init, and fini arrays, and | ||||||
|  | 	.init and .fini processing. | ||||||
|  | 	* m32c/crtn.S: Likewise. | ||||||
|  | 	* m32c/exit.S: Likewise. | ||||||
|  |  | ||||||
| 2005-12-13  Nathan Sidwell  <nathan@codesourcery.com> | 2005-12-13  Nathan Sidwell  <nathan@codesourcery.com> | ||||||
|  |  | ||||||
| 	* mt/16-002.ld: Change architecture to 'mt'.  Remove | 	* mt/16-002.ld: Change architecture to 'mt'.  Remove | ||||||
|   | |||||||
| @@ -74,6 +74,8 @@ _start: | |||||||
| 	mov.w	#0,r0 | 	mov.w	#0,r0 | ||||||
| 	sstr.w | 	sstr.w | ||||||
|  |  | ||||||
|  | 	jsr.a	__m32c_init | ||||||
|  |  | ||||||
| 	jsr.a	_main | 	jsr.a	_main | ||||||
| .LFE2: | .LFE2: | ||||||
|  |  | ||||||
| @@ -85,6 +87,61 @@ _start: | |||||||
|  |  | ||||||
| 	jsr.a	_exit | 	jsr.a	_exit | ||||||
|  |  | ||||||
|  | 	.text | ||||||
|  |  | ||||||
|  | 	.global	_m32c_run_preinit_array | ||||||
|  | 	.type	_m32c_run_preinit_array,@function | ||||||
|  | _m32c_run_preinit_array: | ||||||
|  | 	mov.W	#__preinit_array_start,a0 | ||||||
|  | 	mov.W	#__preinit_array_end,a1 | ||||||
|  | 	jmp.w	_m32c_run_inilist | ||||||
|  |  | ||||||
|  | 	.global	_m32c_run_init_array | ||||||
|  | 	.type	_m32c_run_init_array,@function | ||||||
|  | _m32c_run_init_array: | ||||||
|  | 	mov.W	#__init_array_start,a0 | ||||||
|  | 	mov.W	#__init_array_end,a1 | ||||||
|  | 	jmp.w	_m32c_run_inilist | ||||||
|  |  | ||||||
|  | 	.global	_m32c_run_fini_array | ||||||
|  | 	.type	_m32c_run_fini_array,@function | ||||||
|  | _m32c_run_fini_array: | ||||||
|  | 	mov.W	#__fini_array_start,a0 | ||||||
|  | 	mov.W	#__fini_array_end,a1 | ||||||
|  | 	/* fall through */ | ||||||
|  |  | ||||||
|  | _m32c_run_inilist: | ||||||
|  | next_inilist: | ||||||
|  | 	cmp.W	a0,a1 | ||||||
|  | 	jeq	done_inilist | ||||||
|  | 	pushm	a0,a1 | ||||||
|  | 	mov.W	[a0],a0 | ||||||
|  | #ifdef A16 | ||||||
|  | 	mov.b:s	#0,a1	/* zero extends */ | ||||||
|  | 	jsri.a	a1a0 | ||||||
|  | #else | ||||||
|  | 	jsri.a	a0 | ||||||
|  | #endif | ||||||
|  | 	popm	a0,a1 | ||||||
|  | 	add.W	A(#2,#4),a0 | ||||||
|  | 	jmp.b	next_inilist | ||||||
|  | done_inilist: | ||||||
|  | 	rts | ||||||
|  |  | ||||||
|  | 	.section	.init,"ax",@progbits | ||||||
|  |  | ||||||
|  | 	.global __m32c_init | ||||||
|  | __m32c_init: | ||||||
|  | 	enter	#0 | ||||||
|  |  | ||||||
|  | 	.section	.fini,"ax",@progbits | ||||||
|  |  | ||||||
|  | 	.global __m32c_fini | ||||||
|  | __m32c_fini: | ||||||
|  | 	enter	#0 | ||||||
|  | 	jsr.a	_m32c_run_fini_array | ||||||
|  |  | ||||||
|  |  | ||||||
| ;;; Provide Dwarf unwinding information that will help GDB stop | ;;; Provide Dwarf unwinding information that will help GDB stop | ||||||
| ;;; backtraces at the right place.  This is stolen from assembly | ;;; backtraces at the right place.  This is stolen from assembly | ||||||
| ;;; code generated by GCC with -dA. | ;;; code generated by GCC with -dA. | ||||||
| @@ -116,4 +173,5 @@ _start: | |||||||
| 	.byte 	0x30		; DW_OP_lit0 | 	.byte 	0x30		; DW_OP_lit0 | ||||||
| 	.p2align ALIGN | 	.p2align ALIGN | ||||||
| .LEFDE0: | .LEFDE0: | ||||||
| .text |  | ||||||
|  | 	.text | ||||||
|   | |||||||
| @@ -41,5 +41,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #define W l | #define W l | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | 	.section	.init,"ax",@progbits | ||||||
|  | 	jsr.a	_m32c_run_preinit_array | ||||||
|  | 	jsr.a	_m32c_run_init_array | ||||||
|  | 	exitd | ||||||
|  | 	.global	__m32c_init_end | ||||||
|  | __m32c_init_end: | ||||||
|  |  | ||||||
|  | 	.section	.fini,"ax",@progbits | ||||||
|  |  | ||||||
|  | 	exitd | ||||||
|  | 	.global	__m32c_fini_end | ||||||
|  | __m32c_fini_end: | ||||||
|  |  | ||||||
| 	.text | 	.text | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,4 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
|  |  | ||||||
| #include "m32csys.h" | #include "m32csys.h" | ||||||
|  |  | ||||||
| S(_exit) | 	.global	__exit | ||||||
|  | __exit: | ||||||
|  | 	jsr.a	__m32c_fini | ||||||
|  | 	SYSCALL(SYS_exit) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user