]> git.pld-linux.org Git - packages/crossavr-binutils.git/blame - 200-binutils-avr-size.patch
- release 2 (x32 rebuild)
[packages/crossavr-binutils.git] / 200-binutils-avr-size.patch
CommitLineData
31ce1ede
JR
1diff -Naurp binutils/size.c binutils/size.c
2--- binutils/size.c 2013-02-06 16:32:42.000000000 +0530
3+++ binutils/size.c 2013-02-06 16:53:39.000000000 +0530
3ccd393f 4@@ -36,10 +36,31 @@
b0a81564 5 #include "getopt.h"
6 #include "bucomm.h"
7
8-#ifndef BSD_DEFAULT
9-#define BSD_DEFAULT 1
10+typedef enum
11+{
12+ format_sysv = 0,
13+ format_bsd = 1,
14+ format_avr = 2,
15+} format_type_t;
16+
17+
18+/* Set the default format. */
19+#define FORMAT_DEFAULT_SYSV 0
20+#define FORMAT_DEFAULT_BSD 1
21+#define FORMAT_DEFAULT_AVR 0
22+
23+#if FORMAT_DEFAULT_SYSV
24+ #define FORMAT_DEFAULT format_sysv
25+ #define FORMAT_NAME "sysv"
26+#elif FORMAT_DEFAULT_BSD
27+ #define FORMAT_DEFAULT format_bsd
28+ #define FORMAT_NAME "berkeley"
29+#elif FORMAT_DEFAULT_AVR
30+ #define FORMAT_DEFAULT format_avr
31+ #define FORMAT_NAME "avr"
32 #endif
33
34+
35 /* Program options. */
36
37 static enum
3ccd393f 38@@ -48,9 +69,8 @@ static enum
b0a81564 39 }
40 radix = decimal;
41
42-/* 0 means use AT&T-style output. */
43-static int berkeley_format = BSD_DEFAULT;
44
45+format_type_t format = FORMAT_DEFAULT;
46 static int show_version = 0;
47 static int show_help = 0;
48 static int show_totals = 0;
31ce1ede 49@@ -64,6 +84,308 @@ static bfd_size_type total_textsize;
b0a81564 50 /* Program exit status. */
51 static int return_code = 0;
52
53+
54+/* AVR Size specific stuff */
55+
56+#define AVR64 64UL
57+#define AVR128 128UL
58+#define AVR256 256UL
59+#define AVR512 512UL
31ce1ede 60+#define AVR2112 2112UL
b0a81564 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
31ce1ede
JR
78+#define AVR384K 393216UL
79+#define AVR392K 401408UL
b0a81564 80+
81+typedef struct
82+{
83+ char *name;
84+ long flash;
85+ long ram;
86+ long eeprom;
87+} avr_device_t;
88+
89+avr_device_t avr[] =
90+{
31ce1ede
JR
91+ {"atxmega384c3", AVR392K, AVR32K, AVR4K},
92+
93+ {"atxmega384d3", AVR384K, AVR16K, AVR4K},
94+
95+ {"atmega256rfr2", AVR256K, AVR32K, AVR8K},
96+ {"atmega2564rfr2",AVR256K, AVR32K, AVR8K},
97+
98+ {"atxmega256a3", AVR264K, AVR16K, AVR4K},
99+ {"atxmega256a3u", AVR264K, AVR16K, AVR4K},
100+ {"atxmega256a3b", AVR264K, AVR16K, AVR4K},
101+ {"atxmega256a3bu",AVR264K, AVR16K, AVR4K},
102+ {"atxmega256c3", AVR264K, AVR16K, AVR4K},
103+ {"atxmega256d3", AVR264K, AVR16K, AVR4K},
104+
105+ {"atmega2560", AVR256K, AVR8K, AVR4K},
106+ {"atmega2561", AVR256K, AVR8K, AVR4K},
107+
108+ {"atxmega192a3", AVR200K, AVR16K, AVR2K},
109+ {"atxmega192a3u", AVR200K, AVR16K, AVR2K},
110+ {"atxmega192c3", AVR200K, AVR16K, AVR2K},
111+ {"atxmega192d3", AVR200K, AVR16K, AVR2K},
112+
113+ {"atmega128rfr2", AVR128K, AVR16K, AVR4K},
114+ {"atmega1284rfr2",AVR128K, AVR16K, AVR4K},
115+
116+ {"atxmega128a1", AVR136K, AVR8K, AVR2K},
117+ {"atxmega128a1u", AVR136K, AVR8K, AVR2K},
118+ {"atxmega128a4u", AVR136K, AVR8K, AVR2K},
119+ {"atxmega128a3", AVR136K, AVR8K, AVR2K},
120+ {"atxmega128a3u", AVR136K, AVR8K, AVR2K},
121+ {"atxmega128b1", AVR136K, AVR8K, AVR2K},
122+ {"atxmega128b3", AVR136K, AVR8K, AVR2K},
123+ {"atxmega128c3", AVR136K, AVR8K, AVR2K},
124+ {"atxmega128d3", AVR136K, AVR8K, AVR2K},
125+ {"atxmega128d4", AVR136K, AVR8K, AVR2K},
126+
127+ {"at43usb320", AVR128K, 608UL, 0UL},
128+ {"at90can128", AVR128K, AVR4K, AVR4K},
129+ {"at90usb1286", AVR128K, AVR8K, AVR4K},
130+ {"at90usb1287", AVR128K, AVR8K, AVR4K},
131+ {"atmega128", AVR128K, AVR4K, AVR4K},
132+ {"atmega128a", AVR128K, AVR4K, AVR4K},
133+ {"atmega1280", AVR128K, AVR8K, AVR4K},
134+ {"atmega1281", AVR128K, AVR8K, AVR4K},
135+ {"atmega1284", AVR128K, AVR16K, AVR4K},
136+ {"atmega1284p", AVR128K, AVR16K, AVR4K},
137+ {"atmega128rfa1", AVR128K, AVR16K, AVR4K},
138+ {"atmega103", AVR128K, 4000UL, AVR4K},
3ccd393f 139+
140+ {"atxmega64a1", AVR68K, AVR4K, AVR2K},
141+ {"atxmega64a1u", AVR68K, AVR4K, AVR2K},
142+ {"atxmega64a3", AVR68K, AVR4K, AVR2K},
31ce1ede
JR
143+ {"atxmega64a3u", AVR68K, AVR4K, AVR2K},
144+ {"atxmega64a4u", AVR68K, AVR4K, AVR2K},
145+ {"atxmega64b1", AVR68K, AVR4K, AVR2K},
146+ {"atxmega64b3", AVR68K, AVR4K, AVR2K},
147+ {"atxmega64c3", AVR68K, AVR4K, AVR2K},
3ccd393f 148+ {"atxmega64d3", AVR68K, AVR4K, AVR2K},
31ce1ede
JR
149+ {"atxmega64d4", AVR68K, AVR4K, AVR2K},
150+
151+ {"atmega64rfr2", AVR64K, AVR8K, AVR2K},
152+ {"atmega644rfr2", AVR64K, AVR8K, AVR2K},
b0a81564 153+
997dccbb 154+ {"at90can64", AVR64K, AVR4K, AVR2K},
3ccd393f 155+ {"at90scr100", AVR64K, AVR4K, AVR2K},
997dccbb 156+ {"at90usb646", AVR64K, AVR4K, AVR2K},
157+ {"at90usb647", AVR64K, AVR4K, AVR2K},
31ce1ede
JR
158+ {"ata5505", AVR16K, AVR512, AVR512},
159+ {"ata5790", AVR16K, AVR512, AVR2112},
160+ {"ata5795", AVR8K, AVR512, AVR2112},
161+ {"ata5272", AVR8K, AVR512, AVR512},
997dccbb 162+ {"atmega64", AVR64K, AVR4K, AVR2K},
31ce1ede 163+ {"atmega64a", AVR64K, AVR4K, AVR2K},
997dccbb 164+ {"atmega640", AVR64K, AVR8K, AVR4K},
165+ {"atmega644", AVR64K, AVR4K, AVR2K},
3ccd393f 166+ {"atmega644a", AVR64K, AVR4K, AVR2K},
997dccbb 167+ {"atmega644p", AVR64K, AVR4K, AVR2K},
3ccd393f 168+ {"atmega644pa", AVR64K, AVR4K, AVR2K},
997dccbb 169+ {"atmega645", AVR64K, AVR4K, AVR2K},
3ccd393f 170+ {"atmega645a", AVR64K, AVR4K, AVR2K},
171+ {"atmega645p", AVR64K, AVR4K, AVR2K},
997dccbb 172+ {"atmega6450", AVR64K, AVR4K, AVR2K},
3ccd393f 173+ {"atmega6450a", AVR64K, AVR4K, AVR2K},
174+ {"atmega6450p", AVR64K, AVR4K, AVR2K},
997dccbb 175+ {"atmega649", AVR64K, AVR4K, AVR2K},
3ccd393f 176+ {"atmega649a", AVR64K, AVR4K, AVR2K},
177+ {"atmega649p", AVR64K, AVR4K, AVR2K},
997dccbb 178+ {"atmega6490", AVR64K, AVR4K, AVR2K},
3ccd393f 179+ {"atmega6490a", AVR64K, AVR4K, AVR2K},
180+ {"atmega6490p", AVR64K, AVR4K, AVR2K},
181+ {"atmega64c1", AVR64K, AVR4K, AVR2K},
182+ {"atmega64hve", AVR64K, AVR4K, AVR1K},
183+ {"atmega64m1", AVR64K, AVR4K, AVR2K},
31ce1ede 184+ {"m3000", AVR64K, AVR4K, 0UL},
b0a81564 185+
3ccd393f 186+ {"atmega406", AVR40K, AVR2K, AVR512},
187+
188+ {"atxmega32a4", AVR36K, AVR4K, AVR1K},
31ce1ede
JR
189+ {"atxmega32a4u", AVR36K, AVR4K, AVR1K},
190+ {"atxmega32c4", AVR36K, AVR4K, AVR1K},
3ccd393f 191+ {"atxmega32d4", AVR36K, AVR4K, AVR1K},
31ce1ede
JR
192+ {"atxmega32e5", AVR36K, AVR4K, AVR1K},
193+ {"atxmega16e5", AVR20K, AVR2K, AVR512},
194+ {"atxmega8e5", AVR10K, AVR1K, AVR512},
b0a81564 195+
997dccbb 196+ {"at90can32", AVR32K, AVR2K, AVR1K},
3ccd393f 197+ {"at94k", AVR32K, AVR4K, 0UL},
997dccbb 198+ {"atmega32", AVR32K, AVR2K, AVR1K},
31ce1ede 199+ {"atmega32a", AVR32K, AVR2K, AVR1K},
997dccbb 200+ {"atmega323", AVR32K, AVR2K, AVR1K},
3ccd393f 201+ {"atmega324a", AVR32K, AVR2K, AVR1K},
997dccbb 202+ {"atmega324p", AVR32K, AVR2K, AVR1K},
3ccd393f 203+ {"atmega324pa", AVR32K, AVR2K, AVR1K},
997dccbb 204+ {"atmega325", AVR32K, AVR2K, AVR1K},
3ccd393f 205+ {"atmega325a", AVR32K, AVR2K, AVR1K},
997dccbb 206+ {"atmega325p", AVR32K, AVR2K, AVR1K},
31ce1ede 207+ {"atmega325pa", AVR32K, AVR2K, AVR1K},
997dccbb 208+ {"atmega3250", AVR32K, AVR2K, AVR1K},
3ccd393f 209+ {"atmega3250a", AVR32K, AVR2K, AVR1K},
997dccbb 210+ {"atmega3250p", AVR32K, AVR2K, AVR1K},
31ce1ede 211+ {"atmega3250pa", AVR32K, AVR2K, AVR1K},
3ccd393f 212+ {"atmega328", AVR32K, AVR2K, AVR1K},
997dccbb 213+ {"atmega328p", AVR32K, AVR2K, AVR1K},
214+ {"atmega329", AVR32K, AVR2K, AVR1K},
3ccd393f 215+ {"atmega329a", AVR32K, AVR2K, AVR1K},
997dccbb 216+ {"atmega329p", AVR32K, AVR2K, AVR1K},
3ccd393f 217+ {"atmega329pa", AVR32K, AVR2K, AVR1K},
997dccbb 218+ {"atmega3290", AVR32K, AVR2K, AVR1K},
3ccd393f 219+ {"atmega3290a", AVR32K, AVR2K, AVR1K},
997dccbb 220+ {"atmega3290p", AVR32K, AVR2K, AVR1K},
31ce1ede 221+ {"atmega3290pa", AVR32K, AVR2K, AVR1K},
997dccbb 222+ {"atmega32hvb", AVR32K, AVR2K, AVR1K},
31ce1ede 223+ {"atmega32hvbrevb",AVR32K, AVR2K, AVR1K},
997dccbb 224+ {"atmega32c1", AVR32K, AVR2K, AVR1K},
225+ {"atmega32m1", AVR32K, AVR2K, AVR1K},
3ccd393f 226+ {"atmega32u2", AVR32K, AVR1K, AVR1K},
997dccbb 227+ {"atmega32u4", AVR32K, 2560UL, AVR1K},
228+ {"atmega32u6", AVR32K, 2560UL, AVR1K},
b0a81564 229+
3ccd393f 230+ {"at43usb355", AVR24K, 1120UL, 0UL},
231+
232+ {"atxmega16a4", AVR20K, AVR2K, AVR1K},
31ce1ede
JR
233+ {"atxmega16a4u", AVR20K, AVR2K, AVR1K},
234+ {"atxmega16c4", AVR20K, AVR2K, AVR1K},
3ccd393f 235+ {"atxmega16d4", AVR20K, AVR2K, AVR1K},
b0a81564 236+
3ccd393f 237+ {"at76c711", AVR16K, AVR2K, 0UL},
31ce1ede 238+ {"at90pwm161", AVR16K, AVR1K, AVR512},
997dccbb 239+ {"at90pwm216", AVR16K, AVR1K, AVR512},
240+ {"at90pwm316", AVR16K, AVR1K, AVR512},
241+ {"at90usb162", AVR16K, AVR512, AVR512},
242+ {"atmega16", AVR16K, AVR1K, AVR512},
3ccd393f 243+ {"atmega16a", AVR16K, AVR1K, AVR512},
997dccbb 244+ {"atmega161", AVR16K, AVR1K, AVR512},
245+ {"atmega162", AVR16K, AVR1K, AVR512},
246+ {"atmega163", AVR16K, AVR1K, AVR512},
247+ {"atmega164", AVR16K, AVR1K, AVR512},
3ccd393f 248+ {"atmega164a", AVR16K, AVR1K, AVR512},
997dccbb 249+ {"atmega164p", AVR16K, AVR1K, AVR512},
31ce1ede 250+ {"atmega164pa", AVR16K, AVR1K, AVR512},
3ccd393f 251+ {"atmega165a", AVR16K, AVR1K, AVR512},
997dccbb 252+ {"atmega165", AVR16K, AVR1K, AVR512},
253+ {"atmega165p", AVR16K, AVR1K, AVR512},
31ce1ede 254+ {"atmega165pa", AVR16K, AVR1K, AVR512},
997dccbb 255+ {"atmega168", AVR16K, AVR1K, AVR512},
3ccd393f 256+ {"atmega168a", AVR16K, AVR1K, AVR512},
997dccbb 257+ {"atmega168p", AVR16K, AVR1K, AVR512},
31ce1ede 258+ {"atmega168pa", AVR16K, AVR1K, AVR512},
997dccbb 259+ {"atmega169", AVR16K, AVR1K, AVR512},
3ccd393f 260+ {"atmega169a", AVR16K, AVR1K, AVR512},
997dccbb 261+ {"atmega169p", AVR16K, AVR1K, AVR512},
3ccd393f 262+ {"atmega169pa", AVR16K, AVR1K, AVR512},
263+ {"atmega16hva", AVR16K, 768UL, AVR256},
264+ {"atmega16hva2", AVR16K, AVR1K, AVR256},
31ce1ede
JR
265+ {"atmega16hvb", AVR16K, AVR1K, AVR512},
266+ {"atmega16hvbrevb",AVR16K, AVR1K, AVR512},
3ccd393f 267+ {"atmega16m1", AVR16K, AVR1K, AVR512},
31ce1ede 268+ {"attiny1634", AVR16K, AVR1K, AVR256},
3ccd393f 269+ {"atmega16u2", AVR16K, AVR512, AVR512},
997dccbb 270+ {"atmega16u4", AVR16K, 1280UL, AVR512},
271+ {"attiny167", AVR16K, AVR512, AVR512},
b0a81564 272+
3ccd393f 273+ {"at90c8534", AVR8K, 352UL, AVR512},
997dccbb 274+ {"at90pwm1", AVR8K, AVR512, AVR512},
275+ {"at90pwm2", AVR8K, AVR512, AVR512},
276+ {"at90pwm2b", AVR8K, AVR512, AVR512},
277+ {"at90pwm3", AVR8K, AVR512, AVR512},
278+ {"at90pwm3b", AVR8K, AVR512, AVR512},
3ccd393f 279+ {"at90pwm81", AVR8K, AVR256, AVR512},
997dccbb 280+ {"at90s8515", AVR8K, AVR512, AVR512},
281+ {"at90s8535", AVR8K, AVR512, AVR512},
282+ {"at90usb82", AVR8K, AVR512, AVR512},
31ce1ede
JR
283+ {"ata6285", AVR8K, AVR512, 320UL},
284+ {"ata6286", AVR8K, AVR512, 320UL},
3ccd393f 285+ {"ata6289", AVR8K, AVR512, 320UL},
997dccbb 286+ {"atmega8", AVR8K, AVR1K, AVR512},
31ce1ede 287+ {"atmega8a", AVR8K, AVR1K, AVR512},
997dccbb 288+ {"atmega8515", AVR8K, AVR512, AVR512},
289+ {"atmega8535", AVR8K, AVR512, AVR512},
290+ {"atmega88", AVR8K, AVR1K, AVR512},
3ccd393f 291+ {"atmega88a", AVR8K, AVR1K, AVR512},
997dccbb 292+ {"atmega88p", AVR8K, AVR1K, AVR512},
3ccd393f 293+ {"atmega88pa", AVR8K, AVR1K, AVR512},
294+ {"atmega8hva", AVR8K, 768UL, AVR256},
295+ {"atmega8u2", AVR8K, AVR512, AVR512},
997dccbb 296+ {"attiny84", AVR8K, AVR512, AVR512},
3ccd393f 297+ {"attiny84a", AVR8K, AVR512, AVR512},
997dccbb 298+ {"attiny85", AVR8K, AVR512, AVR512},
299+ {"attiny861", AVR8K, AVR512, AVR512},
3ccd393f 300+ {"attiny861a", AVR8K, AVR512, AVR512},
301+ {"attiny87", AVR8K, AVR512, AVR512},
302+ {"attiny88", AVR8K, AVR512, AVR64},
b0a81564 303+
3ccd393f 304+ {"at90s4414", AVR4K, 352UL, AVR256},
997dccbb 305+ {"at90s4433", AVR4K, AVR128, AVR256},
3ccd393f 306+ {"at90s4434", AVR4K, 352UL, AVR256},
997dccbb 307+ {"atmega48", AVR4K, AVR512, AVR256},
3ccd393f 308+ {"atmega48a", AVR4K, AVR512, AVR256},
31ce1ede 309+ {"atmega48pa", AVR4K, AVR512, AVR256},
997dccbb 310+ {"atmega48p", AVR4K, AVR512, AVR256},
3ccd393f 311+ {"attiny4313", AVR4K, AVR256, AVR256},
997dccbb 312+ {"attiny43u", AVR4K, AVR256, AVR64},
313+ {"attiny44", AVR4K, AVR256, AVR256},
3ccd393f 314+ {"attiny44a", AVR4K, AVR256, AVR256},
997dccbb 315+ {"attiny45", AVR4K, AVR256, AVR256},
316+ {"attiny461", AVR4K, AVR256, AVR256},
3ccd393f 317+ {"attiny461a", AVR4K, AVR256, AVR256},
997dccbb 318+ {"attiny48", AVR4K, AVR256, AVR64},
31ce1ede 319+ {"attiny828", AVR8K, AVR512, AVR256},
b0a81564 320+
3ccd393f 321+ {"at86rf401", AVR2K, 224UL, AVR128},
997dccbb 322+ {"at90s2313", AVR2K, AVR128, AVR128},
323+ {"at90s2323", AVR2K, AVR128, AVR128},
3ccd393f 324+ {"at90s2333", AVR2K, 224UL, AVR128},
997dccbb 325+ {"at90s2343", AVR2K, AVR128, AVR128},
31ce1ede 326+ {"attiny20", AVR2K, AVR128, 0UL},
3ccd393f 327+ {"attiny22", AVR2K, 224UL, AVR128},
997dccbb 328+ {"attiny2313", AVR2K, AVR128, AVR128},
3ccd393f 329+ {"attiny2313a", AVR2K, AVR128, AVR128},
997dccbb 330+ {"attiny24", AVR2K, AVR128, AVR128},
3ccd393f 331+ {"attiny24a", AVR2K, AVR128, AVR128},
997dccbb 332+ {"attiny25", AVR2K, AVR128, AVR128},
333+ {"attiny26", AVR2K, AVR128, AVR128},
334+ {"attiny261", AVR2K, AVR128, AVR128},
3ccd393f 335+ {"attiny261a", AVR2K, AVR128, AVR128},
336+ {"attiny28", AVR2K, 0UL, 0UL},
31ce1ede 337+ {"attiny40", AVR2K, AVR256, 0UL},
b0a81564 338+
3ccd393f 339+ {"at90s1200", AVR1K, 0UL, AVR64},
31ce1ede
JR
340+ {"attiny9", AVR1K, 32UL, 0UL},
341+ {"attiny10", AVR1K, 32UL, 0UL},
3ccd393f 342+ {"attiny11", AVR1K, 0UL, AVR64},
343+ {"attiny12", AVR1K, 0UL, AVR64},
997dccbb 344+ {"attiny13", AVR1K, AVR64, AVR64},
3ccd393f 345+ {"attiny13a", AVR1K, AVR64, AVR64},
346+ {"attiny15", AVR1K, 0UL, AVR64},
347+
31ce1ede
JR
348+ {"attiny4", AVR512, 32UL, 0UL},
349+ {"attiny5", AVR512, 32UL, 0UL},
b0a81564 350+};
351+
352+static char *avrmcu = NULL;
353+
354+
355 static char *target = NULL;
356
357 /* Forward declarations. */
31ce1ede 358@@ -79,7 +401,9 @@ usage (FILE *stream, int status)
b0a81564 359 fprintf (stream, _(" Displays the sizes of sections inside binary files\n"));
360 fprintf (stream, _(" If no input file(s) are specified, a.out is assumed\n"));
361 fprintf (stream, _(" The options are:\n\
362- -A|-B --format={sysv|berkeley} Select output style (default is %s)\n\
363+ -A|-B|-C --format={sysv|berkeley|avr} Select output style (default is %s)\n\
364+ --mcu=<avrmcu> MCU name for AVR format only\n\
31ce1ede 365+ --mlist-devices List all supported MCUs\n\
b0a81564 366 -o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex\n\
367 -t --totals Display the total sizes (Berkeley only)\n\
368 --common Display total size for *COM* syms\n\
31ce1ede 369@@ -88,11 +412,7 @@ usage (FILE *stream, int status)
b0a81564 370 -h --help Display this information\n\
371 -v --version Display the program's version\n\
372 \n"),
373-#if BSD_DEFAULT
374- "berkeley"
375-#else
376- "sysv"
377-#endif
378+FORMAT_NAME
379 );
380 list_supported_targets (program_name, stream);
381 if (REPORT_BUGS_TO[0] && status == 0)
31ce1ede 382@@ -103,6 +423,8 @@ usage (FILE *stream, int status)
b0a81564 383 #define OPTION_FORMAT (200)
384 #define OPTION_RADIX (OPTION_FORMAT + 1)
385 #define OPTION_TARGET (OPTION_RADIX + 1)
386+#define OPTION_MCU (OPTION_TARGET + 1)
31ce1ede 387+#define OPTION_MLIST_DEVICES (OPTION_MCU + 1)
b0a81564 388
389 static struct option long_options[] =
390 {
31ce1ede 391@@ -110,12 +432,38 @@ static struct option long_options[] =
b0a81564 392 {"format", required_argument, 0, OPTION_FORMAT},
393 {"radix", required_argument, 0, OPTION_RADIX},
394 {"target", required_argument, 0, OPTION_TARGET},
395+ {"mcu", required_argument, 0, 203},
31ce1ede 396+ {"mlist-devices", no_argument, 0, OPTION_MLIST_DEVICES},
b0a81564 397 {"totals", no_argument, &show_totals, 1},
398 {"version", no_argument, &show_version, 1},
399 {"help", no_argument, &show_help, 1},
31ce1ede
JR
400 {0, no_argument, 0, 0}
401 };
402
403+static void list_supported_devices (FILE *stream, int status)
404+{
405+ unsigned int i ;
406+ int llen = 0;
407+ fprintf (stream, _("List of supported devices:\n"));
408+ for (i = 0; i < sizeof(avr) / sizeof(avr[0]); i++)
409+ {
410+ int slen = strlen(avr[i].name);
411+ llen += slen + 1 ;
412+ if (llen < 75)
413+ {
414+ fprintf (stream, _(" %s"), avr[i].name);
415+ }
416+ else
417+ {
418+ fprintf (stream, _("\n %s"), avr[i].name);
419+ llen = slen + 2 ;
420+ }
421+ }
422+ fprintf (stream, "\n");
423+
424+ exit (status);
425+}
426+
427 int main (int, char **);
428
429 int
430@@ -141,7 +489,7 @@ main (int argc, char **argv)
b0a81564 431 bfd_init ();
432 set_default_bfd_target ();
433
434- while ((c = getopt_long (argc, argv, "ABHhVvdfotx", long_options,
435+ while ((c = getopt_long (argc, argv, "ABCHhVvdfotx", long_options,
436 (int *) 0)) != EOF)
437 switch (c)
438 {
31ce1ede 439@@ -150,11 +498,15 @@ main (int argc, char **argv)
b0a81564 440 {
441 case 'B':
442 case 'b':
443- berkeley_format = 1;
444+ format = format_bsd;
445 break;
446 case 'S':
447 case 's':
448- berkeley_format = 0;
449+ format = format_sysv;
450+ break;
451+ case 'A':
452+ case 'a':
453+ format = format_avr;
454 break;
455 default:
456 non_fatal (_("invalid argument to --format: %s"), optarg);
31ce1ede 457@@ -162,6 +514,14 @@ main (int argc, char **argv)
b0a81564 458 }
459 break;
460
461+ case OPTION_MCU:
462+ avrmcu = optarg;
463+ break;
31ce1ede
JR
464+
465+ case OPTION_MLIST_DEVICES:
466+ list_supported_devices (stdout, 1);
467+ break;
b0a81564 468+
469 case OPTION_TARGET:
470 target = optarg;
471 break;
31ce1ede 472@@ -190,11 +550,14 @@ main (int argc, char **argv)
b0a81564 473 break;
474
475 case 'A':
476- berkeley_format = 0;
477+ format = format_sysv;
478 break;
479 case 'B':
480- berkeley_format = 1;
481+ format = format_bsd;
482 break;
483+ case 'C':
484+ format = format_avr;
485+ break;
486 case 'v':
487 case 'V':
488 show_version = 1;
31ce1ede 489@@ -240,7 +603,7 @@ main (int argc, char **argv)
b0a81564 490 for (; optind < argc;)
491 display_file (argv[optind++]);
492
493- if (show_totals && berkeley_format)
494+ if (show_totals && format == format_bsd)
495 {
496 bfd_size_type total = total_textsize + total_datasize + total_bsssize;
497
31ce1ede 498@@ -599,13 +962,117 @@ print_sysv_format (bfd *file)
b0a81564 499 printf ("\n\n");
500 }
501
502+
503+static avr_device_t *
504+avr_find_device (void)
505+{
506+ unsigned int i;
507+ if (avrmcu != NULL)
508+ {
509+ for (i = 0; i < sizeof(avr) / sizeof(avr[0]); i++)
510+ {
511+ if (strcmp(avr[i].name, avrmcu) == 0)
512+ {
513+ /* Match found */
514+ return (&avr[i]);
515+ }
516+ }
517+ }
518+ return (NULL);
519+}
520+
521+
522+
523+static void
524+print_avr_format (bfd *file)
525+{
526+ char *avr_name = "Unknown";
527+ int flashmax = 0;
528+ int rammax = 0;
529+ int eeprommax = 0;
530+ asection *section;
30f666e7
PZ
531+ bfd_size_type avr_datasize = 0;
532+ bfd_size_type avr_textsize = 0;
533+ bfd_size_type avr_bsssize = 0;
b0a81564 534+ bfd_size_type bootloadersize = 0;
535+ bfd_size_type noinitsize = 0;
536+ bfd_size_type eepromsize = 0;
537+
538+ avr_device_t *avrdevice = avr_find_device();
539+ if (avrdevice != NULL)
540+ {
541+ avr_name = avrdevice->name;
542+ flashmax = avrdevice->flash;
543+ rammax = avrdevice->ram;
544+ eeprommax = avrdevice->eeprom;
545+ }
546+
547+ if ((section = bfd_get_section_by_name (file, ".data")) != NULL)
30f666e7 548+ avr_datasize = bfd_section_size (file, section);
b0a81564 549+ if ((section = bfd_get_section_by_name (file, ".text")) != NULL)
30f666e7 550+ avr_textsize = bfd_section_size (file, section);
b0a81564 551+ if ((section = bfd_get_section_by_name (file, ".bss")) != NULL)
30f666e7 552+ avr_bsssize = bfd_section_size (file, section);
b0a81564 553+ if ((section = bfd_get_section_by_name (file, ".bootloader")) != NULL)
554+ bootloadersize = bfd_section_size (file, section);
555+ if ((section = bfd_get_section_by_name (file, ".noinit")) != NULL)
556+ noinitsize = bfd_section_size (file, section);
557+ if ((section = bfd_get_section_by_name (file, ".eeprom")) != NULL)
558+ eepromsize = bfd_section_size (file, section);
559+
30f666e7
PZ
560+ bfd_size_type text = avr_textsize + avr_datasize + bootloadersize;
561+ bfd_size_type data = avr_datasize + avr_bsssize + noinitsize;
b0a81564 562+ bfd_size_type eeprom = eepromsize;
563+
564+ printf ("AVR Memory Usage\n"
565+ "----------------\n"
566+ "Device: %s\n\n", avr_name);
567+
568+ /* Text size */
569+ printf ("Program:%8ld bytes", text);
570+ if (flashmax > 0)
571+ {
572+ printf (" (%2.1f%% Full)", ((float)text / flashmax) * 100);
573+ }
574+ printf ("\n(.text + .data + .bootloader)\n\n");
575+
576+ /* Data size */
577+ printf ("Data: %8ld bytes", data);
578+ if (rammax > 0)
579+ {
580+ printf (" (%2.1f%% Full)", ((float)data / rammax) * 100);
581+ }
582+ printf ("\n(.data + .bss + .noinit)\n\n");
583+
584+ /* EEPROM size */
585+ if (eeprom > 0)
586+ {
587+ printf ("EEPROM: %8ld bytes", eeprom);
588+ if (eeprommax > 0)
589+ {
590+ printf (" (%2.1f%% Full)", ((float)eeprom / eeprommax) * 100);
591+ }
592+ printf ("\n(.eeprom)\n\n");
593+ }
594+}
595+
596+
597 static void
598 print_sizes (bfd *file)
599 {
600 if (show_common)
601 calculate_common_size (file);
602- if (berkeley_format)
603- print_berkeley_format (file);
604- else
605- print_sysv_format (file);
606+ switch (format)
607+ {
608+ case format_sysv:
609+ print_sysv_format (file);
610+ break;
611+ case format_bsd:
612+ print_berkeley_format (file);
613+ break;
614+ case format_avr:
615+ default:
616+ print_avr_format (file);
617+ break;
618+ }
619 }
This page took 0.161714 seconds and 4 git commands to generate.