1129202Scognet/* $NetBSD: brk.S,v 1.6 2003/08/07 16:42:04 agc Exp $ */ 2129202Scognet 3129202Scognet/*- 4129202Scognet * Copyright (c) 1990 The Regents of the University of California. 5129202Scognet * All rights reserved. 6129202Scognet * 7129202Scognet * Redistribution and use in source and binary forms, with or without 8129202Scognet * modification, are permitted provided that the following conditions 9129202Scognet * are met: 10129202Scognet * 1. Redistributions of source code must retain the above copyright 11129202Scognet * notice, this list of conditions and the following disclaimer. 12129202Scognet * 2. Redistributions in binary form must reproduce the above copyright 13129202Scognet * notice, this list of conditions and the following disclaimer in the 14129202Scognet * documentation and/or other materials provided with the distribution. 15129202Scognet * 3. Neither the name of the University nor the names of its contributors 16129202Scognet * may be used to endorse or promote products derived from this software 17129202Scognet * without specific prior written permission. 18129202Scognet * 19129202Scognet * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20129202Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21129202Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22129202Scognet * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23129202Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24129202Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25129202Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26129202Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27129202Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28129202Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29129202Scognet * SUCH DAMAGE. 30129202Scognet * 31129202Scognet * from: @(#)brk.s 5.2 (Berkeley) 12/17/90 32129202Scognet */ 33129202Scognet 34129202Scognet#include <machine/asm.h> 35129202Scognet__FBSDID("$FreeBSD: releng/10.2/lib/libc/arm/sys/brk.S 271337 2014-09-09 22:24:01Z ian $"); 36129202Scognet#include "SYS.h" 37129202Scognet 38169722Skan .globl _C_LABEL(_end) 39129202Scognet .globl CURBRK 40129202Scognet 41129202Scognet#ifdef WEAK_ALIAS 42129202ScognetWEAK_ALIAS(brk, _brk) 43129202Scognet#endif 44129202Scognet 45129202Scognet .data 46129202Scognet .align 0 47129202Scognet .globl _C_LABEL(minbrk) 48129202Scognet .type _C_LABEL(minbrk),#object 49129202Scognet_C_LABEL(minbrk): 50169722Skan .word _C_LABEL(_end) 51129202Scognet 52129202Scognet/* 53129202Scognet * Change the data segment size 54129202Scognet */ 55129202ScognetENTRY(_brk) 56129202Scognet#ifdef PIC 57129202Scognet /* Setup the GOT */ 58129202Scognet ldr r3, .Lgot 59129202Scognet add r3, pc, r3 60129202Scognet.L1: 61129202Scognet ldr r1, .Lminbrk 62129202Scognet ldr r1, [r3, r1] 63129202Scognet#else 64129202Scognet ldr r1, .Lminbrk 65129202Scognet#endif 66129202Scognet /* Get the minimum allowable brk address */ 67129202Scognet ldr r1, [r1] 68129202Scognet 69129202Scognet /* 70129202Scognet * Valid the address specified and set to the minimum 71129202Scognet * if the address is below minbrk. 72129202Scognet */ 73129202Scognet cmp r0, r1 74129202Scognet movlt r0, r1 75129202Scognet mov r2, r0 76129202Scognet SYSTRAP(break) 77129202Scognet bcs PIC_SYM(CERROR, PLT) 78129202Scognet 79129202Scognet#ifdef PIC 80129202Scognet ldr r1, .Lcurbrk 81129202Scognet ldr r1, [r3, r1] 82129202Scognet#else 83129202Scognet ldr r1, .Lcurbrk 84129202Scognet#endif 85129202Scognet /* Store the new address in curbrk */ 86129202Scognet str r2, [r1] 87129202Scognet 88129202Scognet /* Return 0 for success */ 89129202Scognet mov r0, #0x00000000 90137464Scognet RET 91129202Scognet 92129202Scognet .align 2 93129202Scognet#ifdef PIC 94129202Scognet.Lgot: 95129202Scognet .word _GLOBAL_OFFSET_TABLE_ - (.L1+4) 96129202Scognet#endif 97129202Scognet.Lminbrk: 98129202Scognet .word PIC_SYM(_C_LABEL(minbrk), GOT) 99129202Scognet.Lcurbrk: 100129202Scognet .word PIC_SYM(CURBRK, GOT) 101271337SianEND(_brk) 102