nm get undefined symbols for whole archive, not separate object files

Viewed 1852

I have two files:

foo.c: int foo() { extern int bar(); return bar(); }

bar.c: int bar() { extern int missing(); return missing() + 42; }

I compile them and and compose into .a static lib:

$ gcc -c foo.c bar.c
$ ar rcs libfoobar.a foo.o bar.o

I want to find which symbols are missing (undefined) from whole archive. But I still get bar as undefined, while it exists in foo.o:

$ nm -u libfoobar.a
foo.o:
    U bar
bar.o:
    U missing

How can I omit bar from output and show only missing?

2 Answers
Related