/*static*/ status_t ELFLoader<Class>::Relocate(preloaded_image* _image) { ImageType* image = static_cast<ImageType*>(_image); status_t status = _ParseDynamicSection(image); if (status != B_OK) return status; // deal with the rels first if (image->rel) { TRACE(("total %i relocs\n", (int)image->rel_len / (int)sizeof(RelType))); status = boot_arch_elf_relocate_rel(image, image->rel, image->rel_len); if (status != B_OK) return status; } if (image->pltrel) { RelType* pltrel = image->pltrel; if (image->pltrel_type == DT_REL) { TRACE(("total %i plt-relocs\n", (int)image->pltrel_len / (int)sizeof(RelType))); status = boot_arch_elf_relocate_rel(image, pltrel, image->pltrel_len); } else { TRACE(("total %i plt-relocs\n", (int)image->pltrel_len / (int)sizeof(RelaType))); status = boot_arch_elf_relocate_rela(image, (RelaType*)pltrel, image->pltrel_len); } if (status != B_OK) return status; } if (image->rela) { TRACE(("total %i rela relocs\n", (int)image->rela_len / (int)sizeof(RelaType))); status = boot_arch_elf_relocate_rela(image, image->rela, image->rela_len); if (status != B_OK) return status; } return B_OK; }
status_t elf_relocate_image(struct preloaded_image *image) { status_t status = elf_parse_dynamic_section(image); if (status != B_OK) return status; // deal with the rels first if (image->rel) { TRACE(("total %i relocs\n", image->rel_len / (int)sizeof(struct Elf32_Rel))); status = boot_arch_elf_relocate_rel(image, image->rel, image->rel_len); if (status < B_OK) return status; } if (image->pltrel) { TRACE(("total %i plt-relocs\n", image->pltrel_len / (int)sizeof(struct Elf32_Rel))); if (image->pltrel_type == DT_REL) { status = boot_arch_elf_relocate_rel(image, image->pltrel, image->pltrel_len); } else { status = boot_arch_elf_relocate_rela(image, (struct Elf32_Rela *)image->pltrel, image->pltrel_len); } if (status < B_OK) return status; } if (image->rela) { TRACE(("total %i rela relocs\n", image->rela_len / (int)sizeof(struct Elf32_Rela))); status = boot_arch_elf_relocate_rela(image, image->rela, image->rela_len); if (status < B_OK) return status; } return B_OK; }