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