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