|
Packit |
6c4009 |
/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by Brendan Kehoe (brendan@zen.org).
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library. If not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
#include <features.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#if defined(PIC)
|
|
Packit |
6c4009 |
/* Put this at the end of libc's text segment so that all of
|
|
Packit |
6c4009 |
the direct branches from the syscalls are forward, and
|
|
Packit |
6c4009 |
thus predicted not taken. */
|
|
Packit |
6c4009 |
.section .text.last, "ax", @progbits
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#if IS_IN (libc)
|
|
Packit |
6c4009 |
# define SYSCALL_ERROR_ERRNO __libc_errno
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define SYSCALL_ERROR_ERRNO errno
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.align 4
|
|
Packit |
6c4009 |
.globl __syscall_error
|
|
Packit |
6c4009 |
.ent __syscall_error
|
|
Packit |
6c4009 |
__syscall_error:
|
|
Packit |
6c4009 |
/* When building a shared library, we branch here without having
|
|
Packit |
6c4009 |
loaded the GP. Nor, since it was a direct branch, have we
|
|
Packit |
6c4009 |
loaded PV with our address.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
When building a static library, we tail call here from another
|
|
Packit |
6c4009 |
object file, possibly with a different GP, and must return with
|
|
Packit |
6c4009 |
the GP of our caller in place so that linker relaxation works.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Both issues are solved by computing the GP into T1 instead of
|
|
Packit |
6c4009 |
clobbering the traditional GP register. */
|
|
Packit |
6c4009 |
.prologue 0
|
|
Packit |
6c4009 |
mov v0, t0
|
|
Packit |
6c4009 |
br t1, 1f
|
|
Packit |
6c4009 |
1: ldah t1, 0(t1) !gpdisp!1
|
|
Packit |
6c4009 |
call_pal PAL_rduniq
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
lda t1, 0(t1) !gpdisp!1
|
|
Packit |
6c4009 |
ldq t1, SYSCALL_ERROR_ERRNO(t1) !gottprel
|
|
Packit |
6c4009 |
addq v0, t1, t1
|
|
Packit |
6c4009 |
lda v0, -1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
stl t0, 0(t1)
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.end __syscall_error
|