Browse Source

Continue the conversion to using per-arch crti.S and crtn.S

Eric Andersen 22 years ago
parent
commit
84f5d5e948
3 changed files with 113 additions and 1 deletions
  1. 26 1
      libc/sysdeps/linux/sh/Makefile
  2. 50 0
      libc/sysdeps/linux/sh/crti.S
  3. 37 0
      libc/sysdeps/linux/sh/crtn.S

+ 26 - 1
libc/sysdeps/linux/sh/Makefile

@@ -26,6 +26,7 @@ SFLAGS= $(CFLAGS) -D__ASSEMBLER__
 CRT0_SRC = crt0.S
 CRT0_OBJ = crt0.o crt1.o gcrt1.o
 CRT0_DEPS=gmon-start.S
+CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
 
 SSRC=setjmp.S __longjmp.S vfork.S clone.S
 SOBJS=$(patsubst %.S,%.o, $(SSRC))
@@ -40,7 +41,7 @@ all: $(OBJS) $(LIBC)
 
 $(LIBC): ar-target 
 
-ar-target: $(OBJS) $(CRT0_OBJ)
+ar-target: $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 	cp $(CRT0_OBJ) $(TOPDIR)lib/
 
@@ -66,6 +67,30 @@ gmon-start.S: ../common/gmon-start.c
 gcrt1.o: $(CRT0_DEPS)
 endif
 
+ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
+crti.o: crti.S
+	$(CC) $(SAFECFLAGS) -c crti.S -o crti.o
+
+$(TOPDIR)lib/crti.o: crti.o
+	$(INSTALL) -d $(TOPDIR)lib/
+	cp crti.o $(TOPDIR)lib/
+
+crtn.o: crtn.S
+	$(CC) $(SAFECFLAGS) -c crtn.S -o crtn.o
+
+$(TOPDIR)lib/crtn.o: crtn.o
+	$(INSTALL) -d $(TOPDIR)lib/
+	cp crtn.o $(TOPDIR)lib/
+else
+$(TOPDIR)lib/crti.o:
+	$(INSTALL) -d $(TOPDIR)lib/
+	$(AR) $(ARFLAGS) $(TOPDIR)lib/crti.o
+$(TOPDIR)lib/crtn.o:
+	$(INSTALL) -d $(TOPDIR)lib/
+	$(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o
+endif
+
+
 headers:
 	$(LN) -fs ../libc/sysdeps/linux/sh/fpu_control.h $(TOPDIR)/include/
 

+ 50 - 0
libc/sysdeps/linux/sh/crti.S

@@ -0,0 +1,50 @@
+	.file	"initfini.c"
+	.text
+	.little
+	
+	.section .init
+	.hidden  _init
+	.align 1
+	.global	_init
+	.type	_init, @function
+_init:
+	mov.l	r12,@-r15
+	mova	.L6,r0
+	mov.l	r14,@-r15
+	sts.l	pr,@-r15
+	mov.l	.L6,r12
+	mov	r15,r14
+	add	r0,r12
+	
+	
+	
+	bra	1f
+	nop
+	.align 2
+.L6:
+	.long	_GLOBAL_OFFSET_TABLE_
+1:
+	
+	.section .fini
+	.hidden  _fini
+	.align 1
+	.global	_fini
+	.type	_fini, @function
+_fini:
+	mov.l	r12,@-r15
+	mova	.L11,r0
+	mov.l	r14,@-r15
+	sts.l	pr,@-r15
+	mov.l	.L11,r12
+	mov	r15,r14
+	add	r0,r12
+	
+	
+	bra	1f
+	nop
+	.align 2
+.L11:
+	.long	_GLOBAL_OFFSET_TABLE_
+1:
+	
+	.ident	"GCC: (GNU) 3.3.2"

+ 37 - 0
libc/sysdeps/linux/sh/crtn.S

@@ -0,0 +1,37 @@
+	.file	"initfini.c"
+	.text
+	.little
+	
+	.section .init
+	.hidden  _init
+	.align 1
+	.global	_init
+	.type	_init, @function
+	mov	r14,r15
+	lds.l	@r15+,pr
+	mov.l	@r15+,r14
+	rts	
+	mov.l	@r15+,r12
+.L8:
+	.align 2
+.L6:
+.L7:
+	.size	_init, .-_init
+	
+	.section .fini
+	.hidden  _fini
+	.align 1
+	.global	_fini
+	.type	_fini, @function
+	mov	r14,r15
+	lds.l	@r15+,pr
+	mov.l	@r15+,r14
+	rts	
+	mov.l	@r15+,r12
+.L13:
+	.align 2
+.L11:
+.L12:
+	.size	_fini, .-_fini
+	
+	.ident	"GCC: (GNU) 3.3.2"