summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-05-05 07:17:40 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-05-05 07:17:40 +0000
commitb9b9e36187d46b2bde434a540aa2f48255622cfd (patch)
tree18e366e9a4b2a629c71b6ec2557737d3ea480ae5
parentd2a822d3caef7fcb06a4988285c9eb698c842604 (diff)
downloadbcm5719-llvm-b9b9e36187d46b2bde434a540aa2f48255622cfd.tar.gz
bcm5719-llvm-b9b9e36187d46b2bde434a540aa2f48255622cfd.zip
[ELF] Use a range based access to the ELFFile's sections collection.
No functional changes. llvm-svn: 207953
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFFile.h35
-rw-r--r--lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h8
2 files changed, 19 insertions, 24 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h
index ed6cfa31b12..4e630094b29 100644
--- a/lld/lib/ReaderWriter/ELF/ELFFile.h
+++ b/lld/lib/ReaderWriter/ELF/ELFFile.h
@@ -465,47 +465,44 @@ template <class ELFT> error_code ELFFile<ELFT>::createAtomizableSections() {
// the contents to the RelocationReferences map.
// Record the number of relocs to guess at preallocating the buffer.
uint64_t totalRelocs = 0;
- for (auto sit = _objFile->begin_sections(), sie = _objFile->end_sections();
- sit != sie; ++sit) {
- const Elf_Shdr *section = &*sit;
-
- if (isIgnoredSection(section))
+ for (const Elf_Shdr &section : _objFile->sections()) {
+ if (isIgnoredSection(&section))
continue;
- if (isMergeableStringSection(section)) {
- _mergeStringSections.push_back(section);
+ if (isMergeableStringSection(&section)) {
+ _mergeStringSections.push_back(&section);
continue;
}
// Create a sectionSymbols entry for every progbits section.
- if ((section->sh_type == llvm::ELF::SHT_PROGBITS) ||
- (section->sh_type == llvm::ELF::SHT_INIT_ARRAY) ||
- (section->sh_type == llvm::ELF::SHT_FINI_ARRAY))
- _sectionSymbols[section];
+ if ((section.sh_type == llvm::ELF::SHT_PROGBITS) ||
+ (section.sh_type == llvm::ELF::SHT_INIT_ARRAY) ||
+ (section.sh_type == llvm::ELF::SHT_FINI_ARRAY))
+ _sectionSymbols[&section];
- if (section->sh_type == llvm::ELF::SHT_RELA) {
- auto sHdr = _objFile->getSection(section->sh_info);
+ if (section.sh_type == llvm::ELF::SHT_RELA) {
+ auto sHdr = _objFile->getSection(section.sh_info);
auto sectionName = _objFile->getSectionName(sHdr);
if (error_code ec = sectionName.getError())
return ec;
- auto rai(_objFile->begin_rela(section));
- auto rae(_objFile->end_rela(section));
+ auto rai(_objFile->begin_rela(&section));
+ auto rae(_objFile->end_rela(&section));
_relocationAddendReferences[*sectionName] = make_range(rai, rae);
totalRelocs += std::distance(rai, rae);
}
- if (section->sh_type == llvm::ELF::SHT_REL) {
- auto sHdr = _objFile->getSection(section->sh_info);
+ if (section.sh_type == llvm::ELF::SHT_REL) {
+ auto sHdr = _objFile->getSection(section.sh_info);
auto sectionName = _objFile->getSectionName(sHdr);
if (error_code ec = sectionName.getError())
return ec;
- auto ri(_objFile->begin_rel(section));
- auto re(_objFile->end_rel(section));
+ auto ri(_objFile->begin_rel(&section));
+ auto re(_objFile->end_rel(&section));
_relocationReferences[*sectionName] = make_range(ri, re);
totalRelocs += std::distance(ri, re);
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h b/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
index 735a4c0f112..6819f44f2ad 100644
--- a/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
+++ b/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
@@ -136,13 +136,11 @@ private:
error_code readRegInfo() {
typedef llvm::object::Elf_RegInfo<ELFT> Elf_RegInfo;
- for (auto sit = this->_objFile->begin_sections(),
- sie = this->_objFile->end_sections();
- sit != sie; ++sit) {
- if (sit->sh_type != llvm::ELF::SHT_MIPS_REGINFO)
+ for (const Elf_Shdr &section : this->_objFile->sections()) {
+ if (section.sh_type != llvm::ELF::SHT_MIPS_REGINFO)
continue;
- auto contents = this->getSectionContents(&*sit);
+ auto contents = this->getSectionContents(&section);
if (error_code ec = contents.getError())
return ec;
OpenPOWER on IntegriCloud