blob: 5fe8d40861d9d9d3c1b85ea899e4b63d3e782371 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* brk system call for Linux/ppc.
2 Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20#include <features.h>
21#include "ppc_asm.h"
22#define _ERRNO_H 1
23#include <bits/errno.h>
24#include <sys/syscall.h>
25
26#ifdef __NR_brk
27
28#ifdef __PIC__
29.section .bss
30 .align 4
31 .globl __curbrk
32 .hidden __curbrk
33__curbrk: .skip 4
34 .type __curbrk,@object
35 .size __curbrk,4
36#else
37.comm __curbrk, 4,4
38#endif
39
40 .text
41 .globl brk
42 .type brk,@function
43 .align 2
44
45brk:
46 stwu r1,-16(r1)
47 stw r3,8(r1)
48 li 0, __NR_brk;
49 sc
50 lwz r6,8(r1)
51#ifdef __PIC__
52 mflr r4
53# ifdef HAVE_ASM_PPC_REL16
54 bcl 20,31,1f
551: mflr r5
56 addis r5,r5,_GLOBAL_OFFSET_TABLE_-1b@ha
57 addi r5,r5,_GLOBAL_OFFSET_TABLE_-1b@l
58# else
59 bl _GLOBAL_OFFSET_TABLE_@local-4
60 mflr r5
61# endif
62 lwz r5,__curbrk@got(r5)
63 mtlr r4
64 stw r3,0(r5)
65#else
66 lis r4,__curbrk@ha
67 stw r3,__curbrk@l(r4)
68#endif
69 cmplw r6,r3
70 addi r1,r1,16
71 li r3,0
72 blelr+
73 li r3,ENOMEM
74
75 b __syscall_error
76
77 .size brk,.-brk
78
79libc_hidden_def(brk)
80#endif