mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
[C++11] Introduce ObjectFile::sections().
Summary: This adds ObjectFile::section_iterator_range, that allows to write range-based for-loops running over all sections of a given file. Several files from lib/ are converted to the new interface. Similar fixes should be applied to a variety of llvm-* tools. Reviewers: rafael Reviewed By: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3069 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203799 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -87,20 +87,24 @@ MCModule *MCObjectDisassembler::buildModule(bool withCFG) {
|
||||
}
|
||||
|
||||
void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
|
||||
for (section_iterator SI = Obj.section_begin(), SE = Obj.section_end();
|
||||
SI != SE; ++SI) {
|
||||
bool isText; SI->isText(isText);
|
||||
bool isData; SI->isData(isData);
|
||||
for (const SectionRef &Section : Obj.sections()) {
|
||||
bool isText;
|
||||
Section.isText(isText);
|
||||
bool isData;
|
||||
Section.isData(isData);
|
||||
if (!isData && !isText)
|
||||
continue;
|
||||
|
||||
uint64_t StartAddr; SI->getAddress(StartAddr);
|
||||
uint64_t SecSize; SI->getSize(SecSize);
|
||||
uint64_t StartAddr;
|
||||
Section.getAddress(StartAddr);
|
||||
uint64_t SecSize;
|
||||
Section.getSize(SecSize);
|
||||
if (StartAddr == UnknownAddressOrSize || SecSize == UnknownAddressOrSize)
|
||||
continue;
|
||||
StartAddr = getEffectiveLoadAddr(StartAddr);
|
||||
|
||||
StringRef Contents; SI->getContents(Contents);
|
||||
StringRef Contents;
|
||||
Section.getContents(Contents);
|
||||
StringRefMemoryObject memoryObject(Contents, StartAddr);
|
||||
|
||||
// We don't care about things like non-file-backed sections yet.
|
||||
@ -108,7 +112,8 @@ void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
|
||||
continue;
|
||||
uint64_t EndAddr = StartAddr + SecSize - 1;
|
||||
|
||||
StringRef SecName; SI->getName(SecName);
|
||||
StringRef SecName;
|
||||
Section.getName(SecName);
|
||||
|
||||
if (isText) {
|
||||
MCTextAtom *Text = 0;
|
||||
@ -495,17 +500,16 @@ MCMachOObjectDisassembler::MCMachOObjectDisassembler(
|
||||
: MCObjectDisassembler(MOOF, Dis, MIA), MOOF(MOOF),
|
||||
VMAddrSlide(VMAddrSlide), HeaderLoadAddress(HeaderLoadAddress) {
|
||||
|
||||
for (section_iterator SI = MOOF.section_begin(), SE = MOOF.section_end();
|
||||
SI != SE; ++SI) {
|
||||
for (const SectionRef &Section : MOOF.sections()) {
|
||||
StringRef Name;
|
||||
SI->getName(Name);
|
||||
Section.getName(Name);
|
||||
// FIXME: We should use the S_ section type instead of the name.
|
||||
if (Name == "__mod_init_func") {
|
||||
DEBUG(dbgs() << "Found __mod_init_func section!\n");
|
||||
SI->getContents(ModInitContents);
|
||||
Section.getContents(ModInitContents);
|
||||
} else if (Name == "__mod_exit_func") {
|
||||
DEBUG(dbgs() << "Found __mod_exit_func section!\n");
|
||||
SI->getContents(ModExitContents);
|
||||
Section.getContents(ModExitContents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user