Listing function exports from object file

Is it possible to view all the functions exported by a given object file?

"dump -tv" comes the closest, but what exactly am I looking for to determine whether the symbol exists in the object file?

Essentially, I have a library that requires a call to "xdr_sizeof" and the compile is failing because the linker can not find it. I am curious if I can find where (and if) this function is provided so I can link it in. I have ran the following under /usr/lib:

for i in `find . -name "*.a"`
do
cnt=`dump -tv $i | grep -c xdr_sizeof`
if [ $cnt -ne 0 ]
then
echo $i " " $cnt
fi
done

Running this I get:

./libnsl.a 3
./libnsl_r.a 3
./libtt.a 1
./libnisdb.a 4

How do I know which of those, if any, actually contains the xdr_sizeof function I want? Is there a better way to do the dump to limit it only to outputing lines for functions exported by the library? Am I completely off base here? I know the function can not be in four different libraries...or it shouldn't be....

AIX 5.2 is the O/S if it matters!

Thanks y'all!

"nm" is also a good tool. If it doesn't work for an object file then put that file in a library and use "nm" on the library.

You may also try

objdump = show info within object files
readelf = show info within elf files.

Thanks

#!/bin/sh

for d in /usr/lib/*.a
do
       nm $d | grep xdr_sizeof

        if test "$?" = "0"
        then
                 echo $d
        fi
done

On AIX 5.1 I find it referenced in

/usr/lib/libnisdb.a
/usr/lib/libnsl.a
/usr/lib/libnsl_r.a
/usr/lib/libtt.a

I would go for libnsl.a

I guess I can give it a shot.... Google is not much help telling much what the heck that library is for, however. If I had to venture a guess, I'd say "network sockets layer".... Sounds good :-).

However, when I do get this from dump:

dump -tv libnsl.a | grep xdr_sizeof
[3768]  a0                                                        ../../../../../../../src/oncplus/usr/lib/libnsl/rpc/xdr_sizeof.c
[3787]  m   0x00038674     .text     1  extern                    .xdr_sizeof
[3805]  m   0x0000eb9c     .data     1  extern                    xdr_sizeof

The extern makes me wonder.... Sounds, however, like there is neither a "good" way to flag nm nor dump to show just functions provided by the library/archive.

-- DreamWarrior

P.S. mah: It seems that objdump and readelf are not available to me on AIX.

You don't want to see a U for undefined, best way is to try to link a tiny C program with main calling the single function.

Yes, it's XCOFF, not ELF