|
Packit |
6c4009 |
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
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 License as
|
|
Packit |
6c4009 |
published by the Free Software Foundation; either version 2.1 of the
|
|
Packit |
6c4009 |
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 |
#ifndef _AARCH64_SYSDEP_H
|
|
Packit |
6c4009 |
#define _AARCH64_SYSDEP_H
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdeps/generic/sysdep.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __LP64__
|
|
Packit |
6c4009 |
# define AARCH64_R(NAME) R_AARCH64_ ## NAME
|
|
Packit |
6c4009 |
# define PTR_REG(n) x##n
|
|
Packit |
6c4009 |
# define PTR_LOG_SIZE 3
|
|
Packit |
6c4009 |
# define DELOUSE(n)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define AARCH64_R(NAME) R_AARCH64_P32_ ## NAME
|
|
Packit |
6c4009 |
# define PTR_REG(n) w##n
|
|
Packit |
6c4009 |
# define PTR_LOG_SIZE 2
|
|
Packit |
6c4009 |
# define DELOUSE(n) mov w##n, w##n
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define PTR_SIZE (1<
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __ASSEMBLER__
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Syntactic details of assembler. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Define an entry point visible from C. */
|
|
Packit |
6c4009 |
#define ENTRY(name) \
|
|
Packit |
6c4009 |
.globl C_SYMBOL_NAME(name); \
|
|
Packit |
6c4009 |
.type C_SYMBOL_NAME(name),%function; \
|
|
Packit |
6c4009 |
.align 4; \
|
|
Packit |
6c4009 |
C_LABEL(name) \
|
|
Packit |
6c4009 |
cfi_startproc; \
|
|
Packit |
6c4009 |
CALL_MCOUNT
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Define an entry point visible from C. */
|
|
Packit |
6c4009 |
#define ENTRY_ALIGN(name, align) \
|
|
Packit |
6c4009 |
.globl C_SYMBOL_NAME(name); \
|
|
Packit |
6c4009 |
.type C_SYMBOL_NAME(name),%function; \
|
|
Packit |
6c4009 |
.p2align align; \
|
|
Packit |
6c4009 |
C_LABEL(name) \
|
|
Packit |
6c4009 |
cfi_startproc; \
|
|
Packit |
6c4009 |
CALL_MCOUNT
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Define an entry point visible from C with a specified alignment and
|
|
Packit |
6c4009 |
pre-padding with NOPs. This can be used to ensure that a critical
|
|
Packit |
6c4009 |
loop within a function is cache line aligned. Note this version
|
|
Packit |
6c4009 |
does not adjust the padding if CALL_MCOUNT is defined. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define ENTRY_ALIGN_AND_PAD(name, align, padding) \
|
|
Packit |
6c4009 |
.globl C_SYMBOL_NAME(name); \
|
|
Packit |
6c4009 |
.type C_SYMBOL_NAME(name),%function; \
|
|
Packit |
6c4009 |
.p2align align; \
|
|
Packit |
6c4009 |
.rep padding; \
|
|
Packit |
6c4009 |
nop; \
|
|
Packit |
6c4009 |
.endr; \
|
|
Packit |
6c4009 |
C_LABEL(name) \
|
|
Packit |
6c4009 |
cfi_startproc; \
|
|
Packit |
6c4009 |
CALL_MCOUNT
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#undef END
|
|
Packit |
6c4009 |
#define END(name) \
|
|
Packit |
6c4009 |
cfi_endproc; \
|
|
Packit |
6c4009 |
ASM_SIZE_DIRECTIVE(name)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* If compiled for profiling, call `mcount' at the start of each function. */
|
|
Packit |
6c4009 |
#ifdef PROF
|
|
Packit |
6c4009 |
# define CALL_MCOUNT \
|
|
Packit |
6c4009 |
str x30, [sp, #-80]!; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (80); \
|
|
Packit |
6c4009 |
cfi_rel_offset (x30, 0); \
|
|
Packit |
6c4009 |
stp x0, x1, [sp, #16]; \
|
|
Packit |
6c4009 |
cfi_rel_offset (x0, 16); \
|
|
Packit |
6c4009 |
cfi_rel_offset (x1, 24); \
|
|
Packit |
6c4009 |
stp x2, x3, [sp, #32]; \
|
|
Packit |
6c4009 |
cfi_rel_offset (x2, 32); \
|
|
Packit |
6c4009 |
cfi_rel_offset (x3, 40); \
|
|
Packit |
6c4009 |
stp x4, x5, [sp, #48]; \
|
|
Packit |
6c4009 |
cfi_rel_offset (x4, 48); \
|
|
Packit |
6c4009 |
cfi_rel_offset (x5, 56); \
|
|
Packit |
6c4009 |
stp x6, x7, [sp, #64]; \
|
|
Packit |
6c4009 |
cfi_rel_offset (x6, 64); \
|
|
Packit |
6c4009 |
cfi_rel_offset (x7, 72); \
|
|
Packit |
6c4009 |
mov x0, x30; \
|
|
Packit |
6c4009 |
bl mcount; \
|
|
Packit |
6c4009 |
ldp x0, x1, [sp, #16]; \
|
|
Packit |
6c4009 |
cfi_restore (x0); \
|
|
Packit |
6c4009 |
cfi_restore (x1); \
|
|
Packit |
6c4009 |
ldp x2, x3, [sp, #32]; \
|
|
Packit |
6c4009 |
cfi_restore (x2); \
|
|
Packit |
6c4009 |
cfi_restore (x3); \
|
|
Packit |
6c4009 |
ldp x4, x5, [sp, #48]; \
|
|
Packit |
6c4009 |
cfi_restore (x4); \
|
|
Packit |
6c4009 |
cfi_restore (x5); \
|
|
Packit |
6c4009 |
ldp x6, x7, [sp, #64]; \
|
|
Packit |
6c4009 |
cfi_restore (x6); \
|
|
Packit |
6c4009 |
cfi_restore (x7); \
|
|
Packit |
6c4009 |
ldr x30, [sp], #80; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-80); \
|
|
Packit |
6c4009 |
cfi_restore (x30);
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define CALL_MCOUNT /* Do nothing. */
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Local label name for asm code. */
|
|
Packit |
6c4009 |
#ifndef L
|
|
Packit |
6c4009 |
# define L(name) .L##name
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Load or store to/from a pc-relative EXPR into/from R, using T.
|
|
Packit |
6c4009 |
Note R and T are register numbers and not register names. */
|
|
Packit |
6c4009 |
#define LDST_PCREL(OP, R, T, EXPR) \
|
|
Packit |
6c4009 |
adrp x##T, EXPR; \
|
|
Packit |
6c4009 |
OP PTR_REG (R), [x##T, #:lo12:EXPR]; \
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Load or store to/from a got-relative EXPR into/from R, using T.
|
|
Packit |
6c4009 |
Note R and T are register numbers and not register names. */
|
|
Packit |
6c4009 |
#define LDST_GLOBAL(OP, R, T, EXPR) \
|
|
Packit |
6c4009 |
adrp x##T, :got:EXPR; \
|
|
Packit |
6c4009 |
ldr PTR_REG (T), [x##T, #:got_lo12:EXPR]; \
|
|
Packit |
6c4009 |
OP PTR_REG (R), [x##T];
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Load an immediate into R.
|
|
Packit |
6c4009 |
Note R is a register number and not a register name. */
|
|
Packit |
6c4009 |
#ifdef __LP64__
|
|
Packit |
6c4009 |
# define MOVL(R, NAME) \
|
|
Packit |
6c4009 |
movz PTR_REG (R), #:abs_g3:NAME; \
|
|
Packit |
6c4009 |
movk PTR_REG (R), #:abs_g2_nc:NAME; \
|
|
Packit |
6c4009 |
movk PTR_REG (R), #:abs_g1_nc:NAME; \
|
|
Packit |
6c4009 |
movk PTR_REG (R), #:abs_g0_nc:NAME;
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define MOVL(R, NAME) \
|
|
Packit |
6c4009 |
movz PTR_REG (R), #:abs_g1:NAME; \
|
|
Packit |
6c4009 |
movk PTR_REG (R), #:abs_g0_nc:NAME;
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Since C identifiers are not normally prefixed with an underscore
|
|
Packit |
6c4009 |
on this system, the asm identifier `syscall_error' intrudes on the
|
|
Packit |
6c4009 |
C name space. Make sure we use an innocuous name. */
|
|
Packit |
6c4009 |
#define syscall_error __syscall_error
|
|
Packit |
6c4009 |
#define mcount _mcount
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* __ASSEMBLER__ */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* _AARCH64_SYSDEP_H */
|