diff options
| author | Rui Ueyama <ruiu@google.com> | 2014-02-25 05:37:47 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2014-02-25 05:37:47 +0000 |
| commit | d08472f6c3a6983328001c9e60de323a8696f45a (patch) | |
| tree | c86ae2262a785da1fa0ed7fb97eb89108e8105cb | |
| parent | 6fe8a7fe8aa67b8103b57fa93deaaf9534f2edaa (diff) | |
| download | bcm5719-llvm-d08472f6c3a6983328001c9e60de323a8696f45a.tar.gz bcm5719-llvm-d08472f6c3a6983328001c9e60de323a8696f45a.zip | |
[COFF] Refactor .drectve section handling. No functionality change.
llvm-svn: 202113
| -rw-r--r-- | lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp index 40fa4e0faf2..8f4372d5110 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp @@ -120,6 +120,8 @@ private: const coff_section *section, const vector<COFFDefinedFileAtom *> &atoms); + error_code getSectionContents(StringRef sectionName, + ArrayRef<uint8_t> &result); error_code getReferenceArch(Reference::KindArch &result); error_code addRelocationReferenceToAtoms(); error_code findSection(StringRef name, const coff_section *&result); @@ -275,15 +277,11 @@ FileCOFF::FileCOFF(std::unique_ptr<MemoryBuffer> mb, error_code &ec) bin.take(); // Read .drectve section if exists. - const coff_section *section = nullptr; - if ((ec = findSection(".drectve", section))) + ArrayRef<uint8_t> contents; + if ((ec = getSectionContents(".drectve", contents))) return; - if (section != nullptr) { - ArrayRef<uint8_t> contents; - if ((ec = _obj->getSectionContents(section, contents))) - return; + if (!contents.empty()) _directives = ArrayRefToString(contents); - } } error_code FileCOFF::parse(StringMap &altNames) { @@ -737,6 +735,19 @@ FileCOFF::addRelocationReference(const coff_relocation *rel, return error_code::success(); } +// Read section contents. +error_code FileCOFF::getSectionContents(StringRef sectionName, + ArrayRef<uint8_t> &result) { + const coff_section *section = nullptr; + if (error_code ec = findSection(sectionName, section)) + return ec; + if (!section) + return error_code::success(); + if (error_code ec = _obj->getSectionContents(section, result)) + return ec; + return error_code::success(); +} + /// Returns the target machine type of the current object file. error_code FileCOFF::getReferenceArch(Reference::KindArch &result) { const llvm::object::coff_file_header *header = nullptr; |

