avr-binutils-size-2.32.patch 16 KB

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