llvm.org GIT mirror llvm / 6dd7893
yaml2coff/elf: Touchup for compatibility. * std::string::append(int, int) can be ambiguous. * std::vector<>::data() is a C++11 feature, use ArrayRef abstraction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192542 91177308-0d34-0410-b5e6-96231b3b80d8 Will Dietz 6 years ago
2 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
3131 COFFParser(COFFYAML::Object &Obj) : Obj(Obj) {
3232 // A COFF string table always starts with a 4 byte size field. Offsets into
3333 // it include this size, so allocate it now.
34 StringTable.append(4, 0);
34 StringTable.append(4, char(0));
3535 }
3636
3737 bool parseSections() {
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "yaml2obj.h"
15 #include "llvm/ADT/ArrayRef.h"
1516 #include "llvm/Object/ELFObjectFile.h"
1617 #include "llvm/Object/ELFYAML.h"
1718 #include "llvm/Support/ELF.h"
118119 } // end anonymous namespace
119120
120121 template
121 static size_t vectorDataSize(const std::vector &Vec) {
122 return Vec.size() * sizeof(T);
122 static size_t arrayDataSize(ArrayRef A) {
123 return A.size() * sizeof(T);
123124 }
124125
125126 template
126 static void writeVectorData(raw_ostream &OS, const std::vector &Vec) {
127 OS.write((const char *)Vec.data(), vectorDataSize(Vec));
127 static void writeArrayData(raw_ostream &OS, ArrayRef A) {
128 OS.write((const char *)A.data(), arrayDataSize(A));
128129 }
129130
130131 template
234235 addSymbols(Symbols.Weak, State, Syms, ELF::STB_WEAK);
235236
236237 ContiguousBlobAccumulator &CBA = State.getSectionContentAccum();
237 writeVectorData(CBA.getOSAndAlignedOffset(SHeader.sh_offset), Syms);
238 SHeader.sh_size = vectorDataSize(Syms);
238 writeArrayData(CBA.getOSAndAlignedOffset(SHeader.sh_offset),
239 makeArrayRef(Syms));
240 SHeader.sh_size = arrayDataSize(makeArrayRef(Syms));
239241 }
240242
241243 template
358360 SHeaders.push_back(SHStrTabSHeader);
359361
360362 OS.write((const char *)&Header, sizeof(Header));
361 writeVectorData(OS, SHeaders);
363 writeArrayData(OS, makeArrayRef(SHeaders));
362364 CBA.writeBlobToStream(OS);
363365 return 0;
364366 }