2012-02-08 14:25:07 +00:00
|
|
|
/* Special .init and .fini section support for PowerPC64.
|
2018-01-01 00:32:25 +00:00
|
|
|
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
2012-02-08 14:25:07 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
In addition to the permissions in the GNU Lesser General Public
|
|
|
|
License, the Free Software Foundation gives you unlimited
|
|
|
|
permission to link the compiled version of this file with other
|
|
|
|
programs, and to distribute those programs without any restriction
|
|
|
|
coming from the use of this file. (The GNU Lesser General Public
|
|
|
|
License restrictions do apply in other respects; for example, they
|
|
|
|
cover modification of the file, and distribution when not linked
|
|
|
|
into another program.)
|
|
|
|
|
|
|
|
Note that people who make modified versions of this file are not
|
|
|
|
obligated to grant this special exception for their modified
|
|
|
|
versions; it is their choice whether to do so. The GNU Lesser
|
|
|
|
General Public License gives permission to release a modified
|
|
|
|
version without this exception; this exception also makes it
|
|
|
|
possible to release a modified version which carries forward this
|
|
|
|
exception.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-03-10 00:44:13 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2012-02-08 14:25:07 +00:00
|
|
|
|
|
|
|
/* crti.S puts a function prologue at the beginning of the .init and
|
|
|
|
.fini sections and defines global symbols for those addresses, so
|
|
|
|
they can be called as functions. The symbols _init and _fini are
|
|
|
|
magic and cause the linker to emit DT_INIT and DT_FINI. */
|
|
|
|
|
|
|
|
#include <libc-symbols.h>
|
|
|
|
#include <sysdep.h>
|
|
|
|
|
|
|
|
#ifndef PREINIT_FUNCTION
|
|
|
|
# define PREINIT_FUNCTION __gmon_start__
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PREINIT_FUNCTION_WEAK
|
|
|
|
# define PREINIT_FUNCTION_WEAK 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if PREINIT_FUNCTION_WEAK
|
|
|
|
weak_extern (PREINIT_FUNCTION)
|
|
|
|
#else
|
|
|
|
.hidden PREINIT_FUNCTION
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if PREINIT_FUNCTION_WEAK
|
|
|
|
.section ".toc", "aw"
|
|
|
|
.LC0:
|
|
|
|
.tc PREINIT_FUNCTION[TC], PREINIT_FUNCTION
|
|
|
|
#endif
|
|
|
|
.section ".init", "ax", @progbits
|
2013-12-04 12:49:15 +00:00
|
|
|
ENTRY_2(_init)
|
2012-02-08 14:25:07 +00:00
|
|
|
.align ALIGNARG (2)
|
|
|
|
BODY_LABEL (_init):
|
2013-12-04 12:51:11 +00:00
|
|
|
LOCALENTRY(_init)
|
2012-02-08 14:25:07 +00:00
|
|
|
mflr 0
|
PowerPC64 ELFv2 ABI 4/6: Stack frame layout changes
This updates glibc for the changes in the ELFv2 relating to the
stack frame layout. These are described in more detail here:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01149.html
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01146.html
Specifically, the "compiler and linker doublewords" were removed,
which has the effect that the save slot for the TOC register is
now at offset 24 rather than 40 to the stack pointer.
In addition, a function may now no longer necessarily assume that
its caller has set up a 64-byte register save area its use.
To address the first change, the patch goes through all assembler
files and replaces immediate offsets in instructions accessing the
ABI-defined stack slots by symbolic offsets. Those already were
defined in ucontext_i.sym and used in some of the context routines,
but that doesn't really seem like the right place for those defines.
The patch instead defines those symbolic offsets in sysdeps.h,
in two variants for the old and new ABI, and uses them systematically
in all assembler files, not just the context routines.
The second change only affected a few assembler files that used
the save area to temporarily store some registers. In those
cases where this happens within a leaf function, this patch
changes the code to store those registers to the "red zone"
below the stack pointer. Otherwise, the functions already allocate
a stack frame, and the patch changes them to add extra space in
these frames as temporary space for the ELFv2 ABI.
2013-12-04 12:55:03 +00:00
|
|
|
std 0, FRAME_LR_SAVE(r1)
|
|
|
|
stdu r1, -FRAME_MIN_SIZE_PARM(r1)
|
2012-02-08 14:25:07 +00:00
|
|
|
#if PREINIT_FUNCTION_WEAK
|
|
|
|
addis r9, r2, .LC0@toc@ha
|
|
|
|
ld r0, .LC0@toc@l(r9)
|
|
|
|
cmpdi cr7, r0, 0
|
|
|
|
beq+ cr7, 1f
|
|
|
|
#endif
|
|
|
|
bl JUMPTARGET (PREINIT_FUNCTION)
|
|
|
|
nop
|
|
|
|
1:
|
|
|
|
|
|
|
|
.section ".fini", "ax", @progbits
|
2013-12-04 12:49:15 +00:00
|
|
|
ENTRY_2(_fini)
|
2012-02-08 14:25:07 +00:00
|
|
|
.align ALIGNARG (2)
|
|
|
|
BODY_LABEL (_fini):
|
2013-12-04 12:51:11 +00:00
|
|
|
LOCALENTRY(_fini)
|
2012-02-08 14:25:07 +00:00
|
|
|
mflr 0
|
PowerPC64 ELFv2 ABI 4/6: Stack frame layout changes
This updates glibc for the changes in the ELFv2 relating to the
stack frame layout. These are described in more detail here:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01149.html
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01146.html
Specifically, the "compiler and linker doublewords" were removed,
which has the effect that the save slot for the TOC register is
now at offset 24 rather than 40 to the stack pointer.
In addition, a function may now no longer necessarily assume that
its caller has set up a 64-byte register save area its use.
To address the first change, the patch goes through all assembler
files and replaces immediate offsets in instructions accessing the
ABI-defined stack slots by symbolic offsets. Those already were
defined in ucontext_i.sym and used in some of the context routines,
but that doesn't really seem like the right place for those defines.
The patch instead defines those symbolic offsets in sysdeps.h,
in two variants for the old and new ABI, and uses them systematically
in all assembler files, not just the context routines.
The second change only affected a few assembler files that used
the save area to temporarily store some registers. In those
cases where this happens within a leaf function, this patch
changes the code to store those registers to the "red zone"
below the stack pointer. Otherwise, the functions already allocate
a stack frame, and the patch changes them to add extra space in
these frames as temporary space for the ELFv2 ABI.
2013-12-04 12:55:03 +00:00
|
|
|
std 0, FRAME_LR_SAVE(r1)
|
|
|
|
stdu r1, -FRAME_MIN_SIZE_PARM(r1)
|