Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linker question



Eric Postpischil wrote:
On November 2, 2005, John Stiles wrote:

  
Is there any way to ask the linker "what references function X? why
did it get included in the final output?"
    

The loader has switches -whyload, which tells why each module is loaded,
and -y<symbol>, which traces the references for a particular symbol.  See
the ld manual page for more details.

  

Thanks for the info.
I tried -whyload but it wasn't useful; it's only interesting if you want to know what symbols are being used from other libraries. This doesn't involve anything crossing library boundaries.
I looked up the docs for -y and I'm not sure if it's what I need. (I can't test it until next week, unfortunately.)

       -ysym (32-bit only)
              Display  each  file  in which sym appears, its type, and whether
              the file defines or references it.  Any multiply defined symbols
              are automatically traced.  Like most of the other symbol-related
              flags, -y takes only one argument; the  flag  may  be  specified
              more  than  once in the command line to trace more than one sym-
              bol.

I already know which files define and reference my various symbols. What I want to know is, why does the linker think that there is a path from the entrypoint (main) to these functions? I am pretty darn positive there isn't such a path, since like I said, I even went so far as to comment out all references to these functions from the main code. At that point, you can remove the cpp's in question and the app compiles/links fine (of course, it doesn't run since I've commented out crucial logic); if you put the cpp's back, they start showing up in "nm" dumps, even though the app is still not referencing the code.

I'm stumped; I'm pretty positive this is just a linker bug. It would be great if there were an option to have the linker show a debug log like this when it is dead stripping:

_start: entrypoint
_start: references main
main: references foo
foo: references bar
bar: references YOUR_SYMBOL_HERE


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden

References: 
 >RE: Linker question (From: "Eric Postpischil" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.