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