From abb77f08cc8f6b0d1c9961704e74a2e52d8d838b Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 12 Dec 2008 23:34:42 +0000 Subject: i386/brk.c: gcc can't figure out how to use %ebx in PIC mode, help it. Code size is the same. --- libc/sysdeps/linux/i386/brk.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'libc/sysdeps/linux') 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; -- cgit v1.2.3