1 /* Arm specific symbolic name handling.
2 Copyright (C) 2002-2009, 2014, 2015 Red Hat, Inc.
3 This file is part of elfutils.
4
5 This file is free software; you can redistribute it and/or modify
6 it under the terms of either
7
8 * the GNU Lesser General Public License as published by the Free
9 Software Foundation; either version 3 of the License, or (at
10 your option) any later version
11
12 or
13
14 * the GNU General Public License as published by the Free
15 Software Foundation; either version 2 of the License, or (at
16 your option) any later version
17
18 or both in parallel, as here.
19
20 elfutils is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
24
25 You should have received copies of the GNU General Public License and
26 the GNU Lesser General Public License along with this program. If
27 not, see <http://www.gnu.org/licenses/>. */
28
29 #ifdef HAVE_CONFIG_H
30 # include <config.h>
31 #endif
32
33 #include <elf.h>
34 #include <stddef.h>
35
36 #define BACKEND arm_
37 #include "libebl_CPU.h"
38
39
40 const char *
arm_segment_type_name(int segment,char * buf,size_t len)41 arm_segment_type_name (int segment, char *buf __attribute__ ((unused)),
42 size_t len __attribute__ ((unused)))
43 {
44 switch (segment)
45 {
46 case PT_ARM_EXIDX:
47 return "ARM_EXIDX";
48 }
49 return NULL;
50 }
51
52 /* Return symbolic representation of section type. */
53 const char *
arm_section_type_name(int type,char * buf,size_t len)54 arm_section_type_name (int type,
55 char *buf __attribute__ ((unused)),
56 size_t len __attribute__ ((unused)))
57 {
58 switch (type)
59 {
60 case SHT_ARM_EXIDX:
61 return "ARM_EXIDX";
62 case SHT_ARM_PREEMPTMAP:
63 return "ARM_PREEMPTMAP";
64 case SHT_ARM_ATTRIBUTES:
65 return "ARM_ATTRIBUTES";
66 }
67
68 return NULL;
69 }
70
71 /* Check whether machine flags are valid. */
72 bool
arm_machine_flag_check(GElf_Word flags)73 arm_machine_flag_check (GElf_Word flags)
74 {
75 switch (flags & EF_ARM_EABIMASK)
76 {
77 case EF_ARM_EABI_UNKNOWN:
78 case EF_ARM_EABI_VER1:
79 case EF_ARM_EABI_VER2:
80 case EF_ARM_EABI_VER3:
81 case EF_ARM_EABI_VER4:
82 case EF_ARM_EABI_VER5:
83 break;
84 default:
85 return false;
86 }
87
88 return ((flags &~ (EF_ARM_EABIMASK
89 | EF_ARM_RELEXEC
90 | EF_ARM_HASENTRY
91 | EF_ARM_INTERWORK
92 | EF_ARM_APCS_26
93 | EF_ARM_APCS_FLOAT
94 | EF_ARM_PIC
95 | EF_ARM_ALIGN8
96 | EF_ARM_NEW_ABI
97 | EF_ARM_OLD_ABI
98 | EF_ARM_SOFT_FLOAT
99 | EF_ARM_VFP_FLOAT
100 | EF_ARM_MAVERICK_FLOAT
101 | EF_ARM_SYMSARESORTED
102 | EF_ARM_DYNSYMSUSESEGIDX
103 | EF_ARM_MAPSYMSFIRST
104 | EF_ARM_EABIMASK
105 | EF_ARM_BE8
106 | EF_ARM_LE8)) == 0);
107 }
108
109 /* Check for the simple reloc types. */
110 Elf_Type
arm_reloc_simple_type(Ebl * ebl,int type)111 arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
112 {
113 switch (type)
114 {
115 case R_ARM_ABS32:
116 return ELF_T_WORD;
117 case R_ARM_ABS16:
118 return ELF_T_HALF;
119 case R_ARM_ABS8:
120 return ELF_T_BYTE;
121 default:
122 return ELF_T_NUM;
123 }
124 }
125
126 /* The SHT_ARM_EXIDX section type is a valid target for relocation. */
127 bool
arm_check_reloc_target_type(Ebl * ebl,Elf64_Word sh_type)128 arm_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_type)
129 {
130 return sh_type == SHT_ARM_EXIDX;
131 }
132
133 const char *
arm_symbol_type_name(int type,char * buf,size_t len)134 arm_symbol_type_name (int type,
135 char *buf __attribute__ ((unused)),
136 size_t len __attribute__ ((unused)))
137 {
138 switch (type)
139 {
140 case STT_ARM_TFUNC:
141 return "ARM_TFUNC";
142 }
143 return NULL;
144 }
145