summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/sysdeps/linux/sh64/Makefile28
-rw-r--r--libc/sysdeps/linux/sh64/crti.S42
-rw-r--r--libc/sysdeps/linux/sh64/crtn.S33
3 files changed, 102 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/sh64/Makefile b/libc/sysdeps/linux/sh64/Makefile
index 8c0b9f399..eaf446a9f 100644
--- a/libc/sysdeps/linux/sh64/Makefile
+++ b/libc/sysdeps/linux/sh64/Makefile
@@ -27,6 +27,7 @@ TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine)
CRT0_SRC = crt0.S
CRT0_OBJ = crt0.o crt1.o
+CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
SSRC = setjmp.S longjmp.S
SOBJS = $(patsubst %.S,%.o, $(SSRC))
@@ -41,7 +42,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/
@@ -57,6 +58,31 @@ $(COBJS): %.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
+
+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:
clean:
diff --git a/libc/sysdeps/linux/sh64/crti.S b/libc/sysdeps/linux/sh64/crti.S
new file mode 100644
index 000000000..597be363d
--- /dev/null
+++ b/libc/sysdeps/linux/sh64/crti.S
@@ -0,0 +1,42 @@
+ .file "initfini.c"
+ .section .text..SHmedia32,"ax"
+ .little
+
+ .section .init
+ .hidden _init
+ .align 2
+ .global _init
+ .type _init, @function
+_init:
+ addi.l r15, -16, r15
+ st.l r15, 4, r12
+ movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) >> 16) & 65535), r12
+ shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) & 65535), r12
+ .LPCS0: ptrel/u r12, tr0
+ st.l r15, 8, r14
+ st.l r15, 12, r18
+ add.l r15, r63, r14
+ gettr tr0, r12
+
+ .align 2
+
+
+ .section .fini
+ .hidden _fini
+ .align 2
+ .global _fini
+ .type _fini, @function
+_fini:
+ addi.l r15, -16, r15
+ st.l r15, 4, r12
+ movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS1-.)) >> 16) & 65535), r12
+ shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS1-.)) & 65535), r12
+ .LPCS1: ptrel/u r12, tr0
+ st.l r15, 8, r14
+ st.l r15, 12, r18
+ add.l r15, r63, r14
+ gettr tr0, r12
+ .align 2
+
+
+ .ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/sh64/crtn.S b/libc/sysdeps/linux/sh64/crtn.S
new file mode 100644
index 000000000..eb6479a56
--- /dev/null
+++ b/libc/sysdeps/linux/sh64/crtn.S
@@ -0,0 +1,33 @@
+ .file "initfini.c"
+ .section .text..SHmedia32,"ax"
+ .little
+
+ .section .init
+ .hidden _init
+ .align 2
+ .global _init
+ .type _init, @function
+ add.l r14, r63, r15
+ ld.l r15, 12, r18
+ ld.l r15, 4, r12
+ ld.l r15, 8, r14
+ ptabs r18, tr0
+ addi.l r15, 16, r15
+ blink tr0, r63
+ .size _init, .-_init
+
+ .section .fini
+ .hidden _fini
+ .align 2
+ .global _fini
+ .type _fini, @function
+ add.l r14, r63, r15
+ ld.l r15, 12, r18
+ ld.l r15, 4, r12
+ ld.l r15, 8, r14
+ ptabs r18, tr0
+ addi.l r15, 16, r15
+ blink tr0, r63
+ .size _fini, .-_fini
+
+ .ident "GCC: (GNU) 3.3.2"