diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-05-31 20:26:44 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-05-31 20:26:44 +0000 |
commit | 05bc4a6f20fb4bad971dc6ebb86b9ee29307bd3d (patch) | |
tree | 689fc46d860140b2305957bac56bfc2073fdeb3b /tools/yaml2obj | |
parent | 47afc19625e97a3716d813f014a3a48468e591ca (diff) | |
download | external_llvm-05bc4a6f20fb4bad971dc6ebb86b9ee29307bd3d.zip external_llvm-05bc4a6f20fb4bad971dc6ebb86b9ee29307bd3d.tar.gz external_llvm-05bc4a6f20fb4bad971dc6ebb86b9ee29307bd3d.tar.bz2 |
Don't allocate temporary string for section data.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/yaml2obj')
-rw-r--r-- | tools/yaml2obj/yaml2obj.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/yaml2obj/yaml2obj.cpp b/tools/yaml2obj/yaml2obj.cpp index d984346..0c285c2 100644 --- a/tools/yaml2obj/yaml2obj.cpp +++ b/tools/yaml2obj/yaml2obj.cpp @@ -139,8 +139,9 @@ static bool layoutCOFF(COFFParser &CP) { for (std::vector<COFFYAML::Section>::iterator i = CP.Obj.Sections.begin(), e = CP.Obj.Sections.end(); i != e; ++i) { - if (!i->SectionData.empty()) { - i->Header.SizeOfRawData = i->SectionData.size()/2; + StringRef SecData = i->SectionData.getHex(); + if (!SecData.empty()) { + i->Header.SizeOfRawData = SecData.size()/2; i->Header.PointerToRawData = CurrentSectionDataOffset; CurrentSectionDataOffset += i->Header.SizeOfRawData; if (!i->Relocations.empty()) { @@ -163,7 +164,7 @@ static bool layoutCOFF(COFFParser &CP) { for (std::vector<COFFYAML::Symbol>::iterator i = CP.Obj.Symbols.begin(), e = CP.Obj.Symbols.end(); i != e; ++i) { - unsigned AuxBytes = i->AuxiliaryData.size() / 2; + unsigned AuxBytes = i->AuxiliaryData.getHex().size() / 2; if (AuxBytes % COFF::SymbolSize != 0) { errs() << "AuxiliaryData size not a multiple of symbol size!\n"; return false; @@ -248,8 +249,9 @@ bool writeCOFF(COFFParser &CP, raw_ostream &OS) { for (std::vector<COFFYAML::Section>::iterator i = CP.Obj.Sections.begin(), e = CP.Obj.Sections.end(); i != e; ++i) { - if (!i->SectionData.empty()) { - if (!writeHexData(i->SectionData, OS)) { + StringRef SecData = i->SectionData.getHex(); + if (!SecData.empty()) { + if (!writeHexData(SecData, OS)) { errs() << "SectionData must be a collection of pairs of hex bytes"; return false; } @@ -273,8 +275,9 @@ bool writeCOFF(COFFParser &CP, raw_ostream &OS) { << binary_le(i->Header.Type) << binary_le(i->Header.StorageClass) << binary_le(i->Header.NumberOfAuxSymbols); - if (!i->AuxiliaryData.empty()) { - if (!writeHexData(i->AuxiliaryData, OS)) { + StringRef Data = i->AuxiliaryData.getHex(); + if (!Data.empty()) { + if (!writeHexData(Data, OS)) { errs() << "AuxiliaryData must be a collection of pairs of hex bytes"; return false; } |