1 /* IA-64 specific symbolic name handling.
2 Copyright (C) 2002-2009 Red Hat, Inc.
3 This file is part of Red Hat elfutils.
4 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
5
6 Red Hat elfutils is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by the
8 Free Software Foundation; version 2 of the License.
9
10 Red Hat elfutils is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with Red Hat elfutils; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18
19 Red Hat elfutils is an included package of the Open Invention Network.
20 An included package of the Open Invention Network is a package for which
21 Open Invention Network licensees cross-license their patents. No patent
22 license is granted, either expressly or impliedly, by designation as an
23 included package. Should you wish to participate in the Open Invention
24 Network licensing program, please visit www.openinventionnetwork.com
25 <http://www.openinventionnetwork.com>. */
26
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30
31 #include <elf.h>
32 #include <stddef.h>
33 #include <assert.h>
34
35 #define BACKEND ia64_
36 #include "libebl_CPU.h"
37
38
39 const char *
ia64_segment_type_name(int segment,char * buf,size_t len)40 ia64_segment_type_name (int segment, char *buf __attribute__ ((unused)),
41 size_t len __attribute__ ((unused)))
42 {
43 switch (segment)
44 {
45 case PT_IA_64_ARCHEXT:
46 return "IA_64_ARCHEXT";
47 case PT_IA_64_UNWIND:
48 return "IA_64_UNWIND";
49 case PT_IA_64_HP_OPT_ANOT:
50 return "IA_64_HP_OPT_ANOT";
51 case PT_IA_64_HP_HSL_ANOT:
52 return "IA_64_HP_HSL_ANOT";
53 case PT_IA_64_HP_STACK:
54 return "IA_64_HP_STACK";
55 default:
56 break;
57 }
58 return NULL;
59 }
60
61 const char *
ia64_dynamic_tag_name(int64_t tag,char * buf,size_t len)62 ia64_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)),
63 size_t len __attribute__ ((unused)))
64 {
65 switch (tag)
66 {
67 case DT_IA_64_PLT_RESERVE:
68 return "IA_64_PLT_RESERVE";
69 default:
70 break;
71 }
72 return NULL;
73 }
74
75 /* Check dynamic tag. */
76 bool
ia64_dynamic_tag_check(int64_t tag)77 ia64_dynamic_tag_check (int64_t tag)
78 {
79 return tag == DT_IA_64_PLT_RESERVE;
80 }
81
82 /* Check whether machine flags are valid. */
83 bool
ia64_machine_flag_check(GElf_Word flags)84 ia64_machine_flag_check (GElf_Word flags)
85 {
86 return ((flags &~ EF_IA_64_ABI64) == 0);
87 }
88
89 /* Check whether SHF_MASKPROC flags are valid. */
90 bool
ia64_machine_section_flag_check(GElf_Xword sh_flags)91 ia64_machine_section_flag_check (GElf_Xword sh_flags)
92 {
93 return (sh_flags &~ (SHF_IA_64_SHORT | SHF_IA_64_NORECOV)) == 0;
94 }
95
96 /* Return symbolic representation of section type. */
97 const char *
ia64_section_type_name(int type,char * buf,size_t len)98 ia64_section_type_name (int type,
99 char *buf __attribute__ ((unused)),
100 size_t len __attribute__ ((unused)))
101 {
102 switch (type)
103 {
104 case SHT_IA_64_EXT:
105 return "IA_64_EXT";
106 case SHT_IA_64_UNWIND:
107 return "IA_64_UNWIND";
108 }
109
110 return NULL;
111 }
112
113 /* Check for the simple reloc types. */
114 Elf_Type
ia64_reloc_simple_type(Ebl * ebl,int type)115 ia64_reloc_simple_type (Ebl *ebl, int type)
116 {
117 switch (type)
118 {
119 /* The SECREL types when used with non-allocated sections
120 like .debug_* are the same as direct absolute relocs
121 applied to those sections, since a 0 section address is assumed.
122 So we treat them the same here. */
123
124 case R_IA64_SECREL32MSB:
125 case R_IA64_DIR32MSB:
126 if (ebl->data == ELFDATA2MSB)
127 return ELF_T_WORD;
128 break;
129 case R_IA64_SECREL32LSB:
130 case R_IA64_DIR32LSB:
131 if (ebl->data == ELFDATA2LSB)
132 return ELF_T_WORD;
133 break;
134 case R_IA64_DIR64MSB:
135 case R_IA64_SECREL64MSB:
136 if (ebl->data == ELFDATA2MSB)
137 return ELF_T_XWORD;
138 break;
139 case R_IA64_SECREL64LSB:
140 case R_IA64_DIR64LSB:
141 if (ebl->data == ELFDATA2LSB)
142 return ELF_T_XWORD;
143 break;
144 }
145
146 return ELF_T_NUM;
147 }
148