/* PPC64 ELF support for BFD.
Copyright (C) 2003-2024 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef RELOC_MACROS_GEN_FUNC
/* Relocation only used internally by gas or ld. If you need to use
these reloc numbers, you can change them to some other unused value
without affecting the ABI. They will never appear in object files. */
RELOC_NUMBER (R_PPC64_LO_DS_OPT, 200)
RELOC_NUMBER (R_PPC64_16DX_HA, 201)
#endif
/* These are GNU extensions used in PIC code sequences. */
RELOC_NUMBER (R_PPC64_REL16, 249)
RELOC_NUMBER (R_PPC64_REL16_LO, 250)
RELOC_NUMBER (R_PPC64_REL16_HI, 251)
RELOC_NUMBER (R_PPC64_REL16_HA, 252)
/* These are GNU extensions to enable C++ vtable garbage collection. */
RELOC_NUMBER (R_PPC64_GNU_VTINHERIT, 253)
RELOC_NUMBER (R_PPC64_GNU_VTENTRY, 254)
/* e_flags bits specifying ABI.
1 for original function descriptor using ABI,
2 for revised ABI without function descriptors,
0 for unspecified or not using any features affected by the differences. */
#define EF_PPC64_ABI 3
/* The ELFv2 ABI uses three bits in the symbol st_other field of a
function definition to specify the number of bytes between a
function's global entry point and local entry point.
Values of two to six specify powers of two from four to sixty four
bytes. For such functions:
The global entry point is used when it is necessary to set up the
toc pointer (r2) for the function. Callers must enter the global
entry point with r12 set to the global entry point address. On
return from the function r2 will contain the toc pointer for the
function.
The local entry point is used when r2 is known to already be valid
for the function. There is no requirement on r12 when using the
local entry point, and on return r2 will contain the same value as
at entry.
A value of zero in these bits means that the function has a single
entry point with no requirement on r12 or r2, and that on return r2
will contain the same value as at entry.
A value of one means that the function has a single entry point
with no requirement on r12 or r2, and that r2 is *not* preserved.
A value of seven is reserved. */
#define STO_PPC64_LOCAL_BIT 5
#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT)
/* 3 bit other field to bytes. */
static inline unsigned int
ppc64_decode_local_entry(unsigned int other)
{
return ((1 << other) >> 2) << 2;
}