Back to index

cell-binutils  2.17cvs20070401
elf32-m68hc1x.h
Go to the documentation of this file.
00001 /* Motorola 68HC11/68HC12-specific support for 32-bit ELF
00002    Copyright 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
00003    Contributed by Stephane Carrez (stcarrez@nerim.fr)
00004 
00005 This file is part of BFD, the Binary File Descriptor library.
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 #ifndef _ELF32_M68HC1X_H
00022 #define _ELF32_M68HC1X_H
00023 
00024 #include "elf-bfd.h"
00025 #include "bfdlink.h"
00026 #include "elf/m68hc11.h"
00027 
00028 /* Name of symbols exported by HC11/HC12 linker when there is a memory
00029    bank window.  */
00030 #define BFD_M68HC11_BANK_START_NAME   "__bank_start"
00031 #define BFD_M68HC11_BANK_SIZE_NAME    "__bank_size"
00032 #define BFD_M68HC11_BANK_VIRTUAL_NAME "__bank_virtual"
00033 
00034 /* Set and control ELF flags in ELF header.  */
00035 extern bfd_boolean _bfd_m68hc11_elf_merge_private_bfd_data (bfd*,bfd*);
00036 extern bfd_boolean _bfd_m68hc11_elf_set_private_flags (bfd*,flagword);
00037 extern bfd_boolean _bfd_m68hc11_elf_print_private_bfd_data (bfd*, void*);
00038 
00039 /* This hash entry is used to record a trampoline that must be generated
00040    to call a far function using a normal calling convention ('jsr').
00041    The trampoline is used when a pointer to a far function is used.
00042    It takes care of installing the proper memory bank as well as creating
00043    the 'call/rtc' calling convention.  */
00044 struct elf32_m68hc11_stub_hash_entry {
00045 
00046   /* Base hash table entry structure.  */
00047   struct bfd_hash_entry root;
00048 
00049   /* The stub section.  */
00050   asection *stub_sec;
00051 
00052   /* Offset within stub_sec of the beginning of this stub.  */
00053   bfd_vma stub_offset;
00054 
00055   /* Given the symbol's value and its section we can determine its final
00056      value when building the stubs (so the stub knows where to jump.  */
00057   bfd_vma target_value;
00058   asection *target_section;
00059 };
00060 
00061 /* Placeholder for the parameters to compute memory page and physical address.
00062    The following formulas are used:
00063 
00064    sym > bank_virtual =>
00065      %addr(sym) = (((sym - bank_virtual) & bank_mask) + bank_physical
00066      %page(sym) = (((sym - bank_virtual) >> bank_shift) % 256
00067 
00068    sym < bank_virtual =>
00069      %addr(sym) = sym
00070      %page(sym) = 0
00071 
00072 
00073    These parameters are obtained from the symbol table by looking
00074    at the following:
00075 
00076    __bank_start         Symbol marking the start of memory bank window
00077                         (bank_physical)
00078    __bank_virtual       Logical address of symbols for which the transformation
00079                         must be computed
00080    __bank_page_size     Size in bytes of page size (this is *NOT* the memory
00081                         bank window size and the window size is always
00082                         less or equal to the page size)
00083 
00084    For 68HC12, the window is at 0x8000 and the page size is 16K (full window).
00085    For 68HC11 this is board specific (implemented by external hardware).
00086 
00087 */
00088 struct m68hc11_page_info
00089 {
00090   bfd_vma bank_virtual;
00091   bfd_vma bank_physical;
00092   bfd_vma bank_physical_end;
00093   bfd_vma bank_mask;
00094   bfd_vma bank_size;
00095   int bank_shift;
00096   int bank_param_initialized;
00097   bfd_vma trampoline_addr;
00098 };
00099 
00100 struct m68hc11_elf_link_hash_table
00101 {
00102   struct elf_link_hash_table root;
00103   struct m68hc11_page_info pinfo;
00104 
00105   /* The stub hash table.  */
00106   struct bfd_hash_table* stub_hash_table;
00107 
00108   /* Linker stub bfd.  */
00109   bfd *stub_bfd;
00110 
00111   asection* stub_section;
00112   asection* tramp_section;
00113 
00114   /* Linker call-backs.  */
00115   asection * (*add_stub_section) PARAMS ((const char *, asection *));
00116 
00117   /* Assorted information used by elf32_hppa_size_stubs.  */
00118   unsigned int bfd_count;
00119   int top_index;
00120   asection **input_list;
00121 
00122   /* Small local sym to section mapping cache.  */
00123   struct sym_sec_cache sym_sec;
00124 
00125   bfd_boolean (* size_one_stub) PARAMS((struct bfd_hash_entry*, void*));
00126   bfd_boolean (* build_one_stub) PARAMS((struct bfd_hash_entry*, void*));
00127 };
00128 
00129 /* Get the Sparc64 ELF linker hash table from a link_info structure.  */
00130 
00131 #define m68hc11_elf_hash_table(p) \
00132   ((struct m68hc11_elf_link_hash_table *) ((p)->hash))
00133 
00134 /* Create a 68HC11/68HC12 ELF linker hash table.  */
00135 
00136 extern struct m68hc11_elf_link_hash_table* m68hc11_elf_hash_table_create
00137   (bfd*);
00138 extern void m68hc11_elf_bfd_link_hash_table_free (struct bfd_link_hash_table*);
00139 
00140 extern void m68hc11_elf_get_bank_parameters (struct bfd_link_info*);
00141 
00142 /* Return 1 if the address is in banked memory.
00143    This can be applied to a virtual address and to a physical address.  */
00144 extern int m68hc11_addr_is_banked (struct m68hc11_page_info*, bfd_vma);
00145 
00146 /* Return the physical address seen by the processor, taking
00147    into account banked memory.  */
00148 extern bfd_vma m68hc11_phys_addr (struct m68hc11_page_info*, bfd_vma);
00149 
00150 /* Return the page number corresponding to an address in banked memory.  */
00151 extern bfd_vma m68hc11_phys_page (struct m68hc11_page_info*, bfd_vma);
00152 
00153 bfd_reloc_status_type m68hc11_elf_ignore_reloc
00154   (bfd *abfd, arelent *reloc_entry,
00155    asymbol *symbol, void *data, asection *input_section,
00156    bfd *output_bfd, char **error_message);
00157 bfd_reloc_status_type m68hc11_elf_special_reloc
00158   (bfd *abfd, arelent *reloc_entry,
00159     asymbol *symbol, void *data, asection *input_section,
00160     bfd *output_bfd, char **error_message);
00161 
00162 bfd_boolean elf32_m68hc11_check_relocs
00163   (bfd * abfd, struct bfd_link_info * info,
00164    asection * sec, const Elf_Internal_Rela * relocs);
00165 bfd_boolean elf32_m68hc11_relocate_section
00166   (bfd *output_bfd, struct bfd_link_info *info,
00167    bfd *input_bfd, asection *input_section,
00168    bfd_byte *contents, Elf_Internal_Rela *relocs,
00169    Elf_Internal_Sym *local_syms, asection **local_sections);
00170 
00171 bfd_boolean elf32_m68hc11_add_symbol_hook
00172   (bfd *abfd, struct bfd_link_info *info,
00173    Elf_Internal_Sym *sym, const char **namep,
00174    flagword *flagsp, asection **secp,
00175    bfd_vma *valp);
00176 
00177 /* Tweak the OSABI field of the elf header.  */
00178 
00179 extern void elf32_m68hc11_post_process_headers (bfd*, struct bfd_link_info*);
00180 
00181 int elf32_m68hc11_setup_section_lists (bfd *, struct bfd_link_info *);
00182 
00183 bfd_boolean elf32_m68hc11_size_stubs
00184   (bfd *, bfd *, struct bfd_link_info *,
00185    asection * (*) (const char *, asection *));
00186 
00187 bfd_boolean elf32_m68hc11_build_stubs (bfd* abfd, struct bfd_link_info *);
00188 #endif