1 //===- PositionalOptions.h ------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef MCLD_LDLITE_POSITIONAL_OPTIONS_H 10 #define MCLD_LDLITE_POSITIONAL_OPTIONS_H 11 #include <llvm/Support/CommandLine.h> 12 #include <mcld/Support/CommandLine.h> 13 #include <mcld/Support/Path.h> 14 #include <string> 15 16 namespace mcld { 17 18 class InputAction; 19 class LinkerConfig; 20 class LinkerScript; 21 22 /** \class PositionalOptions 23 * 24 * The meaning of a positional option depends on its position and its related 25 * positions with the other positional options. There are four kinds of 26 * positional options: 27 * 1. Inputs, object files, such as /tmp/XXXX.o 28 * 2. Namespecs, short names of libraries. A namespec may refer to an archive 29 * or a shared library. For example, -lm. 30 * 3. Attributes of inputs. Attributes describe inputs appears after them. 31 * For example, --as-needed and --whole-archive. 32 * 4. Groups. A Group is a set of archives. Linkers repeatedly read archives 33 * in groups until there is no new undefined symbols. 34 * 5. Definitions of symbols. --defsym option depends on 35 */ 36 class PositionalOptions 37 { 38 public: 39 PositionalOptions(); 40 41 size_t numOfInputs() const; 42 43 bool parse(std::vector<InputAction*>& pActions, 44 const LinkerConfig& pConfig, 45 const LinkerScript& pScript); 46 47 private: 48 size_t numOfActions() const; 49 50 private: 51 llvm::cl::list<mcld::sys::fs::Path>& m_InputObjectFiles; 52 llvm::cl::list<std::string>& m_LinkerScript; 53 llvm::cl::list<std::string>& m_NameSpecList; 54 llvm::cl::list<bool>& m_WholeArchiveList; 55 llvm::cl::list<bool>& m_NoWholeArchiveList; 56 llvm::cl::list<bool>& m_AsNeededList; 57 llvm::cl::list<bool>& m_NoAsNeededList; 58 llvm::cl::list<bool>& m_AddNeededList; 59 llvm::cl::list<bool>& m_NoAddNeededList; 60 llvm::cl::list<bool>& m_BDynamicList; 61 llvm::cl::list<bool>& m_BStaticList; 62 llvm::cl::list<bool>& m_StartGroupList; 63 llvm::cl::list<bool>& m_EndGroupList; 64 llvm::cl::list<std::string>& m_DefSymList; 65 66 }; 67 68 } // namespace of mcld 69 70 #endif 71 72