Home | History | Annotate | Line # | Download | only in bfd
elf32-tilegx.c revision 1.1.1.1.4.2
      1  1.1.1.1.4.2  yamt /* TILE-Gx-specific support for 32-bit ELF.
      2  1.1.1.1.4.2  yamt    Copyright 2011 Free Software Foundation, Inc.
      3  1.1.1.1.4.2  yamt 
      4  1.1.1.1.4.2  yamt    This file is part of BFD, the Binary File Descriptor library.
      5  1.1.1.1.4.2  yamt 
      6  1.1.1.1.4.2  yamt    This program is free software; you can redistribute it and/or modify
      7  1.1.1.1.4.2  yamt    it under the terms of the GNU General Public License as published by
      8  1.1.1.1.4.2  yamt    the Free Software Foundation; either version 3 of the License, or
      9  1.1.1.1.4.2  yamt    (at your option) any later version.
     10  1.1.1.1.4.2  yamt 
     11  1.1.1.1.4.2  yamt    This program is distributed in the hope that it will be useful,
     12  1.1.1.1.4.2  yamt    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  1.1.1.1.4.2  yamt    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  1.1.1.1.4.2  yamt    GNU General Public License for more details.
     15  1.1.1.1.4.2  yamt 
     16  1.1.1.1.4.2  yamt    You should have received a copy of the GNU General Public License
     17  1.1.1.1.4.2  yamt    along with this program; if not, write to the Free Software
     18  1.1.1.1.4.2  yamt    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     19  1.1.1.1.4.2  yamt    MA 02110-1301, USA.  */
     20  1.1.1.1.4.2  yamt 
     21  1.1.1.1.4.2  yamt #include "sysdep.h"
     22  1.1.1.1.4.2  yamt #include "bfd.h"
     23  1.1.1.1.4.2  yamt #include "libbfd.h"
     24  1.1.1.1.4.2  yamt #include "elf-bfd.h"
     25  1.1.1.1.4.2  yamt #include "elfxx-tilegx.h"
     26  1.1.1.1.4.2  yamt #include "elf32-tilegx.h"
     27  1.1.1.1.4.2  yamt 
     28  1.1.1.1.4.2  yamt 
     29  1.1.1.1.4.2  yamt /* Support for core dump NOTE sections.  */
     30  1.1.1.1.4.2  yamt 
     31  1.1.1.1.4.2  yamt static bfd_boolean
     32  1.1.1.1.4.2  yamt tilegx_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
     33  1.1.1.1.4.2  yamt {
     34  1.1.1.1.4.2  yamt   int offset;
     35  1.1.1.1.4.2  yamt   size_t size;
     36  1.1.1.1.4.2  yamt 
     37  1.1.1.1.4.2  yamt   if (note->descsz != TILEGX_PRSTATUS_SIZEOF)
     38  1.1.1.1.4.2  yamt     return FALSE;
     39  1.1.1.1.4.2  yamt 
     40  1.1.1.1.4.2  yamt   /* pr_cursig */
     41  1.1.1.1.4.2  yamt   elf_tdata (abfd)->core_signal =
     42  1.1.1.1.4.2  yamt     bfd_get_16 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_CURSIG);
     43  1.1.1.1.4.2  yamt 
     44  1.1.1.1.4.2  yamt   /* pr_pid */
     45  1.1.1.1.4.2  yamt   elf_tdata (abfd)->core_pid =
     46  1.1.1.1.4.2  yamt     bfd_get_32 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_PID);
     47  1.1.1.1.4.2  yamt 
     48  1.1.1.1.4.2  yamt   /* pr_reg */
     49  1.1.1.1.4.2  yamt   offset = TILEGX_PRSTATUS_OFFSET_PR_REG;
     50  1.1.1.1.4.2  yamt   size   = TILEGX_GREGSET_T_SIZE;
     51  1.1.1.1.4.2  yamt 
     52  1.1.1.1.4.2  yamt   /* Make a ".reg/999" section.  */
     53  1.1.1.1.4.2  yamt   return _bfd_elfcore_make_pseudosection (abfd, ".reg",
     54  1.1.1.1.4.2  yamt 					  size, note->descpos + offset);
     55  1.1.1.1.4.2  yamt }
     56  1.1.1.1.4.2  yamt 
     57  1.1.1.1.4.2  yamt static bfd_boolean
     58  1.1.1.1.4.2  yamt tilegx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
     59  1.1.1.1.4.2  yamt {
     60  1.1.1.1.4.2  yamt   if (note->descsz != TILEGX_PRPSINFO_SIZEOF)
     61  1.1.1.1.4.2  yamt     return FALSE;
     62  1.1.1.1.4.2  yamt 
     63  1.1.1.1.4.2  yamt   elf_tdata (abfd)->core_program
     64  1.1.1.1.4.2  yamt     = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_FNAME, 16);
     65  1.1.1.1.4.2  yamt   elf_tdata (abfd)->core_command
     66  1.1.1.1.4.2  yamt     = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_PSARGS, ELF_PR_PSARGS_SIZE);
     67  1.1.1.1.4.2  yamt 
     68  1.1.1.1.4.2  yamt 
     69  1.1.1.1.4.2  yamt   /* Note that for some reason, a spurious space is tacked
     70  1.1.1.1.4.2  yamt      onto the end of the args in some (at least one anyway)
     71  1.1.1.1.4.2  yamt      implementations, so strip it off if it exists.  */
     72  1.1.1.1.4.2  yamt   {
     73  1.1.1.1.4.2  yamt     char *command = elf_tdata (abfd)->core_command;
     74  1.1.1.1.4.2  yamt     int n = strlen (command);
     75  1.1.1.1.4.2  yamt 
     76  1.1.1.1.4.2  yamt     if (0 < n && command[n - 1] == ' ')
     77  1.1.1.1.4.2  yamt       command[n - 1] = '\0';
     78  1.1.1.1.4.2  yamt   }
     79  1.1.1.1.4.2  yamt 
     80  1.1.1.1.4.2  yamt   return TRUE;
     81  1.1.1.1.4.2  yamt }
     82  1.1.1.1.4.2  yamt 
     83  1.1.1.1.4.2  yamt 
     84  1.1.1.1.4.2  yamt #define ELF_ARCH		bfd_arch_tilegx
     85  1.1.1.1.4.2  yamt #define ELF_TARGET_ID		TILEGX_ELF_DATA
     86  1.1.1.1.4.2  yamt #define ELF_MACHINE_CODE	EM_TILEGX
     87  1.1.1.1.4.2  yamt #define ELF_MAXPAGESIZE		0x10000
     88  1.1.1.1.4.2  yamt #define ELF_COMMONPAGESIZE	0x10000
     89  1.1.1.1.4.2  yamt 
     90  1.1.1.1.4.2  yamt #define TARGET_BIG_SYM          bfd_elf32_tilegx_be_vec
     91  1.1.1.1.4.2  yamt #define TARGET_BIG_NAME         "elf32-tilegx-be"
     92  1.1.1.1.4.2  yamt #define TARGET_LITTLE_SYM       bfd_elf32_tilegx_le_vec
     93  1.1.1.1.4.2  yamt #define TARGET_LITTLE_NAME      "elf32-tilegx-le"
     94  1.1.1.1.4.2  yamt 
     95  1.1.1.1.4.2  yamt #define elf_backend_reloc_type_class	     tilegx_reloc_type_class
     96  1.1.1.1.4.2  yamt 
     97  1.1.1.1.4.2  yamt #define bfd_elf32_bfd_reloc_name_lookup      tilegx_reloc_name_lookup
     98  1.1.1.1.4.2  yamt #define bfd_elf32_bfd_link_hash_table_create tilegx_elf_link_hash_table_create
     99  1.1.1.1.4.2  yamt #define bfd_elf32_bfd_reloc_type_lookup	     tilegx_reloc_type_lookup
    100  1.1.1.1.4.2  yamt #define bfd_elf32_bfd_merge_private_bfd_data \
    101  1.1.1.1.4.2  yamt   _bfd_tilegx_elf_merge_private_bfd_data
    102  1.1.1.1.4.2  yamt 
    103  1.1.1.1.4.2  yamt #define elf_backend_copy_indirect_symbol     tilegx_elf_copy_indirect_symbol
    104  1.1.1.1.4.2  yamt #define elf_backend_create_dynamic_sections  tilegx_elf_create_dynamic_sections
    105  1.1.1.1.4.2  yamt #define elf_backend_check_relocs	     tilegx_elf_check_relocs
    106  1.1.1.1.4.2  yamt #define elf_backend_adjust_dynamic_symbol    tilegx_elf_adjust_dynamic_symbol
    107  1.1.1.1.4.2  yamt #define elf_backend_omit_section_dynsym	     tilegx_elf_omit_section_dynsym
    108  1.1.1.1.4.2  yamt #define elf_backend_size_dynamic_sections    tilegx_elf_size_dynamic_sections
    109  1.1.1.1.4.2  yamt #define elf_backend_relocate_section	     tilegx_elf_relocate_section
    110  1.1.1.1.4.2  yamt #define elf_backend_finish_dynamic_symbol    tilegx_elf_finish_dynamic_symbol
    111  1.1.1.1.4.2  yamt #define elf_backend_finish_dynamic_sections  tilegx_elf_finish_dynamic_sections
    112  1.1.1.1.4.2  yamt #define elf_backend_gc_mark_hook	     tilegx_elf_gc_mark_hook
    113  1.1.1.1.4.2  yamt #define elf_backend_gc_sweep_hook            tilegx_elf_gc_sweep_hook
    114  1.1.1.1.4.2  yamt #define elf_backend_plt_sym_val		     tilegx_elf_plt_sym_val
    115  1.1.1.1.4.2  yamt #define elf_info_to_howto_rel                NULL
    116  1.1.1.1.4.2  yamt #define elf_info_to_howto                    tilegx_info_to_howto_rela
    117  1.1.1.1.4.2  yamt #define elf_backend_grok_prstatus            tilegx_elf_grok_prstatus
    118  1.1.1.1.4.2  yamt #define elf_backend_grok_psinfo              tilegx_elf_grok_psinfo
    119  1.1.1.1.4.2  yamt #define elf_backend_additional_program_headers tilegx_additional_program_headers
    120  1.1.1.1.4.2  yamt 
    121  1.1.1.1.4.2  yamt #define elf_backend_init_index_section	_bfd_elf_init_1_index_section
    122  1.1.1.1.4.2  yamt 
    123  1.1.1.1.4.2  yamt #define elf_backend_can_gc_sections 1
    124  1.1.1.1.4.2  yamt #define elf_backend_can_refcount 1
    125  1.1.1.1.4.2  yamt #define elf_backend_want_got_plt 1
    126  1.1.1.1.4.2  yamt #define elf_backend_plt_readonly 1
    127  1.1.1.1.4.2  yamt /* Align PLT mod 64 byte L2 line size. */
    128  1.1.1.1.4.2  yamt #define elf_backend_plt_alignment 6
    129  1.1.1.1.4.2  yamt #define elf_backend_want_plt_sym 1
    130  1.1.1.1.4.2  yamt #define elf_backend_got_header_size 4
    131  1.1.1.1.4.2  yamt #define elf_backend_rela_normal 1
    132  1.1.1.1.4.2  yamt #define elf_backend_default_execstack 0
    133  1.1.1.1.4.2  yamt 
    134  1.1.1.1.4.2  yamt #include "elf32-target.h"
    135