| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 1 | //===- lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp -------------------===// |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Linker |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| Rui Ueyama | fd50283 | 2013-07-24 22:53:23 +0000 | [diff] [blame] | 10 | #include "Atoms.h" |
| Rui Ueyama | c91c24e3 | 2013-12-13 06:58:27 +0000 | [diff] [blame] | 11 | #include "EdataPass.h" |
| Rui Ueyama | 991f42c | 2013-06-19 17:46:57 +0000 | [diff] [blame] | 12 | #include "GroupedSectionsPass.h" |
| Rui Ueyama | c8a5379 | 2013-07-11 08:46:21 +0000 | [diff] [blame] | 13 | #include "IdataPass.h" |
| Rui Ueyama | 908606d | 2013-08-09 04:44:15 +0000 | [diff] [blame] | 14 | #include "LinkerGeneratedSymbolFile.h" |
| Rui Ueyama | 1a11b3b | 2013-11-25 02:00:00 +0000 | [diff] [blame] | 15 | #include "SetSubsystemPass.h" |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 16 | |
| Rui Ueyama | d95a155 | 2013-06-17 16:59:54 +0000 | [diff] [blame] | 17 | #include "lld/Core/PassManager.h" |
| 18 | #include "lld/Passes/LayoutPass.h" |
| Rui Ueyama | c9752fa | 2013-11-01 19:52:37 +0000 | [diff] [blame] | 19 | #include "lld/Passes/RoundTripNativePass.h" |
| 20 | #include "lld/Passes/RoundTripYAMLPass.h" |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 21 | #include "lld/ReaderWriter/PECOFFLinkingContext.h" |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 22 | #include "lld/ReaderWriter/Reader.h" |
| Rui Ueyama | fd50283 | 2013-07-24 22:53:23 +0000 | [diff] [blame] | 23 | #include "lld/ReaderWriter/Simple.h" |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 24 | #include "lld/ReaderWriter/Writer.h" |
| Rui Ueyama | c9752fa | 2013-11-01 19:52:37 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/SmallString.h" |
| 26 | #include "llvm/Support/Allocator.h" |
| 27 | #include "llvm/Support/Path.h" |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 28 | |
| Rui Ueyama | 9149181 | 2013-09-23 19:52:35 +0000 | [diff] [blame] | 29 | #include <bitset> |
| Rui Ueyama | 863931c | 2013-10-26 00:46:57 +0000 | [diff] [blame] | 30 | #include <set> |
| Rui Ueyama | 9149181 | 2013-09-23 19:52:35 +0000 | [diff] [blame] | 31 | |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 32 | namespace lld { |
| 33 | |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 34 | bool PECOFFLinkingContext::validateImpl(raw_ostream &diagnostics) { |
| Rui Ueyama | eb0cc96 | 2013-06-08 03:59:00 +0000 | [diff] [blame] | 35 | if (_stackReserve < _stackCommit) { |
| 36 | diagnostics << "Invalid stack size: reserve size must be equal to or " |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 37 | << "greater than commit size, but got " << _stackCommit |
| 38 | << " and " << _stackReserve << ".\n"; |
| Rui Ueyama | 8db1edd | 2013-09-24 23:26:34 +0000 | [diff] [blame] | 39 | return false; |
| Rui Ueyama | eb0cc96 | 2013-06-08 03:59:00 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| Rui Ueyama | 9dd08d9 | 2013-06-08 22:59:10 +0000 | [diff] [blame] | 42 | if (_heapReserve < _heapCommit) { |
| 43 | diagnostics << "Invalid heap size: reserve size must be equal to or " |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 44 | << "greater than commit size, but got " << _heapCommit |
| 45 | << " and " << _heapReserve << ".\n"; |
| Rui Ueyama | 8db1edd | 2013-09-24 23:26:34 +0000 | [diff] [blame] | 46 | return false; |
| Rui Ueyama | 9dd08d9 | 2013-06-08 22:59:10 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| Rui Ueyama | 530488c | 2013-09-03 22:57:00 +0000 | [diff] [blame] | 49 | // It's an error if the base address is not multiple of 64K. |
| 50 | if (_baseAddress & 0xffff) { |
| 51 | diagnostics << "Base address have to be multiple of 64K, but got " |
| 52 | << _baseAddress << "\n"; |
| Rui Ueyama | 8db1edd | 2013-09-24 23:26:34 +0000 | [diff] [blame] | 53 | return false; |
| Rui Ueyama | 530488c | 2013-09-03 22:57:00 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| Rui Ueyama | a6fddab | 2013-12-16 09:15:58 +0000 | [diff] [blame^] | 56 | // Check for duplicate export ordinals. |
| 57 | std::set<int> exports; |
| 58 | for (const PECOFFLinkingContext::ExportDesc &desc : getDllExports()) { |
| 59 | if (desc.ordinal == -1) |
| 60 | continue; |
| 61 | if (exports.count(desc.ordinal) == 1) { |
| 62 | diagnostics << "Duplicate export ordinals: " << desc.ordinal << "\n"; |
| 63 | return false; |
| 64 | } |
| 65 | exports.insert(desc.ordinal); |
| 66 | } |
| 67 | |
| Rui Ueyama | 41b99dc | 2013-11-06 19:30:14 +0000 | [diff] [blame] | 68 | std::bitset<64> alignment(_sectionDefaultAlignment); |
| Rui Ueyama | 9149181 | 2013-09-23 19:52:35 +0000 | [diff] [blame] | 69 | if (alignment.count() != 1) { |
| 70 | diagnostics << "Section alignment must be a power of 2, but got " |
| Rui Ueyama | 41b99dc | 2013-11-06 19:30:14 +0000 | [diff] [blame] | 71 | << _sectionDefaultAlignment << "\n"; |
| Rui Ueyama | 8db1edd | 2013-09-24 23:26:34 +0000 | [diff] [blame] | 72 | return false; |
| Rui Ueyama | 9149181 | 2013-09-23 19:52:35 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| Rui Ueyama | 98896ed | 2013-09-12 19:46:53 +0000 | [diff] [blame] | 75 | // Architectures other than i386 is not supported yet. |
| 76 | if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386) { |
| 77 | diagnostics << "Machine type other than x86 is not supported.\n"; |
| Rui Ueyama | 8db1edd | 2013-09-24 23:26:34 +0000 | [diff] [blame] | 78 | return false; |
| Rui Ueyama | 98896ed | 2013-09-12 19:46:53 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 81 | _reader = createReaderPECOFF(*this); |
| 82 | _writer = createWriterPECOFF(*this); |
| Rui Ueyama | 8db1edd | 2013-09-24 23:26:34 +0000 | [diff] [blame] | 83 | return true; |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| Shankar Easwaran | a96f3a3 | 2013-10-07 02:47:09 +0000 | [diff] [blame] | 86 | std::unique_ptr<File> PECOFFLinkingContext::createEntrySymbolFile() const { |
| Shankar Easwaran | d26c8e3 | 2013-08-31 05:27:38 +0000 | [diff] [blame] | 87 | if (entrySymbolName().empty()) |
| 88 | return nullptr; |
| 89 | std::unique_ptr<SimpleFile> entryFile( |
| 90 | new SimpleFile(*this, "command line option /entry")); |
| 91 | entryFile->addAtom( |
| 92 | *(new (_allocator) SimpleUndefinedAtom(*entryFile, entrySymbolName()))); |
| 93 | return std::move(entryFile); |
| 94 | } |
| Rui Ueyama | 908606d | 2013-08-09 04:44:15 +0000 | [diff] [blame] | 95 | |
| Shankar Easwaran | a96f3a3 | 2013-10-07 02:47:09 +0000 | [diff] [blame] | 96 | std::unique_ptr<File> PECOFFLinkingContext::createUndefinedSymbolFile() const { |
| Shankar Easwaran | d26c8e3 | 2013-08-31 05:27:38 +0000 | [diff] [blame] | 97 | if (_initialUndefinedSymbols.empty()) |
| 98 | return nullptr; |
| 99 | std::unique_ptr<SimpleFile> undefinedSymFile( |
| 100 | new SimpleFile(*this, "command line option /c (or) /include")); |
| 101 | for (auto undefSymStr : _initialUndefinedSymbols) |
| 102 | undefinedSymFile->addAtom(*(new (_allocator) SimpleUndefinedAtom( |
| 103 | *undefinedSymFile, undefSymStr))); |
| 104 | return std::move(undefinedSymFile); |
| 105 | } |
| 106 | |
| Shankar Easwaran | a96f3a3 | 2013-10-07 02:47:09 +0000 | [diff] [blame] | 107 | bool PECOFFLinkingContext::createImplicitFiles( |
| 108 | std::vector<std::unique_ptr<File> > &) const { |
| 109 | std::unique_ptr<SimpleFileNode> fileNode( |
| 110 | new SimpleFileNode("Implicit Files")); |
| 111 | std::unique_ptr<File> linkerGeneratedSymFile( |
| Rui Ueyama | 091071f | 2013-12-13 02:58:27 +0000 | [diff] [blame] | 112 | new pecoff::LinkerGeneratedSymbolFile(*this)); |
| Shankar Easwaran | a96f3a3 | 2013-10-07 02:47:09 +0000 | [diff] [blame] | 113 | fileNode->appendInputFile(std::move(linkerGeneratedSymFile)); |
| 114 | inputGraph().insertOneElementAt(std::move(fileNode), |
| 115 | InputGraph::Position::END); |
| 116 | return true; |
| Rui Ueyama | fd50283 | 2013-07-24 22:53:23 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| Rui Ueyama | 863931c | 2013-10-26 00:46:57 +0000 | [diff] [blame] | 119 | /// Returns the section name in the resulting executable. |
| 120 | /// |
| 121 | /// Sections in object files are usually output to the executable with the same |
| 122 | /// name, but you can rename by command line option. /merge:from=to makes the |
| 123 | /// linker to combine "from" section contents to "to" section in the |
| 124 | /// executable. We have a mapping for the renaming. This method looks up the |
| 125 | /// table and returns a new section name if renamed. |
| 126 | StringRef |
| Rui Ueyama | 951dd1d | 2013-11-27 18:03:31 +0000 | [diff] [blame] | 127 | PECOFFLinkingContext::getOutputSectionName(StringRef sectionName) const { |
| Rui Ueyama | 863931c | 2013-10-26 00:46:57 +0000 | [diff] [blame] | 128 | auto it = _renamedSections.find(sectionName); |
| 129 | if (it == _renamedSections.end()) |
| 130 | return sectionName; |
| Rui Ueyama | 951dd1d | 2013-11-27 18:03:31 +0000 | [diff] [blame] | 131 | return getOutputSectionName(it->second); |
| Rui Ueyama | 863931c | 2013-10-26 00:46:57 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | /// Adds a mapping to the section renaming table. This method will be used for |
| 135 | /// /merge command line option. |
| 136 | bool PECOFFLinkingContext::addSectionRenaming(raw_ostream &diagnostics, |
| 137 | StringRef from, StringRef to) { |
| 138 | auto it = _renamedSections.find(from); |
| 139 | if (it != _renamedSections.end()) { |
| 140 | if (it->second == to) |
| 141 | // There's already the same mapping. |
| 142 | return true; |
| 143 | diagnostics << "Section \"" << from << "\" is already mapped to \"" |
| 144 | << it->second << ", so it cannot be mapped to \"" << to << "\"."; |
| 145 | return true; |
| 146 | } |
| 147 | |
| 148 | // Add a mapping, and check if there's no cycle in the renaming mapping. The |
| 149 | // cycle detection algorithm we use here is naive, but that's OK because the |
| 150 | // number of mapping is usually less than 10. |
| 151 | _renamedSections[from] = to; |
| 152 | for (auto elem : _renamedSections) { |
| 153 | StringRef sectionName = elem.first; |
| 154 | std::set<StringRef> visited; |
| 155 | visited.insert(sectionName); |
| 156 | for (;;) { |
| Nick Kledzik | 3df8104 | 2013-11-06 21:30:15 +0000 | [diff] [blame] | 157 | auto pos = _renamedSections.find(sectionName); |
| 158 | if (pos == _renamedSections.end()) |
| Rui Ueyama | 863931c | 2013-10-26 00:46:57 +0000 | [diff] [blame] | 159 | break; |
| Nick Kledzik | 3df8104 | 2013-11-06 21:30:15 +0000 | [diff] [blame] | 160 | if (visited.count(pos->second)) { |
| Rui Ueyama | 863931c | 2013-10-26 00:46:57 +0000 | [diff] [blame] | 161 | diagnostics << "/merge:" << from << "=" << to << " makes a cycle"; |
| 162 | return false; |
| 163 | } |
| Nick Kledzik | 3df8104 | 2013-11-06 21:30:15 +0000 | [diff] [blame] | 164 | sectionName = pos->second; |
| Rui Ueyama | 863931c | 2013-10-26 00:46:57 +0000 | [diff] [blame] | 165 | visited.insert(sectionName); |
| 166 | } |
| 167 | } |
| 168 | return true; |
| 169 | } |
| 170 | |
| Rui Ueyama | 34d6e9b | 2013-12-09 01:47:32 +0000 | [diff] [blame] | 171 | StringRef PECOFFLinkingContext::getAlternateName(StringRef def) const { |
| 172 | auto it = _alternateNames.find(def); |
| 173 | if (it == _alternateNames.end()) |
| 174 | return ""; |
| 175 | return it->second; |
| 176 | } |
| 177 | |
| 178 | void PECOFFLinkingContext::setAlternateName(StringRef weak, StringRef def) { |
| 179 | _alternateNames[def] = weak; |
| 180 | } |
| 181 | |
| Rui Ueyama | 2897feb | 2013-07-19 02:18:25 +0000 | [diff] [blame] | 182 | /// Try to find the input library file from the search paths and append it to |
| 183 | /// the input file list. Returns true if the library file is found. |
| Shankar Easwaran | e44104b | 2013-08-21 22:57:10 +0000 | [diff] [blame] | 184 | StringRef PECOFFLinkingContext::searchLibraryFile(StringRef filename) const { |
| Rui Ueyama | 2897feb | 2013-07-19 02:18:25 +0000 | [diff] [blame] | 185 | // Current directory always takes precedence over the search paths. |
| Shankar Easwaran | e44104b | 2013-08-21 22:57:10 +0000 | [diff] [blame] | 186 | if (llvm::sys::path::is_absolute(filename) || llvm::sys::fs::exists(filename)) |
| 187 | return filename; |
| Rui Ueyama | 2897feb | 2013-07-19 02:18:25 +0000 | [diff] [blame] | 188 | // Iterate over the search paths. |
| 189 | for (StringRef dir : _inputSearchPaths) { |
| 190 | SmallString<128> path = dir; |
| 191 | llvm::sys::path::append(path, filename); |
| Shankar Easwaran | e44104b | 2013-08-21 22:57:10 +0000 | [diff] [blame] | 192 | if (llvm::sys::fs::exists(path.str())) |
| Rui Ueyama | 90bcd11 | 2013-11-21 00:17:31 +0000 | [diff] [blame] | 193 | return allocate(path.str()); |
| Rui Ueyama | 2897feb | 2013-07-19 02:18:25 +0000 | [diff] [blame] | 194 | } |
| Shankar Easwaran | e44104b | 2013-08-21 22:57:10 +0000 | [diff] [blame] | 195 | return filename; |
| Rui Ueyama | 2897feb | 2013-07-19 02:18:25 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| Rui Ueyama | abc227b | 2013-12-14 04:32:29 +0000 | [diff] [blame] | 198 | /// Returns the decorated name of the given symbol name. On 32-bit x86, it |
| 199 | /// adds "_" at the beginning of the string. On other architectures, the |
| 200 | /// return value is the same as the argument. |
| 201 | StringRef PECOFFLinkingContext::decorateSymbol(StringRef name) const { |
| 202 | if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386) |
| 203 | return name; |
| 204 | std::string str = "_"; |
| 205 | str.append(name); |
| 206 | return allocate(str); |
| 207 | } |
| 208 | |
| 209 | StringRef PECOFFLinkingContext::undecorateSymbol(StringRef name) const { |
| 210 | if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386) |
| 211 | return name; |
| 212 | assert(name.startswith("_")); |
| 213 | return name.substr(1); |
| 214 | } |
| 215 | |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 216 | Writer &PECOFFLinkingContext::writer() const { return *_writer; } |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 217 | |
| 218 | ErrorOr<Reference::Kind> |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 219 | PECOFFLinkingContext::relocKindFromString(StringRef str) const { |
| Rui Ueyama | e1c30a4 | 2013-11-06 04:47:19 +0000 | [diff] [blame] | 220 | #define LLD_CASE(name) .Case(#name, llvm::COFF::name) |
| Shankar Easwaran | 53bae6f | 2013-10-26 19:38:31 +0000 | [diff] [blame] | 221 | int32_t ret = llvm::StringSwitch<int32_t>(str) |
| 222 | LLD_CASE(IMAGE_REL_I386_ABSOLUTE) |
| 223 | LLD_CASE(IMAGE_REL_I386_DIR32) |
| 224 | LLD_CASE(IMAGE_REL_I386_DIR32NB) |
| Rui Ueyama | fac7332 | 2013-12-03 09:18:31 +0000 | [diff] [blame] | 225 | LLD_CASE(IMAGE_REL_I386_SECTION) |
| 226 | LLD_CASE(IMAGE_REL_I386_SECREL) |
| Shankar Easwaran | 53bae6f | 2013-10-26 19:38:31 +0000 | [diff] [blame] | 227 | LLD_CASE(IMAGE_REL_I386_REL32) |
| 228 | .Default(-1); |
| Rui Ueyama | e1c30a4 | 2013-11-06 04:47:19 +0000 | [diff] [blame] | 229 | #undef LLD_CASE |
| Shankar Easwaran | 53bae6f | 2013-10-26 19:38:31 +0000 | [diff] [blame] | 230 | if (ret == -1) |
| 231 | return make_error_code(YamlReaderError::illegal_value); |
| 232 | return ret; |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | ErrorOr<std::string> |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 236 | PECOFFLinkingContext::stringFromRelocKind(Reference::Kind kind) const { |
| Shankar Easwaran | 53bae6f | 2013-10-26 19:38:31 +0000 | [diff] [blame] | 237 | switch (kind) { |
| Rui Ueyama | e1c30a4 | 2013-11-06 04:47:19 +0000 | [diff] [blame] | 238 | #define LLD_CASE(name) \ |
| 239 | case llvm::COFF::name: \ |
| 240 | return std::string(#name); |
| 241 | |
| Shankar Easwaran | 53bae6f | 2013-10-26 19:38:31 +0000 | [diff] [blame] | 242 | LLD_CASE(IMAGE_REL_I386_ABSOLUTE) |
| 243 | LLD_CASE(IMAGE_REL_I386_DIR32) |
| 244 | LLD_CASE(IMAGE_REL_I386_DIR32NB) |
| Rui Ueyama | fac7332 | 2013-12-03 09:18:31 +0000 | [diff] [blame] | 245 | LLD_CASE(IMAGE_REL_I386_SECTION) |
| 246 | LLD_CASE(IMAGE_REL_I386_SECREL) |
| Shankar Easwaran | 53bae6f | 2013-10-26 19:38:31 +0000 | [diff] [blame] | 247 | LLD_CASE(IMAGE_REL_I386_REL32) |
| Rui Ueyama | e1c30a4 | 2013-11-06 04:47:19 +0000 | [diff] [blame] | 248 | #undef LLD_CASE |
| Shankar Easwaran | 53bae6f | 2013-10-26 19:38:31 +0000 | [diff] [blame] | 249 | } |
| Rui Ueyama | c6015f6 | 2013-10-09 00:57:22 +0000 | [diff] [blame] | 250 | return make_error_code(YamlReaderError::illegal_value); |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| Rui Ueyama | 615b200 | 2013-11-27 21:34:16 +0000 | [diff] [blame] | 253 | void PECOFFLinkingContext::setSectionSetMask(StringRef sectionName, |
| 254 | uint32_t newFlags) { |
| 255 | _sectionSetMask[sectionName] |= newFlags; |
| 256 | _sectionClearMask[sectionName] &= ~newFlags; |
| 257 | const uint32_t rwx = (llvm::COFF::IMAGE_SCN_MEM_READ | |
| 258 | llvm::COFF::IMAGE_SCN_MEM_WRITE | |
| 259 | llvm::COFF::IMAGE_SCN_MEM_EXECUTE); |
| 260 | if (newFlags & rwx) |
| 261 | _sectionClearMask[sectionName] |= ~_sectionSetMask[sectionName] & rwx; |
| 262 | assert((_sectionSetMask[sectionName] & _sectionClearMask[sectionName]) == 0); |
| 263 | } |
| 264 | |
| 265 | void PECOFFLinkingContext::setSectionClearMask(StringRef sectionName, |
| 266 | uint32_t newFlags) { |
| 267 | _sectionClearMask[sectionName] |= newFlags; |
| 268 | _sectionSetMask[sectionName] &= ~newFlags; |
| 269 | assert((_sectionSetMask[sectionName] & _sectionClearMask[sectionName]) == 0); |
| 270 | } |
| 271 | |
| 272 | uint32_t PECOFFLinkingContext::getSectionAttributes(StringRef sectionName, |
| 273 | uint32_t flags) const { |
| 274 | auto si = _sectionSetMask.find(sectionName); |
| 275 | uint32_t setMask = (si == _sectionSetMask.end()) ? 0 : si->second; |
| 276 | auto ci = _sectionClearMask.find(sectionName); |
| 277 | uint32_t clearMask = (ci == _sectionClearMask.end()) ? 0 : ci->second; |
| 278 | return (flags | setMask) & ~clearMask; |
| 279 | } |
| 280 | |
| Shankar Easwaran | 2bc2492 | 2013-10-29 05:12:14 +0000 | [diff] [blame] | 281 | void PECOFFLinkingContext::addPasses(PassManager &pm) { |
| Rui Ueyama | 1a11b3b | 2013-11-25 02:00:00 +0000 | [diff] [blame] | 282 | pm.add(std::unique_ptr<Pass>(new pecoff::SetSubsystemPass(*this))); |
| Rui Ueyama | c91c24e3 | 2013-12-13 06:58:27 +0000 | [diff] [blame] | 283 | pm.add(std::unique_ptr<Pass>(new pecoff::EdataPass(*this))); |
| Rui Ueyama | 3ee2bf6 | 2013-09-15 22:33:15 +0000 | [diff] [blame] | 284 | pm.add(std::unique_ptr<Pass>(new pecoff::IdataPass(*this))); |
| Rui Ueyama | d95a155 | 2013-06-17 16:59:54 +0000 | [diff] [blame] | 285 | pm.add(std::unique_ptr<Pass>(new LayoutPass())); |
| Rui Ueyama | 32c3f17 | 2013-12-07 00:27:17 +0000 | [diff] [blame] | 286 | pm.add(std::unique_ptr<Pass>(new pecoff::GroupedSectionsPass())); |
| Rui Ueyama | d95a155 | 2013-06-17 16:59:54 +0000 | [diff] [blame] | 287 | } |
| Rui Ueyama | 091071f | 2013-12-13 02:58:27 +0000 | [diff] [blame] | 288 | |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 289 | } // end namespace lld |