Skip to content

Commit e9e92e4

Browse files
committed
Renamed findSection2 to tryFindSectionHeader
1 parent 1071237 commit e9e92e4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/patchelf.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ std::string ElfFile<ElfFileParamNames>::getSectionName(const Elf_Shdr & shdr) co
471471
template<ElfFileParams>
472472
Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sectionName)
473473
{
474-
auto shdr = findSection2(sectionName);
474+
auto shdr = tryFindSectionHeader(sectionName);
475475
if (!shdr) {
476476
std::string extraMsg;
477477
if (sectionName == ".interp" || sectionName == ".dynamic" || sectionName == ".dynstr")
@@ -483,7 +483,7 @@ Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(const SectionName & sec
483483

484484

485485
template<ElfFileParams>
486-
std::optional<std::reference_wrapper<Elf_Shdr>> ElfFile<ElfFileParamNames>::findSection2(const SectionName & sectionName)
486+
std::optional<std::reference_wrapper<Elf_Shdr>> ElfFile<ElfFileParamNames>::tryFindSectionHeader(const SectionName & sectionName)
487487
{
488488
auto i = getSectionIndex(sectionName);
489489
if (i)
@@ -967,7 +967,7 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
967967
/* Update all those nasty virtual addresses in the .dynamic
968968
section. Note that not all executables have .dynamic sections
969969
(e.g., those produced by klibc's klcc). */
970-
auto shdrDynamic = findSection2(".dynamic");
970+
auto shdrDynamic = tryFindSectionHeader(".dynamic");
971971
if (shdrDynamic) {
972972
auto dyn_table = (Elf_Dyn *) (fileContents->data() + rdi((*shdrDynamic).get().sh_offset));
973973
unsigned int d_tag;
@@ -981,30 +981,30 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
981981
else if (d_tag == DT_HASH)
982982
dyn->d_un.d_ptr = findSectionHeader(".hash").sh_addr;
983983
else if (d_tag == DT_GNU_HASH) {
984-
auto shdr = findSection2(".gnu.hash");
984+
auto shdr = tryFindSectionHeader(".gnu.hash");
985985
// some binaries might this section stripped
986986
// in which case we just ignore the value.
987987
if (shdr) dyn->d_un.d_ptr = (*shdr).get().sh_addr;
988988
} else if (d_tag == DT_JMPREL) {
989-
auto shdr = findSection2(".rel.plt");
990-
if (!shdr) shdr = findSection2(".rela.plt");
989+
auto shdr = tryFindSectionHeader(".rel.plt");
990+
if (!shdr) shdr = tryFindSectionHeader(".rela.plt");
991991
/* 64-bit Linux, x86-64 */
992-
if (!shdr) shdr = findSection2(".rela.IA_64.pltoff"); /* 64-bit Linux, IA-64 */
992+
if (!shdr) shdr = tryFindSectionHeader(".rela.IA_64.pltoff"); /* 64-bit Linux, IA-64 */
993993
if (!shdr) error("cannot find section corresponding to DT_JMPREL");
994994
dyn->d_un.d_ptr = (*shdr).get().sh_addr;
995995
}
996996
else if (d_tag == DT_REL) { /* !!! hack! */
997-
auto shdr = findSection2(".rel.dyn");
997+
auto shdr = tryFindSectionHeader(".rel.dyn");
998998
/* no idea if this makes sense, but it was needed for some
999999
program */
1000-
if (!shdr) shdr = findSection2(".rel.got");
1000+
if (!shdr) shdr = tryFindSectionHeader(".rel.got");
10011001
/* some programs have neither section, but this doesn't seem
10021002
to be a problem */
10031003
if (!shdr) continue;
10041004
dyn->d_un.d_ptr = (*shdr).get().sh_addr;
10051005
}
10061006
else if (d_tag == DT_RELA) {
1007-
auto shdr = findSection2(".rela.dyn");
1007+
auto shdr = tryFindSectionHeader(".rela.dyn");
10081008
/* some programs lack this section, but it doesn't seem to
10091009
be a problem */
10101010
if (!shdr) continue;
@@ -1017,7 +1017,7 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
10171017
else if (d_tag == DT_MIPS_RLD_MAP_REL) {
10181018
/* the MIPS_RLD_MAP_REL tag stores the offset to the debug
10191019
pointer, relative to the address of the tag */
1020-
auto shdr = findSection2(".rld_map");
1020+
auto shdr = tryFindSectionHeader(".rld_map");
10211021
if (shdr) {
10221022
auto rld_map_addr = findSectionHeader(".rld_map").sh_addr;
10231023
auto dyn_offset = ((char*)dyn) - ((char*)dyn_table);

src/patchelf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class ElfFile
104104

105105
Elf_Shdr & findSectionHeader(const SectionName & sectionName);
106106

107-
std::optional<std::reference_wrapper<Elf_Shdr>> findSection2(const SectionName & sectionName);
107+
std::optional<std::reference_wrapper<Elf_Shdr>> tryFindSectionHeader(const SectionName & sectionName);
108108

109109
unsigned int getSectionIndex(const SectionName & sectionName);
110110

0 commit comments

Comments
 (0)