summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-12 23:34:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-12 23:34:42 +0000
commitabb77f08cc8f6b0d1c9961704e74a2e52d8d838b (patch)
tree6d146b66994a569e8af249dce58f48bae5332fcc
parent0c2be5a1d1ac59951bfac58ec82897b654ee4d7a (diff)
i386/brk.c: gcc can't figure out how to use %ebx in PIC mode,
help it. Code size is the same.
-rw-r--r--libc/sysdeps/linux/i386/brk.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libc/sysdeps/linux/i386/brk.c b/libc/sysdeps/linux/i386/brk.c
index 744d1d037..4b47a3b19 100644
--- a/libc/sysdeps/linux/i386/brk.c
+++ b/libc/sysdeps/linux/i386/brk.c
@@ -25,14 +25,19 @@
void *__curbrk attribute_hidden = 0;
/* libc_hidden_proto(brk) */
-int brk (void *addr)
+int brk(void *addr)
{
- void *newbrk, *ebx;
-
- __asm__ (
- "int $0x80\n"
- : "=a" (newbrk), "=b" (ebx)
- : "0" (__NR_brk), "1" (addr)
+ void *newbrk;
+
+ /* %ebx is used in PIC code, need to save/restore it manually.
+ * gcc won't do it for us if we will request it in constraints
+ */
+ __asm__("pushl %%ebx\n"
+ "movl %2, %%ebx\n"
+ "int $0x80\n"
+ "popl %%ebx\n"
+ : "=a" (newbrk)
+ : "0" (__NR_brk), "g" (addr)
);
__curbrk = newbrk;