From 45fc82678d89f3912fe70047b00ac23c5449e266 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Thu, 11 Sep 2014 16:07:09 -0500 Subject: Allow DT_REL without .rel.dyn or .rel.got Some DT_REL files are missing both .rel.dyn and .rel.got. This doesn't seem to be an error, so it shouldn't be treated as such. --- src/patchelf.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/patchelf.cc b/src/patchelf.cc index 731b9ad..1d0c9a7 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -840,11 +840,18 @@ void ElfFile::rewriteHeaders(Elf_Addr phdrAddress) /* 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"); + /* some programs have neither section, but this doesn't seem + to be a problem */ + if (!shdr) continue; + dyn->d_un.d_ptr = shdr->sh_addr; + } + else if (d_tag == DT_RELA) { + Elf_Shdr * shdr = findSection2(".rela.dyn"); + /* some programs lack this section, but it doesn't seem to + be a problem */ + if (!shdr) continue; dyn->d_un.d_ptr = shdr->sh_addr; } - else if (d_tag == DT_RELA) - dyn->d_un.d_ptr = findSection(".rela.dyn").sh_addr; /* PPC Linux */ else if (d_tag == DT_VERNEED) dyn->d_un.d_ptr = findSection(".gnu.version_r").sh_addr; else if (d_tag == DT_VERSYM) -- cgit v0.12