1 //===- llvm/Linker.h - Module Linker Interface ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Reid Spencer and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interface to the module/file/archive linker.
12 //===----------------------------------------------------------------------===//
25 /// This is the heart of the linker. The \p Src module is linked into the \p
26 /// Dest module. If an error occurs, true is returned, otherwise false. If \p
27 /// ErrorMsg is not null and an error occurs, \p *ErrorMsg will be set to a
28 /// readable string that indicates the nature of the error. Note that this can
29 /// destroy the Src module in arbitrary ways.
31 /// @returns true if there's an error
32 /// @brief Link two modules together
34 Module* Dest, ///< Module into which \p Src is linked
35 Module* Src, ///< Module linked into \p Dest
36 std::string* ErrorMsg ///< Optional error message string
39 /// This function links the bytecode \p Files into the \p HeadModule. Note that
40 /// this does not do any linking of unresolved symbols. The \p Files are all
41 /// completely linked into \p HeadModule regardless of unresolved symbols. This
42 /// function just loads each bytecode file and calls LinkModules on them.
43 /// @returns true if an error occurs, false otherwise
45 const char * progname, ///< Name of the program being linked (for output)
46 Module * HeadModule, ///< Main (resulting) module to be linked into
47 const std::vector<std::string> & Files, ///< Files to link in
48 bool Verbose ///< Link verbosely, indicating each action
51 /// This function links one archive, \p Filename, that contains bytecode into
52 /// \p HeadModule. If an error occurs, true is returned, otherwise false. If
53 /// \p ErrorMsg is not null and an error occurs, \p *ErrorMsg will be set to a
54 /// readable string that indicates the nature of the error.
55 /// @returns true if there's an error
56 /// @brief Link in one archive.
58 Module* HeadModule, ///< Main (resulting) module to be linked into
59 const std::string& Filename, ///< Filename of the archive to link
60 std::string* ErrorMsg, ///< Error message if an error occurs.
61 bool Verbose ///< Link verbosely, indicating each action
64 /// This function provides the ability to handle the -L and -l options on a
65 /// linker's command line. It will link into \p HeadModule any modules found in
66 /// the \p Libraries (which might be found in the \p LibPaths).
67 /// @brief Link libraries into a module
69 const char * progname, ///< Name of the program being linked (for output)
70 Module* HeadModule, ///< Main (resulting) module to be linked into
71 const std::vector<std::string> & Libraries, ///< Set of libraries to link in
72 const std::vector<std::string> & LibPaths, ///< Set of library paths
73 bool Verbose, ///< Link verbosely, indicating each action
74 bool Native ///< Linking is for a native executable
77 /// This function looks at Module \p M and returns a set of strings,
78 /// \p DefinedSymbols, that is the publicly visible defined symbols in
80 void GetAllDefinedSymbols (Module *M, std::set<std::string> &DefinedSymbols);
82 /// This function looks at Module \p M and returns a set of strings,
83 /// \p UnefinedSymbols, that is the publicly visible undefined symbols in
85 void GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols);
87 /// This function looks through a set of \p Paths to find a library with the
88 /// name \p Filename. If \p SharedObjectOnly is true, it only finds a match
89 /// if the file is a shared library.
90 std::string FindLib(const std::string &Filename,
91 const std::vector<std::string> &Paths,
92 bool SharedObjectOnly = false);
94 } // End llvm namespace