summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-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;