Julian Foad writes:

> Jon Berndt wrote:
> > Is there a way to determine which methods/attributes in a class are unused
> > by anybody? I'm thinking maybe there's a utility out there somewhere or a
> > link directive. This would assist in code streamlining/cleanup.
> 
> 
> Getting the linker to tell you is an interesting idea that I haven't 
> looked into.  Perhaps you could do this manually by listing the public 
> symbols in each library first, and then in the linked application, and 
> comparing the two lists.  Or perhaps you can make one list of all the 
> exported symbols from the application and its libraries, and another 
> list of all the imported symbols, and compare those.  The unix utilities 
> "nm" and "objdump" can list symbols in object files and libraries.
> 
> I haven't come across a utility specifically for doing this, but I'd be 
> interested.

This one got me thinking to :-)

I am not familiar enough with the internals of the ld to know how
todo this but this is EXACTLY the kind of thing that libbfd is for

% info bfd

ld can create a cross reference file that may be a good starting
point for doing this by hand.  

The resulting cxref file lists all the functions sorted alphabetically 
and all of the object files that they are referenced from

FGFCS::GetComponentName(int)                      
../../src/FDM/JSBSim/libJSBSim.a(FGFCS.o)
FGFCS::GetComponentOutput(int)                    
../../src/FDM/JSBSim/libJSBSim.a(FGFCS.o)
FGFCS::GetComponentStrings()                      
../../src/FDM/JSBSim/libJSBSim.a(FGFCS.o)
                                                  
../../src/FDM/JSBSim/libJSBSim.a(FGOutput.o)
FGFCS::GetComponentValues()                       
../../src/FDM/JSBSim/libJSBSim.a(FGFCS.o)
                                                  
../../src/FDM/JSBSim/libJSBSim.a(FGOutput.o)
FGFCS::GetDaCmd() const                           
../../src/FDM/JSBSim/libJSBSim.a(FGFCS.o)

add -Wl,--cref to $LDFLAGS in the src/Main/Makefile if you want to experiment

be warned this results in a large cxref file  ~5 meg 

Norman



_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to