Bug 13256 - AR + plugin fails with "no operation specified" error
Summary: AR + plugin fails with "no operation specified" error
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: 2.33
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-04 21:33 UTC by Dmitry Gorbachev
Modified: 2022-11-20 02:54 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gorbachev 2011-10-04 21:33:06 UTC
GNU Binutils 2.22.51.20111004.

$ ar --plugin /path/to/liblto_plugin.so cr libfoo.a foo.o
ar: no operation specified

These commands work as expected:

$ ar cr --plugin /path/to/liblto_plugin.so libfoo.a foo.o
$ ar --plugin /path/to/liblto_plugin.so -cr libfoo.a foo.o
Comment 1 Ákos Szőts 2019-07-24 07:31:34 UTC
Still present in 2.32.

The reason might be that in ar.c:480 getopt_long doesn't recognise additional options followed by a long option (--plugin xy) and exits from the loop.
Comment 2 Sourceware Commits 2019-07-24 11:18:59 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2f86d5594071a16665711ae13da88af1cc904371

commit 2f86d5594071a16665711ae13da88af1cc904371
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Jul 24 12:17:37 2019 +0100

    Fix ar so that it can correctly detect non-dash prefixed options that appear after dash prefixed options.
    
    	PR 13256
    	* ar.c (decode_options): Restart option scanning if no operation
    	is detected and argument remain to be scanned.
Comment 3 Nick Clifton 2019-07-24 11:22:27 UTC
Hi Akos,

  OK, I have checked in a patch which should fix this problem.  At least
  for the case where "no operation specified" would have occurred.  There
  will still be an issue if an operation is specified, so for example:
  "ar --plugin <foo> -c r libfoo.a foo.o" will not work because the "r" 
  option will be interpreted as a file name.  But I think that such a 
  situation is unlikely to occur in real world uses of ar.

Cheers
  Nick