From fc5cb4be7ae77c94eee46cc65dcde7f21d8f4797 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Mar 2006 21:57:07 +0000 Subject: * Hack: if we can't find .rel.dyn, use .rel.got. No idea if this makes sense. --- src/patchelf.cc | 25 ++++++++++++++++++++----- 1 file 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) -- cgit v0.12