places where we have only a const Elf_file*.
elfcpp/
* elfcpp_file.h (Elf_file::shnum): New const function.
(Elf_file::shstrndx): New const function.
(Elf_file::large_shndx_offset): New const function.
(Elf_file::section_name): Add const attribute.
(Elf_file::section_header_offset): Likewise.
gold/
* dwp.cc (Sized_relobj_dwo::do_section_name): Add const attribute.
* dynobj.h (Sized_dynobj::do_section_name): Likewise.
* incremental.cc (Sized_relobj_incr::do_section_name): Likewise.
(Sized_incr_dynobj::do_section_name): Likewise.
* incremental.h (Sized_relobj_incr::do_section_name): Likewise.
(Sized_incr_dynobj::do_section_name): Likewise.
* object.h (Object::section_name): Likewise.
(Object::do_section_name): Likewise.
(Sized_relobj_file::do_section_name): Likewise.
* plugin.cc (Sized_pluginobj::do_section_name): Likewise.
* plugin.h (Sized_pluginobj::do_section_name): Likewise.
+2014-09-02 Cary Coutant <ccoutant@google.com>
+
+ * elfcpp_file.h (Elf_file::shnum): New const function.
+ (Elf_file::shstrndx): New const function.
+ (Elf_file::large_shndx_offset): New const function.
+ (Elf_file::section_name): Add const attribute.
+ (Elf_file::section_header_offset): Likewise.
+
2014-08-08 Han Shen <shenhan@google.com>
* aarch64.h (withdrawn): Replaced with R_AARCH64_withdrawn.
return this->shnum_;
}
+ unsigned int
+ shnum() const
+ {
+ if (this->shnum_ == 0 && this->shoff_ != 0)
+ this->file_->error(_("ELF file has not been initialized yet"
+ " (internal error)"));
+ return this->shnum_;
+ }
+
// Return the section index of the section name string table.
unsigned int
shstrndx()
return this->shstrndx_;
}
+ unsigned int
+ shstrndx() const
+ {
+ if (this->shstrndx_ == SHN_XINDEX && this->shoff_ != 0)
+ {
+ this->file_->error(_("ELF file has not been initialized yet"
+ " (internal error)"));
+ return 0;
+ }
+ return this->shstrndx_;
+ }
+
// Return the value to subtract from section indexes >=
// SHN_LORESERVE. See the comment in initialize_shnum.
int
return this->large_shndx_offset_;
}
+ int
+ large_shndx_offset() const
+ {
+ if (this->shstrndx_ == SHN_XINDEX && this->shoff_ != 0)
+ this->file_->error(_("ELF file has not been initialized yet"
+ " (internal error)"));
+ return this->large_shndx_offset_;
+ }
+
// Return the location of the header of section SHNDX.
typename File::Location
section_header(unsigned int shndx)
// Return the name of section SHNDX.
std::string
- section_name(unsigned int shndx);
+ section_name(unsigned int shndx) const;
// Return the location of the contents of section SHNDX.
typename File::Location
// Return the file offset of the header of section SHNDX.
off_t
- section_header_offset(unsigned int shndx);
+ section_header_offset(unsigned int shndx) const;
// The file we are reading.
File* file_;
template<int size, bool big_endian, typename File>
off_t
-Elf_file<size, big_endian, File>::section_header_offset(unsigned int shndx)
+Elf_file<size, big_endian, File>::section_header_offset(unsigned int shndx) const
{
if (shndx >= this->shnum())
this->file_->error(_("section_header_offset: bad shndx %u >= %u"),
template<int size, bool big_endian, typename File>
std::string
-Elf_file<size, big_endian, File>::section_name(unsigned int shndx)
+Elf_file<size, big_endian, File>::section_name(unsigned int shndx) const
{
File* const file = this->file_;
+2014-09-02 Cary Coutant <ccoutant@google.com>
+
+ * dwp.cc (Sized_relobj_dwo::do_section_name): Add const attribute.
+ * dynobj.h (Sized_dynobj::do_section_name): Likewise.
+ * incremental.cc (Sized_relobj_incr::do_section_name): Likewise.
+ (Sized_incr_dynobj::do_section_name): Likewise.
+ * incremental.h (Sized_relobj_incr::do_section_name): Likewise.
+ (Sized_incr_dynobj::do_section_name): Likewise.
+ * object.h (Object::section_name): Likewise.
+ (Object::do_section_name): Likewise.
+ (Sized_relobj_file::do_section_name): Likewise.
+ * plugin.cc (Sized_pluginobj::do_section_name): Likewise.
+ * plugin.h (Sized_pluginobj::do_section_name): Likewise.
+
2014-09-02 Cary Coutant <ccoutant@google.com>
PR gold/17005
// Get the name of a section.
std::string
- do_section_name(unsigned int shndx)
+ do_section_name(unsigned int shndx) const
{ return this->elf_file_.section_name(shndx); }
// Get the size of a section.
// Get the name of a section.
std::string
- do_section_name(unsigned int shndx)
+ do_section_name(unsigned int shndx) const
{ return this->elf_file_.section_name(shndx); }
// Return a view of the contents of a section. Set *PLEN to the
template<int size, bool big_endian>
std::string
-Sized_relobj_incr<size, big_endian>::do_section_name(unsigned int shndx)
+Sized_relobj_incr<size, big_endian>::do_section_name(unsigned int shndx) const
{
- Output_sections& out_sections(this->output_sections());
- Output_section* os = out_sections[shndx];
+ const Output_sections& out_sections(this->output_sections());
+ const Output_section* os = out_sections[shndx];
if (os == NULL)
return NULL;
return os->name();
template<int size, bool big_endian>
std::string
-Sized_incr_dynobj<size, big_endian>::do_section_name(unsigned int)
+Sized_incr_dynobj<size, big_endian>::do_section_name(unsigned int) const
{
gold_unreachable();
}
// Get the name of a section.
std::string
- do_section_name(unsigned int shndx);
+ do_section_name(unsigned int shndx) const;
// Return a view of the contents of a section.
const unsigned char*
// Get the name of a section.
std::string
- do_section_name(unsigned int shndx);
+ do_section_name(unsigned int shndx) const;
// Return a view of the contents of a section.
const unsigned char*
// Return the name of a section given a section index.
std::string
- section_name(unsigned int shndx)
+ section_name(unsigned int shndx) const
{ return this->do_section_name(shndx); }
// Return the section flags given a section index.
// Get the name of a section--implemented by child class.
virtual std::string
- do_section_name(unsigned int shndx) = 0;
+ do_section_name(unsigned int shndx) const = 0;
// Get section flags--implemented by child class.
virtual uint64_t
// Get the name of a section.
std::string
- do_section_name(unsigned int shndx)
+ do_section_name(unsigned int shndx) const
{ return this->elf_file_.section_name(shndx); }
// Return the location of the contents of a section.
template<int size, bool big_endian>
std::string
-Sized_pluginobj<size, big_endian>::do_section_name(unsigned int)
+Sized_pluginobj<size, big_endian>::do_section_name(unsigned int) const
{
gold_unreachable();
return std::string();
// Get the name of a section.
std::string
- do_section_name(unsigned int shndx);
+ do_section_name(unsigned int shndx) const;
// Return a view of the contents of a section.
const unsigned char*