@@ -535,7 +535,7 @@ std::string ElfFile<ElfFileParamNames>::getSectionName(const Elf_Shdr & shdr) co
535
535
536
536
537
537
template <ElfFileParams>
538
- Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sectionName)
538
+ const Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sectionName) const
539
539
{
540
540
auto shdr = tryFindSectionHeader (sectionName);
541
541
if (!shdr) {
@@ -549,7 +549,7 @@ Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sec
549
549
550
550
551
551
template <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
553
553
{
554
554
auto i = getSectionIndex (sectionName);
555
555
if (i)
@@ -602,7 +602,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
602
602
clobbering previously written new section contents. */
603
603
for (auto & i : replacedSections) {
604
604
const std::string & sectionName = i.first ;
605
- Elf_Shdr & shdr = findSectionHeader (sectionName);
605
+ const Elf_Shdr & shdr = findSectionHeader (sectionName);
606
606
if (rdi (shdr.sh_type ) != SHT_NOBITS)
607
607
memset (fileContents->data () + rdi (shdr.sh_offset ), ' X' , rdi (shdr.sh_size ));
608
608
}
@@ -1190,10 +1190,10 @@ static void setSubstr(std::string & s, unsigned int pos, const std::string & t)
1190
1190
1191
1191
1192
1192
template <ElfFileParams>
1193
- std::string ElfFile<ElfFileParamNames>::getInterpreter()
1193
+ std::string ElfFile<ElfFileParamNames>::getInterpreter() const
1194
1194
{
1195
1195
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 );
1197
1197
}
1198
1198
1199
1199
template <ElfFileParams>
@@ -1776,13 +1776,13 @@ void ElfFile<ElfFileParamNames>::addNeeded(const std::set<std::string> & libs)
1776
1776
}
1777
1777
1778
1778
template <ElfFileParams>
1779
- void ElfFile<ElfFileParamNames>::printNeededLibs() // const
1779
+ void ElfFile<ElfFileParamNames>::printNeededLibs() const
1780
1780
{
1781
1781
const auto shdrDynamic = findSectionHeader (" .dynamic" );
1782
1782
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 );
1784
1784
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 ));
1786
1786
1787
1787
for (; rdi (dyn->d_tag ) != DT_NULL; dyn++) {
1788
1788
if (rdi (dyn->d_tag ) == DT_NEEDED) {
0 commit comments