brk.S revision 1.2
11.2Sfvdl/* $NetBSD: brk.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */ 21.1Sfvdl 31.1Sfvdl/*- 41.1Sfvdl * Copyright (c) 1990 The Regents of the University of California. 51.1Sfvdl * All rights reserved. 61.1Sfvdl * 71.1Sfvdl * This code is derived from software contributed to Berkeley by 81.1Sfvdl * William Jolitz. 91.1Sfvdl * 101.1Sfvdl * Redistribution and use in source and binary forms, with or without 111.1Sfvdl * modification, are permitted provided that the following conditions 121.1Sfvdl * are met: 131.1Sfvdl * 1. Redistributions of source code must retain the above copyright 141.1Sfvdl * notice, this list of conditions and the following disclaimer. 151.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright 161.1Sfvdl * notice, this list of conditions and the following disclaimer in the 171.1Sfvdl * documentation and/or other materials provided with the distribution. 181.1Sfvdl * 3. All advertising materials mentioning features or use of this software 191.1Sfvdl * must display the following acknowledgement: 201.1Sfvdl * This product includes software developed by the University of 211.1Sfvdl * California, Berkeley and its contributors. 221.1Sfvdl * 4. Neither the name of the University nor the names of its contributors 231.1Sfvdl * may be used to endorse or promote products derived from this software 241.1Sfvdl * without specific prior written permission. 251.1Sfvdl * 261.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271.1Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281.1Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291.1Sfvdl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301.1Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311.1Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321.1Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331.1Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341.1Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351.1Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361.1Sfvdl * SUCH DAMAGE. 371.1Sfvdl * 381.1Sfvdl * from: @(#)brk.s 5.2 (Berkeley) 12/17/90 391.1Sfvdl */ 401.1Sfvdl 411.1Sfvdl#include <machine/asm.h> 421.1Sfvdl#if defined(SYSLIBC_SCCS) && !defined(lint) 431.2Sfvdl RCSID("$NetBSD: brk.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $") 441.1Sfvdl#endif /* SYSLIBC_SCCS and not lint */ 451.1Sfvdl 461.1Sfvdl#include "SYS.h" 471.1Sfvdl 481.1Sfvdl .globl _end 491.1Sfvdl .globl _C_LABEL(__minbrk) 501.1Sfvdl .globl CURBRK 511.1Sfvdl 521.1Sfvdl#ifdef WEAK_ALIAS 531.1SfvdlWEAK_ALIAS(brk, _brk) 541.1Sfvdl#endif 551.1Sfvdl 561.1Sfvdl .data 571.1Sfvdl_C_LABEL(__minbrk): 581.1Sfvdl .quad _end 591.1Sfvdl .text 601.1Sfvdl 611.1SfvdlENTRY(_brk) 621.1Sfvdl#ifdef PIC 631.1Sfvdl movq PIC_GOT(_C_LABEL(__minbrk)),%rdx 641.1Sfvdl cmpq %rdi,(%rdx) 651.1Sfvdl jb 1f 661.1Sfvdl movq (%rdx),%rdi 671.1Sfvdl1: 681.1Sfvdl SYSTRAP(break) 691.1Sfvdl jc err 701.1Sfvdl movq PIC_GOT(CURBRK),%rdx # set up GOT addressing 711.2Sfvdl movq %rdi,(%rdx) 721.1Sfvdl xorl %eax,%eax 731.1Sfvdl ret 741.1Sfvdlerr: 751.1Sfvdl movq PIC_GOT(CERROR),%rdx 761.1Sfvdl jmp *%rdx 771.1Sfvdl#else 781.1Sfvdl cmpq %rdi,_C_LABEL(__minbrk)(%rip) 791.1Sfvdl jb 1f 801.1Sfvdl movq _C_LABEL(__minbrk)(%rip),%rdi 811.1Sfvdl1: 821.1Sfvdl SYSTRAP(break) 831.1Sfvdl jc err 841.1Sfvdl movq %rdi,CURBRK(%rip) 851.1Sfvdl xorl %eax,%eax 861.1Sfvdl ret 871.1Sfvdlerr: 881.1Sfvdl jmp CERROR 891.1Sfvdl#endif 90