当前位置: 首页>>代码示例>>C++>>正文


C++ SymbolBody::isTLS方法代码示例

本文整理汇总了C++中SymbolBody::isTLS方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolBody::isTLS方法的具体用法?C++ SymbolBody::isTLS怎么用?C++ SymbolBody::isTLS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SymbolBody的用法示例。


在下文中一共展示了SymbolBody::isTLS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: canBePreempted

void Writer<ELFT>::scanRelocs(
    InputSectionBase<ELFT> &C,
    iterator_range<const Elf_Rel_Impl<ELFT, isRela> *> Rels) {
  typedef Elf_Rel_Impl<ELFT, isRela> RelType;
  const ObjectFile<ELFT> &File = *C.getFile();
  for (const RelType &RI : Rels) {
    uint32_t SymIndex = RI.getSymbol(Config->Mips64EL);
    SymbolBody *Body = File.getSymbolBody(SymIndex);
    uint32_t Type = RI.getType(Config->Mips64EL);

    if (Target->isTlsLocalDynamicReloc(Type)) {
      if (Target->isTlsOptimized(Type, nullptr))
        continue;
      if (Out<ELFT>::LocalModuleTlsIndexOffset == uint32_t(-1)) {
        Out<ELFT>::LocalModuleTlsIndexOffset =
            Out<ELFT>::Got->addLocalModuleTlsIndex();
        Out<ELFT>::RelaDyn->addReloc({&C, &RI});
      }
      continue;
    }

    // Set "used" bit for --as-needed.
    if (Body && Body->isUndefined() && !Body->isWeak())
      if (auto *S = dyn_cast<SharedSymbol<ELFT>>(Body->repl()))
        S->File->IsUsed = true;

    if (Body)
      Body = Body->repl();

    if (Body && Body->isTLS() && Target->isTlsGlobalDynamicReloc(Type)) {
      if (Target->isTlsOptimized(Type, Body))
        continue;
      if (Body->isInGot())
        continue;
      Out<ELFT>::Got->addDynTlsEntry(Body);
      Out<ELFT>::RelaDyn->addReloc({&C, &RI});
      Out<ELFT>::RelaDyn->addReloc({nullptr, nullptr});
      Body->setUsedInDynamicReloc();
      continue;
    }

    if (Body && Body->isTLS() && !Target->isTlsDynReloc(Type))
      continue;

    bool NeedsGot = false;
    bool NeedsPlt = false;
    if (Body) {
      if (auto *E = dyn_cast<SharedSymbol<ELFT>>(Body)) {
        if (E->needsCopy())
          continue;
        if (Target->relocNeedsCopy(Type, *Body))
          E->OffsetInBSS = 0;
      }
      NeedsPlt = Target->relocNeedsPlt(Type, *Body);
      if (NeedsPlt) {
        if (Body->isInPlt())
          continue;
        Out<ELFT>::Plt->addEntry(Body);
      }
      NeedsGot = Target->relocNeedsGot(Type, *Body);
      if (NeedsGot) {
        if (NeedsPlt && Target->supportsLazyRelocations()) {
          Out<ELFT>::GotPlt->addEntry(Body);
        } else {
          if (Body->isInGot())
            continue;
          Out<ELFT>::Got->addEntry(Body);
        }
      }
    }

    if (Config->EMachine == EM_MIPS && NeedsGot) {
      // MIPS ABI has special rules to process GOT entries
      // and doesn't require relocation entries for them.
      // See "Global Offset Table" in Chapter 5 in the following document
      // for detailed description:
      // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
      Body->setUsedInDynamicReloc();
      continue;
    }
    bool CBP = canBePreempted(Body, NeedsGot);
    if (!CBP && (!Config->Shared || Target->isRelRelative(Type)))
      continue;
    if (CBP)
      Body->setUsedInDynamicReloc();
    if (NeedsPlt && Target->supportsLazyRelocations())
      Out<ELFT>::RelaPlt->addReloc({&C, &RI});
    else
      Out<ELFT>::RelaDyn->addReloc({&C, &RI});
  }
}
开发者ID:8l,项目名称:lld,代码行数:91,代码来源:Writer.cpp


注:本文中的SymbolBody::isTLS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。