]>
Commit | Line | Data |
---|---|---|
b0a81564 | 1 | AVR specific only |
3ccd393f | 2 | =========================================================== |
b0a81564 | 3 | --- binutils/size.c 2007-08-06 13:56:14.000000000 -0600 |
4 | +++ binutils/size.c 2007-09-13 09:13:10.281250000 -0600 | |
3ccd393f | 5 | @@ -36,10 +36,31 @@ |
b0a81564 | 6 | #include "getopt.h" |
7 | #include "bucomm.h" | |
8 | ||
9 | -#ifndef BSD_DEFAULT | |
10 | -#define BSD_DEFAULT 1 | |
11 | +typedef enum | |
12 | +{ | |
13 | + format_sysv = 0, | |
14 | + format_bsd = 1, | |
15 | + format_avr = 2, | |
16 | +} format_type_t; | |
17 | + | |
18 | + | |
19 | +/* Set the default format. */ | |
20 | +#define FORMAT_DEFAULT_SYSV 0 | |
21 | +#define FORMAT_DEFAULT_BSD 1 | |
22 | +#define FORMAT_DEFAULT_AVR 0 | |
23 | + | |
24 | +#if FORMAT_DEFAULT_SYSV | |
25 | + #define FORMAT_DEFAULT format_sysv | |
26 | + #define FORMAT_NAME "sysv" | |
27 | +#elif FORMAT_DEFAULT_BSD | |
28 | + #define FORMAT_DEFAULT format_bsd | |
29 | + #define FORMAT_NAME "berkeley" | |
30 | +#elif FORMAT_DEFAULT_AVR | |
31 | + #define FORMAT_DEFAULT format_avr | |
32 | + #define FORMAT_NAME "avr" | |
33 | #endif | |
34 | ||
35 | + | |
36 | /* Program options. */ | |
37 | ||
38 | static enum | |
3ccd393f | 39 | @@ -48,9 +69,8 @@ static enum |
b0a81564 | 40 | } |
41 | radix = decimal; | |
42 | ||
43 | -/* 0 means use AT&T-style output. */ | |
44 | -static int berkeley_format = BSD_DEFAULT; | |
45 | ||
46 | +format_type_t format = FORMAT_DEFAULT; | |
47 | static int show_version = 0; | |
48 | static int show_help = 0; | |
49 | static int show_totals = 0; | |
3ccd393f | 50 | @@ -64,6 +84,246 @@ static bfd_size_type total_textsize; |
b0a81564 | 51 | /* Program exit status. */ |
52 | static int return_code = 0; | |
53 | ||
54 | + | |
55 | +/* AVR Size specific stuff */ | |
56 | + | |
57 | +#define AVR64 64UL | |
58 | +#define AVR128 128UL | |
59 | +#define AVR256 256UL | |
60 | +#define AVR512 512UL | |
61 | +#define AVR1K 1024UL | |
62 | +#define AVR2K 2048UL | |
63 | +#define AVR4K 4096UL | |
64 | +#define AVR8K 8192UL | |
65 | +#define AVR16K 16384UL | |
3ccd393f | 66 | +#define AVR20K 20480UL |
b0a81564 | 67 | +#define AVR24K 24576UL |
68 | +#define AVR32K 32768UL | |
3ccd393f | 69 | +#define AVR36K 36864UL |
b0a81564 | 70 | +#define AVR40K 40960UL |
71 | +#define AVR64K 65536UL | |
3ccd393f | 72 | +#define AVR68K 69632UL |
b0a81564 | 73 | +#define AVR128K 131072UL |
3ccd393f | 74 | +#define AVR136K 139264UL |
75 | +#define AVR200K 204800UL | |
b0a81564 | 76 | +#define AVR256K 262144UL |
3ccd393f | 77 | +#define AVR264K 270336UL |
b0a81564 | 78 | + |
79 | +typedef struct | |
80 | +{ | |
81 | + char *name; | |
82 | + long flash; | |
83 | + long ram; | |
84 | + long eeprom; | |
85 | +} avr_device_t; | |
86 | + | |
87 | +avr_device_t avr[] = | |
88 | +{ | |
3ccd393f | 89 | + {"atxmega256a3", AVR264K, AVR16K, AVR4K}, |
90 | + {"atxmega256a3b", AVR264K, AVR16K, AVR4K}, | |
91 | + {"atxmega256d3", AVR264K, AVR16K, AVR4K}, | |
92 | + | |
997dccbb | 93 | + {"atmega2560", AVR256K, AVR8K, AVR4K}, |
94 | + {"atmega2561", AVR256K, AVR8K, AVR4K}, | |
b0a81564 | 95 | + |
3ccd393f | 96 | + {"atxmega192a3", AVR200K, AVR16K, AVR2K}, |
97 | + {"atxmega192d3", AVR200K, AVR16K, AVR2K}, | |
98 | + | |
99 | + {"atxmega128a1", AVR136K, AVR8K, AVR2K}, | |
100 | + {"atxmega128a1u", AVR136K, AVR8K, AVR2K}, | |
101 | + {"atxmega128a3", AVR136K, AVR8K, AVR2K}, | |
102 | + {"atxmega128d3", AVR136K, AVR8K, AVR2K}, | |
103 | + | |
104 | + {"at43usb320", AVR128K, 608UL, 0UL}, | |
997dccbb | 105 | + {"at90can128", AVR128K, AVR4K, AVR4K}, |
106 | + {"at90usb1286", AVR128K, AVR8K, AVR4K}, | |
107 | + {"at90usb1287", AVR128K, AVR8K, AVR4K}, | |
108 | + {"atmega128", AVR128K, AVR4K, AVR4K}, | |
109 | + {"atmega1280", AVR128K, AVR8K, AVR4K}, | |
110 | + {"atmega1281", AVR128K, AVR8K, AVR4K}, | |
3ccd393f | 111 | + {"atmega1284p", AVR128K, AVR16K, AVR4K}, |
112 | + {"atmega128rfa1", AVR128K, AVR16K, AVR4K}, | |
113 | + {"atmega103", AVR128K, 4000UL, AVR4K}, | |
114 | + | |
115 | + {"atxmega64a1", AVR68K, AVR4K, AVR2K}, | |
116 | + {"atxmega64a1u", AVR68K, AVR4K, AVR2K}, | |
117 | + {"atxmega64a3", AVR68K, AVR4K, AVR2K}, | |
118 | + {"atxmega64d3", AVR68K, AVR4K, AVR2K}, | |
b0a81564 | 119 | + |
997dccbb | 120 | + {"at90can64", AVR64K, AVR4K, AVR2K}, |
3ccd393f | 121 | + {"at90scr100", AVR64K, AVR4K, AVR2K}, |
997dccbb | 122 | + {"at90usb646", AVR64K, AVR4K, AVR2K}, |
123 | + {"at90usb647", AVR64K, AVR4K, AVR2K}, | |
124 | + {"atmega64", AVR64K, AVR4K, AVR2K}, | |
125 | + {"atmega640", AVR64K, AVR8K, AVR4K}, | |
126 | + {"atmega644", AVR64K, AVR4K, AVR2K}, | |
3ccd393f | 127 | + {"atmega644a", AVR64K, AVR4K, AVR2K}, |
997dccbb | 128 | + {"atmega644p", AVR64K, AVR4K, AVR2K}, |
3ccd393f | 129 | + {"atmega644pa", AVR64K, AVR4K, AVR2K}, |
997dccbb | 130 | + {"atmega645", AVR64K, AVR4K, AVR2K}, |
3ccd393f | 131 | + {"atmega645a", AVR64K, AVR4K, AVR2K}, |
132 | + {"atmega645p", AVR64K, AVR4K, AVR2K}, | |
997dccbb | 133 | + {"atmega6450", AVR64K, AVR4K, AVR2K}, |
3ccd393f | 134 | + {"atmega6450a", AVR64K, AVR4K, AVR2K}, |
135 | + {"atmega6450p", AVR64K, AVR4K, AVR2K}, | |
997dccbb | 136 | + {"atmega649", AVR64K, AVR4K, AVR2K}, |
3ccd393f | 137 | + {"atmega649a", AVR64K, AVR4K, AVR2K}, |
138 | + {"atmega649p", AVR64K, AVR4K, AVR2K}, | |
997dccbb | 139 | + {"atmega6490", AVR64K, AVR4K, AVR2K}, |
3ccd393f | 140 | + {"atmega6490a", AVR64K, AVR4K, AVR2K}, |
141 | + {"atmega6490p", AVR64K, AVR4K, AVR2K}, | |
142 | + {"atmega64c1", AVR64K, AVR4K, AVR2K}, | |
143 | + {"atmega64hve", AVR64K, AVR4K, AVR1K}, | |
144 | + {"atmega64m1", AVR64K, AVR4K, AVR2K}, | |
145 | + {"m3000", AVR64K, AVR4K, 0UL}, | |
b0a81564 | 146 | + |
3ccd393f | 147 | + {"atmega406", AVR40K, AVR2K, AVR512}, |
148 | + | |
149 | + {"atxmega32a4", AVR36K, AVR4K, AVR1K}, | |
150 | + {"atxmega32d4", AVR36K, AVR4K, AVR1K}, | |
b0a81564 | 151 | + |
997dccbb | 152 | + {"at90can32", AVR32K, AVR2K, AVR1K}, |
3ccd393f | 153 | + {"at94k", AVR32K, AVR4K, 0UL}, |
997dccbb | 154 | + {"atmega32", AVR32K, AVR2K, AVR1K}, |
155 | + {"atmega323", AVR32K, AVR2K, AVR1K}, | |
3ccd393f | 156 | + {"atmega324a", AVR32K, AVR2K, AVR1K}, |
997dccbb | 157 | + {"atmega324p", AVR32K, AVR2K, AVR1K}, |
3ccd393f | 158 | + {"atmega324pa", AVR32K, AVR2K, AVR1K}, |
997dccbb | 159 | + {"atmega325", AVR32K, AVR2K, AVR1K}, |
3ccd393f | 160 | + {"atmega325a", AVR32K, AVR2K, AVR1K}, |
997dccbb | 161 | + {"atmega325p", AVR32K, AVR2K, AVR1K}, |
162 | + {"atmega3250", AVR32K, AVR2K, AVR1K}, | |
3ccd393f | 163 | + {"atmega3250a", AVR32K, AVR2K, AVR1K}, |
997dccbb | 164 | + {"atmega3250p", AVR32K, AVR2K, AVR1K}, |
3ccd393f | 165 | + {"atmega328", AVR32K, AVR2K, AVR1K}, |
997dccbb | 166 | + {"atmega328p", AVR32K, AVR2K, AVR1K}, |
167 | + {"atmega329", AVR32K, AVR2K, AVR1K}, | |
3ccd393f | 168 | + {"atmega329a", AVR32K, AVR2K, AVR1K}, |
997dccbb | 169 | + {"atmega329p", AVR32K, AVR2K, AVR1K}, |
3ccd393f | 170 | + {"atmega329pa", AVR32K, AVR2K, AVR1K}, |
997dccbb | 171 | + {"atmega3290", AVR32K, AVR2K, AVR1K}, |
3ccd393f | 172 | + {"atmega3290a", AVR32K, AVR2K, AVR1K}, |
997dccbb | 173 | + {"atmega3290p", AVR32K, AVR2K, AVR1K}, |
174 | + {"atmega32hvb", AVR32K, AVR2K, AVR1K}, | |
175 | + {"atmega32c1", AVR32K, AVR2K, AVR1K}, | |
3ccd393f | 176 | + {"atmega32hvb", AVR32K, AVR2K, AVR1K}, |
997dccbb | 177 | + {"atmega32m1", AVR32K, AVR2K, AVR1K}, |
3ccd393f | 178 | + {"atmega32u2", AVR32K, AVR1K, AVR1K}, |
997dccbb | 179 | + {"atmega32u4", AVR32K, 2560UL, AVR1K}, |
180 | + {"atmega32u6", AVR32K, 2560UL, AVR1K}, | |
b0a81564 | 181 | + |
3ccd393f | 182 | + {"at43usb355", AVR24K, 1120UL, 0UL}, |
183 | + | |
184 | + {"atxmega16a4", AVR20K, AVR2K, AVR1K}, | |
185 | + {"atxmega16d4", AVR20K, AVR2K, AVR1K}, | |
b0a81564 | 186 | + |
3ccd393f | 187 | + {"at76c711", AVR16K, AVR2K, 0UL}, |
997dccbb | 188 | + {"at90pwm216", AVR16K, AVR1K, AVR512}, |
189 | + {"at90pwm316", AVR16K, AVR1K, AVR512}, | |
190 | + {"at90usb162", AVR16K, AVR512, AVR512}, | |
191 | + {"atmega16", AVR16K, AVR1K, AVR512}, | |
3ccd393f | 192 | + {"atmega16a", AVR16K, AVR1K, AVR512}, |
997dccbb | 193 | + {"atmega161", AVR16K, AVR1K, AVR512}, |
194 | + {"atmega162", AVR16K, AVR1K, AVR512}, | |
195 | + {"atmega163", AVR16K, AVR1K, AVR512}, | |
196 | + {"atmega164", AVR16K, AVR1K, AVR512}, | |
3ccd393f | 197 | + {"atmega164a", AVR16K, AVR1K, AVR512}, |
997dccbb | 198 | + {"atmega164p", AVR16K, AVR1K, AVR512}, |
3ccd393f | 199 | + {"atmega165a", AVR16K, AVR1K, AVR512}, |
997dccbb | 200 | + {"atmega165", AVR16K, AVR1K, AVR512}, |
201 | + {"atmega165p", AVR16K, AVR1K, AVR512}, | |
202 | + {"atmega168", AVR16K, AVR1K, AVR512}, | |
3ccd393f | 203 | + {"atmega168a", AVR16K, AVR1K, AVR512}, |
997dccbb | 204 | + {"atmega168p", AVR16K, AVR1K, AVR512}, |
205 | + {"atmega169", AVR16K, AVR1K, AVR512}, | |
3ccd393f | 206 | + {"atmega169a", AVR16K, AVR1K, AVR512}, |
997dccbb | 207 | + {"atmega169p", AVR16K, AVR1K, AVR512}, |
3ccd393f | 208 | + {"atmega169pa", AVR16K, AVR1K, AVR512}, |
209 | + {"atmega16hva", AVR16K, 768UL, AVR256}, | |
210 | + {"atmega16hva2", AVR16K, AVR1K, AVR256}, | |
211 | + {"atmega16hvb", AVR16K, AVR1K, AVR512}, | |
212 | + {"atmega16m1", AVR16K, AVR1K, AVR512}, | |
213 | + {"atmega16u2", AVR16K, AVR512, AVR512}, | |
997dccbb | 214 | + {"atmega16u4", AVR16K, 1280UL, AVR512}, |
215 | + {"attiny167", AVR16K, AVR512, AVR512}, | |
b0a81564 | 216 | + |
3ccd393f | 217 | + {"at90c8534", AVR8K, 352UL, AVR512}, |
997dccbb | 218 | + {"at90pwm1", AVR8K, AVR512, AVR512}, |
219 | + {"at90pwm2", AVR8K, AVR512, AVR512}, | |
220 | + {"at90pwm2b", AVR8K, AVR512, AVR512}, | |
221 | + {"at90pwm3", AVR8K, AVR512, AVR512}, | |
222 | + {"at90pwm3b", AVR8K, AVR512, AVR512}, | |
3ccd393f | 223 | + {"at90pwm81", AVR8K, AVR256, AVR512}, |
997dccbb | 224 | + {"at90s8515", AVR8K, AVR512, AVR512}, |
225 | + {"at90s8535", AVR8K, AVR512, AVR512}, | |
226 | + {"at90usb82", AVR8K, AVR512, AVR512}, | |
3ccd393f | 227 | + {"ata6289", AVR8K, AVR512, 320UL}, |
997dccbb | 228 | + {"atmega8", AVR8K, AVR1K, AVR512}, |
229 | + {"atmega8515", AVR8K, AVR512, AVR512}, | |
230 | + {"atmega8535", AVR8K, AVR512, AVR512}, | |
231 | + {"atmega88", AVR8K, AVR1K, AVR512}, | |
3ccd393f | 232 | + {"atmega88a", AVR8K, AVR1K, AVR512}, |
997dccbb | 233 | + {"atmega88p", AVR8K, AVR1K, AVR512}, |
3ccd393f | 234 | + {"atmega88pa", AVR8K, AVR1K, AVR512}, |
235 | + {"atmega8hva", AVR8K, 768UL, AVR256}, | |
236 | + {"atmega8u2", AVR8K, AVR512, AVR512}, | |
997dccbb | 237 | + {"attiny84", AVR8K, AVR512, AVR512}, |
3ccd393f | 238 | + {"attiny84a", AVR8K, AVR512, AVR512}, |
997dccbb | 239 | + {"attiny85", AVR8K, AVR512, AVR512}, |
240 | + {"attiny861", AVR8K, AVR512, AVR512}, | |
3ccd393f | 241 | + {"attiny861a", AVR8K, AVR512, AVR512}, |
242 | + {"attiny87", AVR8K, AVR512, AVR512}, | |
243 | + {"attiny88", AVR8K, AVR512, AVR64}, | |
b0a81564 | 244 | + |
3ccd393f | 245 | + {"at90s4414", AVR4K, 352UL, AVR256}, |
997dccbb | 246 | + {"at90s4433", AVR4K, AVR128, AVR256}, |
3ccd393f | 247 | + {"at90s4434", AVR4K, 352UL, AVR256}, |
997dccbb | 248 | + {"atmega48", AVR4K, AVR512, AVR256}, |
3ccd393f | 249 | + {"atmega48a", AVR4K, AVR512, AVR256}, |
997dccbb | 250 | + {"atmega48p", AVR4K, AVR512, AVR256}, |
3ccd393f | 251 | + {"attiny4313", AVR4K, AVR256, AVR256}, |
997dccbb | 252 | + {"attiny43u", AVR4K, AVR256, AVR64}, |
253 | + {"attiny44", AVR4K, AVR256, AVR256}, | |
3ccd393f | 254 | + {"attiny44a", AVR4K, AVR256, AVR256}, |
997dccbb | 255 | + {"attiny45", AVR4K, AVR256, AVR256}, |
256 | + {"attiny461", AVR4K, AVR256, AVR256}, | |
3ccd393f | 257 | + {"attiny461a", AVR4K, AVR256, AVR256}, |
997dccbb | 258 | + {"attiny48", AVR4K, AVR256, AVR64}, |
b0a81564 | 259 | + |
3ccd393f | 260 | + {"at86rf401", AVR2K, 224UL, AVR128}, |
997dccbb | 261 | + {"at90s2313", AVR2K, AVR128, AVR128}, |
262 | + {"at90s2323", AVR2K, AVR128, AVR128}, | |
3ccd393f | 263 | + {"at90s2333", AVR2K, 224UL, AVR128}, |
997dccbb | 264 | + {"at90s2343", AVR2K, AVR128, AVR128}, |
3ccd393f | 265 | + {"attiny20", AVR2K, AVR128, 0UL}, |
266 | + {"attiny22", AVR2K, 224UL, AVR128}, | |
997dccbb | 267 | + {"attiny2313", AVR2K, AVR128, AVR128}, |
3ccd393f | 268 | + {"attiny2313a", AVR2K, AVR128, AVR128}, |
997dccbb | 269 | + {"attiny24", AVR2K, AVR128, AVR128}, |
3ccd393f | 270 | + {"attiny24a", AVR2K, AVR128, AVR128}, |
997dccbb | 271 | + {"attiny25", AVR2K, AVR128, AVR128}, |
272 | + {"attiny26", AVR2K, AVR128, AVR128}, | |
273 | + {"attiny261", AVR2K, AVR128, AVR128}, | |
3ccd393f | 274 | + {"attiny261a", AVR2K, AVR128, AVR128}, |
275 | + {"attiny28", AVR2K, 0UL, 0UL}, | |
276 | + {"attiny40", AVR2K, AVR256, 0UL}, | |
b0a81564 | 277 | + |
3ccd393f | 278 | + {"at90s1200", AVR1K, 0UL, AVR64}, |
279 | + {"attiny9", AVR1K, 32UL, 0UL}, | |
280 | + {"attiny10", AVR1K, 32UL, 0UL}, | |
281 | + {"attiny11", AVR1K, 0UL, AVR64}, | |
282 | + {"attiny12", AVR1K, 0UL, AVR64}, | |
997dccbb | 283 | + {"attiny13", AVR1K, AVR64, AVR64}, |
3ccd393f | 284 | + {"attiny13a", AVR1K, AVR64, AVR64}, |
285 | + {"attiny15", AVR1K, 0UL, AVR64}, | |
286 | + | |
287 | + {"attiny4", AVR512, 32UL, 0UL}, | |
288 | + {"attiny5", AVR512, 32UL, 0UL}, | |
b0a81564 | 289 | +}; |
290 | + | |
291 | +static char *avrmcu = NULL; | |
292 | + | |
293 | + | |
294 | static char *target = NULL; | |
295 | ||
296 | /* Forward declarations. */ | |
3ccd393f | 297 | @@ -79,7 +337,8 @@ usage (FILE *stream, int status) |
b0a81564 | 298 | fprintf (stream, _(" Displays the sizes of sections inside binary files\n")); |
299 | fprintf (stream, _(" If no input file(s) are specified, a.out is assumed\n")); | |
300 | fprintf (stream, _(" The options are:\n\ | |
301 | - -A|-B --format={sysv|berkeley} Select output style (default is %s)\n\ | |
302 | + -A|-B|-C --format={sysv|berkeley|avr} Select output style (default is %s)\n\ | |
303 | + --mcu=<avrmcu> MCU name for AVR format only\n\ | |
304 | -o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex\n\ | |
305 | -t --totals Display the total sizes (Berkeley only)\n\ | |
306 | --common Display total size for *COM* syms\n\ | |
3ccd393f | 307 | @@ -88,11 +337,7 @@ usage (FILE *stream, int status) |
b0a81564 | 308 | -h --help Display this information\n\ |
309 | -v --version Display the program's version\n\ | |
310 | \n"), | |
311 | -#if BSD_DEFAULT | |
312 | - "berkeley" | |
313 | -#else | |
314 | - "sysv" | |
315 | -#endif | |
316 | +FORMAT_NAME | |
317 | ); | |
318 | list_supported_targets (program_name, stream); | |
319 | if (REPORT_BUGS_TO[0] && status == 0) | |
3ccd393f | 320 | @@ -103,6 +359,7 @@ usage (FILE *stream, int status) |
b0a81564 | 321 | #define OPTION_FORMAT (200) |
322 | #define OPTION_RADIX (OPTION_FORMAT + 1) | |
323 | #define OPTION_TARGET (OPTION_RADIX + 1) | |
324 | +#define OPTION_MCU (OPTION_TARGET + 1) | |
325 | ||
326 | static struct option long_options[] = | |
327 | { | |
3ccd393f | 328 | @@ -110,6 +368,7 @@ static struct option long_options[] = |
b0a81564 | 329 | {"format", required_argument, 0, OPTION_FORMAT}, |
330 | {"radix", required_argument, 0, OPTION_RADIX}, | |
331 | {"target", required_argument, 0, OPTION_TARGET}, | |
332 | + {"mcu", required_argument, 0, 203}, | |
333 | {"totals", no_argument, &show_totals, 1}, | |
334 | {"version", no_argument, &show_version, 1}, | |
335 | {"help", no_argument, &show_help, 1}, | |
3ccd393f | 336 | @@ -141,7 +399,7 @@ main (int argc, char **argv) |
b0a81564 | 337 | bfd_init (); |
338 | set_default_bfd_target (); | |
339 | ||
340 | - while ((c = getopt_long (argc, argv, "ABHhVvdfotx", long_options, | |
341 | + while ((c = getopt_long (argc, argv, "ABCHhVvdfotx", long_options, | |
342 | (int *) 0)) != EOF) | |
343 | switch (c) | |
344 | { | |
3ccd393f | 345 | @@ -150,11 +409,15 @@ main (int argc, char **argv) |
b0a81564 | 346 | { |
347 | case 'B': | |
348 | case 'b': | |
349 | - berkeley_format = 1; | |
350 | + format = format_bsd; | |
351 | break; | |
352 | case 'S': | |
353 | case 's': | |
354 | - berkeley_format = 0; | |
355 | + format = format_sysv; | |
356 | + break; | |
357 | + case 'A': | |
358 | + case 'a': | |
359 | + format = format_avr; | |
360 | break; | |
361 | default: | |
362 | non_fatal (_("invalid argument to --format: %s"), optarg); | |
3ccd393f | 363 | @@ -162,6 +424,10 @@ main (int argc, char **argv) |
b0a81564 | 364 | } |
365 | break; | |
366 | ||
367 | + case OPTION_MCU: | |
368 | + avrmcu = optarg; | |
369 | + break; | |
370 | + | |
371 | case OPTION_TARGET: | |
372 | target = optarg; | |
373 | break; | |
3ccd393f | 374 | @@ -190,11 +457,14 @@ main (int argc, char **argv) |
b0a81564 | 375 | break; |
376 | ||
377 | case 'A': | |
378 | - berkeley_format = 0; | |
379 | + format = format_sysv; | |
380 | break; | |
381 | case 'B': | |
382 | - berkeley_format = 1; | |
383 | + format = format_bsd; | |
384 | break; | |
385 | + case 'C': | |
386 | + format = format_avr; | |
387 | + break; | |
388 | case 'v': | |
389 | case 'V': | |
390 | show_version = 1; | |
3ccd393f | 391 | @@ -240,7 +509,7 @@ main (int argc, char **argv) |
b0a81564 | 392 | for (; optind < argc;) |
393 | display_file (argv[optind++]); | |
394 | ||
395 | - if (show_totals && berkeley_format) | |
396 | + if (show_totals && format == format_bsd) | |
397 | { | |
398 | bfd_size_type total = total_textsize + total_datasize + total_bsssize; | |
399 | ||
3ccd393f | 400 | @@ -599,13 +869,117 @@ print_sysv_format (bfd *file) |
b0a81564 | 401 | printf ("\n\n"); |
402 | } | |
403 | ||
404 | + | |
405 | +static avr_device_t * | |
406 | +avr_find_device (void) | |
407 | +{ | |
408 | + unsigned int i; | |
409 | + if (avrmcu != NULL) | |
410 | + { | |
411 | + for (i = 0; i < sizeof(avr) / sizeof(avr[0]); i++) | |
412 | + { | |
413 | + if (strcmp(avr[i].name, avrmcu) == 0) | |
414 | + { | |
415 | + /* Match found */ | |
416 | + return (&avr[i]); | |
417 | + } | |
418 | + } | |
419 | + } | |
420 | + return (NULL); | |
421 | +} | |
422 | + | |
423 | + | |
424 | + | |
425 | +static void | |
426 | +print_avr_format (bfd *file) | |
427 | +{ | |
428 | + char *avr_name = "Unknown"; | |
429 | + int flashmax = 0; | |
430 | + int rammax = 0; | |
431 | + int eeprommax = 0; | |
432 | + asection *section; | |
3ccd393f | 433 | + bfd_size_type datasize = 0; |
434 | + bfd_size_type textsize = 0; | |
435 | + bfd_size_type bsssize = 0; | |
b0a81564 | 436 | + bfd_size_type bootloadersize = 0; |
437 | + bfd_size_type noinitsize = 0; | |
438 | + bfd_size_type eepromsize = 0; | |
439 | + | |
440 | + avr_device_t *avrdevice = avr_find_device(); | |
441 | + if (avrdevice != NULL) | |
442 | + { | |
443 | + avr_name = avrdevice->name; | |
444 | + flashmax = avrdevice->flash; | |
445 | + rammax = avrdevice->ram; | |
446 | + eeprommax = avrdevice->eeprom; | |
447 | + } | |
448 | + | |
449 | + if ((section = bfd_get_section_by_name (file, ".data")) != NULL) | |
3ccd393f | 450 | + datasize = bfd_section_size (file, section); |
b0a81564 | 451 | + if ((section = bfd_get_section_by_name (file, ".text")) != NULL) |
3ccd393f | 452 | + textsize = bfd_section_size (file, section); |
b0a81564 | 453 | + if ((section = bfd_get_section_by_name (file, ".bss")) != NULL) |
3ccd393f | 454 | + bsssize = bfd_section_size (file, section); |
b0a81564 | 455 | + if ((section = bfd_get_section_by_name (file, ".bootloader")) != NULL) |
456 | + bootloadersize = bfd_section_size (file, section); | |
457 | + if ((section = bfd_get_section_by_name (file, ".noinit")) != NULL) | |
458 | + noinitsize = bfd_section_size (file, section); | |
459 | + if ((section = bfd_get_section_by_name (file, ".eeprom")) != NULL) | |
460 | + eepromsize = bfd_section_size (file, section); | |
461 | + | |
3ccd393f | 462 | + bfd_size_type text = textsize + datasize + bootloadersize; |
463 | + bfd_size_type data = datasize + bsssize + noinitsize; | |
b0a81564 | 464 | + bfd_size_type eeprom = eepromsize; |
465 | + | |
466 | + printf ("AVR Memory Usage\n" | |
467 | + "----------------\n" | |
468 | + "Device: %s\n\n", avr_name); | |
469 | + | |
470 | + /* Text size */ | |
471 | + printf ("Program:%8ld bytes", text); | |
472 | + if (flashmax > 0) | |
473 | + { | |
474 | + printf (" (%2.1f%% Full)", ((float)text / flashmax) * 100); | |
475 | + } | |
476 | + printf ("\n(.text + .data + .bootloader)\n\n"); | |
477 | + | |
478 | + /* Data size */ | |
479 | + printf ("Data: %8ld bytes", data); | |
480 | + if (rammax > 0) | |
481 | + { | |
482 | + printf (" (%2.1f%% Full)", ((float)data / rammax) * 100); | |
483 | + } | |
484 | + printf ("\n(.data + .bss + .noinit)\n\n"); | |
485 | + | |
486 | + /* EEPROM size */ | |
487 | + if (eeprom > 0) | |
488 | + { | |
489 | + printf ("EEPROM: %8ld bytes", eeprom); | |
490 | + if (eeprommax > 0) | |
491 | + { | |
492 | + printf (" (%2.1f%% Full)", ((float)eeprom / eeprommax) * 100); | |
493 | + } | |
494 | + printf ("\n(.eeprom)\n\n"); | |
495 | + } | |
496 | +} | |
497 | + | |
498 | + | |
499 | static void | |
500 | print_sizes (bfd *file) | |
501 | { | |
502 | if (show_common) | |
503 | calculate_common_size (file); | |
504 | - if (berkeley_format) | |
505 | - print_berkeley_format (file); | |
506 | - else | |
507 | - print_sysv_format (file); | |
508 | + switch (format) | |
509 | + { | |
510 | + case format_sysv: | |
511 | + print_sysv_format (file); | |
512 | + break; | |
513 | + case format_bsd: | |
514 | + print_berkeley_format (file); | |
515 | + break; | |
516 | + case format_avr: | |
517 | + default: | |
518 | + print_avr_format (file); | |
519 | + break; | |
520 | + } | |
521 | } |