1/* Freescale XGATE-specific support for 32-bit ELF 2 Copyright (C) 2012-2017 Free Software Foundation, Inc. 3 4 Contributed by Sean Keys (skeys@ipdatasys.com) 5 (Heavily copied from the HC11 port by Stephane Carrez (stcarrez@nerim.fr)) 6 7 This file is part of BFD, the Binary File Descriptor library. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 22 MA 02110-1301, USA. */ 23 24#ifndef _ELF32_XGATE_H 25#define _ELF32_XGATE_H 26 27#include "elf-bfd.h" 28#include "bfdlink.h" 29#include "elf/xgate.h" 30 31/* Set and control ELF flags in ELF header. */ 32extern bfd_boolean _bfd_xgate_elf_set_private_flags (bfd*,flagword); 33extern bfd_boolean _bfd_xgate_elf_print_private_bfd_data (bfd*, void*); 34 35struct elf32_xgate_stub_hash_entry 36{ 37 /* Base hash table entry structure. */ 38 struct bfd_hash_entry root; 39 40 /* The stub section. */ 41 asection *stub_sec; 42 43 /* Offset within stub_sec of the beginning of this stub. */ 44 bfd_vma stub_offset; 45 46 /* Given the symbol's value and its section we can determine its final 47 value when building the stubs (so the stub knows where to jump. */ 48 bfd_vma target_value; 49 asection *target_section; 50}; 51 52struct xgate_page_info 53{ 54 bfd_vma bank_virtual; 55 bfd_vma bank_physical; 56 bfd_vma bank_physical_end; 57 bfd_vma bank_mask; 58 bfd_vma bank_size; 59 int bank_shift; 60 int bank_param_initialized; 61 bfd_vma trampoline_addr; 62}; 63 64struct xgate_elf_link_hash_table 65{ 66 struct elf_link_hash_table root; 67 struct xgate_page_info pinfo; 68 69 /* The stub hash table. */ 70 struct bfd_hash_table* stub_hash_table; 71 72 /* Linker stub bfd. */ 73 bfd *stub_bfd; 74 75 asection* stub_section; 76 asection* tramp_section; 77 78 /* Linker call-backs. */ 79 asection * (*add_stub_section) (const char *, asection *); 80 81 /* Assorted information used by elf32_hppa_size_stubs. */ 82 unsigned int bfd_count; 83 int top_index; 84 asection ** input_list; 85 86 /* Small local sym cache. */ 87 struct sym_cache sym_cache; 88 89 bfd_boolean (*size_one_stub) (struct bfd_hash_entry*, void*); 90 bfd_boolean (*build_one_stub) (struct bfd_hash_entry*, void*); 91}; 92 93/* Get the XGate ELF linker hash table from a link_info structure. */ 94 95#define xgate_elf_hash_table(p) \ 96 ((struct xgate_elf_link_hash_table *) ((p)->hash)) 97 98/* Create a XGATE ELF linker hash table. */ 99 100extern struct xgate_elf_link_hash_table* xgate_elf_hash_table_create 101 (bfd *); 102 103extern void xgate_elf_get_bank_parameters (struct bfd_link_info *); 104 105/* Return 1 if the address is in banked memory. 106 This can be applied to a virtual address and to a physical address. */ 107extern int xgate_addr_is_banked (struct xgate_page_info *, bfd_vma); 108 109/* Return the physical address seen by the processor, taking 110 into account banked memory. */ 111extern bfd_vma xgate_phys_addr (struct xgate_page_info *, bfd_vma); 112 113/* Return the page number corresponding to an address in banked memory. */ 114extern bfd_vma xgate_phys_page (struct xgate_page_info *, bfd_vma); 115 116bfd_reloc_status_type xgate_elf_ignore_reloc 117 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 118bfd_reloc_status_type xgate_elf_special_reloc 119 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); 120 121bfd_boolean elf32_xgate_check_relocs 122 (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); 123bfd_boolean elf32_xgate_relocate_section 124 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 125 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **); 126 127bfd_boolean elf32_xgate_add_symbol_hook 128 (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, 129 flagword *, asection **, bfd_vma *); 130 131/* Tweak the OSABI field of the elf header. */ 132extern void elf32_xgate_post_process_headers (bfd *, struct bfd_link_info *); 133 134int elf32_xgate_setup_section_lists (bfd *, struct bfd_link_info *); 135 136bfd_boolean elf32_xgate_size_stubs 137 (bfd *, bfd *, struct bfd_link_info *, 138 asection * (*) (const char *, asection *)); 139 140bfd_boolean elf32_xgate_build_stubs (bfd * abfd, struct bfd_link_info *); 141 142#endif /* _ELF32_XGATE_H */ 143