summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-03-03 21:57:07 (GMT)
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-03-03 21:57:07 (GMT)
commitfc5cb4be7ae77c94eee46cc65dcde7f21d8f4797 (patch)
tree8ed155ab2a90a81e414ca7db8b8f15231a1db118
parent020c2393cf78708b1d821ab8e777002b00f2c608 (diff)
downloadpatchelf-fc5cb4be7ae77c94eee46cc65dcde7f21d8f4797.zip
patchelf-fc5cb4be7ae77c94eee46cc65dcde7f21d8f4797.tar.gz
patchelf-fc5cb4be7ae77c94eee46cc65dcde7f21d8f4797.tar.bz2
* Hack: if we can't find .rel.dyn, use .rel.got. No idea if this
makes sense.
-rw-r--r--src/patchelf.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index 28c442e..03ff227 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -215,11 +215,20 @@ static string getSectionName(const Elf32_Shdr & shdr)
}
-static Elf32_Shdr & findSection(const SectionName & sectionName)
+static Elf32_Shdr * findSection2(const SectionName & sectionName)
{
for (unsigned int i = 1; i < hdr->e_shnum; ++i)
- if (getSectionName(shdrs[i]) == sectionName) return shdrs[i];
- error("cannot find section");
+ if (getSectionName(shdrs[i]) == sectionName) return &shdrs[i];
+ return 0;
+}
+
+
+static Elf32_Shdr & findSection(const SectionName & sectionName)
+{
+ Elf32_Shdr * shdr = findSection2(sectionName);
+ if (!shdr)
+ error("cannot find section " + sectionName);
+ return *shdr;
}
@@ -426,8 +435,14 @@ static void rewriteSections()
dyn->d_un.d_ptr = findSection(".hash").sh_addr;
else if (dyn->d_tag == DT_JMPREL)
dyn->d_un.d_ptr = findSection(".rel.plt").sh_addr;
- else if (dyn->d_tag == DT_REL)
- dyn->d_un.d_ptr = findSection(".rel.dyn").sh_addr;
+ else if (dyn->d_tag == DT_REL) { /* !!! hack! */
+ Elf32_Shdr * shdr = findSection2(".rel.dyn");
+ /* no idea if this makes sense, but it was needed for some
+ program*/
+ if (!shdr) shdr = findSection2(".rel.got");
+ if (!shdr) error("cannot find .rel.dyn or .rel.got");
+ dyn->d_un.d_ptr = shdr->sh_addr;
+ }
else if (dyn->d_tag == DT_VERNEED)
dyn->d_un.d_ptr = findSection(".gnu.version_r").sh_addr;
else if (dyn->d_tag == DT_VERSYM)