[lld] r202113 - [COFF] Refactor .drectve section handling. No functionality change.
Rui Ueyama
ruiu at google.com
Mon Feb 24 21:37:47 PST 2014
Author: ruiu
Date: Mon Feb 24 23:37:47 2014
New Revision: 202113
URL: http://llvm.org/viewvc/llvm-project?rev=202113&view=rev
Log:
[COFF] Refactor .drectve section handling. No functionality change.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=202113&r1=202112&r2=202113&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Mon Feb 24 23:37:47 2014
@@ -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<Memor
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 c
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;
More information about the llvm-commits
mailing list