• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Dead code stripping
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dead code stripping


  • Subject: Dead code stripping
  • From: Jonas Maebe <email@hidden>
  • Date: Sun, 16 Apr 2006 21:31:40 +0200

Hello,

I'm trying to add support for dead code stripping on Darwin to the Free Pascal Compiler, but I've run into a snag:

a) traditionally, the way we did this was by putting each symbol and its data/code in a separate object file and then put all those object files together in a static library. LD then only links in the objects (= symbols) that are needed. I can't get this to work on Darwin/Mac OS X because those libraries may be interdependent, and as the man page of LD explains, LD only searches static libraries for the currently unresolved symbols.
`
Even passing all static libraries twice to LD doesn't solve all problems, because there may be cascade effects (by finding a symbol, LD may again need to resolve some other symbols because they were referenced from the code/data belonging to that symbol, and the same can be true for these newly found symbols).


"-all_load" solves this problem, but then no dead code stripping is performed at all (all symbols are not just loaded then, but also linked in it seems).


b) Even if the above would work, a big downside would be that it's quite slow (since you have to call the assembler as many times as there are symbols in the compilation unit). However, I can't get the ".subsections_via_symbols" functionaly to cooperate with our compiler either. The problem is that our compiler supports attaching multiple symbols to one function (i.e., creating an alias for a function). This results in code like


.globl  SYSTEM_MOVE$formal$formal$LONGINT
SYSTEM_MOVE$formal$formal$LONGINT:
.globl  FPC_MOVE
FPC_MOVE:
# Temps allocated between r1+60 and r1+60
        mflr    r0
        stw     r0,8(r1)
        stwu    r1,-64(r1)

etc

Now, if a particular program only references this function by using the auto-generated name (SYSTEM_MOVE$formal$formal$LONGINT), then this function will be stripped (as explained at http:// developer.apple.com/documentation/DeveloperTools/Reference/Assembler/ ASMDirectives/chapter_5_section_6.html#//apple_ref/doc/uid/TP30000823- CJBJAAGI)

Adding a ".no_dead_strip FPC_MOVE" doesn't seem appropriate either, since then the function will never be stripped away.


Is there a way around the problems I'm encountering in either a) or b)? On other OS'es we nowadays use GNU LD's --gc-sections functionality, which allows for stripping at the section level (i.e., every section which is not reachable is automatically stripped), so if there is a way to manually define 'subsections' that would be fine.


Thanks,


Jonas _______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Dead code stripping
      • From: "Peter O'Gorman" <email@hidden>
  • Prev by Date: Java console app debugging in Xcode
  • Next by Date: SCM and XCode
  • Previous by thread: Re: Java console app debugging in Xcode
  • Next by thread: Re: Dead code stripping
  • Index(es):
    • Date
    • Thread