ELF_SHF Flags;
llvm::yaml::Hex64 Address;
StringRef Link;
- StringRef Info;
llvm::yaml::Hex64 AddressAlign;
Section(SectionKind Kind) : Kind(Kind) {}
virtual ~Section();
StringRef Symbol;
};
struct RelocationSection : Section {
+ StringRef Info;
std::vector<Relocation> Relocations;
RelocationSection() : Section(SectionKind::Relocation) {}
static bool classof(const Section *S) {
IO.mapOptional("Flags", Section.Flags, ELFYAML::ELF_SHF(0));
IO.mapOptional("Address", Section.Address, Hex64(0));
IO.mapOptional("Link", Section.Link, StringRef());
- IO.mapOptional("Info", Section.Info, StringRef());
IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
}
static void sectionMapping(IO &IO, ELFYAML::RelocationSection &Section) {
commonSectionMapping(IO, Section);
+ IO.mapOptional("Info", Section.Info, StringRef());
IO.mapOptional("Relocations", Section.Relocations);
}
ELF-MIPSEL-NEXT: - Name: .rel.text
ELF-MIPSEL-NEXT: Type: SHT_REL
ELF-MIPSEL-NEXT: Link: .symtab
-ELF-MIPSEL-NEXT: Info: .text
ELF-MIPSEL-NEXT: AddressAlign: 0x0000000000000004
+ELF-MIPSEL-NEXT: Info: .text
ELF-MIPSEL-NEXT: Relocations:
ELF-MIPSEL-NEXT: - Offset: 0
ELF-MIPSEL-NEXT: Symbol: _gp_disp
ELF-MIPS64EL-NEXT: - Name: .rela.data
ELF-MIPS64EL-NEXT: Type: SHT_RELA
ELF-MIPS64EL-NEXT: Link: .symtab
-ELF-MIPS64EL-NEXT: Info: .data
ELF-MIPS64EL-NEXT: AddressAlign: 0x0000000000000008
+ELF-MIPS64EL-NEXT: Info: .data
ELF-MIPS64EL-NEXT: Relocations:
ELF-MIPS64EL-NEXT: - Offset: 0
ELF-MIPS64EL-NEXT: Symbol: zed
ELF-X86-64-NEXT: Type: SHT_RELA
ELF-X86-64-NEXT: Address: 0x0000000000000038
ELF-X86-64-NEXT: Link: .symtab
-ELF-X86-64-NEXT: Info: .text
ELF-X86-64-NEXT: AddressAlign: 0x0000000000000008
+ELF-X86-64-NEXT: Info: .text
ELF-X86-64-NEXT: Relocations:
ELF-X86-64-NEXT: - Offset: 0x000000000000000D
ELF-X86-64-NEXT: Symbol: .rodata.str1.1
error_code dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S);
error_code dumpCommonSection(const Elf_Shdr *Shdr, ELFYAML::Section &S);
+ error_code dumpCommonRelocationSection(const Elf_Shdr *Shdr,
+ ELFYAML::RelocationSection &S);
template <class RelT>
error_code dumpRelocation(const Elf_Shdr *Shdr, const RelT *Rel,
ELFYAML::Relocation &R);
Y->Sections.push_back(std::unique_ptr<ELFYAML::Section>(S.get()));
break;
}
+ // FIXME: Support SHT_GROUP section format.
default: {
ErrorOr<ELFYAML::RawContentSection *> S = dumpContentSection(&Sec);
if (error_code EC = S.getError())
S.Link = NameOrErr.get();
}
}
- if (Shdr->sh_info != ELF::SHN_UNDEF) {
- if (const Elf_Shdr *InfoSection = Obj.getSection(Shdr->sh_info)) {
- NameOrErr = Obj.getSectionName(InfoSection);
- if (error_code EC = NameOrErr.getError())
- return EC;
- S.Info = NameOrErr.get();
- }
+
+ return obj2yaml_error::success;
+}
+
+template <class ELFT>
+error_code
+ELFDumper<ELFT>::dumpCommonRelocationSection(const Elf_Shdr *Shdr,
+ ELFYAML::RelocationSection &S) {
+ if (error_code EC = dumpCommonSection(Shdr, S))
+ return EC;
+
+ if (const Elf_Shdr *InfoSection = Obj.getSection(Shdr->sh_info)) {
+ ErrorOr<StringRef> NameOrErr = Obj.getSectionName(InfoSection);
+ if (error_code EC = NameOrErr.getError())
+ return EC;
+ S.Info = NameOrErr.get();
}
+
return obj2yaml_error::success;
}
assert(Shdr->sh_type == ELF::SHT_REL && "Section type is not SHT_REL");
auto S = make_unique<ELFYAML::RelocationSection>();
- if (error_code EC = dumpCommonSection(Shdr, *S))
+ if (error_code EC = dumpCommonRelocationSection(Shdr, *S))
return EC;
for (auto RI = Obj.begin_rel(Shdr), RE = Obj.end_rel(Shdr); RI != RE;
assert(Shdr->sh_type == ELF::SHT_RELA && "Section type is not SHT_RELA");
auto S = make_unique<ELFYAML::RelocationSection>();
- if (error_code EC = dumpCommonSection(Shdr, *S))
+ if (error_code EC = dumpCommonRelocationSection(Shdr, *S))
return EC;
for (auto RI = Obj.begin_rela(Shdr), RE = Obj.end_rela(Shdr); RI != RE;