static bool canUseLocalRelocation(const MCSectionMachO &Section,
                                  const MCSymbol &Symbol, unsigned Log2Size) {
    // Debug info sections can use local relocations.
    if (Section.hasAttribute(MachO::S_ATTR_DEBUG))
        return true;

    // Otherwise, only pointer sized relocations are supported.
    if (Log2Size != 3)
        return false;

    // But only if they don't point to a few forbidden sections.
    if (!Symbol.isInSection())
        return true;
    const MCSectionMachO &RefSec = cast<MCSectionMachO>(Symbol.getSection());
    if (RefSec.getType() == MachO::S_CSTRING_LITERALS)
        return false;

    if (RefSec.getSegmentName() == "__DATA" &&
            RefSec.getSectionName() == "__cfstring")
        return false;

    if (RefSec.getSegmentName() == "__DATA" &&
            RefSec.getSectionName() == "__objc_classrefs")
        return false;

    return true;
}
Пример #2
0
static bool canUseLocalRelocation(const MCSectionMachO &Section,
                                  const MCSymbol &Symbol, unsigned Log2Size) {
  // Debug info sections can use local relocations.
  if (Section.hasAttribute(MachO::S_ATTR_DEBUG))
    return true;

  // Otherwise, only pointer sized relocations are supported.
  if (Log2Size != 3)
    return false;

  // But only if they don't point to a few forbidden sections.
  if (!Symbol.isInSection())
    return true;
  const MCSectionMachO &RefSec = cast<MCSectionMachO>(Symbol.getSection());
  if (RefSec.getType() == MachO::S_CSTRING_LITERALS)
    return false;

  if (RefSec.getSegmentName() == "__DATA" &&
      RefSec.getSectionName() == "__objc_classrefs")
    return false;

  // FIXME: ld64 currently handles internal pointer-sized relocations
  // incorrectly (applying the addend twice). We should be able to return true
  // unconditionally by this point when that's fixed.
  return false;
}