mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
[yaml2obj][ELF] Support st_info through Binding
and Type
YAML keys.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184263 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
70a3dc1bc2
commit
5ba1225fb0
@ -39,6 +39,8 @@ LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA)
|
|||||||
LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT)
|
LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT)
|
||||||
// Just use 64, since it can hold 32-bit values too.
|
// Just use 64, since it can hold 32-bit values too.
|
||||||
LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF)
|
LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF)
|
||||||
|
LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STB)
|
||||||
|
LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STT)
|
||||||
|
|
||||||
// For now, hardcode 64 bits everywhere that 32 or 64 would be needed
|
// For now, hardcode 64 bits everywhere that 32 or 64 would be needed
|
||||||
// since 64-bit can hold 32-bit values too.
|
// since 64-bit can hold 32-bit values too.
|
||||||
@ -51,6 +53,8 @@ struct FileHeader {
|
|||||||
};
|
};
|
||||||
struct Symbol {
|
struct Symbol {
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
|
ELF_STB Binding;
|
||||||
|
ELF_STT Type;
|
||||||
};
|
};
|
||||||
struct Section {
|
struct Section {
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
@ -107,6 +111,16 @@ struct ScalarBitSetTraits<ELFYAML::ELF_SHF> {
|
|||||||
static void bitset(IO &IO, ELFYAML::ELF_SHF &Value);
|
static void bitset(IO &IO, ELFYAML::ELF_SHF &Value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ScalarEnumerationTraits<ELFYAML::ELF_STB> {
|
||||||
|
static void enumeration(IO &IO, ELFYAML::ELF_STB &Value);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ScalarEnumerationTraits<ELFYAML::ELF_STT> {
|
||||||
|
static void enumeration(IO &IO, ELFYAML::ELF_STT &Value);
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct MappingTraits<ELFYAML::FileHeader> {
|
struct MappingTraits<ELFYAML::FileHeader> {
|
||||||
static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr);
|
static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr);
|
||||||
|
@ -251,6 +251,29 @@ void ScalarBitSetTraits<ELFYAML::ELF_SHF>::bitset(IO &IO,
|
|||||||
#undef BCase
|
#undef BCase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScalarEnumerationTraits<ELFYAML::ELF_STB>::enumeration(
|
||||||
|
IO &IO, ELFYAML::ELF_STB &Value) {
|
||||||
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X);
|
||||||
|
ECase(STB_LOCAL)
|
||||||
|
ECase(STB_GLOBAL)
|
||||||
|
ECase(STB_WEAK)
|
||||||
|
#undef ECase
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScalarEnumerationTraits<ELFYAML::ELF_STT>::enumeration(
|
||||||
|
IO &IO, ELFYAML::ELF_STT &Value) {
|
||||||
|
#define ECase(X) IO.enumCase(Value, #X, ELF::X);
|
||||||
|
ECase(STT_NOTYPE)
|
||||||
|
ECase(STT_OBJECT)
|
||||||
|
ECase(STT_FUNC)
|
||||||
|
ECase(STT_SECTION)
|
||||||
|
ECase(STT_FILE)
|
||||||
|
ECase(STT_COMMON)
|
||||||
|
ECase(STT_TLS)
|
||||||
|
ECase(STT_GNU_IFUNC)
|
||||||
|
#undef ECase
|
||||||
|
}
|
||||||
|
|
||||||
void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
|
void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
|
||||||
ELFYAML::FileHeader &FileHdr) {
|
ELFYAML::FileHeader &FileHdr) {
|
||||||
IO.mapRequired("Class", FileHdr.Class);
|
IO.mapRequired("Class", FileHdr.Class);
|
||||||
@ -262,6 +285,8 @@ void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
|
|||||||
|
|
||||||
void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) {
|
void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) {
|
||||||
IO.mapOptional("Name", Symbol.Name, StringRef());
|
IO.mapOptional("Name", Symbol.Name, StringRef());
|
||||||
|
IO.mapOptional("Binding", Symbol.Binding, ELFYAML::ELF_STB(0));
|
||||||
|
IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingTraits<ELFYAML::Section>::mapping(IO &IO,
|
void MappingTraits<ELFYAML::Section>::mapping(IO &IO,
|
||||||
|
@ -13,9 +13,13 @@ Sections:
|
|||||||
Type: SHT_SYMTAB
|
Type: SHT_SYMTAB
|
||||||
Symbols:
|
Symbols:
|
||||||
- Name: main
|
- Name: main
|
||||||
|
Binding: STB_GLOBAL
|
||||||
|
Type: STT_FUNC
|
||||||
|
|
||||||
# CHECK: Symbols [
|
# CHECK: Symbols [
|
||||||
# CHECK-NEXT: Symbol {
|
# CHECK-NEXT: Symbol {
|
||||||
# CHECK-NEXT: Name: (0)
|
# CHECK-NEXT: Name: (0)
|
||||||
# CHECK: Symbol {
|
# CHECK: Symbol {
|
||||||
# CHECK-NEXT: Name: main
|
# CHECK-NEXT: Name: main
|
||||||
|
# CHECK: Binding: Global
|
||||||
|
# CHECK-NEXT: Type: Function
|
||||||
|
@ -166,6 +166,7 @@ static void handleSymtabSectionHeader(
|
|||||||
zero(Symbol);
|
zero(Symbol);
|
||||||
if (!Sym.Name.empty())
|
if (!Sym.Name.empty())
|
||||||
Symbol.st_name = StrTab.addString(Sym.Name);
|
Symbol.st_name = StrTab.addString(Sym.Name);
|
||||||
|
Symbol.setBindingAndType(Sym.Binding, Sym.Type);
|
||||||
Syms.push_back(Symbol);
|
Syms.push_back(Symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user