title: How to specify output artifact from a cc_library in bazel?
body: <p>I want to build "foo.c" as a library and then execute "readelf" on the generated .so but not the ".a", how can I write it in bazel?</p>
  
  <p>The following BUILD.bazel file doesn't work:</p>
  
  <pre><code>cc_library(
      name = "foo",
      srcs = ["foo.c"],
  )
  
  genrule(
      name = "readelf_foo",
      srcs = ["libfoo.so"],
      outs = ["readelf_foo.txt"],
      cmd = "readelf -a $(SRCS) &gt; $@",
  )
  </code></pre>
  
  <p>The error is "missing input file '//:libfoo.so'".</p>
  
  <p>Changing the genrule's srcs attribute to ":foo" passes both the ".a" and ".so" file to readelf, which is not what I need.</p>
  
  <p>Is there any way to specify which output of ":foo" to pass to the genrule?</p>