summaryrefslogtreecommitdiff
path: root/patches/uClibc/0.9.32/120-ctor-dtor-nptl-Fix-init-and-fini-function-compilation.patch
blob: 146610bba446120e40a82e9ca0877288c94fb11c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
commit f9e311d11c374e68736c741ede1845bdc8091627
Author: Khem Raj <raj.khem@gmail.com>
Date:   Mon Jun 13 16:30:55 2011 -0700

    ctor/dtor nptl: Fix init and fini function compilation
    
    We need to define the rules for .S files so it
    gets the include paths some architectures like mips
    include headers
    
    Some architectures e.g. SH have their own version
    of pt-initfini.c so look for that first before resorting
    to generic version of pt-initfini.c
    
    Signed-off-by: Khem Raj <raj.khem@gmail.com>
    Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>

diff --git a/libc/sysdeps/linux/mips/crtn.S b/libc/sysdeps/linux/mips/crtn.S
index cedd593..f3756a2 100644
--- a/libc/sysdeps/linux/mips/crtn.S
+++ b/libc/sysdeps/linux/mips/crtn.S
@@ -10,7 +10,6 @@
 #NO_APP
 	.align	2
 	.globl	_init
-	.ent	_init
 	.type	_init, @function
 #NO_APP
 	lw	$31,28($sp)
@@ -22,14 +21,12 @@
 	.set	macro
 	.set	reorder
 
-	.end	_init
 #APP
 	
 	.section .fini
 #NO_APP
 	.align	2
 	.globl	_fini
-	.ent	_fini
 	.type	_fini, @function
 #NO_APP
 	lw	$31,28($sp)
@@ -41,7 +38,6 @@
 	.set	macro
 	.set	reorder
 
-	.end	_fini
 #APP
 	
 	.ident	"GCC: (GNU) 3.3.2"
@@ -54,10 +50,8 @@
 	
 	.section .init
 #NO_APP
-	.align	2
 	.align	3
 	.globl	_init
-	.ent	_init
 	.type	_init, @function
 #NO_APP
 	ld	$31,8($sp)
@@ -68,16 +62,12 @@
 	addiu	$sp,$sp,16
 	.set	macro
 	.set	reorder
-
-	.end	_init
 #APP
 	
 	.section .fini
 #NO_APP
-	.align	2
 	.align	3
 	.globl	_fini
-	.ent	_fini
 	.type	_fini, @function
 #NO_APP
 	ld	$31,8($sp)
@@ -89,7 +79,6 @@
 	.set	macro
 	.set	reorder
 
-	.end	_fini
 #APP
 	
 	.ident	"GCC: (GNU) 3.4.3"
@@ -105,7 +94,6 @@
 #NO_APP
 	.align	2
 	.globl	_init
-	.ent	_init
 	.type	_init, @function
 #NO_APP
 	ld	$31,24($sp)
@@ -118,14 +106,12 @@
 	.set	macro
 	.set	reorder
 
-	.end	_init
 #APP
 	
 	.section .fini
 #NO_APP
 	.align	2
 	.globl	_fini
-	.ent	_fini
 	.type	_fini, @function
 #NO_APP
 	ld	$31,24($sp)
@@ -138,7 +124,6 @@
 	.set	macro
 	.set	reorder
 
-	.end	_fini
 #APP
 	
 	.ident	"GCC: (GNU) 3.3.2"
diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index 92d72a6..849bd59 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -64,8 +64,8 @@ endif
 librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS)
 
 ifeq ($(UCLIBC_CTOR_DTOR),y)
-START_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/crti.o
-END_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/crtn.o
+START_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crti.o
+END_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crtn.o
 LDFLAGS-libpthread.so += -nostartfiles
 $(top_builddir)lib/libpthread.so: | $(START_FILE-libpthread.so) $(END_FILE-libpthread.so)
 endif
diff --git a/libpthread/nptl/sysdeps/pthread/Makefile.in b/libpthread/nptl/sysdeps/pthread/Makefile.in
index d93b3a5..398eaea 100644
--- a/libpthread/nptl/sysdeps/pthread/Makefile.in
+++ b/libpthread/nptl/sysdeps/pthread/Makefile.in
@@ -73,23 +73,37 @@ CFLAGS-pt-initfini.c = -S -g0 $(PICFLAG) -fno-inline-functions	\
 			-finhibit-size-directive			\
 			-fno-asynchronous-unwind-tables -fno-unwind-tables \
 			$(patsubst -f%,-fno-%,$(call check_gcc,-fexceptions,))
-ASFLAGS-crti.S = -g0
-ASFLAGS-crtn.S = -g0
 
-$(libpthread_pthread_OUT)/pt-initfini.s: $(libpthread_pthread_DIR)/pt-initfini.c
+#ASFLAGS += $(PICFLAG) -I$(top_srcdir)include -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
+ifneq ($(wildcard $(libpthread_DIR)/sysdeps/linux/$(TARGET_ARCH)/pt-initfini.c),)
+PTHREAD_INITFINI := $(libpthread_DIR)/sysdeps/linux/$(TARGET_ARCH)/pt-initfini.c
+else
+PTHREAD_INITFINI := $(libpthread_pthread_DIR)/pt-initfini.c
+endif
+
+ASFLAGS-pt-crti.S =  $(PICFLAG)
+ASFLAGS-pt-crtn.S =  $(PICFLAG)
+
+$(libpthread_pthread_OUT)/pt-crti.o: $(libpthread_pthread_OUT)/pt-crti.S
+	$(compile.S)
+
+$(libpthread_pthread_OUT)/pt-crtn.o: $(libpthread_pthread_OUT)/pt-crtn.S
+	$(compile.S)
+
+$(libpthread_pthread_OUT)/pt-initfini.s: $(PTHREAD_INITFINI)
 	$(compile.c)
-$(libpthread_pthread_OUT)/defs.h: $(libpthread_pthread_DIR)/pt-initfini.c
+$(libpthread_pthread_OUT)/defs.h: $(PTHREAD_INITFINI)
 	$(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
 		$(AWK) -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
 	$(Q)mv $@.tmp $@
 
-$(libpthread_pthread_OUT)/crti.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
+$(libpthread_pthread_OUT)/pt-crti.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
 	$(do_sed) -n -e '/[ 	]*\.file/d' \
 		-e '1,/@HEADER_ENDS/p' \
 		-e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
 		-e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp
 	$(Q)mv $@.tmp $@
-$(libpthread_pthread_OUT)/crtn.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
+$(libpthread_pthread_OUT)/pt-crtn.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
 	$(do_sed) -n -e '/[ 	]*\.file/d' \
 		-e '1,/@HEADER_ENDS/p' \
 		-e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \