binutils-gdb/bfd/elf64-ppc.h

45 lines
1.7 KiB
C
Raw Normal View History

* elflink.c (_bfd_elf_create_dynamic_sections): Don't set SEC_CODE when plt_not_loaded. * elf64-ppc.c (ppc64_elf_create_dynamic_sections): No need to clear .plt SEC_CODE here. Create .stub and correct .glink flags. (PLT_INITIAL_ENTRY_SIZE): Set to 24. (ppc64_elf_glink_code): Delete. (PPC64_ELF_GLINK_SIZE): Delete. (ADDIS_R12_R2, STD_R2_40R1, LD_R11_0R12, LD_R2_0R12, MTCTR_R11, BCTR, ADDIS_R12_R12_1, LD_R2_40R1, NOP, LI_R0_0, B_DOT, LIS_R0_0, ORI_R0_R0_0): Define. (PLT_CALL_STUB_SIZE, GLINK_CALL_STUB_SIZE): Define. (struct ppc_link_hash_table): Add sstub and plt_overflow. (ppc64_elf_link_hash_table_create): Init them. (ppc64_elf_check_relocs <R_PPC64_REL24>): Refcount .plt entry. Don't copy to shared lib. (ppc64_elf_check_relocs): Call bfd_set_error on errors. (ppc64_elf_gc_sweep_hook <R_PPC64_REL24>): Sweep plt refcount. (allocate_dynrelocs <plt>): Don't change function sym here. Make room for .stub and .glink code. (ppc64_elf_size_dynamic_sections): Handle .stub. Make entry for DT_PPC64_GLINK. (ppc64_elf_final_link): Rename to ppc64_elf_set_toc. Don't call bfd_elf64_bfd_final_link. (bfd_elf64_bfd_final_link): Don't define. (ppc64_elf_size_stubs): New. (build_plt_stub): New. (build_one_stub): New. (ppc64_elf_build_stubs): New. (ppc64_elf_relocate_section <toc relocs>): Remove assert. (ppc64_elf_relocate_section): Don't copy R_PPC64_REL24 relocs. (ppc64_elf_finish_dynamic_symbol): Don't build stubs here. Set DT_PPC64_GLINK entry. Tweak DT_PLTGOT, DT_JMPREL, DT_PLTRELSZ in case output sections not separate. Adjust DT_RELASZ to not include plt relocs. Set reserved got entry. Set got and plt entry size. (elf_backend_got_header_size): Set to 8. * elf64-ppc.h: New file.
2002-01-16 06:50:03 +01:00
/* PowerPC64-specific support for 64-bit ELF.
* reloc.c: Add PPC and PPC64 TLS relocs. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. * elf64-ppc.c (TP_OFFSET, DTP_OFFSET): Declare. (ppc64_elf_howto_raw): Add TLS howto's. Adjust R_PPC64_NONE to be against a 32 bit field. (ppc64_elf_reloc_type_lookup): Handle TLS relocs. (_ppc64_elf_section_data): Add t_symndx and comments. (ppc64_elf_section_data): Use elf_section_data macro. (ppc64_elf_new_section_hook): American spelling. (struct got_entry, struct plt_entry): New. (MUST_BE_DYN_RELOC): Rename from IS_ABSOLUTE_RELOC. (struct ppc_stub_hash_entry): Add "addend" field. (struct ppc_link_hash_entry): Add "tls_type". (TLS_TLS, TLS_GD_LD, TLS_LD, TLS_TPREL, TLS_DTPREL, TLS_EXPLICIT): Define. (struct ppc_link_hash_table): Add tls_sec, tls_get_addr, tlsld_got. (link_hash_newfunc): Init new fields. (ppc64_elf_link_hash_table_create): Likewise. Set init_relcount and init_offset to NULL. (ppc64_elf_copy_indirect_symbol): Copy got and plt info. Don't call _bfd_elf_link_hash_copy_indirect, rather insert relevant code from there. (update_local_sym_info, update_plt_info): New functions. (ppc64_elf_check_relocs): Use them. Handle TLS relocs. Adjust GOT handling to use got.glist rather than got.refcount. Likewise for PLT. (ppc64_elf_gc_sweep_hook): Handle TLS relocs, new GOT and PLT lists. (func_desc_adjust): Adjust for new PLT list. (ppc64_elf_adjust_dynamic_symbol): Likewise. (get_sym_h, get_tls_type): New functions. (ppc64_elf_edit_opd): Remove unused variable. Use get_sym_h. (ppc64_elf_tls_optimize): New function. (allocate_dynrelocs): Adjust for new PLT and GOT lists. Allocate TLS relocs. (ppc64_elf_size_dynamic_sections): Likewise. (ppc_type_of_stub): Adjust for new PLT list. (ppc_build_one_stub): Likewise. (ppc64_elf_size_stubs): Likewise. Use get_sym_h. Treat __tls_get_addr calls specially. (ppc64_elf_relocate_section): Adjust for new GOT and PLT lists. Handle TLS relocs. Report local syms using bfd_elf_local_sym_name. Don't init GOT entries that have a reloc. Generate GOT relocs here.. (ppc64_elf_finish_dynamic_symbol): ..not here. Adjust for PLT list. * elf64-ppc.h (ppc64_elf_tls_optimize): Declare.
2003-02-04 15:50:50 +01:00
Copyright 2002, 2003 Free Software Foundation, Inc.
* elflink.c (_bfd_elf_create_dynamic_sections): Don't set SEC_CODE when plt_not_loaded. * elf64-ppc.c (ppc64_elf_create_dynamic_sections): No need to clear .plt SEC_CODE here. Create .stub and correct .glink flags. (PLT_INITIAL_ENTRY_SIZE): Set to 24. (ppc64_elf_glink_code): Delete. (PPC64_ELF_GLINK_SIZE): Delete. (ADDIS_R12_R2, STD_R2_40R1, LD_R11_0R12, LD_R2_0R12, MTCTR_R11, BCTR, ADDIS_R12_R12_1, LD_R2_40R1, NOP, LI_R0_0, B_DOT, LIS_R0_0, ORI_R0_R0_0): Define. (PLT_CALL_STUB_SIZE, GLINK_CALL_STUB_SIZE): Define. (struct ppc_link_hash_table): Add sstub and plt_overflow. (ppc64_elf_link_hash_table_create): Init them. (ppc64_elf_check_relocs <R_PPC64_REL24>): Refcount .plt entry. Don't copy to shared lib. (ppc64_elf_check_relocs): Call bfd_set_error on errors. (ppc64_elf_gc_sweep_hook <R_PPC64_REL24>): Sweep plt refcount. (allocate_dynrelocs <plt>): Don't change function sym here. Make room for .stub and .glink code. (ppc64_elf_size_dynamic_sections): Handle .stub. Make entry for DT_PPC64_GLINK. (ppc64_elf_final_link): Rename to ppc64_elf_set_toc. Don't call bfd_elf64_bfd_final_link. (bfd_elf64_bfd_final_link): Don't define. (ppc64_elf_size_stubs): New. (build_plt_stub): New. (build_one_stub): New. (ppc64_elf_build_stubs): New. (ppc64_elf_relocate_section <toc relocs>): Remove assert. (ppc64_elf_relocate_section): Don't copy R_PPC64_REL24 relocs. (ppc64_elf_finish_dynamic_symbol): Don't build stubs here. Set DT_PPC64_GLINK entry. Tweak DT_PLTGOT, DT_JMPREL, DT_PLTRELSZ in case output sections not separate. Adjust DT_RELASZ to not include plt relocs. Set reserved got entry. Set got and plt entry size. (elf_backend_got_header_size): Set to 8. * elf64-ppc.h: New file.
2002-01-16 06:50:03 +01:00
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
void ppc64_elf_init_stub_bfd
(bfd *, struct bfd_link_info *);
bfd_boolean ppc64_elf_mark_entry_syms
(struct bfd_link_info *);
bfd_boolean ppc64_elf_edit_opd
(bfd *, struct bfd_link_info *);
* elf64-ppc.c (TLS_GD_LD): Don't define.. (TLS_GD): ..define this instead and update all uses. (TLS_TPRELGD): Define. (ppc64_elf_link_hash_table_create): Tweak initialization of init_refcount and init_offset. (ppc64_elf_check_relocs): Add one extra element to t_symndx array. Mark second slot of GD or LD toc entries. (get_tls_type): Return an int. Distinguish toc GD and LD entries from other tls types. (ppc64_elf_tls_setup): New function, split out from.. (ppc64_elf_tls_optimize): ..here. Don't optimize when symbols are defined in a dynamic object. Fix LD optimization. Don't set TLS_TPREL on GD->IE optimization, use TLS_TPRELGD instead. Use get_tls_type return value to properly decide whether toc GD and LD entries can optimize away __tls_get_addr call. Check next reloc after DTPMOD64 to determine GD or LD rather than looking at TLS_LD flag. Don't attempt to adjust got entry tls_type here.. (allocate_dynrelocs): ..instead, adjust got entry tls_type here, and look for possible merges. (ppc64_elf_size_dynamic_sections): Adjust local got entries for optimization. (ppc64_elf_size_stubs): Tweak __tls_get_addr fudge. (ppc64_elf_relocate_section): Rename some vars to better reflect usage. Make use of return value from get_tls_type to properly detect GD and LD optimizations. Split tlsld/gd hi/ha from lo/ds case. Don't handle tls_get_addr removal when looking at REL24 relocs, do it when looking at the previous reloc. Check reloc after DTPMOD64 to determine GD or LD. * elf64-ppc.h (ppc64_elf_tls_setup): Declare.
2003-02-09 05:36:23 +01:00
bfd_boolean ppc64_elf_tls_setup
(bfd *, struct bfd_link_info *);
* reloc.c: Add PPC and PPC64 TLS relocs. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. * elf64-ppc.c (TP_OFFSET, DTP_OFFSET): Declare. (ppc64_elf_howto_raw): Add TLS howto's. Adjust R_PPC64_NONE to be against a 32 bit field. (ppc64_elf_reloc_type_lookup): Handle TLS relocs. (_ppc64_elf_section_data): Add t_symndx and comments. (ppc64_elf_section_data): Use elf_section_data macro. (ppc64_elf_new_section_hook): American spelling. (struct got_entry, struct plt_entry): New. (MUST_BE_DYN_RELOC): Rename from IS_ABSOLUTE_RELOC. (struct ppc_stub_hash_entry): Add "addend" field. (struct ppc_link_hash_entry): Add "tls_type". (TLS_TLS, TLS_GD_LD, TLS_LD, TLS_TPREL, TLS_DTPREL, TLS_EXPLICIT): Define. (struct ppc_link_hash_table): Add tls_sec, tls_get_addr, tlsld_got. (link_hash_newfunc): Init new fields. (ppc64_elf_link_hash_table_create): Likewise. Set init_relcount and init_offset to NULL. (ppc64_elf_copy_indirect_symbol): Copy got and plt info. Don't call _bfd_elf_link_hash_copy_indirect, rather insert relevant code from there. (update_local_sym_info, update_plt_info): New functions. (ppc64_elf_check_relocs): Use them. Handle TLS relocs. Adjust GOT handling to use got.glist rather than got.refcount. Likewise for PLT. (ppc64_elf_gc_sweep_hook): Handle TLS relocs, new GOT and PLT lists. (func_desc_adjust): Adjust for new PLT list. (ppc64_elf_adjust_dynamic_symbol): Likewise. (get_sym_h, get_tls_type): New functions. (ppc64_elf_edit_opd): Remove unused variable. Use get_sym_h. (ppc64_elf_tls_optimize): New function. (allocate_dynrelocs): Adjust for new PLT and GOT lists. Allocate TLS relocs. (ppc64_elf_size_dynamic_sections): Likewise. (ppc_type_of_stub): Adjust for new PLT list. (ppc_build_one_stub): Likewise. (ppc64_elf_size_stubs): Likewise. Use get_sym_h. Treat __tls_get_addr calls specially. (ppc64_elf_relocate_section): Adjust for new GOT and PLT lists. Handle TLS relocs. Report local syms using bfd_elf_local_sym_name. Don't init GOT entries that have a reloc. Generate GOT relocs here.. (ppc64_elf_finish_dynamic_symbol): ..not here. Adjust for PLT list. * elf64-ppc.h (ppc64_elf_tls_optimize): Declare.
2003-02-04 15:50:50 +01:00
bfd_boolean ppc64_elf_tls_optimize
(bfd *, struct bfd_link_info *);
2002-05-02 11:48:15 +02:00
bfd_vma ppc64_elf_toc
(bfd *);
* elf64-ppc.c (CROR_151515, CROR_313131): Define. (ppc64_elf_relocate_section): Use them. Don't look for plt calls on R_PPC64_ADDR24 relocs. Require a nop or no link reg on plt call branches. Correct undefined weak destination. (ppc64_elf_func_desc_adjust): Always create at least one blr in .sfpr, and correct case where either only savef* or restf* is needed. Long branch stubs, multiple stub sections. * elf64-ppc.h (ppc64_elf_setup_section_lists): Declare. (ppc64_elf_next_input_section): Declare. * elf64-ppc.c: Move linker-only prototypes. (STUB_SUFFIX): Define. (enum ppc_stub_type): New. (struct ppc_stub_hash_entry): New. (struct ppc_branch_hash_entry): New. (struct ppc_link_hash_entry): Add stub_cache, oh. (struct ppc_link_hash_table): Add stub_hash_table etc. Remove sstub. Add sbrlt, srelbrlt, has_14bit_branch, stub_iteration. Rename plt_overflow to stub_error. (ppc_stub_hash_lookup): Define. (ppc_branch_hash_lookup): Define. (stub_hash_newfunc): New function. (branch_hash_newfunc): New function. (link_hash_newfunc): Init new fields. (ppc64_elf_link_hash_table_create): Likewise. (ppc64_elf_link_hash_table_free): New function. (ppc_stub_name): New function. (ppc_get_stub_entry): New function. (ppc_add_stub): New function. (create_linkage_sections): Use bfd_make_section_anyway. Create .branch_lt and .rela.branch_lt sections. Don't create .stub. (ppc64_elf_check_relocs): Set has_14bit_branch on R_PPC64_REL14*, and set up for plt call stubs. Link func and func desc syms. (ppc64_elf_gc_sweep_hook): Handle REL14* as per REL24. (func_desc_adjust): Avoid hash lookup when func desc sym available via shortcut, and set links when processing. (ppc64_elf_hide_symbol): Likewise. (allocate_dynrelocs): Don't allocate stub section here. (ppc64_elf_size_dynamic_sections): Handle sbrlt and srelbrlt. Remove sstub code. (ppc_type_of_stub): New function. (build_one_stub): Delete. (ppc_build_one_stub): New function. (ppc_size_one_stub): New function. (ppc64_elf_setup_section_lists): New function. (ppc64_elf_next_input_section): New function. (group_sections): New function. (get_local_syms): New function. (ppc64_elf_size_stubs): Rewrite. (ppc64_elf_build_stubs): Rewrite. (ppc64_elf_relocate_section): Look up stub entry for REL24 relocs. Don't propagate REL14* to dynamic objects. Look for long branch stubs if REL14* or REL24 relocs won't reach. (bfd_elf64_bfd_link_hash_table_free): Define.
2002-05-01 04:34:20 +02:00
int ppc64_elf_setup_section_lists
(bfd *, struct bfd_link_info *);
* elf64-ppc.c: Move TARGET_LITTLE_SYM and other macros used by elfxx-target.h so that we can use elf_backend_got_header_size. (ELF_MACHINE_ALT1, ELF_MACHINE_ALT2): Delete. (GLINK_CALL_STUB_SIZE): Modify. Define new glink call stub and associated macros. (ppc64_elf_howto_raw <GOT_TPREL16_DS, GOT_TPREL16_LO_DS>): Correct dst_mask. (enum ppc_stub_type): Add ppc_stub_long_branch_r2off and ppc_stub_plt_branch_r2off. (struct ppc_stub_hash_entry): Reorganize. (struct ppc_link_hash_table): Add no_multi_toc, multi_toc_needed, toc_curr, toc_off and emit_stub_syms. (ppc64_elf_link_hash_table_create): Init them. (ppc_stub_name): Correct string size. (ppc64_elf_check_relocs): Set has_gp_reloc on GOT and TOC relocs. (ppc64_elf_size_dynamic_sections): Set no_multi_toc if GOT entries used. (ppc_type_of_stub): Tweak root.type test. (build_plt_stub): Remove glink code. Adjust for insn macro changes. (ppc_size_one_stub): Handle ppc_stub_long_branch_r2off and ppc_stub_plt_branch_r2off. (ppc_build_one_stub): Likewise. Fix var shadowing. Correct addis,addi range test. Use toc_off to calculte r2 values. Handle emit_stub_syms. (ppc64_elf_setup_section_lists): Remove htab creator flavour test. Initialize elf_gp and toc_curr. (ppc64_elf_next_toc_section, ppc64_elf_reinit_toc): New functions. (ppc64_elf_next_input_section): Set toc_off. (group_sections): Ensure groups have the same TOC. (ppc64_elf_size_stubs): Check whether we need a TOC adjusting stub. (ppc64_elf_build_stubs): Add emit_stub_syms param, and stash in htab. Build new glink stub. (ppc64_elf_relocate_section): Handle multiple TOCs. Fix comments. (ppc64_elf_finish_dynamic_sections): Adjust DT_PPC64_GLINK. * elf64-ppc.h (ppc64_elf_build_stubs): Update prototype. (ppc64_elf_next_toc_section, ppc64_elf_reinit_toc): Declare. * section.c (struct sec): Rename flag12 to has_gp_reloc. (STD_SECTION): Update. * ecoff.c (bfd_debug_section): Update comment. * bfd-in2.h: Regenerate.
2003-06-08 16:06:38 +02:00
void ppc64_elf_next_toc_section
(struct bfd_link_info *, asection *);
* elf64-ppc.c: Move TARGET_LITTLE_SYM and other macros used by elfxx-target.h so that we can use elf_backend_got_header_size. (ELF_MACHINE_ALT1, ELF_MACHINE_ALT2): Delete. (GLINK_CALL_STUB_SIZE): Modify. Define new glink call stub and associated macros. (ppc64_elf_howto_raw <GOT_TPREL16_DS, GOT_TPREL16_LO_DS>): Correct dst_mask. (enum ppc_stub_type): Add ppc_stub_long_branch_r2off and ppc_stub_plt_branch_r2off. (struct ppc_stub_hash_entry): Reorganize. (struct ppc_link_hash_table): Add no_multi_toc, multi_toc_needed, toc_curr, toc_off and emit_stub_syms. (ppc64_elf_link_hash_table_create): Init them. (ppc_stub_name): Correct string size. (ppc64_elf_check_relocs): Set has_gp_reloc on GOT and TOC relocs. (ppc64_elf_size_dynamic_sections): Set no_multi_toc if GOT entries used. (ppc_type_of_stub): Tweak root.type test. (build_plt_stub): Remove glink code. Adjust for insn macro changes. (ppc_size_one_stub): Handle ppc_stub_long_branch_r2off and ppc_stub_plt_branch_r2off. (ppc_build_one_stub): Likewise. Fix var shadowing. Correct addis,addi range test. Use toc_off to calculte r2 values. Handle emit_stub_syms. (ppc64_elf_setup_section_lists): Remove htab creator flavour test. Initialize elf_gp and toc_curr. (ppc64_elf_next_toc_section, ppc64_elf_reinit_toc): New functions. (ppc64_elf_next_input_section): Set toc_off. (group_sections): Ensure groups have the same TOC. (ppc64_elf_size_stubs): Check whether we need a TOC adjusting stub. (ppc64_elf_build_stubs): Add emit_stub_syms param, and stash in htab. Build new glink stub. (ppc64_elf_relocate_section): Handle multiple TOCs. Fix comments. (ppc64_elf_finish_dynamic_sections): Adjust DT_PPC64_GLINK. * elf64-ppc.h (ppc64_elf_build_stubs): Update prototype. (ppc64_elf_next_toc_section, ppc64_elf_reinit_toc): Declare. * section.c (struct sec): Rename flag12 to has_gp_reloc. (STD_SECTION): Update. * ecoff.c (bfd_debug_section): Update comment. * bfd-in2.h: Regenerate.
2003-06-08 16:06:38 +02:00
void ppc64_elf_reinit_toc
(bfd *, struct bfd_link_info *);
bfd_boolean ppc64_elf_next_input_section
(struct bfd_link_info *, asection *);
bfd_boolean ppc64_elf_size_stubs
(bfd *, struct bfd_link_info *, bfd_signed_vma,
asection *(*) (const char *, asection *), void (*) (void));
bfd_boolean ppc64_elf_build_stubs
(bfd_boolean, struct bfd_link_info *, char **);