aboutsummaryrefslogtreecommitdiffstats
path: root/main/libc0.9.32/uclibc-libm-pic.patch
blob: ad87b78b248a68282c4ec08934fc7a3955461720 (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
GCC can emit prologue/epilogue code for the functions in various
different cases:
 - frame pointers
 - PIC build (to load ebx for indirect calls/jumps)
 - forced stack smashing protection

If we used jump in such cases, we'd corrupt the call stack and
crash.

Signed-off-by: Timo Teräs <timo.teras at iki.fi>
---
 libm/ldouble_wrappers.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c
index 7d5af90..5b424dc 100644
--- a/libm/ldouble_wrappers.c
+++ b/libm/ldouble_wrappers.c
@@ -60,7 +60,9 @@ long long func##l(long double x) \
  * The return value is returned in st(0) per ABI in both cases (returning
  * a long double or returning a double). So we can simply jump to func.
  * Using __GI_func in jump to make optimized intra-library jump.
- * gcc will still generate a useless "ret" after asm. Oh well...
+ *
+ * We do need to use call (instead of tail jump) as gcc can create
+ * stack frame, and push/modify/pop ebx during PIC build.
  */
 # define WRAPPER1(func) \
 long double func##l(long double x) \
@@ -69,7 +71,7 @@ long double func##l(long double x) \
 	__asm ( \
 	"	fldt	%1\n" \
 	"	fstpl	%1\n" \
-	"	jmp	" __stringify(__GI_##func) "\n" \
+	"	call	" __stringify(__GI_##func) "\n" \
 	: "=t" (st_top) \
 	: "m" (x) \
 	); \
@@ -82,7 +84,7 @@ int func##l(long double x) \
 	__asm ( \
 	"	fldt	%1\n" \
 	"	fstpl	%1\n" \
-	"	jmp	" __stringify(__GI_##func) "\n" \
+	"	call	" __stringify(__GI_##func) "\n" \
 	: "=a" (ret) \
 	: "m" (x) \
 	); \
@@ -95,7 +97,7 @@ long func##l(long double x) \
 	__asm ( \
 	"	fldt	%1\n" \
 	"	fstpl	%1\n" \
-	"	jmp	" __stringify(__GI_##func) "\n" \
+	"	call	" __stringify(__GI_##func) "\n" \
 	: "=a" (ret) \
 	: "m" (x) \
 	); \
@@ -108,7 +110,7 @@ long long func##l(long double x) \
 	__asm ( \
 	"	fldt	%1\n" \
 	"	fstpl	%1\n" \
-	"	jmp	" __stringify(__GI_##func) "\n" \
+	"	call	" __stringify(__GI_##func) "\n" \
 	: "=A" (ret) \
 	: "m" (x) \
 	); \
-- 
1.7.0.4