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


C++ LinkerConfig类代码示例

本文整理汇总了C++中LinkerConfig的典型用法代码示例。如果您正苦于以下问题:C++ LinkerConfig类的具体用法?C++ LinkerConfig怎么用?C++ LinkerConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GNULDBackend

//===----------------------------------------------------------------------===//
// X86GNULDBackend
//===----------------------------------------------------------------------===//
X86GNULDBackend::X86GNULDBackend(const LinkerConfig& pConfig,
				 GNUInfo* pInfo,
				 Relocation::Type pCopyRel)
  : GNULDBackend(pConfig, pInfo),
    m_pRelocator(NULL),
    m_pPLT(NULL),
    m_pRelDyn(NULL),
    m_pRelPLT(NULL),
    m_pDynamic(NULL),
    m_pGOTSymbol(NULL),
    m_CopyRel(pCopyRel)
{
  Triple::ArchType arch = pConfig.targets().triple().getArch();
  assert (arch == Triple::x86 || arch == Triple::x86_64);
  if (arch == Triple::x86 ||
      pConfig.targets().triple().getEnvironment() == Triple::GNUX32) {
    m_RelEntrySize = 8;
    m_RelaEntrySize = 12;
    if (arch == Triple::x86)
      m_PointerRel = llvm::ELF::R_386_32;
    else
      m_PointerRel = llvm::ELF::R_X86_64_32;
  }
  else {
    m_RelEntrySize = 16;
    m_RelaEntrySize = 24;
    m_PointerRel = llvm::ELF::R_X86_64_64;
  }
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_frameworks_compile_mclinker,代码行数:32,代码来源:X86LDBackend.cpp

示例2: if

/// configure the output filename
bool OutputFormatOptions::parseOutput(Module& pModule, LinkerConfig& pConfig)
{
  if (true == m_Shared || true == m_PIE) {
    // -shared or -pie
    m_FileType = mcld::LinkerConfig::DynObj;
  }
  else if (true == m_Relocatable) {
    // partial linking
    m_FileType = mcld::LinkerConfig::Object;
  }
  else if (mcld::LinkerConfig::Binary == m_OFormat) {
    // binary output
    m_FileType = mcld::LinkerConfig::Binary;
  }

  pConfig.setCodeGenType(m_FileType);

  std::string output_filename(m_OutputFilename.native());

  if (m_OutputFilename.empty()) {

    if (llvm::Triple::Win32 == pConfig.targets().triple().getOS()) {
      output_filename.assign("_out");
      switch (m_FileType) {
        case mcld::LinkerConfig::Object: {
          output_filename += ".obj";
        break;
        }
        case mcld::LinkerConfig::DynObj: {
          output_filename += ".dll";
          break;
        }
        case mcld::LinkerConfig::Exec: {
          output_filename += ".exe";
          break;
        }
        case mcld::LinkerConfig::External:
          break;
        default: {
          return false;
          break;
        }
      } // switch
    }
    else {
      if (mcld::LinkerConfig::Object   == m_FileType ||
          mcld::LinkerConfig::DynObj   == m_FileType ||
          mcld::LinkerConfig::Exec     == m_FileType ||
          mcld::LinkerConfig::External == m_FileType) {
        output_filename.assign("a.out");
      }
      else {
        return false;
      }
    }
  } // end of if empty m_OutputFilename

  pModule.setName(output_filename);
  return true;
}
开发者ID:Androtos,项目名称:toolchain_mclinker,代码行数:61,代码来源:OutputFormatOptions.cpp

示例3: MCLDEmulateELF

// FIXME: LinkerConfig& pConfig should be constant
bool MCLDEmulateELF(LinkerScript& pScript, LinkerConfig& pConfig) {
  // set up section map
  if (pConfig.options().getScriptList().empty() &&
      pConfig.codeGenType() != LinkerConfig::Object) {
    const unsigned int map_size = (sizeof(map) / sizeof(map[0]));
    for (unsigned int i = 0; i < map_size; ++i) {
      std::pair<SectionMap::mapping, bool> res =
          pScript.sectionMap().insert(map[i].from, map[i].to, map[i].policy);
      if (!res.second)
        return false;
    }
  } else {
    // FIXME: this is the hack to help assignment processing in current
    // implementation.
    pScript.sectionMap().insert("", "");
  }

  if (!pConfig.options().nostdlib()) {
    // TODO: check if user sets the default search path instead via -Y option
    // set up default search path
    switch (pConfig.targets().triple().getOS()) {
      case llvm::Triple::NetBSD:
        pScript.directories().insert("=/usr/lib");
        break;
      case llvm::Triple::Win32:
        pScript.directories().insert("=/mingw/lib");
        break;
      default:
        pScript.directories().insert("=/lib");
        pScript.directories().insert("=/usr/lib");
        break;
    }
  }
  return true;
}
开发者ID:crystax,项目名称:android-toolchain-mclinker,代码行数:36,代码来源:ELFEmulation.cpp

示例4: MCLDEmulateX86ELF

static bool MCLDEmulateX86ELF(LinkerScript& pScript, LinkerConfig& pConfig)
{
  if (!MCLDEmulateELF(pScript, pConfig))
    return false;

  // set up bitclass and endian
  pConfig.targets().setEndian(TargetOptions::Little);
  unsigned int bitclass;
  Triple::ArchType arch = pConfig.targets().triple().getArch();
  assert (arch == Triple::x86 || arch == Triple::x86_64);
  if (arch == Triple::x86 ||
      pConfig.targets().triple().getEnvironment() == Triple::GNUX32) {
    bitclass = 32;
  }
  else {
    bitclass = 64;
  }
  pConfig.targets().setBitClass(bitclass);

  // set up target-dependent constraints of attributes
  pConfig.attribute().constraint().enableWholeArchive();
  pConfig.attribute().constraint().enableAsNeeded();
  pConfig.attribute().constraint().setSharedSystem();

  // set up the predefined attributes
  pConfig.attribute().predefined().unsetWholeArchive();
  pConfig.attribute().predefined().unsetAsNeeded();
  pConfig.attribute().predefined().setDynamic();
  return true;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_frameworks_compile_mclinker,代码行数:30,代码来源:X86Emulation.cpp

示例5: MCLDEmulateARMELF

static bool MCLDEmulateARMELF(LinkerScript& pScript, LinkerConfig& pConfig)
{
  if (!MCLDEmulateELF(pScript, pConfig))
    return false;

  // set up bitclass and endian
  pConfig.targets().setEndian(TargetOptions::Little);
  pConfig.targets().setBitClass(32);

  // set up target-dependent constraints of attributes
  pConfig.attribute().constraint().enableWholeArchive();
  pConfig.attribute().constraint().enableAsNeeded();
  pConfig.attribute().constraint().setSharedSystem();

  // set up the predefined attributes
  pConfig.attribute().predefined().unsetWholeArchive();
  pConfig.attribute().predefined().unsetAsNeeded();
  pConfig.attribute().predefined().setDynamic();

  // set up section map
  if (pConfig.options().getScriptList().empty() &&
      pConfig.codeGenType() != LinkerConfig::Object) {
    pScript.sectionMap().insert(".ARM.exidx*", ".ARM.exidx");
    pScript.sectionMap().insert(".ARM.extab*", ".ARM.extab");
    pScript.sectionMap().insert(".ARM.attributes*", ".ARM.attributes");
  }
  return true;
}
开发者ID:PixNDom,项目名称:android_mediatek_frameworks,代码行数:28,代码来源:ARMEmulation.cpp

示例6: parse

bool SearchPathOptions::parse(LinkerConfig& pConfig, LinkerScript& pScript)
{
  // set --sysroot
  if (!m_SysRoot.empty()) {
    if (exists(m_SysRoot) && is_directory(m_SysRoot))
      pScript.setSysroot(m_SysRoot);
  }

  // set -L[path]
  llvm::cl::list<std::string>::iterator sd;
  llvm::cl::list<std::string>::iterator sdEnd = m_SearchDirList.end();
  for (sd = m_SearchDirList.begin(); sd != sdEnd; ++sd) {
    if (!pScript.directories().insert(*sd)) {
      // FIXME: need a warning function
      errs() << "WARNING: can not open search directory `-L"
             << *sd
             << "'.\n";
    }
  }

  // set -no-stdlib
  pConfig.options().setNoStdlib(m_NoStdlib);

  // set --rpath [path]
  llvm::cl::list<std::string>::iterator rp;
  llvm::cl::list<std::string>::iterator rpEnd = m_RuntimePath.end();
  for (rp = m_RuntimePath.begin(); rp != rpEnd; ++rp) {
    pConfig.options().getRpathList().push_back(*rp);
  }

  return true;
}
开发者ID:PixNDom,项目名称:android_mediatek_frameworks,代码行数:32,代码来源:SearchPathOptions.cpp

示例7: sizeof

void ELFObjectWriter::writeELFHeader(const LinkerConfig& pConfig,
                                     const Module& pModule,
                                     MemoryArea& pOutput) const
{
  typedef typename ELFSizeTraits<SIZE>::Ehdr ElfXX_Ehdr;
  typedef typename ELFSizeTraits<SIZE>::Shdr ElfXX_Shdr;
  typedef typename ELFSizeTraits<SIZE>::Phdr ElfXX_Phdr;

  // ELF header must start from 0x0
  MemoryRegion *region = pOutput.request(0, sizeof(ElfXX_Ehdr));
  ElfXX_Ehdr* header = (ElfXX_Ehdr*)region->start();

  memcpy(header->e_ident, ElfMagic, EI_MAG3+1);

  header->e_ident[EI_CLASS]      = (SIZE == 32) ? ELFCLASS32 : ELFCLASS64;
  header->e_ident[EI_DATA]       = pConfig.targets().isLittleEndian()?
                                       ELFDATA2LSB : ELFDATA2MSB;
  header->e_ident[EI_VERSION]    = target().getInfo().ELFVersion();
  header->e_ident[EI_OSABI]      = target().getInfo().OSABI();
  header->e_ident[EI_ABIVERSION] = target().getInfo().ABIVersion();

  // FIXME: add processor-specific and core file types.
  switch(pConfig.codeGenType()) {
    case LinkerConfig::Object:
      header->e_type = ET_REL;
      break;
    case LinkerConfig::DynObj:
      header->e_type = ET_DYN;
      break;
    case LinkerConfig::Exec:
      header->e_type = ET_EXEC;
      break;
    default:
      llvm::errs() << "unspported output file type: " << pConfig.codeGenType() << ".\n";
      header->e_type = ET_NONE;
  }
  header->e_machine   = target().getInfo().machine();
  header->e_version   = header->e_ident[EI_VERSION];
  header->e_entry     = getEntryPoint(pConfig, pModule);

  if (LinkerConfig::Object != pConfig.codeGenType())
    header->e_phoff   = sizeof(ElfXX_Ehdr);
  else
    header->e_phoff   = 0x0;

  header->e_shoff     = getLastStartOffset<SIZE>(pModule);
  header->e_flags     = target().getInfo().flags();
  header->e_ehsize    = sizeof(ElfXX_Ehdr);
  header->e_phentsize = sizeof(ElfXX_Phdr);
  header->e_phnum     = target().elfSegmentTable().size();
  header->e_shentsize = sizeof(ElfXX_Shdr);
  header->e_shnum     = pModule.size();
  header->e_shstrndx  = pModule.getSection(".shstrtab")->index();
}
开发者ID:rig-project,项目名称:mclinker,代码行数:54,代码来源:ELFObjectWriter.cpp

示例8: if

//===----------------------------------------------------------------------===//
// ELFDynObjReader
//===----------------------------------------------------------------------===//
ELFDynObjReader::ELFDynObjReader(GNULDBackend& pBackend,
                                 IRBuilder& pBuilder,
                                 const LinkerConfig& pConfig)
  : DynObjReader(),
    m_pELFReader(0),
    m_Builder(pBuilder) {
  if (pConfig.targets().is32Bits() && pConfig.targets().isLittleEndian())
    m_pELFReader = new ELFReader<32, true>(pBackend);
  else if (pConfig.targets().is64Bits() && pConfig.targets().isLittleEndian())
    m_pELFReader = new ELFReader<64, true>(pBackend);
}
开发者ID:aurorarom,项目名称:JsonUtil,代码行数:14,代码来源:ELFDynObjReader.cpp

示例9: emulateX86LD

//===----------------------------------------------------------------------===//
// emulateX86LD - the help function to emulate X86 ld
//===----------------------------------------------------------------------===//
bool emulateX86LD(LinkerScript& pScript, LinkerConfig& pConfig)
{
  if (pConfig.targets().triple().isOSDarwin()) {
    assert(0 && "MachO linker has not supported yet");
    return false;
  }
  if (pConfig.targets().triple().isOSWindows()) {
    assert(0 && "COFF linker has not supported yet");
    return false;
  }

  return MCLDEmulateX86ELF(pScript, pConfig);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_frameworks_compile_mclinker,代码行数:16,代码来源:X86Emulation.cpp

示例10: parse

bool TargetControlOptions::parse(LinkerConfig& pConfig)
{
  // set -G [size]
  pConfig.options().setGPSize(m_GPSize);

  // set --warn-shared-textrel
  pConfig.options().setWarnSharedTextrel(m_WarnSharedTextrel);

  // set --fix-cortex-a8
  if (m_FIXCA8)
    mcld::warning(mcld::diag::warn_unsupported_option) << m_FIXCA8.ArgStr;

  return true;
}
开发者ID:aurorarom,项目名称:JsonUtil,代码行数:14,代码来源:TargetControlOptions.cpp

示例11: emitRelocation

/// emitRelocation
void ELFObjectWriter::emitRelocation(const LinkerConfig& pConfig,
                                     const LDSection& pSection,
                                     MemoryRegion& pRegion) const
{
  const RelocData* sect_data = pSection.getRelocData();
  assert(NULL != sect_data && "SectionData is NULL in emitRelocation!");

  if (pSection.type() == SHT_REL) {
    if (pConfig.targets().is32Bits())
      emitRel<32>(pConfig, *sect_data, pRegion);
    else if (pConfig.targets().is64Bits())
      emitRel<64>(pConfig, *sect_data, pRegion);
    else {
      fatal(diag::unsupported_bitclass) << pConfig.targets().triple().str()
                                        << pConfig.targets().bitclass();
    }
  } else if (pSection.type() == SHT_RELA) {
    if (pConfig.targets().is32Bits())
      emitRela<32>(pConfig, *sect_data, pRegion);
    else if (pConfig.targets().is64Bits())
      emitRela<64>(pConfig, *sect_data, pRegion);
    else {
      fatal(diag::unsupported_bitclass) << pConfig.targets().triple().str()
                                        << pConfig.targets().bitclass();
    }
  } else
    llvm::report_fatal_error("unsupported relocation section type!");
}
开发者ID:rig-project,项目名称:mclinker,代码行数:29,代码来源:ELFObjectWriter.cpp

示例12:

enum Linker::ErrorCode Linker::extractFiles(const LinkerConfig& pConfig) {
  mLDConfig = pConfig.getLDConfig();
  if (mLDConfig == NULL) {
    return kDelegateLDInfo;
  }
  return kSuccess;
}
开发者ID:gaojunchen,项目名称:android-4.3-1,代码行数:7,代码来源:Linker.cpp

示例13: parse

bool DynamicSectionOptions::parse(LinkerConfig& pConfig,
                                  LinkerScript& pScript) {
  // set up entry point from -e
  pScript.setEntry(m_Entry);

  // --Bsymbolic
  pConfig.options().setBsymbolic(m_Bsymbolic);

  // --Bgroup
  pConfig.options().setBgroup(m_Bgroup);

  // set --soname [soname]
  pConfig.options().setSOName(m_SOName);

  // set -z options
  llvm::cl::list<ZOption>::iterator zOpt;
  llvm::cl::list<ZOption>::iterator zOptEnd = m_ZOptionList.end();
  for (zOpt = m_ZOptionList.begin(); zOpt != zOptEnd; ++zOpt) {
    pConfig.options().addZOption(*zOpt);
  }

  // set --no-undefined
  if (llvm::cl::BOU_UNSET != m_NoUndefined)
    pConfig.options().setNoUndefined(llvm::cl::BOU_TRUE == m_NoUndefined);

  // set --allow-multiple-definition
  if (llvm::cl::BOU_UNSET != m_AllowMulDefs)
    pConfig.options().setMulDefs(llvm::cl::BOU_TRUE == m_AllowMulDefs);

  // set --dynamic-linker [dyld]
  pConfig.options().setDyld(m_Dyld);

  // set --enable-new-dtags
  pConfig.options().setNewDTags(m_EnableNewDTags);

  // set --auxiliary, -f
  llvm::cl::list<std::string>::iterator aux;
  llvm::cl::list<std::string>::iterator auxEnd = m_Auxiliary.end();
  for (aux = m_Auxiliary.begin(); aux != auxEnd; ++aux)
    pConfig.options().getAuxiliaryList().push_back(*aux);

  // set --filter, -F
  pConfig.options().setFilter(m_Filter);

  return true;
}
开发者ID:FulcronZ,项目名称:NyuziToolchain,代码行数:46,代码来源:DynamicSectionOptions.cpp

示例14: TEST_F

//===----------------------------------------------------------------------===//
// Testcases
//===----------------------------------------------------------------------===//
TEST_F(ELFBinaryReaderTest, is_myformat) {
  LinkerScript script;
  Module module("test", script);
  LinkerConfig config;
  IRBuilder builder(module, config);
  ELFBinaryReader* reader = new ELFBinaryReader(builder, config);

  Input input("test.bin");

  bool doContinue = false;
  config.options().setBinaryInput();
  ASSERT_TRUE(reader->isMyFormat(input, doContinue));

  config.options().setBinaryInput(false);
  ASSERT_FALSE(reader->isMyFormat(input, doContinue));

  delete reader;
}
开发者ID:FulcronZ,项目名称:NyuziToolchain,代码行数:21,代码来源:ELFBinaryReaderTest.cpp

示例15: if

//===----------------------------------------------------------------------===//
// ELFObjectReader
//===----------------------------------------------------------------------===//
/// constructor
ELFObjectReader::ELFObjectReader(GNULDBackend& pBackend,
                                 IRBuilder& pBuilder,
                                 const LinkerConfig& pConfig)
  : ObjectReader(),
    m_pELFReader(NULL),
    m_pEhFrameReader(NULL),
    m_Builder(pBuilder),
    m_ReadFlag(ParseEhFrame),
    m_Backend(pBackend),
    m_Config(pConfig) {
  if (pConfig.targets().is32Bits() && pConfig.targets().isLittleEndian()) {
    m_pELFReader = new ELFReader<32, true>(pBackend);
  }
  else if (pConfig.targets().is64Bits() && pConfig.targets().isLittleEndian()) {
    m_pELFReader = new ELFReader<64, true>(pBackend);
  }

  m_pEhFrameReader = new EhFrameReader();
}
开发者ID:PixNDom,项目名称:android_mediatek_frameworks,代码行数:23,代码来源:ELFObjectReader.cpp


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