sbrk.S revision 302408
1160814Ssimon/*- 2160814Ssimon * Copyright (c) 1990 The Regents of the University of California. 3160814Ssimon * All rights reserved. 4160814Ssimon * 5276864Sjkim * This code is derived from software contributed to Berkeley by 6276864Sjkim * William Jolitz. 7276864Sjkim * 8160814Ssimon * Redistribution and use in source and binary forms, with or without 9160814Ssimon * modification, are permitted provided that the following conditions 10160814Ssimon * are met: 11276864Sjkim * 1. Redistributions of source code must retain the above copyright 12276864Sjkim * notice, this list of conditions and the following disclaimer. 13160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright 14276864Sjkim * notice, this list of conditions and the following disclaimer in the 15276864Sjkim * documentation and/or other materials provided with the distribution. 16276864Sjkim * 4. Neither the name of the University nor the names of its contributors 17276864Sjkim * may be used to endorse or promote products derived from this software 18276864Sjkim * without specific prior written permission. 19276864Sjkim * 20160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21160814Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23160814Ssimon * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24160814Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25160814Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26276864Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27276864Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28276864Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29160814Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30276864Sjkim * SUCH DAMAGE. 31276864Sjkim */ 32276864Sjkim 33276864Sjkim#if defined(SYSLIBC_SCCS) && !defined(lint) 34160814Ssimon .asciz "@(#)sbrk.s 5.1 (Berkeley) 4/23/90" 35276864Sjkim#endif /* SYSLIBC_SCCS and not lint */ 36276864Sjkim#include <machine/asm.h> 37276864Sjkim__FBSDID("$FreeBSD: stable/11/lib/libc/i386/sys/sbrk.S 240152 2012-09-05 21:41:05Z jilles $"); 38160814Ssimon 39276864Sjkim#include "SYS.h" 40276864Sjkim 41160814Ssimon .globl CNAME(_end) 42276864Sjkim .globl HIDENAME(minbrk) 43276864Sjkim .globl HIDENAME(curbrk) 44160814Ssimon 45276864Sjkim .data 46276864SjkimHIDENAME(minbrk): .long CNAME(_end) 47160814SsimonHIDENAME(curbrk): .long CNAME(_end) 48276864Sjkim .text 49160814Ssimon 50276864SjkimENTRY(sbrk) 51160814Ssimon#ifdef PIC 52276864Sjkim movl 4(%esp),%ecx 53160814Ssimon PIC_PROLOGUE 54276864Sjkim movl PIC_GOT(HIDENAME(curbrk)),%edx 55276864Sjkim movl (%edx),%eax 56160814Ssimon PIC_EPILOGUE 57276864Sjkim testl %ecx,%ecx 58276864Sjkim jz back 59160814Ssimon addl %eax,4(%esp) 60160814Ssimon mov $SYS_break,%eax 61276864Sjkim KERNCALL 62160814Ssimon jb HIDENAME(cerror) 63276864Sjkim PIC_PROLOGUE 64276864Sjkim movl PIC_GOT(HIDENAME(curbrk)),%edx 65276864Sjkim movl (%edx),%eax 66276864Sjkim addl %ecx,(%edx) 67276864Sjkim PIC_EPILOGUE 68160814Ssimonback: 69160814Ssimon ret 70160814Ssimon 71160814Ssimon#else /* !PIC */ 72160814Ssimon 73160814Ssimon movl 4(%esp),%ecx 74160814Ssimon movl HIDENAME(curbrk),%eax 75276864Sjkim testl %ecx,%ecx 76160814Ssimon jz back 77160814Ssimon addl %eax,4(%esp) 78276864Sjkim mov $SYS_break,%eax 79160814Ssimon KERNCALL 80160814Ssimon jb HIDENAME(cerror) 81160814Ssimon movl HIDENAME(curbrk),%eax 82160814Ssimon addl %ecx,HIDENAME(curbrk) 83160814Ssimonback: 84160814Ssimon ret 85160814Ssimon#endif /* PIC */ 86160814SsimonEND(sbrk) 87276864Sjkim 88276864Sjkim .section .note.GNU-stack,"",%progbits 89276864Sjkim