mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-26 18:20:39 +00:00
Use range loops. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241105 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -616,44 +616,41 @@ void ELFDumper<ELFT>::printSections() {
|
|||||||
ListScope SectionsD(W, "Sections");
|
ListScope SectionsD(W, "Sections");
|
||||||
|
|
||||||
int SectionIndex = -1;
|
int SectionIndex = -1;
|
||||||
for (typename ELFO::Elf_Shdr_Iter SecI = Obj->section_begin(),
|
for (const typename ELFO::Elf_Shdr &Sec : Obj->sections()) {
|
||||||
SecE = Obj->section_end();
|
|
||||||
SecI != SecE; ++SecI) {
|
|
||||||
++SectionIndex;
|
++SectionIndex;
|
||||||
|
|
||||||
const Elf_Shdr *Section = &*SecI;
|
StringRef Name = errorOrDefault(Obj->getSectionName(&Sec));
|
||||||
StringRef Name = errorOrDefault(Obj->getSectionName(Section));
|
|
||||||
|
|
||||||
DictScope SectionD(W, "Section");
|
DictScope SectionD(W, "Section");
|
||||||
W.printNumber("Index", SectionIndex);
|
W.printNumber("Index", SectionIndex);
|
||||||
W.printNumber("Name", Name, Section->sh_name);
|
W.printNumber("Name", Name, Sec.sh_name);
|
||||||
W.printHex("Type",
|
W.printHex("Type",
|
||||||
getElfSectionType(Obj->getHeader()->e_machine, Section->sh_type),
|
getElfSectionType(Obj->getHeader()->e_machine, Sec.sh_type),
|
||||||
Section->sh_type);
|
Sec.sh_type);
|
||||||
W.printFlags ("Flags", Section->sh_flags, makeArrayRef(ElfSectionFlags));
|
W.printFlags("Flags", Sec.sh_flags, makeArrayRef(ElfSectionFlags));
|
||||||
W.printHex ("Address", Section->sh_addr);
|
W.printHex("Address", Sec.sh_addr);
|
||||||
W.printHex ("Offset", Section->sh_offset);
|
W.printHex("Offset", Sec.sh_offset);
|
||||||
W.printNumber("Size", Section->sh_size);
|
W.printNumber("Size", Sec.sh_size);
|
||||||
W.printNumber("Link", Section->sh_link);
|
W.printNumber("Link", Sec.sh_link);
|
||||||
W.printNumber("Info", Section->sh_info);
|
W.printNumber("Info", Sec.sh_info);
|
||||||
W.printNumber("AddressAlignment", Section->sh_addralign);
|
W.printNumber("AddressAlignment", Sec.sh_addralign);
|
||||||
W.printNumber("EntrySize", Section->sh_entsize);
|
W.printNumber("EntrySize", Sec.sh_entsize);
|
||||||
|
|
||||||
if (opts::SectionRelocations) {
|
if (opts::SectionRelocations) {
|
||||||
ListScope D(W, "Relocations");
|
ListScope D(W, "Relocations");
|
||||||
printRelocations(Section);
|
printRelocations(&Sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts::SectionSymbols) {
|
if (opts::SectionSymbols) {
|
||||||
ListScope D(W, "Symbols");
|
ListScope D(W, "Symbols");
|
||||||
for (const typename ELFO::Elf_Sym &Sym : Obj->symbols()) {
|
for (const typename ELFO::Elf_Sym &Sym : Obj->symbols()) {
|
||||||
if (Obj->getSection(&Sym) == Section)
|
if (Obj->getSection(&Sym) == &Sec)
|
||||||
printSymbol(&Sym, false);
|
printSymbol(&Sym, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts::SectionData && Section->sh_type != ELF::SHT_NOBITS) {
|
if (opts::SectionData && Sec.sh_type != ELF::SHT_NOBITS) {
|
||||||
ArrayRef<uint8_t> Data = errorOrDefault(Obj->getSectionContents(Section));
|
ArrayRef<uint8_t> Data = errorOrDefault(Obj->getSectionContents(&Sec));
|
||||||
W.printBinaryBlock("SectionData",
|
W.printBinaryBlock("SectionData",
|
||||||
StringRef((const char *)Data.data(), Data.size()));
|
StringRef((const char *)Data.data(), Data.size()));
|
||||||
}
|
}
|
||||||
@@ -665,20 +662,18 @@ void ELFDumper<ELFT>::printRelocations() {
|
|||||||
ListScope D(W, "Relocations");
|
ListScope D(W, "Relocations");
|
||||||
|
|
||||||
int SectionNumber = -1;
|
int SectionNumber = -1;
|
||||||
for (typename ELFO::Elf_Shdr_Iter SecI = Obj->section_begin(),
|
for (const typename ELFO::Elf_Shdr &Sec : Obj->sections()) {
|
||||||
SecE = Obj->section_end();
|
|
||||||
SecI != SecE; ++SecI) {
|
|
||||||
++SectionNumber;
|
++SectionNumber;
|
||||||
|
|
||||||
if (SecI->sh_type != ELF::SHT_REL && SecI->sh_type != ELF::SHT_RELA)
|
if (Sec.sh_type != ELF::SHT_REL && Sec.sh_type != ELF::SHT_RELA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
StringRef Name = errorOrDefault(Obj->getSectionName(&*SecI));
|
StringRef Name = errorOrDefault(Obj->getSectionName(&Sec));
|
||||||
|
|
||||||
W.startLine() << "Section (" << SectionNumber << ") " << Name << " {\n";
|
W.startLine() << "Section (" << SectionNumber << ") " << Name << " {\n";
|
||||||
W.indent();
|
W.indent();
|
||||||
|
|
||||||
printRelocations(&*SecI);
|
printRelocations(&Sec);
|
||||||
|
|
||||||
W.unindent();
|
W.unindent();
|
||||||
W.startLine() << "}\n";
|
W.startLine() << "}\n";
|
||||||
@@ -1129,12 +1124,11 @@ template <> void ELFDumper<ELFType<support::little, false>>::printAttributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DictScope BA(W, "BuildAttributes");
|
DictScope BA(W, "BuildAttributes");
|
||||||
for (ELFO::Elf_Shdr_Iter SI = Obj->section_begin(), SE = Obj->section_end();
|
for (const ELFO::Elf_Shdr &Sec : Obj->sections()) {
|
||||||
SI != SE; ++SI) {
|
if (Sec.sh_type != ELF::SHT_ARM_ATTRIBUTES)
|
||||||
if (SI->sh_type != ELF::SHT_ARM_ATTRIBUTES)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ErrorOr<ArrayRef<uint8_t> > Contents = Obj->getSectionContents(&(*SI));
|
ErrorOr<ArrayRef<uint8_t>> Contents = Obj->getSectionContents(&Sec);
|
||||||
if (!Contents)
|
if (!Contents)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user