* Support executables without a .dynamic section (klcc generates

'em).
This commit is contained in:
Eelco Dolstra
2008-05-28 14:31:08 +00:00
parent 59f7b9a4d0
commit 0c5f99f90a

View File

@@ -736,9 +736,11 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
/* Update all those nasty virtual addresses in the .dynamic
section. */
Elf_Shdr & shdrDynamic = findSection(".dynamic");
Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset));
section. Note that not all executables have .dynamic sections
(e.g., those produced by klibc's klcc). */
Elf_Shdr * shdrDynamic = findSection2(".dynamic");
if (shdrDynamic) {
Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic->sh_offset));
unsigned int d_tag;
for ( ; (d_tag = rdi(dyn->d_tag)) != DT_NULL; dyn++)
if (d_tag == DT_STRTAB)
@@ -770,6 +772,7 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
else if (d_tag == DT_VERSYM)
dyn->d_un.d_ptr = findSection(".gnu.version").sh_addr;
}
}