mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 00:29:20 +00:00
Remove COFFYAML::Header.
Instead, use MappingNormalization to directly parse COFF::header. Also change the naming convention of the helper classes to be a bit shorter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179917 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
69394f2997
commit
f59a2a86ff
@ -121,11 +121,6 @@ namespace COFFYAML {
|
|||||||
StringRef Name;
|
StringRef Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Header {
|
|
||||||
COFF::MachineTypes Machine;
|
|
||||||
COFF::Characteristics Characteristics;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Symbol {
|
struct Symbol {
|
||||||
COFF::SymbolBaseType SimpleType;
|
COFF::SymbolBaseType SimpleType;
|
||||||
uint8_t NumberOfAuxSymbols;
|
uint8_t NumberOfAuxSymbols;
|
||||||
@ -138,7 +133,7 @@ namespace COFFYAML {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Object {
|
struct Object {
|
||||||
Header HeaderData;
|
COFF::header HeaderData;
|
||||||
std::vector<Section> Sections;
|
std::vector<Section> Sections;
|
||||||
std::vector<Symbol> Symbols;
|
std::vector<Symbol> Symbols;
|
||||||
};
|
};
|
||||||
@ -632,31 +627,57 @@ struct MappingTraits<COFFYAML::Symbol> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct MappingTraits<COFFYAML::Header> {
|
struct MappingTraits<COFF::header> {
|
||||||
static void mapping(IO &IO, COFFYAML::Header &H) {
|
struct NMachine {
|
||||||
IO.mapRequired("Machine", H.Machine);
|
NMachine(IO&) : Machine(COFF::MachineTypes(0)) {
|
||||||
IO.mapOptional("Characteristics", H.Characteristics);
|
}
|
||||||
|
NMachine(IO&, uint16_t M) : Machine(COFF::MachineTypes(M)) {
|
||||||
|
}
|
||||||
|
uint16_t denormalize(IO &) {
|
||||||
|
return Machine;
|
||||||
|
}
|
||||||
|
COFF::MachineTypes Machine;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NCharacteristics {
|
||||||
|
NCharacteristics(IO&) : Characteristics(COFF::Characteristics(0)) {
|
||||||
|
}
|
||||||
|
NCharacteristics(IO&, uint16_t C) :
|
||||||
|
Characteristics(COFF::Characteristics(C)) {
|
||||||
|
}
|
||||||
|
uint16_t denormalize(IO &) {
|
||||||
|
return Characteristics;
|
||||||
|
}
|
||||||
|
|
||||||
|
COFF::Characteristics Characteristics;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void mapping(IO &IO, COFF::header &H) {
|
||||||
|
MappingNormalization<NMachine, uint16_t> NM(IO, H.Machine);
|
||||||
|
MappingNormalization<NCharacteristics, uint16_t> NC(IO, H.Characteristics);
|
||||||
|
|
||||||
|
IO.mapRequired("Machine", NM->Machine);
|
||||||
|
IO.mapOptional("Characteristics", NC->Characteristics);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct MappingTraits<COFF::relocation> {
|
struct MappingTraits<COFF::relocation> {
|
||||||
struct NormalizedType {
|
struct NType {
|
||||||
public:
|
NType(IO &) : Type(COFF::RelocationTypeX86(0)) {
|
||||||
NormalizedType(IO &) : Type(COFF::RelocationTypeX86(0)) {
|
|
||||||
}
|
}
|
||||||
NormalizedType(IO &, uint16_t T) : Type(COFF::RelocationTypeX86(T)) {
|
NType(IO &, uint16_t T) : Type(COFF::RelocationTypeX86(T)) {
|
||||||
}
|
}
|
||||||
uint16_t denormalize(IO &) {
|
uint16_t denormalize(IO &) {
|
||||||
return Type;
|
return Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
COFF::RelocationTypeX86 Type;
|
COFF::RelocationTypeX86 Type;
|
||||||
};
|
};
|
||||||
static void mapping(IO &IO, COFF::relocation &Rel) {
|
|
||||||
MappingNormalization<NormalizedType, uint16_t> foo(IO, Rel.Type);
|
|
||||||
|
|
||||||
IO.mapRequired("Type", foo->Type);
|
static void mapping(IO &IO, COFF::relocation &Rel) {
|
||||||
|
MappingNormalization<NType, uint16_t> NT(IO, Rel.Type);
|
||||||
|
|
||||||
|
IO.mapRequired("Type", NT->Type);
|
||||||
IO.mapRequired("VirtualAddress", Rel.VirtualAddress);
|
IO.mapRequired("VirtualAddress", Rel.VirtualAddress);
|
||||||
IO.mapRequired("SymbolTableIndex", Rel.SymbolTableIndex);
|
IO.mapRequired("SymbolTableIndex", Rel.SymbolTableIndex);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user