/src/binutils-gdb/include/elf/avr.h
Line | Count | Source |
1 | | /* AVR ELF support for BFD. |
2 | | Copyright (C) 1999-2026 Free Software Foundation, Inc. |
3 | | Contributed by Denis Chertykov <denisc@overta.ru> |
4 | | |
5 | | This file is part of BFD, the Binary File Descriptor library. |
6 | | |
7 | | This program is free software; you can redistribute it and/or modify |
8 | | it under the terms of the GNU General Public License as published by |
9 | | the Free Software Foundation; either version 3 of the License, or |
10 | | (at your option) any later version. |
11 | | |
12 | | This program is distributed in the hope that it will be useful, |
13 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | GNU General Public License for more details. |
16 | | |
17 | | You should have received a copy of the GNU General Public License |
18 | | along with this program; if not, write to the Free Software Foundation, |
19 | | Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
20 | | |
21 | | #ifndef _ELF_AVR_H |
22 | | #define _ELF_AVR_H |
23 | | |
24 | | #include "elf/reloc-macros.h" |
25 | | #include "libiberty.h" // ARRAY_SIZE |
26 | | |
27 | | /* Processor specific flags for the ELF header e_flags field. */ |
28 | 1.23k | #define EF_AVR_MACH 0x7F |
29 | | |
30 | | /* If bit #7 is set, it is assumed that the elf file uses local symbols |
31 | | as reference for the relocations so that linker relaxation is possible. */ |
32 | 881 | #define EF_AVR_LINKRELAX_PREPARED 0x80 |
33 | | |
34 | 606 | #define E_AVR_MACH_AVR1 1 |
35 | 211 | #define E_AVR_MACH_AVR2 2 |
36 | 7 | #define E_AVR_MACH_AVR25 25 |
37 | 10 | #define E_AVR_MACH_AVR3 3 |
38 | 8 | #define E_AVR_MACH_AVR31 31 |
39 | 10 | #define E_AVR_MACH_AVR35 35 |
40 | 15 | #define E_AVR_MACH_AVR4 4 |
41 | 22 | #define E_AVR_MACH_AVR5 5 |
42 | 10 | #define E_AVR_MACH_AVR51 51 |
43 | 17 | #define E_AVR_MACH_AVR6 6 |
44 | 10 | #define E_AVR_MACH_AVRTINY 100 |
45 | 18 | #define E_AVR_MACH_XMEGA1 101 |
46 | 7 | #define E_AVR_MACH_XMEGA2 102 |
47 | 15 | #define E_AVR_MACH_XMEGA3 103 |
48 | 6 | #define E_AVR_MACH_XMEGA4 104 |
49 | 7 | #define E_AVR_MACH_XMEGA5 105 |
50 | 7 | #define E_AVR_MACH_XMEGA6 106 |
51 | 10 | #define E_AVR_MACH_XMEGA7 107 |
52 | | |
53 | | /* Relocations. */ |
54 | 1.31k | START_RELOC_NUMBERS (elf_avr_reloc_type) |
55 | 1.31k | RELOC_NUMBER (R_AVR_NONE, 0) |
56 | 32 | RELOC_NUMBER (R_AVR_32, 1) |
57 | 17 | RELOC_NUMBER (R_AVR_7_PCREL, 2) |
58 | 1 | RELOC_NUMBER (R_AVR_13_PCREL, 3) |
59 | 13 | RELOC_NUMBER (R_AVR_16, 4) |
60 | 7 | RELOC_NUMBER (R_AVR_16_PM, 5) |
61 | 5 | RELOC_NUMBER (R_AVR_LO8_LDI, 6) |
62 | 17 | RELOC_NUMBER (R_AVR_HI8_LDI, 7) |
63 | 17 | RELOC_NUMBER (R_AVR_HH8_LDI, 8) |
64 | 28 | RELOC_NUMBER (R_AVR_LO8_LDI_NEG, 9) |
65 | 7 | RELOC_NUMBER (R_AVR_HI8_LDI_NEG, 10) |
66 | 6 | RELOC_NUMBER (R_AVR_HH8_LDI_NEG, 11) |
67 | 5 | RELOC_NUMBER (R_AVR_LO8_LDI_PM, 12) |
68 | 6 | RELOC_NUMBER (R_AVR_HI8_LDI_PM, 13) |
69 | 0 | RELOC_NUMBER (R_AVR_HH8_LDI_PM, 14) |
70 | 6 | RELOC_NUMBER (R_AVR_LO8_LDI_PM_NEG, 15) |
71 | 33 | RELOC_NUMBER (R_AVR_HI8_LDI_PM_NEG, 16) |
72 | 1 | RELOC_NUMBER (R_AVR_HH8_LDI_PM_NEG, 17) |
73 | 12 | RELOC_NUMBER (R_AVR_CALL, 18) |
74 | 0 | RELOC_NUMBER (R_AVR_LDI, 19) |
75 | 8 | RELOC_NUMBER (R_AVR_6, 20) |
76 | 2 | RELOC_NUMBER (R_AVR_6_ADIW, 21) |
77 | 0 | RELOC_NUMBER (R_AVR_MS8_LDI, 22) |
78 | 3 | RELOC_NUMBER (R_AVR_MS8_LDI_NEG, 23) |
79 | 3 | RELOC_NUMBER (R_AVR_LO8_LDI_GS, 24) |
80 | 0 | RELOC_NUMBER (R_AVR_HI8_LDI_GS, 25) |
81 | 0 | RELOC_NUMBER (R_AVR_8, 26) |
82 | 2 | RELOC_NUMBER (R_AVR_8_LO8, 27) |
83 | 0 | RELOC_NUMBER (R_AVR_8_HI8, 28) |
84 | 22 | RELOC_NUMBER (R_AVR_8_HLO8, 29) |
85 | 48 | RELOC_NUMBER (R_AVR_DIFF8, 30) |
86 | 12 | RELOC_NUMBER (R_AVR_DIFF16, 31) |
87 | 11 | RELOC_NUMBER (R_AVR_DIFF32, 32) |
88 | 4 | RELOC_NUMBER (R_AVR_LDS_STS_16, 33) |
89 | 8 | RELOC_NUMBER (R_AVR_PORT6, 34) |
90 | 3 | RELOC_NUMBER (R_AVR_PORT5, 35) |
91 | 5 | RELOC_NUMBER (R_AVR_32_PCREL, 36) |
92 | 543 | END_RELOC_NUMBERS (R_AVR_max) |
93 | | |
94 | | |
95 | | // Object attribute tags. |
96 | | enum |
97 | | { |
98 | | // 0-3 are generic. |
99 | | |
100 | | // VTABLE is located in some named address space. |
101 | | Tag_GNU_AVR_VTABLE_AS = 4, |
102 | | |
103 | | // Bits used by the double type, or 0 if no see. |
104 | | Tag_GNU_AVR_BITS_DOUBLE = 8, |
105 | | |
106 | | // Bits used by the long double type, or 0 if no see. |
107 | | Tag_GNU_AVR_BITS_LONG_DOUBLE = 12, |
108 | | }; |
109 | | |
110 | | |
111 | | // Object attribute values. |
112 | | enum |
113 | | { |
114 | | // There's no VTABLE instance or VTABLE access in the ojbect file. |
115 | | Val_GNU_AVR_VTABLE_NONE = 0, |
116 | | |
117 | | // When the module hosts or reads a VTABLE, then Tag_GNU_AVR_VTABLE_AS is |
118 | | // one plus AVR GCC's address space enum from <GCC>/gcc/config/avr/avr.h. |
119 | | |
120 | | // VTABLE is located in AS0, the generic address space (RAM). |
121 | | // This includes .rodata. */ |
122 | | Val_GNU_AVR_VTABLE_RAM = 0 + 1, |
123 | | |
124 | | // __flash: 16-bit flash in 0x0 -- 0xffff. |
125 | | Val_GNU_AVR_VTABLE_FLASH = 1 + 1, |
126 | | |
127 | | // __flash1: 16-bit flash in 0x10000 -- 0x1ffff. |
128 | | Val_GNU_AVR_VTABLE_FLASH1 = 2 + 1, |
129 | | |
130 | | // __flash2: 16-bit flash in 0x20000 -- 0x2ffff. |
131 | | Val_GNU_AVR_VTABLE_FLASH2 = 3 + 1, |
132 | | |
133 | | // __flash3: 16-bit flash in 0x30000 -- 0x3ffff. |
134 | | Val_GNU_AVR_VTABLE_FLASH3 = 4 + 1, |
135 | | |
136 | | // __flash4: 16-bit flash in 0x40000 -- 0x4ffff. |
137 | | Val_GNU_AVR_VTABLE_FLASH4 = 5 + 1, |
138 | | |
139 | | // __flash5: 16-bit flash in 0x50000 -- 0x5ffff. |
140 | | Val_GNU_AVR_VTABLE_FLASH5 = 6 + 1, |
141 | | |
142 | | // __flashx: 24-bit flash. |
143 | | Val_GNU_AVR_VTABLE_FLASHX = 7 + 1, |
144 | | |
145 | | Val_GNU_AVR_VTABLE_Sentinel |
146 | | }; |
147 | | |
148 | | |
149 | | // Map Tag_GNU_AVR_VTABLE_AS to a static string for diagnostics. |
150 | | |
151 | | static inline const char * |
152 | | avr_tag_vtable_as_name (int tag) |
153 | 1.19k | { |
154 | 1.19k | switch (tag) |
155 | 1.19k | { |
156 | 511 | default: |
157 | 511 | break; |
158 | 511 | case Val_GNU_AVR_VTABLE_NONE: return "no vtables"; |
159 | 33 | case Val_GNU_AVR_VTABLE_RAM: return "generic address space"; |
160 | 0 | case Val_GNU_AVR_VTABLE_FLASH: return "__flash"; |
161 | 22 | case Val_GNU_AVR_VTABLE_FLASH1: return "__flash1"; |
162 | 338 | case Val_GNU_AVR_VTABLE_FLASH2: return "__flash2"; |
163 | 2 | case Val_GNU_AVR_VTABLE_FLASH3: return "__flash3"; |
164 | 0 | case Val_GNU_AVR_VTABLE_FLASH4: return "__flash4"; |
165 | 0 | case Val_GNU_AVR_VTABLE_FLASH5: return "__flash5"; |
166 | 8 | case Val_GNU_AVR_VTABLE_FLASHX: return "__flashx"; |
167 | 1.19k | } |
168 | | |
169 | 511 | return "<unknown>"; |
170 | 1.19k | } Unexecuted instantiation: elf32-avr.c:avr_tag_vtable_as_name fuzz_readelf.c:avr_tag_vtable_as_name Line | Count | Source | 153 | 1.19k | { | 154 | 1.19k | switch (tag) | 155 | 1.19k | { | 156 | 511 | default: | 157 | 511 | break; | 158 | 511 | case Val_GNU_AVR_VTABLE_NONE: return "no vtables"; | 159 | 33 | case Val_GNU_AVR_VTABLE_RAM: return "generic address space"; | 160 | 0 | case Val_GNU_AVR_VTABLE_FLASH: return "__flash"; | 161 | 22 | case Val_GNU_AVR_VTABLE_FLASH1: return "__flash1"; | 162 | 338 | case Val_GNU_AVR_VTABLE_FLASH2: return "__flash2"; | 163 | 2 | case Val_GNU_AVR_VTABLE_FLASH3: return "__flash3"; | 164 | 0 | case Val_GNU_AVR_VTABLE_FLASH4: return "__flash4"; | 165 | 0 | case Val_GNU_AVR_VTABLE_FLASH5: return "__flash5"; | 166 | 8 | case Val_GNU_AVR_VTABLE_FLASHX: return "__flashx"; | 167 | 1.19k | } | 168 | | | 169 | 511 | return "<unknown>"; | 170 | 1.19k | } |
|
171 | | |
172 | | #endif /* _ELF_AVR_H */ |