#include "yaml2obj.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ELFYAML.h"
-#include "llvm/Object/StringTableBuilder.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/YAMLTraits.h"
Symbol.st_shndx = Index;
} // else Symbol.st_shndex == SHN_UNDEF (== 0), since it was zero'd earlier.
Symbol.st_value = Sym.Value;
+ Symbol.st_other = Sym.Visibility;
Symbol.st_size = Sym.Size;
Syms.push_back(Symbol);
}
ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::RawContentSection &Section,
ContiguousBlobAccumulator &CBA) {
- Section.Content.writeAsBinary(CBA.getOSAndAlignedOffset(SHeader.sh_offset));
+ assert(Section.Size >= Section.Content.binary_size() &&
+ "Section size and section content are inconsistent");
+ raw_ostream &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset);
+ Section.Content.writeAsBinary(OS);
+ for (auto i = Section.Content.binary_size(); i < Section.Size; ++i)
+ OS.write(0);
SHeader.sh_entsize = 0;
- SHeader.sh_size = Section.Content.binary_size();
+ SHeader.sh_size = Section.Size;
}
template <class ELFT>
return Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
}
-int yaml2elf(llvm::raw_ostream &Out, llvm::MemoryBuffer *Buf) {
- yaml::Input YIn(Buf->getBuffer());
+int yaml2elf(yaml::Input &YIn, raw_ostream &Out) {
ELFYAML::Object Doc;
YIn >> Doc;
if (YIn.error()) {
typedef ELFType<support::big, 4, false> BE32;
if (is64Bit(Doc)) {
if (isLittleEndian(Doc))
- return ELFState<LE64>::writeELF(outs(), Doc);
+ return ELFState<LE64>::writeELF(Out, Doc);
else
- return ELFState<BE64>::writeELF(outs(), Doc);
+ return ELFState<BE64>::writeELF(Out, Doc);
} else {
if (isLittleEndian(Doc))
- return ELFState<LE32>::writeELF(outs(), Doc);
+ return ELFState<LE32>::writeELF(Out, Doc);
else
- return ELFState<BE32>::writeELF(outs(), Doc);
+ return ELFState<BE32>::writeELF(Out, Doc);
}
}