mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-23 01:30:19 +00:00
[yaml2obj][ELF] Make this "type switch" actually readable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184623 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e766884193
commit
efc78986b3
@ -361,6 +361,14 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is64Bit(const ELFYAML::Object &Doc) {
|
||||||
|
return Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isLittleEndian(const ELFYAML::Object &Doc) {
|
||||||
|
return Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
|
||||||
|
}
|
||||||
|
|
||||||
int yaml2elf(llvm::raw_ostream &Out, llvm::MemoryBuffer *Buf) {
|
int yaml2elf(llvm::raw_ostream &Out, llvm::MemoryBuffer *Buf) {
|
||||||
yaml::Input YIn(Buf->getBuffer());
|
yaml::Input YIn(Buf->getBuffer());
|
||||||
ELFYAML::Object Doc;
|
ELFYAML::Object Doc;
|
||||||
@ -369,15 +377,20 @@ int yaml2elf(llvm::raw_ostream &Out, llvm::MemoryBuffer *Buf) {
|
|||||||
errs() << "yaml2obj: Failed to parse YAML file!\n";
|
errs() << "yaml2obj: Failed to parse YAML file!\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64)) {
|
using object::ELFType;
|
||||||
if (Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB))
|
typedef ELFType<support::little, 8, true> LE64;
|
||||||
return writeELF<object::ELFType<support::little, 8, true> >(outs(), Doc);
|
typedef ELFType<support::big, 8, true> BE64;
|
||||||
|
typedef ELFType<support::little, 4, false> LE32;
|
||||||
|
typedef ELFType<support::big, 4, false> BE32;
|
||||||
|
if (is64Bit(Doc)) {
|
||||||
|
if (isLittleEndian(Doc))
|
||||||
|
return writeELF<LE64>(outs(), Doc);
|
||||||
else
|
else
|
||||||
return writeELF<object::ELFType<support::big, 8, true> >(outs(), Doc);
|
return writeELF<BE64>(outs(), Doc);
|
||||||
} else {
|
} else {
|
||||||
if (Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB))
|
if (isLittleEndian(Doc))
|
||||||
return writeELF<object::ELFType<support::little, 4, false> >(outs(), Doc);
|
return writeELF<LE32>(outs(), Doc);
|
||||||
else
|
else
|
||||||
return writeELF<object::ELFType<support::big, 4, false> >(outs(), Doc);
|
return writeELF<BE32>(outs(), Doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user