1999-05-03 15:29:06 +08:00
|
|
|
/* PPC ELF support for BFD.
|
2009-03-04 13:50:48 +08:00
|
|
|
Copyright 1995, 1996, 1998, 2000, 2001, 2002, 2003, 2005, 2007, 2008,
|
2010-04-15 18:26:09 +08:00
|
|
|
2009, 2010 Free Software Foundation, Inc.
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2010-04-15 18:26:09 +08:00
|
|
|
By Michael Meissner, Cygnus Support, <meissner@cygnus.com>,
|
|
|
|
from information in the System V Application Binary Interface,
|
|
|
|
PowerPC Processor Supplement and the PowerPC Embedded Application
|
|
|
|
Binary Interface (eabi).
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2010-04-15 18:26:09 +08:00
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2010-04-15 18:26:09 +08:00
|
|
|
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.
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2010-04-15 18:26:09 +08:00
|
|
|
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.
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2010-04-15 18:26:09 +08:00
|
|
|
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. */
|
1999-05-03 15:29:06 +08:00
|
|
|
|
|
|
|
/* This file holds definitions specific to the PPC ELF ABI. Note
|
|
|
|
that most of this is not actually implemented by BFD. */
|
|
|
|
|
|
|
|
#ifndef _ELF_PPC_H
|
|
|
|
#define _ELF_PPC_H
|
|
|
|
|
|
|
|
#include "elf/reloc-macros.h"
|
|
|
|
|
|
|
|
/* Relocations. */
|
|
|
|
START_RELOC_NUMBERS (elf_ppc_reloc_type)
|
2003-02-04 22:48:36 +08:00
|
|
|
RELOC_NUMBER (R_PPC_NONE, 0)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR32, 1)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR24, 2)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR16, 3)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR16_LO, 4)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR16_HI, 5)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR16_HA, 6)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR14, 7)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR14_BRTAKEN, 8)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR14_BRNTAKEN, 9)
|
|
|
|
RELOC_NUMBER (R_PPC_REL24, 10)
|
|
|
|
RELOC_NUMBER (R_PPC_REL14, 11)
|
|
|
|
RELOC_NUMBER (R_PPC_REL14_BRTAKEN, 12)
|
|
|
|
RELOC_NUMBER (R_PPC_REL14_BRNTAKEN, 13)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT16, 14)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT16_LO, 15)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT16_HI, 16)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT16_HA, 17)
|
|
|
|
RELOC_NUMBER (R_PPC_PLTREL24, 18)
|
|
|
|
RELOC_NUMBER (R_PPC_COPY, 19)
|
|
|
|
RELOC_NUMBER (R_PPC_GLOB_DAT, 20)
|
|
|
|
RELOC_NUMBER (R_PPC_JMP_SLOT, 21)
|
|
|
|
RELOC_NUMBER (R_PPC_RELATIVE, 22)
|
|
|
|
RELOC_NUMBER (R_PPC_LOCAL24PC, 23)
|
|
|
|
RELOC_NUMBER (R_PPC_UADDR32, 24)
|
|
|
|
RELOC_NUMBER (R_PPC_UADDR16, 25)
|
|
|
|
RELOC_NUMBER (R_PPC_REL32, 26)
|
|
|
|
RELOC_NUMBER (R_PPC_PLT32, 27)
|
|
|
|
RELOC_NUMBER (R_PPC_PLTREL32, 28)
|
|
|
|
RELOC_NUMBER (R_PPC_PLT16_LO, 29)
|
|
|
|
RELOC_NUMBER (R_PPC_PLT16_HI, 30)
|
|
|
|
RELOC_NUMBER (R_PPC_PLT16_HA, 31)
|
|
|
|
RELOC_NUMBER (R_PPC_SDAREL16, 32)
|
|
|
|
RELOC_NUMBER (R_PPC_SECTOFF, 33)
|
|
|
|
RELOC_NUMBER (R_PPC_SECTOFF_LO, 34)
|
|
|
|
RELOC_NUMBER (R_PPC_SECTOFF_HI, 35)
|
|
|
|
RELOC_NUMBER (R_PPC_SECTOFF_HA, 36)
|
|
|
|
RELOC_NUMBER (R_PPC_ADDR30, 37)
|
|
|
|
|
2009-07-10 20:19:55 +08:00
|
|
|
#ifndef RELOC_MACROS_GEN_FUNC
|
|
|
|
/* Fake relocations for branch stubs, only used internally by ld. */
|
2009-12-17 13:45:25 +08:00
|
|
|
RELOC_NUMBER (R_PPC_RELAX, 48)
|
|
|
|
RELOC_NUMBER (R_PPC_RELAX_PLT, 49)
|
|
|
|
RELOC_NUMBER (R_PPC_RELAX_PLTREL24, 50)
|
2009-07-10 20:19:55 +08:00
|
|
|
#endif
|
|
|
|
|
2003-02-04 22:48:36 +08:00
|
|
|
/* Relocs added to support TLS. */
|
|
|
|
RELOC_NUMBER (R_PPC_TLS, 67)
|
2003-02-18 14:03:41 +08:00
|
|
|
RELOC_NUMBER (R_PPC_DTPMOD32, 68)
|
2003-02-04 22:48:36 +08:00
|
|
|
RELOC_NUMBER (R_PPC_TPREL16, 69)
|
|
|
|
RELOC_NUMBER (R_PPC_TPREL16_LO, 70)
|
|
|
|
RELOC_NUMBER (R_PPC_TPREL16_HI, 71)
|
|
|
|
RELOC_NUMBER (R_PPC_TPREL16_HA, 72)
|
2003-02-18 14:03:41 +08:00
|
|
|
RELOC_NUMBER (R_PPC_TPREL32, 73)
|
2003-02-04 22:48:36 +08:00
|
|
|
RELOC_NUMBER (R_PPC_DTPREL16, 74)
|
|
|
|
RELOC_NUMBER (R_PPC_DTPREL16_LO, 75)
|
|
|
|
RELOC_NUMBER (R_PPC_DTPREL16_HI, 76)
|
|
|
|
RELOC_NUMBER (R_PPC_DTPREL16_HA, 77)
|
2003-02-18 14:03:41 +08:00
|
|
|
RELOC_NUMBER (R_PPC_DTPREL32, 78)
|
2003-02-04 22:48:36 +08:00
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSGD16, 79)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSGD16_LO, 80)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSGD16_HI, 81)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSGD16_HA, 82)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSLD16, 83)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSLD16_LO, 84)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSLD16_HI, 85)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TLSLD16_HA, 86)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TPREL16, 87)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TPREL16_LO, 88)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TPREL16_HI, 89)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_TPREL16_HA, 90)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_DTPREL16, 91)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_DTPREL16_LO, 92)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_DTPREL16_HI, 93)
|
|
|
|
RELOC_NUMBER (R_PPC_GOT_DTPREL16_HA, 94)
|
2009-03-04 13:50:48 +08:00
|
|
|
RELOC_NUMBER (R_PPC_TLSGD, 95)
|
|
|
|
RELOC_NUMBER (R_PPC_TLSLD, 96)
|
2001-08-27 18:26:34 +08:00
|
|
|
|
1999-05-03 15:29:06 +08:00
|
|
|
/* The remaining relocs are from the Embedded ELF ABI, and are not
|
|
|
|
in the SVR4 ELF ABI. */
|
2003-02-04 22:48:36 +08:00
|
|
|
RELOC_NUMBER (R_PPC_EMB_NADDR32, 101)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_NADDR16, 102)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_NADDR16_LO, 103)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_NADDR16_HI, 104)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_NADDR16_HA, 105)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_SDAI16, 106)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_SDA2I16, 107)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_SDA2REL, 108)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_SDA21, 109)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_MRKREF, 110)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_RELSEC16, 111)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_RELST_LO, 112)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_RELST_HI, 113)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_RELST_HA, 114)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_BIT_FLD, 115)
|
|
|
|
RELOC_NUMBER (R_PPC_EMB_RELSDA, 116)
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2009-07-10 20:19:55 +08:00
|
|
|
/* Support STT_GNU_IFUNC plt calls. */
|
|
|
|
RELOC_NUMBER (R_PPC_IRELATIVE, 248)
|
2005-05-11 22:08:45 +08:00
|
|
|
|
|
|
|
/* These are GNU extensions used in PIC code sequences. */
|
|
|
|
RELOC_NUMBER (R_PPC_REL16, 249)
|
|
|
|
RELOC_NUMBER (R_PPC_REL16_LO, 250)
|
|
|
|
RELOC_NUMBER (R_PPC_REL16_HI, 251)
|
|
|
|
RELOC_NUMBER (R_PPC_REL16_HA, 252)
|
2003-07-29 14:42:51 +08:00
|
|
|
|
|
|
|
/* These are GNU extensions to enable C++ vtable garbage collection. */
|
2003-02-04 22:48:36 +08:00
|
|
|
RELOC_NUMBER (R_PPC_GNU_VTINHERIT, 253)
|
|
|
|
RELOC_NUMBER (R_PPC_GNU_VTENTRY, 254)
|
1999-05-03 15:29:06 +08:00
|
|
|
|
|
|
|
/* This is a phony reloc to handle any old fashioned TOC16 references
|
|
|
|
that may still be in object files. */
|
2003-02-04 22:48:36 +08:00
|
|
|
RELOC_NUMBER (R_PPC_TOC16, 255)
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2000-06-07 11:43:33 +08:00
|
|
|
END_RELOC_NUMBERS (R_PPC_max)
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2003-02-18 14:03:41 +08:00
|
|
|
#define IS_PPC_TLS_RELOC(R) \
|
|
|
|
((R) >= R_PPC_TLS && (R) <= R_PPC_GOT_DTPREL16_HA)
|
2002-02-12 14:31:24 +08:00
|
|
|
|
2005-05-14 13:07:15 +08:00
|
|
|
/* Specify the value of _GLOBAL_OFFSET_TABLE_. */
|
include/elf/
* ppc.h (DT_PPC_TLSOPT): Define.
* ppc64.h (DT_PPC64_TLSOPT): Define.
bfd/
* elf32-ppc.c (TLS_GET_ADDR_GLINK_SIZE): Define.
(ADD_3_12_2, BEQLR, CMPWI_11_0, LWZ_11_3, LWZ_12_3): Define.
(MR_0_3, MR_3_0): Define.
(struct ppc_elf_link_hash_table): Add no_tls_get_addr_opt.
(ppc_elf_select_plt_layout): Save emit_stub_syms param earlier.
(ppc_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt
(allocate_dynrelocs): Increase glink entry size for __tls_get_addr.
(ppc_elf_size_dynamic_sections): Add DT_PPC_TLS_OPT tag.
(write_glink_stub): Add param p.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Emit special glink call stub for
__tls_get_addr.
* elf32-ppc.h (ppc_elf_tls_setup): Update prototype.
* elf64-ppc.c (struct ppc_link_hash_table): Add no_tls_get_addr_opt.
(ppc64_elf_tls_setup): Add no_tls_get_addr_opt param and save to hash
table. Check for presense of __tls_get_addr_opt.
(ppc64_elf_size_dynamic_sections): Add DT_PPC64_TLS_OPT tag.
(LD_R11_0R3, LD_R12_0R3, MR_R0_R3, CMPDI_R11_0, ADD_R3_R12_R13,
BEQLR, MR_R3_R0, MFLR_R11, STD_R11_0R1, BCTRL, LD_R11_0R1,
LD_R2_0R1, MTLR_R11): Define.
(build_tls_get_addr_stub): New function.
(ppc_build_one_stub): Call it.
(ppc_size_one_stub): Add extra size for __tls_get_addr stub.
(ppc64_elf_relocate_section): Don't change nop to ld 2,40(1) for
__tls_get_addr plt call.
* elf64-ppc.h (ppc64_elf_tls_setup): Update prototype.
binutils/
* readelf.c (get_ppc_dynamic_type): Add TLSOPT.
(get_ppc64_dynamic_type): Likewise.
ld/
* emultempl/ppc32elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define. Redefine other options in
terms of previous option.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
* emultempl/ppc64elf.em (no_tls_get_addr_opt): New var.
(ppc_before_allocation): Pass to ppc64_elf_tls_setup.
(OPTION_NO_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add
--no-tls-get-addr-optimize.
(PARSE_AND_LIST_ARGS_CASES): Handle it.
ld/testsuite/
* ld-powerpc/tlslib.s: Delete dot-symbol entry syms. Add
__tls_get_addr_opt.
* ld-powerpc/tlslib32.s: Add __tls_get_addr_opt.
* ld-powerpc/oldtlslib.s: New file, old-abi version of tlslib.s.
* ld-powerpc/powerpc.exp: Build old-abi library and use it in
two new link tests.
* ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub.
* ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d,
* ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r,
* ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g,
* ld-powerpc/tlsexetoc.r: Likewise.
2009-09-21 19:51:01 +08:00
|
|
|
#define DT_PPC_GOT (DT_LOPROC)
|
|
|
|
|
|
|
|
/* Specify that tls descriptors should be optimized. */
|
|
|
|
#define DT_PPC_TLSOPT (DT_LOPROC + 1)
|
2005-05-11 22:08:45 +08:00
|
|
|
|
1999-05-03 15:29:06 +08:00
|
|
|
/* Processor specific flags for the ELF header e_flags field. */
|
|
|
|
|
2000-08-08 02:54:49 +08:00
|
|
|
#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag. */
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2000-08-08 02:54:49 +08:00
|
|
|
#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag. */
|
|
|
|
#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib flag. */
|
1999-05-03 15:29:06 +08:00
|
|
|
|
2000-08-08 02:54:49 +08:00
|
|
|
/* Processor specific section headers, sh_type field. */
|
1999-05-03 15:29:06 +08:00
|
|
|
|
|
|
|
#define SHT_ORDERED SHT_HIPROC /* Link editor is to sort the \
|
|
|
|
entries in this section \
|
|
|
|
based on the address \
|
|
|
|
specified in the associated \
|
|
|
|
symbol table entry. */
|
|
|
|
|
bfd:
* elf32-ppc.c (ppc_elf_merge_obj_attributes): New.
(ppc_elf_merge_private_bfd_data): Call it.
binutils:
* readelf.c (display_power_gnu_attribute, process_power_specific):
New.
(process_arch_specific): Call process_power_specific.
include/elf:
* ppc.h (Tag_GNU_Power_ABI_FP): Define.
ld/testsuite:
* ld-powerpc/attr-gnu-4-0.s, ld-powerpc/attr-gnu-4-00.d,
ld-powerpc/attr-gnu-4-01.d, ld-powerpc/attr-gnu-4-02.d,
ld-powerpc/attr-gnu-4-1.s, ld-powerpc/attr-gnu-4-10.d,
ld-powerpc/attr-gnu-4-11.d, ld-powerpc/attr-gnu-4-12.d,
ld-powerpc/attr-gnu-4-13.d, ld-powerpc/attr-gnu-4-2.s,
ld-powerpc/attr-gnu-4-20.d, ld-powerpc/attr-gnu-4-21.d,
ld-powerpc/attr-gnu-4-22.d, ld-powerpc/attr-gnu-4-3.s,
ld-powerpc/attr-gnu-4-31.d: New.
* ld-powerpc/powerpc.exp: Run these new tests.
2007-06-30 08:03:40 +08:00
|
|
|
/* Object attribute tags. */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/* 0-3 are generic. */
|
|
|
|
Tag_GNU_Power_ABI_FP = 4, /* Value 1 for hard-float, 2 for
|
2008-07-26 21:10:47 +08:00
|
|
|
soft-float, 3 for single=precision
|
|
|
|
hard-float; 0 for not tagged or not
|
bfd:
* elf32-ppc.c (ppc_elf_merge_obj_attributes): New.
(ppc_elf_merge_private_bfd_data): Call it.
binutils:
* readelf.c (display_power_gnu_attribute, process_power_specific):
New.
(process_arch_specific): Call process_power_specific.
include/elf:
* ppc.h (Tag_GNU_Power_ABI_FP): Define.
ld/testsuite:
* ld-powerpc/attr-gnu-4-0.s, ld-powerpc/attr-gnu-4-00.d,
ld-powerpc/attr-gnu-4-01.d, ld-powerpc/attr-gnu-4-02.d,
ld-powerpc/attr-gnu-4-1.s, ld-powerpc/attr-gnu-4-10.d,
ld-powerpc/attr-gnu-4-11.d, ld-powerpc/attr-gnu-4-12.d,
ld-powerpc/attr-gnu-4-13.d, ld-powerpc/attr-gnu-4-2.s,
ld-powerpc/attr-gnu-4-20.d, ld-powerpc/attr-gnu-4-21.d,
ld-powerpc/attr-gnu-4-22.d, ld-powerpc/attr-gnu-4-3.s,
ld-powerpc/attr-gnu-4-31.d: New.
* ld-powerpc/powerpc.exp: Run these new tests.
2007-06-30 08:03:40 +08:00
|
|
|
using any ABIs affected by the
|
|
|
|
differences. */
|
2007-10-25 23:20:24 +08:00
|
|
|
|
|
|
|
/* Value 1 for general purpose registers only, 2 for AltiVec
|
|
|
|
registers, 3 for SPE registers; 0 for not tagged or not using any
|
|
|
|
ABIs affected by the differences. */
|
|
|
|
Tag_GNU_Power_ABI_Vector = 8,
|
2008-10-11 04:55:36 +08:00
|
|
|
|
|
|
|
/* Value 1 for ABIs using r3/r4 for returning structures <= 8 bytes,
|
|
|
|
2 for ABIs using memory; 0 for not tagged or not using any ABIs
|
|
|
|
affected by the differences. */
|
|
|
|
Tag_GNU_Power_ABI_Struct_Return = 12
|
bfd:
* elf32-ppc.c (ppc_elf_merge_obj_attributes): New.
(ppc_elf_merge_private_bfd_data): Call it.
binutils:
* readelf.c (display_power_gnu_attribute, process_power_specific):
New.
(process_arch_specific): Call process_power_specific.
include/elf:
* ppc.h (Tag_GNU_Power_ABI_FP): Define.
ld/testsuite:
* ld-powerpc/attr-gnu-4-0.s, ld-powerpc/attr-gnu-4-00.d,
ld-powerpc/attr-gnu-4-01.d, ld-powerpc/attr-gnu-4-02.d,
ld-powerpc/attr-gnu-4-1.s, ld-powerpc/attr-gnu-4-10.d,
ld-powerpc/attr-gnu-4-11.d, ld-powerpc/attr-gnu-4-12.d,
ld-powerpc/attr-gnu-4-13.d, ld-powerpc/attr-gnu-4-2.s,
ld-powerpc/attr-gnu-4-20.d, ld-powerpc/attr-gnu-4-21.d,
ld-powerpc/attr-gnu-4-22.d, ld-powerpc/attr-gnu-4-3.s,
ld-powerpc/attr-gnu-4-31.d: New.
* ld-powerpc/powerpc.exp: Run these new tests.
2007-06-30 08:03:40 +08:00
|
|
|
};
|
|
|
|
|
1999-05-03 15:29:06 +08:00
|
|
|
#endif /* _ELF_PPC_H */
|