blob: 3edda7247ef1ff62aa3588e0369b8c64b4f92104 [file] [log] [blame]
Brian Silverman86497922018-02-10 19:28:39 -05001/* Arm specific symbolic name handling.
2 Copyright (C) 2002-2009, 2014, 2015, 2017 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#include <string.h>
36
37#define BACKEND arm_
38#include "libebl_CPU.h"
39
40
41const char *
42arm_segment_type_name (int segment, char *buf __attribute__ ((unused)),
43 size_t len __attribute__ ((unused)))
44{
45 switch (segment)
46 {
47 case PT_ARM_EXIDX:
48 return "ARM_EXIDX";
49 }
50 return NULL;
51}
52
53/* Return symbolic representation of section type. */
54const char *
55arm_section_type_name (int type,
56 char *buf __attribute__ ((unused)),
57 size_t len __attribute__ ((unused)))
58{
59 switch (type)
60 {
61 case SHT_ARM_EXIDX:
62 return "ARM_EXIDX";
63 case SHT_ARM_PREEMPTMAP:
64 return "ARM_PREEMPTMAP";
65 case SHT_ARM_ATTRIBUTES:
66 return "ARM_ATTRIBUTES";
67 }
68
69 return NULL;
70}
71
72/* Check whether machine flags are valid. */
73bool
74arm_machine_flag_check (GElf_Word flags)
75{
76 switch (flags & EF_ARM_EABIMASK)
77 {
78 case EF_ARM_EABI_UNKNOWN:
79 case EF_ARM_EABI_VER1:
80 case EF_ARM_EABI_VER2:
81 case EF_ARM_EABI_VER3:
82 case EF_ARM_EABI_VER4:
83 case EF_ARM_EABI_VER5:
84 break;
85 default:
86 return false;
87 }
88
89 return ((flags &~ (EF_ARM_EABIMASK
90 | EF_ARM_RELEXEC
91 | EF_ARM_HASENTRY
92 | EF_ARM_INTERWORK
93 | EF_ARM_APCS_26
94 | EF_ARM_APCS_FLOAT
95 | EF_ARM_PIC
96 | EF_ARM_ALIGN8
97 | EF_ARM_NEW_ABI
98 | EF_ARM_OLD_ABI
99 | EF_ARM_SOFT_FLOAT
100 | EF_ARM_VFP_FLOAT
101 | EF_ARM_MAVERICK_FLOAT
102 | EF_ARM_SYMSARESORTED
103 | EF_ARM_DYNSYMSUSESEGIDX
104 | EF_ARM_MAPSYMSFIRST
105 | EF_ARM_EABIMASK
106 | EF_ARM_BE8
107 | EF_ARM_LE8)) == 0);
108}
109
110/* Check for the simple reloc types. */
111Elf_Type
112arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
113{
114 switch (type)
115 {
116 case R_ARM_ABS32:
117 return ELF_T_WORD;
118 case R_ARM_ABS16:
119 return ELF_T_HALF;
120 case R_ARM_ABS8:
121 return ELF_T_BYTE;
122 default:
123 return ELF_T_NUM;
124 }
125}
126
127/* The SHT_ARM_EXIDX section type is a valid target for relocation. */
128bool
129arm_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_type)
130{
131 return sh_type == SHT_ARM_EXIDX;
132}
133
134const char *
135arm_symbol_type_name (int type,
136 char *buf __attribute__ ((unused)),
137 size_t len __attribute__ ((unused)))
138{
139 switch (type)
140 {
141 case STT_ARM_TFUNC:
142 return "ARM_TFUNC";
143 }
144 return NULL;
145}
146
147/* A data mapping symbol is a symbol with "$d" name or "$d.<any...>" name,
148 * STT_NOTYPE, STB_LOCAL and st_size of zero. The indicate the stat of a
149 * sequence of data items. */
150bool
151arm_data_marker_symbol (const GElf_Sym *sym, const char *sname)
152{
153 return (sym != NULL && sname != NULL
154 && sym->st_size == 0 && GELF_ST_BIND (sym->st_info) == STB_LOCAL
155 && GELF_ST_TYPE (sym->st_info) == STT_NOTYPE
156 && (strcmp (sname, "$d") == 0 || strncmp (sname, "$d.", 3) == 0));
157}