| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 1 | //===- lib/ReaderWriter/PECOFF/PECOFFTargetInfo.cpp -----------------------===// |
| 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 | 991f42c | 2013-06-19 17:46:57 +0000 | [diff] [blame^] | 10 | #include "GroupedSectionsPass.h" |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 11 | |
| Rui Ueyama | d95a155 | 2013-06-17 16:59:54 +0000 | [diff] [blame] | 12 | #include "lld/Core/PassManager.h" |
| 13 | #include "lld/Passes/LayoutPass.h" |
| Rui Ueyama | 991f42c | 2013-06-19 17:46:57 +0000 | [diff] [blame^] | 14 | #include "lld/ReaderWriter/PECOFFTargetInfo.h" |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 15 | #include "lld/ReaderWriter/Reader.h" |
| 16 | #include "lld/ReaderWriter/Writer.h" |
| 17 | |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 18 | namespace lld { |
| 19 | |
| 20 | error_code PECOFFTargetInfo::parseFile( |
| 21 | std::unique_ptr<MemoryBuffer> &mb, |
| 22 | std::vector<std::unique_ptr<File>> &result) const { |
| 23 | return _reader->parseFile(mb, result); |
| 24 | } |
| 25 | |
| Rafael Espindola | c1b3268 | 2013-06-11 12:36:05 +0000 | [diff] [blame] | 26 | bool PECOFFTargetInfo::validateImpl(raw_ostream &diagnostics) { |
| Rui Ueyama | eb0cc96 | 2013-06-08 03:59:00 +0000 | [diff] [blame] | 27 | if (_stackReserve < _stackCommit) { |
| 28 | diagnostics << "Invalid stack size: reserve size must be equal to or " |
| 29 | << "greater than commit size, but got " |
| 30 | << _stackCommit << " and " << _stackReserve << ".\n"; |
| 31 | return true; |
| 32 | } |
| 33 | |
| Rui Ueyama | 9dd08d9 | 2013-06-08 22:59:10 +0000 | [diff] [blame] | 34 | if (_heapReserve < _heapCommit) { |
| 35 | diagnostics << "Invalid heap size: reserve size must be equal to or " |
| 36 | << "greater than commit size, but got " |
| 37 | << _heapCommit << " and " << _heapReserve << ".\n"; |
| 38 | return true; |
| 39 | } |
| 40 | |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 41 | _reader = createReaderPECOFF(*this); |
| 42 | _writer = createWriterPECOFF(*this); |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | Writer &PECOFFTargetInfo::writer() const { |
| 47 | return *_writer; |
| 48 | } |
| 49 | |
| 50 | ErrorOr<Reference::Kind> |
| 51 | PECOFFTargetInfo::relocKindFromString(StringRef str) const { |
| 52 | return make_error_code(yaml_reader_error::illegal_value); |
| 53 | } |
| 54 | |
| 55 | ErrorOr<std::string> |
| 56 | PECOFFTargetInfo::stringFromRelocKind(Reference::Kind kind) const { |
| 57 | return make_error_code(yaml_reader_error::illegal_value); |
| 58 | } |
| 59 | |
| Rui Ueyama | d95a155 | 2013-06-17 16:59:54 +0000 | [diff] [blame] | 60 | void PECOFFTargetInfo::addPasses(PassManager &pm) const { |
| Rui Ueyama | 991f42c | 2013-06-19 17:46:57 +0000 | [diff] [blame^] | 61 | pm.add(std::unique_ptr<Pass>(new pecoff::GroupedSectionsPass())); |
| Rui Ueyama | d95a155 | 2013-06-17 16:59:54 +0000 | [diff] [blame] | 62 | pm.add(std::unique_ptr<Pass>(new LayoutPass())); |
| 63 | } |
| 64 | |
| Rui Ueyama | 9e56839 | 2013-05-28 18:13:31 +0000 | [diff] [blame] | 65 | } // end namespace lld |