function call in executable


 
Thread Tools Search this Thread
Top Forums Programming function call in executable
# 1  
Old 01-23-2006
function call in executable

Hi,
I want to write a program in C or in Perl which will tell me that a function is called in which executables.
I tried to use the unix command like 'nm', 'strings' and so on to find out whether a function is called in that executable or not but could not able to find a clue. The whole object is dummed inside the executable and it does not specifiy me whether the function is really called or not.
The function is a seperate file with several other function. If either of the function is called from that object file then the whole object is dumped inside the executable which does not show whether the function in the object file is really called in the exe.

ex : file test1.c has function test1(), test2() and test3() which will only create object test1.o
there is 3 executable exe1 , exe2 and exe3
exe1 is calling test1() which means test1.o will be dummped whole.
exe2 is calling test2() which means test1.o will be also dumped here
exe3 is calling test3() which means test1.o will be also dumped here

i need to know in which exe test2() is really called which means only exe2 should come in the result.
Please give me some hint since i need the answer as soon as possible.

Thanks.

Last edited by rocky_74; 01-23-2006 at 09:10 AM..
# 2  
Old 01-23-2006
This is a link issue. Let me give you an example:
Code:
grep JSInitReport tmp.c 
... returns nothing, the symbol in not in tmp.c
nm tmp | grep JSInitReport  
... returns nothing

ll tmp
-rw-r--r--   1 jmcnama    prog        21392 Jan 23 08:33 tmp
.. note the size of the tmp executable image file.
.. if I add this to the list of input files to cc
/utility/c/lib/libsctu.a
.... Now:
nm tmp | grep JSInitReport      
JSInitReport        |     12484|extern|entry  |$CODE$
ll tmp
-rw-r--r--   1 jmcnama    prog        214925 Jan 23 08:39 tmp
... note the executable image is now almost ten times larger because of new static symbols

The linker added the symbol, even though the primary module did not call it.
And it will never be executed

You need to find a different way to link your files if you have to use nm to find only symbols that are actually invoked.

I believe if you use ar to create a library, you can then ask the linker to search the library, rather than including all the symbols from the whole archive. Use the
Code:
 -l <file.a> -a archive

syntax

Last edited by jim mcnamara; 01-23-2006 at 12:08 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Xargs to call python executable to process multiple bam files

I am running the below loop that to process the 3 bam files (which isn't always the case). A .py executable is then called using | xargs sh to further process. If I just run it with echo the output is fine and expected, however when | xargs sh is added I get the error. I tried adding | xargs... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

After exit from function it should not call other function

Below is my script that is function properly per my conditions but I am facing one problem here that is when one function fails then Iy should not check other functions but it calls the other function too So anyone can help me how could i achieve this? iNOUT i AM GIVING TO THE... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

3. Programming

Call a C programming executable inside a C program

hi guys i have only basic knowledge of C so guys plz help me ..... is C language support call the C executable inside the C ?? example contect mainA.c have a many function define in the struct,when i compile mainA and make a executable the name is ( A ),can i use executable C inside the C... (5 Replies)
Discussion started by: isnoname
5 Replies

4. Programming

how to call c executable inside c program??

hi guys i have only basic knowledge of c so guys plz help me ..... i want 2 call c executable which requires file name as argument and i need to modify file contents before calling that executable now my question is how can i call this c executable inside another c program with arguments ?? i... (9 Replies)
Discussion started by: zedex
9 Replies

5. Shell Programming and Scripting

Unable to call executable from script

Now I am using the HP-UX11.11 version. The scripts are runninh in KSH shell. While I wan to call one executable of any Pro*C file, I have got the following error, however the executable is running fine directly. testpri Started at 10.05.200923:40 /usr/lib/dld.sl: Bad magic number for... (0 Replies)
Discussion started by: priyankak
0 Replies

6. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

7. Shell Programming and Scripting

Function Call

Hi, I have a string corresponding to a function. How I can call that function without if statement? Thanks in advance. (4 Replies)
Discussion started by: Zaxon
4 Replies

8. Shell Programming and Scripting

Function Call

How we can start a process if doesn't exists before? (1 Reply)
Discussion started by: Zaxon
1 Replies

9. Shell Programming and Scripting

Need to call an Executable (.exe) using shell

Hi all , I need to call an executable (.exe) using shell script. Actual need is i need to call that shell script and do an export of some tables is there any way . the executable is datamover Please let me know if there are any option !! (2 Replies)
Discussion started by: raghav1982
2 Replies

10. Programming

How to get exit value of an executable that gets called from function?

How to get exit value of an executable that gets called from function? I have an executable called “myexec” which returns 0 on success and different values for different fail scenarios. I need to call this (myexec) executable from “myprog()” function of other executable and get the exit value... (1 Reply)
Discussion started by: sureshreddi_ps
1 Replies
Login or Register to Ask a Question