#1148721 avr-size should support the option -C

Package:
binutils-avr
Source:
binutils-avr
Description:
Binary utilities supporting Atmel's AVR targets
Submitter:
Edgar Bonet
Date:
2026-09-22 14:37:02 UTC
Severity:
normal
#1148721#5
Date:
2026-09-22 14:14:27 UTC
From:
To:
Dear maintainer,

On Debian trixie, forky and sid, calling avr-size with the option ‘-C’
fails as follows:

    $ avr-size -C some-file.elf
    avr-size: invalid option -- 'C'
    Usage: avr-size [option(s)] [file(s)]
     Displays the sizes of sections inside binary files
     If no input file(s) are specified, a.out is assumed
     The options are:
      -A|-B|-G  --format={sysv|berkeley|gnu|avr}  Select output style (default is berkeley)
      [...]

I suggest that avr-size should support the option ‘-C’ as a synonym of
‘--format=avr’, for the following reasons:

 1. The option is supported on Debian bookworm (binutils-avr
    2.26.20160125+Atmel3.6.2-4), with this semantics.

 2. The Debian package arduino-mk expects avr-size to support the
    option: see the definition[1] of SIZEFLAGS in
    /usr/share/arduino/Arduino.mk .

 3. The file size_avr_support.patch within this source package already
    contains unreachable code[2] meant to interpret the ‘-C’ option this
    way. I thus assume this is already the expected behavior.

The reason the code in [2] is unreachable is because avr-size parses its
command line as follows:

  while ((c = getopt_long (argc, argv, "ABGHhVvdfotx", long_options,
                           (int *) 0)) != EOF)
    switch (c)
      {
      [...]
      case 'C':                               // these three lines
        selected_output_format = FORMAT_AVR;  // are added by
        break;                                // size_avr_support.patch
      [...]
      case '?':
        usage (stderr, 1);
      }

The third argument of getopt_long() (the string "ABGHhVvdfotx") is
interpreted as the list of single-letter options the command accepts.
Since ‘C’ is missing from this list, the option is not recognized.

Suggested fix:

  • In size_avr_support.patch, patch also the call to getopt_long(),
    adding the missing ‘C’.

  • Patch also the help message in order to include the option.

Regards,

Edgar Bonet.

[1] https://github.com/sudar/Arduino-Makefile/blob/1.5.2/Arduino.mk#L1074
[2] https://salsa.debian.org/debian/binutils-avr/-/blob/debian/2.43.50.20250108-1/debian/size_avr_support.patch?ref_type=tags#L468-470