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


C++ Linker类代码示例

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


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

示例1: HELIUM_ASSERT

/// Update object reference linking for the given object load request.
///
/// @param[in] pRequest  Load request to update.
///
/// @return  True if linking still requires processing, false if it is complete.
bool GameObjectLoader::TickLink( LoadRequest* pRequest )
{
    HELIUM_ASSERT( pRequest );
    HELIUM_ASSERT( !( pRequest->stateFlags & ( LOAD_FLAG_PRECACHED | LOAD_FLAG_LOADED ) ) );

    // Make sure each dependency has finished its preload process.
    bool bHavePendingLinkEntries = false;

    DynArray< LinkEntry >& rLinkTable = pRequest->linkTable;
    size_t linkTableSize = rLinkTable.GetSize();
    for( size_t linkIndex = 0; linkIndex < linkTableSize; ++linkIndex )
    {
        LinkEntry& rLinkEntry = rLinkTable[ linkIndex ];
        if( IsValid( rLinkEntry.loadId ) )
        {
            LoadRequest* pLinkRequest = m_loadRequestPool.GetObject( rLinkEntry.loadId );
            HELIUM_ASSERT( pLinkRequest );
            if( pLinkRequest->stateFlags & LOAD_FLAG_PRELOADED )
            {
                rLinkEntry.spObject = pLinkRequest->spObject;
            }
            else
            {
                bHavePendingLinkEntries = true;
            }
        }
    }

    if( bHavePendingLinkEntries )
    {
        return false;
    }

    // Ready to link.
    GameObject* pObject = pRequest->spObject;
    if( pObject )
    {
        uint32_t objectFlags = pObject->GetFlags();
        if( !( objectFlags & GameObject::FLAG_LINKED ) )
        {
            if( !( objectFlags & GameObject::FLAG_BROKEN ) )
            {
                Linker linker;
                linker.Prepare( rLinkTable.GetData(), static_cast< uint32_t >( linkTableSize ) );
                if( !linker.Serialize( pObject ) )
                {
                    pObject->SetFlags( GameObject::FLAG_BROKEN );
                }
            }

            pObject->SetFlags( GameObject::FLAG_LINKED );
        }
    }

    AtomicOrRelease( pRequest->stateFlags, LOAD_FLAG_LINKED );

    return true;
}
开发者ID:,项目名称:,代码行数:63,代码来源:

示例2: TEST_F

// %MCLinker --shared -soname=libplasma.so -Bsymbolic
// -mtriple="armv7-none-linux-gnueabi"
// -L=%p/../../../libs/ARM/Android/android-14
// %p/../../../libs/ARM/Android/android-14/crtbegin_so.o
// %p/plasma.o
// -lm -llog -ljnigraphics -lc
// %p/../../../libs/ARM/Android/android-14/crtend_so.o
// -o libplasma.so
TEST_F( LinkerTest, plasma) {

    Initialize();
    Linker linker;
    LinkerScript script;

    ///< --mtriple="armv7-none-linux-gnueabi"
    LinkerConfig config("armv7-none-linux-gnueabi");

    /// -L=${TOPDIR}/test/libs/ARM/Android/android-14
    Path search_dir(TOPDIR);
    search_dir.append("test/libs/ARM/Android/android-14");
    script.directories().insert(search_dir);

    /// To configure linker before setting options. Linker::config sets up
    /// default target-dependent configuration to LinkerConfig.
    linker.emulate(script, config);

    config.setCodeGenType(LinkerConfig::DynObj);  ///< --shared
    config.options().setSOName("libplasma.so");   ///< --soname=libplasma.so
    config.options().setBsymbolic();              ///< -Bsymbolic

    Module module("libplasma.so", script);
    IRBuilder builder(module, config);

    /// ${TOPDIR}/test/libs/ARM/Android/android-14/crtbegin_so.o
    Path crtbegin(search_dir);
    crtbegin.append("crtbegin_so.o");
    builder.ReadInput("crtbegin", crtbegin);

    /// ${TOPDIR}/test/Android/Plasma/ARM/plasma.o
    Path plasma(TOPDIR);
    plasma.append("test/Android/Plasma/ARM/plasma.o");
    builder.ReadInput("plasma", plasma);

    // -lm -llog -ljnigraphics -lc
    builder.ReadInput("m");
    builder.ReadInput("log");
    builder.ReadInput("jnigraphics");
    builder.ReadInput("c");

    /// ${TOPDIR}/test/libs/ARM/Android/android-14/crtend_so.o
    Path crtend(search_dir);
    crtend.append("crtend_so.o");
    builder.ReadInput("crtend", crtend);

    if (linker.link(module, builder)) {
        linker.emit("libplasma.so"); ///< -o libplasma.so
    }

    Finalize();
}
开发者ID:rig-project,项目名称:mclinker,代码行数:60,代码来源:LinkerTest.cpp

示例3: linkFiles

static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
                      const cl::list<std::string> &Files,
                      unsigned Flags) {
  // Filter out flags that don't apply to the first file we load.
  unsigned ApplicableFlags = Flags & Linker::Flags::OverrideFromSrc;
  for (const auto &File : Files) {
    std::unique_ptr<Module> M = loadFile(argv0, File, Context);
    if (!M.get()) {
      errs() << argv0 << ": error loading file '" << File << "'\n";
      return false;
    }

    if (verifyModule(*M, &errs())) {
      errs() << argv0 << ": " << File << ": error: input module is broken!\n";
      return false;
    }

    if (Verbose)
      errs() << "Linking in '" << File << "'\n";

    if (L.linkInModule(M.get(), ApplicableFlags))
      return false;
    // All linker flags apply to linking of subsequent files.
    ApplicableFlags = Flags;
  }

  return true;
}
开发者ID:RichardsonAlex,项目名称:llvm-1,代码行数:28,代码来源:llvm-link.cpp

示例4: main

int main() {

    char *fileName = "monkey.wrl"; //Model name
    int numLayer = 1; //Number of layers used in this application
    int numInterator = 0;

    // Transfer the OF data to CybParameters structure
    CybDataObtainer<cybSurfaceTriTraits> data(numLayer, numInterator);

    CybViewMono view;

    //Access the parameters information of scene and graphical objects
    CybParameters *cybCore = CybParameters::getInstance();

    sMesh *mesh = new sMesh[numLayer];
    mfReaderModel<cybSurfaceTriTraits> in;
    in.read(&mesh[0], fileName);
    data.loadModel(mesh);
    cout << "loadModel()" << endl;
    /*Load the model from VRML file (layerID, fileName)*/
    //data.loadModel(0, fileName);

    /*Initialize the meshes parameters*/
    data.startParameters(numLayer);

    //Set the object color (layerID, r, g, b,a)
    cybCore->setColor(0,1,1,0.7,0.9);

    //Set the window name
    view.setWindowName("Simple Visualization");

    Provider * provider = new Provider();
    CybBayesianNetwork* net = new CybBayesianNetwork(3);
    CybNetworkIO* netIO = new CybNetworkIO
    ("/root/Desktop/teste");
    Linker* linker = new Linker(net, provider, netIO);

    linker->init();
    /*Initialize visualization*/
    view.init();

    delete provider;
    delete net;
    delete netIO;
    delete linker;
}
开发者ID:naneaa,项目名称:Cybermed-4.0,代码行数:46,代码来源:AssessTest.cpp

示例5: NnfwIteratorGetLinker

C_NNFW_API NnfwLinker* NnfwIteratorGetLinker( NnfwIterator* itera, int i ) {
	Linker* ln;
	switch( itera->type ) {
	case 0:
		return 0;
		break;
	case 1:
		ln = itera->linkvec->at(i);
		break;
	case 2:
		if ( dynamic_cast<Cluster*>(itera->upvec->at(i)) ) {
			return 0;
		}
		ln = (Linker*)(itera->upvec->at(i));
		break;
	default:
		return 0;
	}
	if ( linkmap.count( ln ) == 0 ) {
		NnfwLinker* nln = new NnfwLinker();
		nln->linker = ln;
		nln->myup = nln->linker;
		Cluster* cl = ln->from();
		if ( clmap.count( cl ) == 0 ) {
			NnfwCluster* ncl = new NnfwCluster();
			ncl->cluster = cl;
			ncl->myup = ncl->cluster;
			ncl->func = new NnfwOutputFunction();
			ncl->func->func = cl->getFunction();
			clmap[cl] = ncl;
		}
		nln->from = clmap[cl];
		cl = ln->to();
		if ( clmap.count( cl ) == 0 ) {
			NnfwCluster* ncl = new NnfwCluster();
			ncl->cluster = cl;
			ncl->myup = ncl->cluster;
			ncl->func = new NnfwOutputFunction();
			ncl->func->func = cl->getFunction();
			clmap[cl] = ncl;
		}
		nln->to = clmap[cl];
		linkmap[ln] = nln;
	}
	return linkmap[ln];
}
开发者ID:BackupTheBerlios,项目名称:nnfw-svn,代码行数:46,代码来源:cnnfw.cpp

示例6: linkFiles

static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
                      const cl::list<std::string> &Files,
                      unsigned Flags) {
  // Filter out flags that don't apply to the first file we load.
  unsigned ApplicableFlags = Flags & Linker::Flags::OverrideFromSrc;
  for (const auto &File : Files) {
    std::unique_ptr<Module> M = loadFile(argv0, File, Context);
    if (!M.get()) {
      errs() << argv0 << ": error loading file '" << File << "'\n";
      return false;
    }

    // Note that when ODR merging types cannot verify input files in here When
    // doing that debug metadata in the src module might already be pointing to
    // the destination.
    if (DisableDITypeMap && verifyModule(*M, &errs())) {
      errs() << argv0 << ": " << File << ": error: input module is broken!\n";
      return false;
    }

    // If a module summary index is supplied, load it so linkInModule can treat
    // local functions/variables as exported and promote if necessary.
    if (!SummaryIndex.empty()) {
      std::unique_ptr<ModuleSummaryIndex> Index =
          ExitOnErr(llvm::getModuleSummaryIndexForFile(SummaryIndex));

      // Conservatively mark all internal values as promoted, since this tool
      // does not do the ThinLink that would normally determine what values to
      // promote.
      for (auto &I : *Index) {
        for (auto &S : I.second) {
          if (GlobalValue::isLocalLinkage(S->linkage()))
            S->setLinkage(GlobalValue::ExternalLinkage);
        }
      }

      // Promotion
      if (renameModuleForThinLTO(*M, *Index))
        return true;
    }

    if (Verbose)
      errs() << "Linking in '" << File << "'\n";

    if (L.linkInModule(std::move(M), ApplicableFlags))
      return false;
    // All linker flags apply to linking of subsequent files.
    ApplicableFlags = Flags;
  }

  return true;
}
开发者ID:anupam128,项目名称:llvm,代码行数:52,代码来源:llvm-link.cpp

示例7: linkFiles

static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
                      const cl::list<std::string> &Files,
                      unsigned Flags) {
  // Filter out flags that don't apply to the first file we load.
  unsigned ApplicableFlags = Flags & Linker::Flags::OverrideFromSrc;
  for (const auto &File : Files) {
    std::unique_ptr<Module> M = loadFile(argv0, File, Context);
    if (!M.get()) {
      errs() << argv0 << ": error loading file '" << File << "'\n";
      return false;
    }

    if (verifyModule(*M, &errs())) {
      errs() << argv0 << ": " << File << ": error: input module is broken!\n";
      return false;
    }

    // If a function index is supplied, load it so linkInModule can treat
    // local functions/variables as exported and promote if necessary.
    std::unique_ptr<FunctionInfoIndex> Index;
    if (!FunctionIndex.empty()) {
      ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
          llvm::getFunctionIndexForFile(FunctionIndex, diagnosticHandler);
      std::error_code EC = IndexOrErr.getError();
      if (EC) {
        errs() << EC.message() << '\n';
        return false;
      }
      Index = std::move(IndexOrErr.get());
    }

    if (Verbose)
      errs() << "Linking in '" << File << "'\n";

    if (L.linkInModule(std::move(M), ApplicableFlags, Index.get()))
      return false;
    // All linker flags apply to linking of subsequent files.
    ApplicableFlags = Flags;

    // If requested for testing, preserve modules by releasing them from
    // the unique_ptr before the are freed. This can help catch any
    // cross-module references from e.g. unneeded metadata references
    // that aren't properly set to null but instead mapped to the source
    // module version. The bitcode writer will assert if it finds any such
    // cross-module references.
    if (PreserveModules)
      M.release();
  }

  return true;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:51,代码来源:llvm-link.cpp

示例8: linkFiles

static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
                      const cl::list<std::string> &Files,
                      unsigned Flags) {
  // Filter out flags that don't apply to the first file we load.
  unsigned ApplicableFlags = Flags & Linker::Flags::OverrideFromSrc;
  for (const auto &File : Files) {
    std::unique_ptr<Module> M = loadFile(argv0, File, Context);
    if (!M.get()) {
      errs() << argv0 << ": error loading file '" << File << "'\n";
      return false;
    }

    // Note that when ODR merging types cannot verify input files in here When
    // doing that debug metadata in the src module might already be pointing to
    // the destination.
    if (DisableDITypeMap && verifyModule(*M, &errs())) {
      errs() << argv0 << ": " << File << ": error: input module is broken!\n";
      return false;
    }

    // If a module summary index is supplied, load it so linkInModule can treat
    // local functions/variables as exported and promote if necessary.
    if (!SummaryIndex.empty()) {
      ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
          llvm::getModuleSummaryIndexForFile(SummaryIndex, diagnosticHandler);
      std::error_code EC = IndexOrErr.getError();
      if (EC) {
        errs() << EC.message() << '\n';
        return false;
      }
      auto Index = std::move(IndexOrErr.get());

      // Promotion
      if (renameModuleForThinLTO(*M, *Index))
        return true;
    }

    if (Verbose)
      errs() << "Linking in '" << File << "'\n";

    if (L.linkInModule(std::move(M), ApplicableFlags))
      return false;
    // All linker flags apply to linking of subsequent files.
    ApplicableFlags = Flags;
  }

  return true;
}
开发者ID:CSI-LLVM,项目名称:llvm,代码行数:48,代码来源:llvm-link.cpp

示例9: main


//.........这里部分代码省略.........
					}
					else if (pType->GetKind() == type_enum)
					{
						((EnumType*)pType)->m_typedesc = (Type_Info*)typedesc;
					}

					typedesc->_m_data = pType2;

					AddPersistentLiveRoot((Object**)&typedesc->_m_data);
#endif
				}
				else
				{
					TRACE("-----%s\n", name->c_str());
				}
			}
		}
#endif

	{
#if 1
		ULONG heapsize = heap->m_next - (heap->m_data);
#else
		ULONG heapsize = heap->m_next - (heap->m_data+heap->m_size);
#endif

		printf("heapsize: %f MB\n", heapsize / (1024.0*1024));
	}

	#if AMIGA

		printf("Calling");

		char* line = strdup("programname parameter0 parameter1");
		entrypoint_hook(pOFile->m_textdata, line, strlen(line));
	#endif
	}

#if 0
	if (argc <= 1)
	{
		printf("Usage:\n");
		printf("loader objectfile\n");
		return -10;
	}

	Linker linker;

	for (int i = 1; i < argc; i++)
	{
		linker.m_files.Add(new StringA(argv[i]));
	}

	printf("pass1...");
	linker.pass1();
//	linker.pass2();

	/*
	GlobalSymbol* globsym = linker.globsyms["_main2"];

	FileByteStream file(globsym->m_filename);
	linker.LoadObjectFile(file);

	printf("Calling...");
	((dllentrypoint)globsym->Value)();
	printf("done\n");
	*/

	printf("done\n");

	printf("loading...");
	fflush(stdout);

//	FileByteStream* file = new FileByteStream(linker.m_files[0]);
//	printf("sdfsdf\n");
//	fflush(stdout);
	linker.LoadObjectFile(linker.m_objectFiles[0]);

	linker.sets();

	OFile* pOFile = linker.LoadObjectFile2(linker.m_objectFiles[0]);

	printf("done\n");

	if (linker.m_undefinedReferenceCount)
	{
		printf("undefined reference count: %d\n", linker.m_undefinedReferenceCount);
		TRACE("undefined reference count: %d\n", linker.m_undefinedReferenceCount);
	}
	else
	{
	#if AMIGA
		char* line = strdup("programname parameter0 parameter1");
		entrypoint_hook(pOFile->m_textdata, line, strlen(line));
	#endif
	}
#endif

	return 0;
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例10: importFunctions

/// Import any functions requested via the -import option.
static bool importFunctions(const char *argv0, LLVMContext &Context,
                            Linker &L) {
  for (const auto &Import : Imports) {
    // Identify the requested function and its bitcode source file.
    size_t Idx = Import.find(':');
    if (Idx == std::string::npos) {
      errs() << "Import parameter bad format: " << Import << "\n";
      return false;
    }
    std::string FunctionName = Import.substr(0, Idx);
    std::string FileName = Import.substr(Idx + 1, std::string::npos);

    // Load the specified source module.
    std::unique_ptr<Module> M = loadFile(argv0, FileName, Context);
    if (!M.get()) {
      errs() << argv0 << ": error loading file '" << FileName << "'\n";
      return false;
    }

    if (verifyModule(*M, &errs())) {
      errs() << argv0 << ": " << FileName
             << ": error: input module is broken!\n";
      return false;
    }

    Function *F = M->getFunction(FunctionName);
    if (!F) {
      errs() << "Ignoring import request for non-existent function "
             << FunctionName << " from " << FileName << "\n";
      continue;
    }
    // We cannot import weak_any functions without possibly affecting the
    // order they are seen and selected by the linker, changing program
    // semantics.
    if (F->hasWeakAnyLinkage()) {
      errs() << "Ignoring import request for weak-any function " << FunctionName
             << " from " << FileName << "\n";
      continue;
    }

    if (Verbose)
      errs() << "Importing " << FunctionName << " from " << FileName << "\n";

    std::unique_ptr<FunctionInfoIndex> Index;
    if (!FunctionIndex.empty()) {
      ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
          llvm::getFunctionIndexForFile(FunctionIndex, diagnosticHandler);
      std::error_code EC = IndexOrErr.getError();
      if (EC) {
        errs() << EC.message() << '\n';
        return false;
      }
      Index = std::move(IndexOrErr.get());
    }

    // Link in the specified function.
    DenseSet<const GlobalValue *> FunctionsToImport;
    FunctionsToImport.insert(F);
    if (L.linkInModule(*M, Linker::Flags::None, Index.get(),
                       &FunctionsToImport))
      return false;
  }
  return true;
}
开发者ID:jhayworth,项目名称:llvm,代码行数:65,代码来源:llvm-link.cpp

示例11: importFunctions

/// Import any functions requested via the -import option.
static bool importFunctions(const char *argv0, LLVMContext &Context,
                            Linker &L) {
  StringMap<std::unique_ptr<DenseMap<unsigned, MDNode *>>>
      ModuleToTempMDValsMap;
  for (const auto &Import : Imports) {
    // Identify the requested function and its bitcode source file.
    size_t Idx = Import.find(':');
    if (Idx == std::string::npos) {
      errs() << "Import parameter bad format: " << Import << "\n";
      return false;
    }
    std::string FunctionName = Import.substr(0, Idx);
    std::string FileName = Import.substr(Idx + 1, std::string::npos);

    // Load the specified source module.
    std::unique_ptr<Module> M = loadFile(argv0, FileName, Context, false);
    if (!M.get()) {
      errs() << argv0 << ": error loading file '" << FileName << "'\n";
      return false;
    }

    if (verifyModule(*M, &errs())) {
      errs() << argv0 << ": " << FileName
             << ": error: input module is broken!\n";
      return false;
    }

    Function *F = M->getFunction(FunctionName);
    if (!F) {
      errs() << "Ignoring import request for non-existent function "
             << FunctionName << " from " << FileName << "\n";
      continue;
    }
    // We cannot import weak_any functions without possibly affecting the
    // order they are seen and selected by the linker, changing program
    // semantics.
    if (F->hasWeakAnyLinkage()) {
      errs() << "Ignoring import request for weak-any function " << FunctionName
             << " from " << FileName << "\n";
      continue;
    }

    if (Verbose)
      errs() << "Importing " << FunctionName << " from " << FileName << "\n";

    std::unique_ptr<FunctionInfoIndex> Index;
    if (!FunctionIndex.empty()) {
      ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
          llvm::getFunctionIndexForFile(FunctionIndex, diagnosticHandler);
      std::error_code EC = IndexOrErr.getError();
      if (EC) {
        errs() << EC.message() << '\n';
        return false;
      }
      Index = std::move(IndexOrErr.get());
    }

    // Save the mapping of value ids to temporary metadata created when
    // importing this function. If we have already imported from this module,
    // add new temporary metadata to the existing mapping.
    auto &TempMDVals = ModuleToTempMDValsMap[FileName];
    if (!TempMDVals)
      TempMDVals = llvm::make_unique<DenseMap<unsigned, MDNode *>>();

    // Link in the specified function.
    DenseSet<const GlobalValue *> FunctionsToImport;
    FunctionsToImport.insert(F);
    if (L.linkInModule(std::move(M), Linker::Flags::None, Index.get(),
                       &FunctionsToImport, TempMDVals.get()))
      return false;
  }

  // Now link in metadata for all modules from which we imported functions.
  for (StringMapEntry<std::unique_ptr<DenseMap<unsigned, MDNode *>>> &SME :
       ModuleToTempMDValsMap) {
    // Load the specified source module.
    std::unique_ptr<Module> M = loadFile(argv0, SME.getKey(), Context, true);
    if (!M.get()) {
      errs() << argv0 << ": error loading file '" << SME.getKey() << "'\n";
      return false;
    }

    if (verifyModule(*M, &errs())) {
      errs() << argv0 << ": " << SME.getKey()
             << ": error: input module is broken!\n";
      return false;
    }

    // Link in all necessary metadata from this module.
    if (L.linkInMetadata(*M, SME.getValue().get()))
      return false;
  }
  return true;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:95,代码来源:llvm-link.cpp

示例12: importFunctions

/// Import any functions requested via the -import option.
static bool importFunctions(const char *argv0, LLVMContext &Context,
                            Linker &L) {
  if (SummaryIndex.empty())
    return true;
  std::unique_ptr<ModuleSummaryIndex> Index =
      ExitOnErr(llvm::getModuleSummaryIndexForFile(SummaryIndex));

  // Map of Module -> List of globals to import from the Module
  std::map<StringRef, DenseSet<const GlobalValue *>> ModuleToGlobalsToImportMap;
  auto ModuleLoader = [&Context](const char *argv0,
                                 const std::string &Identifier) {
    return loadFile(argv0, Identifier, Context, false);
  };
  ModuleLazyLoaderCache ModuleLoaderCache(ModuleLoader);
  for (const auto &Import : Imports) {
    // Identify the requested function and its bitcode source file.
    size_t Idx = Import.find(':');
    if (Idx == std::string::npos) {
      errs() << "Import parameter bad format: " << Import << "\n";
      return false;
    }
    std::string FunctionName = Import.substr(0, Idx);
    std::string FileName = Import.substr(Idx + 1, std::string::npos);

    // Load the specified source module.
    auto &SrcModule = ModuleLoaderCache(argv0, FileName);

    if (verifyModule(SrcModule, &errs())) {
      errs() << argv0 << ": " << FileName
             << ": error: input module is broken!\n";
      return false;
    }

    Function *F = SrcModule.getFunction(FunctionName);
    if (!F) {
      errs() << "Ignoring import request for non-existent function "
             << FunctionName << " from " << FileName << "\n";
      continue;
    }
    // We cannot import weak_any functions without possibly affecting the
    // order they are seen and selected by the linker, changing program
    // semantics.
    if (F->hasWeakAnyLinkage()) {
      errs() << "Ignoring import request for weak-any function " << FunctionName
             << " from " << FileName << "\n";
      continue;
    }

    if (Verbose)
      errs() << "Importing " << FunctionName << " from " << FileName << "\n";

    auto &Entry = ModuleToGlobalsToImportMap[SrcModule.getModuleIdentifier()];
    Entry.insert(F);

    ExitOnErr(F->materialize());
  }

  // Do the actual import of globals now, one Module at a time
  for (auto &GlobalsToImportPerModule : ModuleToGlobalsToImportMap) {
    // Get the module for the import
    auto &GlobalsToImport = GlobalsToImportPerModule.second;
    std::unique_ptr<Module> SrcModule =
        ModuleLoaderCache.takeModule(GlobalsToImportPerModule.first);
    assert(&Context == &SrcModule->getContext() && "Context mismatch");

    // If modules were created with lazy metadata loading, materialize it
    // now, before linking it (otherwise this will be a noop).
    ExitOnErr(SrcModule->materializeMetadata());
    UpgradeDebugInfo(*SrcModule);

    // Linkage Promotion and renaming
    if (renameModuleForThinLTO(*SrcModule, *Index, &GlobalsToImport))
      return true;

    // Instruct the linker to not automatically import linkonce defintion.
    unsigned Flags = Linker::Flags::DontForceLinkLinkonceODR;

    if (L.linkInModule(std::move(SrcModule), Flags, &GlobalsToImport))
      return false;
  }

  return true;
}
开发者ID:anupam128,项目名称:llvm,代码行数:84,代码来源:llvm-link.cpp

示例13: init

void init()
{
	output_type = OUPUT_EXE;
	subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;

	lib_path = get_lib_path();

	linker.init();
}
开发者ID:FireLeaf,项目名称:CLike,代码行数:9,代码来源:main.cpp

示例14: main

int main(int argc, char** argv)
{
	
	int opind;
	char *ext;
	init();
	opind = process_command(argc, argv);
	if (opind == 0)
	{
		return 0;
	}

	for (int src_idx = 0; src_idx < static_cast<int>(src_files.size()); src_idx++)
	{
		filename = src_files[src_idx];
		ext = get_file_ext(filename);
		if (!strcmp(ext, "c"))
		{
			compile(filename);
		}
		
		if (!strcmp(ext, "obj"))
		{
			linker.load_obj_file(filename);
		}
	}

	if (!outfile)
	{
		printf("usage: scc [-c infile] [-o outfile] [-lib] [infile] infile2...\n");
		return -1;
	}

	if (output_type == OUTPUT_OBJ)
	{
		syntax.coff.write_obj(outfile);
	}
	else
		linker.pe_output_file(outfile);

	getchar();

	return 0;
}
开发者ID:FireLeaf,项目名称:CLike,代码行数:44,代码来源:main.cpp


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