@@ -535,7 +535,7 @@ std::string ElfFile<ElfFileParamNames>::getSectionName(const Elf_Shdr & shdr) co
535535
536536
537537template <ElfFileParams>
538- Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sectionName)
538+ const Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sectionName) const
539539{
540540 auto shdr = tryFindSectionHeader (sectionName);
541541 if (!shdr) {
@@ -549,7 +549,7 @@ Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sec
549549
550550
551551template <ElfFileParams>
552- std::optional<std::reference_wrapper<Elf_Shdr>> ElfFile<ElfFileParamNames>::tryFindSectionHeader(const SectionName & sectionName)
552+ std::optional<std::reference_wrapper<const Elf_Shdr>> ElfFile<ElfFileParamNames>::tryFindSectionHeader(const SectionName & sectionName) const
553553{
554554 auto i = getSectionIndex (sectionName);
555555 if (i)
@@ -602,7 +602,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
602602 clobbering previously written new section contents. */
603603 for (auto & i : replacedSections) {
604604 const std::string & sectionName = i.first ;
605- Elf_Shdr & shdr = findSectionHeader (sectionName);
605+ const Elf_Shdr & shdr = findSectionHeader (sectionName);
606606 if (rdi (shdr.sh_type ) != SHT_NOBITS)
607607 memset (fileContents->data () + rdi (shdr.sh_offset ), ' X' , rdi (shdr.sh_size ));
608608 }
@@ -1190,10 +1190,10 @@ static void setSubstr(std::string & s, unsigned int pos, const std::string & t)
11901190
11911191
11921192template <ElfFileParams>
1193- std::string ElfFile<ElfFileParamNames>::getInterpreter()
1193+ std::string ElfFile<ElfFileParamNames>::getInterpreter() const
11941194{
11951195 auto shdr = findSectionHeader (" .interp" );
1196- return std::string ((char *) fileContents->data () + rdi (shdr.sh_offset ), rdi (shdr.sh_size ) - 1 );
1196+ return std::string ((const char *) fileContents->data () + rdi (shdr.sh_offset ), rdi (shdr.sh_size ) - 1 );
11971197}
11981198
11991199template <ElfFileParams>
@@ -1776,13 +1776,13 @@ void ElfFile<ElfFileParamNames>::addNeeded(const std::set<std::string> & libs)
17761776}
17771777
17781778template <ElfFileParams>
1779- void ElfFile<ElfFileParamNames>::printNeededLibs() // const
1779+ void ElfFile<ElfFileParamNames>::printNeededLibs() const
17801780{
17811781 const auto shdrDynamic = findSectionHeader (" .dynamic" );
17821782 const auto shdrDynStr = findSectionHeader (" .dynstr" );
1783- const char *strTab = (char *)fileContents->data () + rdi (shdrDynStr.sh_offset );
1783+ const char *strTab = (const char *)fileContents->data () + rdi (shdrDynStr.sh_offset );
17841784
1785- const Elf_Dyn *dyn = (Elf_Dyn *) (fileContents->data () + rdi (shdrDynamic.sh_offset ));
1785+ const Elf_Dyn *dyn = (const Elf_Dyn *) (fileContents->data () + rdi (shdrDynamic.sh_offset ));
17861786
17871787 for (; rdi (dyn->d_tag ) != DT_NULL; dyn++) {
17881788 if (rdi (dyn->d_tag ) == DT_NEEDED) {
0 commit comments