1 /* Arm-specific ELF flag names.
2 Copyright (C) 2022 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 #define BACKEND arm_
34 #include "libebl_CPU.h"
35
36 const char *
arm_machine_flag_name(Elf64_Word orig,Elf64_Word * flagref)37 arm_machine_flag_name (Elf64_Word orig, Elf64_Word *flagref)
38 {
39 unsigned version = EF_ARM_EABI_VERSION (*flagref) >> 24;
40 if (version != 0)
41 {
42 static const char vername[5][14] =
43 {
44 "Version1 EABI",
45 "Version2 EABI",
46 "Version3 EABI",
47 "Version4 EABI",
48 "Version5 EABI",
49 };
50 *flagref &= ~((Elf64_Word) EF_ARM_EABIMASK);
51 return vername[version - 1];
52 }
53 switch (EF_ARM_EABI_VERSION (orig))
54 {
55 case EF_ARM_EABI_VER2:
56 if ((*flagref & EF_ARM_DYNSYMSUSESEGIDX) != 0)
57 {
58 *flagref &= ~((Elf64_Word) EF_ARM_DYNSYMSUSESEGIDX);
59 return "dynamic symbols use segment index";
60 }
61 if ((*flagref & EF_ARM_MAPSYMSFIRST) != 0)
62 {
63 *flagref &= ~((Elf64_Word) EF_ARM_MAPSYMSFIRST);
64 return "mapping symbols precede others";
65 }
66 FALLTHROUGH;
67 case EF_ARM_EABI_VER1:
68 if ((*flagref & EF_ARM_SYMSARESORTED) != 0)
69 {
70 *flagref &= ~((Elf64_Word) EF_ARM_SYMSARESORTED);
71 return "sorted symbol tables";
72 }
73 break;
74 case EF_ARM_EABI_VER3:
75 break;
76 case EF_ARM_EABI_VER5:
77 if ((*flagref & EF_ARM_SOFT_FLOAT) != 0)
78 {
79 *flagref &= ~((Elf64_Word) EF_ARM_SOFT_FLOAT);
80 return "soft-float ABI";
81 }
82 if ((*flagref & EF_ARM_VFP_FLOAT) != 0)
83 {
84 *flagref &= ~((Elf64_Word) EF_ARM_VFP_FLOAT);
85 return "hard-float ABI";
86 }
87 FALLTHROUGH;
88 case EF_ARM_EABI_VER4:
89 if ((*flagref & EF_ARM_BE8) != 0)
90 {
91 *flagref &= ~((Elf64_Word) EF_ARM_BE8);
92 return "BE8";
93 }
94 if ((*flagref & EF_ARM_LE8) != 0)
95 {
96 *flagref &= ~((Elf64_Word) EF_ARM_LE8);
97 return "LE8";
98 }
99 break;
100 case EF_ARM_EABI_UNKNOWN:
101 if ((*flagref & EF_ARM_INTERWORK) != 0)
102 {
103 *flagref &= ~((Elf64_Word) EF_ARM_INTERWORK);
104 return "interworking enabled";
105 }
106 if ((*flagref & EF_ARM_APCS_26) != 0)
107 {
108 *flagref &= ~((Elf64_Word) EF_ARM_APCS_26);
109 return "uses APCS/26";
110 }
111 if ((*flagref & EF_ARM_APCS_FLOAT) != 0)
112 {
113 *flagref &= ~((Elf64_Word) EF_ARM_APCS_FLOAT);
114 return "uses APCS/float";
115 }
116 if ((*flagref & EF_ARM_PIC) != 0)
117 {
118 *flagref &= ~((Elf64_Word) EF_ARM_PIC);
119 return "position independent";
120 }
121 if ((*flagref & EF_ARM_ALIGN8) != 0)
122 {
123 *flagref &= ~((Elf64_Word) EF_ARM_ALIGN8);
124 return "8 bit structure alignment";
125 }
126 if ((*flagref & EF_ARM_NEW_ABI) != 0)
127 {
128 *flagref &= ~((Elf64_Word) EF_ARM_NEW_ABI);
129 return "uses new ABI";
130 }
131 if ((*flagref & EF_ARM_OLD_ABI) != 0)
132 {
133 *flagref &= ~((Elf64_Word) EF_ARM_OLD_ABI);
134 return "uses old ABI";
135 }
136 if ((*flagref & EF_ARM_SOFT_FLOAT) != 0)
137 {
138 *flagref &= ~((Elf64_Word) EF_ARM_SOFT_FLOAT);
139 return "software FP";
140 }
141 if ((*flagref & EF_ARM_VFP_FLOAT) != 0)
142 {
143 *flagref &= ~((Elf64_Word) EF_ARM_VFP_FLOAT);
144 return "VFP";
145 }
146 if ((*flagref & EF_ARM_MAVERICK_FLOAT) != 0)
147 {
148 *flagref &= ~((Elf64_Word) EF_ARM_MAVERICK_FLOAT);
149 return "Maverick FP";
150 }
151 break;
152 default:
153 break;
154 }
155 return NULL;
156 }
157