about summary refs log tree commit diff
path: root/sysdeps/sparc64/elf/crtbegin.S
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/sparc64/elf/crtbegin.S')
-rw-r--r--sysdeps/sparc64/elf/crtbegin.S49
1 files changed, 49 insertions, 0 deletions
diff --git a/sysdeps/sparc64/elf/crtbegin.S b/sysdeps/sparc64/elf/crtbegin.S
new file mode 100644
index 0000000000..fbd731cad0
--- /dev/null
+++ b/sysdeps/sparc64/elf/crtbegin.S
@@ -0,0 +1,49 @@
+.section ".ctors",#alloc,#write
+
+	.align 8
+__CTOR_LIST__:
+	.xword	-1
+
+.section ".dtors",#alloc,#write
+
+	.align 8
+__DTOR_LIST__:
+	.xword	-1
+
+.section ".fini",#alloc,#execinstr
+
+	call	__do_global_dtors_aux
+	 nop
+
+.text
+
+	.align 4
+	.type __do_global_dtors_aux,#function
+__do_global_dtors_aux:
+	save	%sp,-160,%sp
+
+#ifdef PIC
+1:	rd	%pc, %g1
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
+	or	%l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
+	add	%l7, %g1, %l7
+	sethi	%hi(__DTOR_LIST__), %l0
+	or	%l0, %lo(__DTOR_LIST__), %l0
+	ldx	[%l7+%l0], %l0
+#else
+	sethi	%hi(__DTOR_LIST__), %l0
+	or	%l0, %lo(__DTOR_LIST__), %l0
+	add	%l0, %g4, %l0
+#endif
+
+	ba	3f
+	 ldx	[%l0+8], %l1
+2:	jmpl	%l1, %o7
+	 ldx	[%l0+8], %l1
+3:	brnz,pt	%l1, 2b
+	 add	%l0, 8, %l0
+
+	ret
+	 restore
+
+	.size __do_global_dtors_aux,.-__do_global_dtors_aux