Listing function exports from object file


 
Thread Tools Search this Thread
Top Forums Programming Listing function exports from object file
# 1  
Old 10-17-2007
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:

Code:
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!
# 2  
Old 10-17-2007
"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.
# 3  
Old 10-18-2007
You may also try

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

Thanks
# 4  
Old 10-18-2007
Code:
#!/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

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

I would go for libnsl.a

Last edited by porter; 10-18-2007 at 02:08 PM..
# 5  
Old 10-18-2007
Quote:
Originally Posted by porter
*snip*
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:

Code:
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.
# 6  
Old 10-18-2007
Quote:
Originally Posted by DreamWarrior
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.
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.

Quote:
Originally Posted by DreamWarrior
P.S. mah: It seems that objdump and readelf are not available to me on AIX.
Yes, it's XCOFF, not ELF
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to initialize an object with another object of different class?

How to initialize an object of class say "A", with an object of type say "B". The following code give the error message "error: conversion from âAâ to non-scalar type âBâ requested" #include <iostream> using namespace std; class B; class A{ public: A() { cout <<"\nA()" << endl; } ... (1 Reply)
Discussion started by: techmonk
1 Replies

2. UNIX for Dummies Questions & Answers

NFS not showing under /etc/fstab nor /etc/exports

Hi guys, I was asked to perform the following: On server usdfslpsap04 following NFS mounts should be disabled usdfslpwmt3:/u01/opt/wm6_data/ebiz_edi/CALIBER_data 50412232 13369544 34481872 28% /u01/opt/wm6_data/ebiz_edi/CALIBER_data usauxoradw:/DWH/Transfer/current... (1 Reply)
Discussion started by: 300zxmuro
1 Replies

3. Programming

passing object to function, columns class

I am working on a small columns class, since I use allot of tabular data. I am trying to set up code to allow me to efficiently read in tabular data, manipulate it, and write to output files. I more or less know what I need to do, but there are many options to sort through. I have the beginnings... (14 Replies)
Discussion started by: LMHmedchem
14 Replies

4. SCO

Problem with nfs exports between 5.0.5 and 5.0.7

Hello everyone! I have two systems: an old SCO 5.0.5 Openserver (here's the uname -a output): /# uname -a SCO_SV munixela 3.2 5.0.5 i386 And a SCO 5.0.7 OpenServer (uname -a output): /# uname -a SCO_SV catedral 3.2 5.0.7 i386 I exported a Filesystem from the 5.0.7 machine, using the... (13 Replies)
Discussion started by: superchivo
13 Replies

5. Programming

question about function object

I have a code as following: #include <iostream> #include <algorithm> #include <list> using namespace std; //the class Nth is a predicates class Nth{ private: int nth; int count; public: Nth(int n):nth(n),count(0){} bool operator()(int){ ... (2 Replies)
Discussion started by: homeboy
2 Replies

6. Shell Programming and Scripting

How to Call external function in .C or .So (Shared Object)

Hi, Anybody know any way to Call with Shell Script an external function wrote in .C or .So (Shared Object) on AIX enviroment and returning parameters of .C or .SO to Shell Script? Tks!! (6 Replies)
Discussion started by: rdgsantos
6 Replies

7. AIX

AIX Exports file

Why can I not add more than 1 filesystem to the /etc/exports file and export them via smitty, or command line? I have tried, I stopped the NFS daemons, edited the /etc/exports file by hand, saved it, then re-started NFS, but it only still exports the first line in the exports file. ... (4 Replies)
Discussion started by: mrmurdock
4 Replies

8. UNIX for Dummies Questions & Answers

Object reference not set to an instance of an object

I am new to PHP and UNIX. I am using Apache to do my testing on a Windows Vista machine. I am getting this error when I am trying to connect to a web service. I did a search and did not see any posts that pertain to this. Here is my function: <?php function TRECSend($a, $b, $c, $d,... (0 Replies)
Discussion started by: EddiRae
0 Replies

9. UNIX for Advanced & Expert Users

How can i read a non text file in unix - ELF-64 executable object file - IA64

The binary file is ELF-64 executable object file - IA64. How i know that the source is Is there any comamnd in unix i can read these kind of files or use a thirty party software? Thanks for your help (8 Replies)
Discussion started by: alexcol
8 Replies

10. UNIX for Dummies Questions & Answers

/etc/exports

i have the following entry in /etc/exports which is /opt/hpxt. i am on hpux b11.0.0 questions 1) is /hpxt in the same physical machine? got confused by the meaning of export. (1 Reply)
Discussion started by: yls177
1 Replies
Login or Register to Ask a Question