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. No
40 /// matching of symbols is done. It simply calls loads each module and calls
41 /// LinkModules for each one.
42 /// @returns true if an error occurs, false otherwise
44 const char * progname, ///< Name of the program being linked (for output)
45 Module * HeadModule, ///< Main (resulting) module to be linked into
46 const std::vector<std::string> & Files, ///< Files to link in
47 bool Verbose ///< Link verbosely, indicating each action
50 /// This function links one archive, \p Filename, that contains bytecode into
51 /// \p HeadModule. If an error occurs, true is returned, otherwise false. If
52 /// \p ErrorMsg is not null and an error occurs, \p *ErrorMsg will be set to a
53 /// readable string that indicates the nature of the error.
54 /// @returns true if there's an error
55 /// @brief Link in one archive.
57 Module* HeadModule, ///< Main (resulting) module to be linked into
58 const std::string& Filename, ///< Filename of the archive to link
59 std::string* ErrorMsg, ///< Error message if an error occurs.
60 bool Verbose ///< Link verbosely, indicating each action
63 /// This function provides the ability to handle the -L and -l options on a
64 /// linker's command line. It will link into \p HeadModule any modules found in
65 /// the \p Libraries (which might be found in the \p LibPaths).
66 /// @brief Link libraries into a module
68 const char * progname, ///< Name of the program being linked (for output)
69 Module* HeadModule, ///< Main (resulting) module to be linked into
70 const std::vector<std::string> & Libraries, ///< Set of libraries to link in
71 const std::vector<std::string> & LibPaths, ///< Set of library paths
72 bool Verbose, ///< Link verbosely, indicating each action
73 bool Native ///< Linking is for a native executable
76 /// This function looks at Module \p M and returns a set of strings,
77 /// \p DefinedSymbols, that is the publicly visible defined symbols in
79 void GetAllDefinedSymbols (Module *M, std::set<std::string> &DefinedSymbols);
81 /// This function looks at Module \p M and returns a set of strings,
82 /// \p UnefinedSymbols, that is the publicly visible undefined symbols in
84 void GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols);
86 /// This function looks through a set of \p Paths to find a library with the
87 /// name \p Filename. If \p SharedObjectOnly is true, it only finds a match
88 /// if the file is a shared library.
89 std::string FindLib(const std::string &Filename,
90 const std::vector<std::string> &Paths,
91 bool SharedObjectOnly = false);
93 } // End llvm namespace