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