Class DylibStubContentsScrubber

  • All Implemented Interfaces:
    FileContentsScrubber, FileScrubber

    public class DylibStubContentsScrubber
    extends Object
    implements FileContentsScrubber
    Scrubs the contents of dylib stubs, so that they're independent of the contents of the source dylib. That means that if the source dylib's ABI does not change, it will produce the exact same dylib stub.

    The linker itself does not actually care about the symbol addresses, it just wants to ensure any referenced symbols exist. That means we can reset the addresses to any value we would like. Note that the symbol addresses themselves are already invalid in the dylib stub, as the contents (i.e., binary instructions) have been stripped by "strip".

    Dylib stubs produced by "strip" are still dependent on symbol addresses and the UUID. To make them independent, we do the following:

    • Set the UUID to the same value each time
    • Update the _LINKEDIT segment and remove any addresses for symbols
      • Update the exports info
      • Update the symbol table