diff options
author | Freya Murphy <freya@freyacat.org> | 2024-09-22 16:02:42 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-09-22 16:02:42 -0400 |
commit | 85471efb4c740bb775c9ebdb10f775620c979598 (patch) | |
tree | c4afa5cf8108df4192e73488c4da271ed166217c /mld/seg.c | |
parent | update make clear (diff) | |
download | mips-85471efb4c740bb775c9ebdb10f775620c979598.tar.gz mips-85471efb4c740bb775c9ebdb10f775620c979598.tar.bz2 mips-85471efb4c740bb775c9ebdb10f775620c979598.zip |
mld done
Diffstat (limited to '')
-rw-r--r-- | mld/seg.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -82,6 +82,13 @@ static int load_reltab(struct object *obj, struct segment *seg) if (type != SHT_REL && type != SHT_RELA) continue; + if ((type == SHT_REL && B32(hdr->sh_entsize) != + sizeof(Elf32_Rel)) || (type == SHT_RELA && + B32(hdr->sh_entsize) != sizeof(Elf32_Rela))) { + ERROR("reltab [%d] has invalid entry size", i); + return M_ERROR; + } + if (B32(hdr->sh_info) != seg->shdr_idx) continue; @@ -101,9 +108,8 @@ static int load_reltab(struct object *obj, struct segment *seg) uint32_t len = B32(hdr->sh_size); uint32_t off = B32(hdr->sh_offset); - seg->reltab.symtab = symtab; - seg->reltab.len = len; + seg->reltab.len = len / B32(hdr->sh_entsize); seg->reltab.raw = obj->mapped + off; seg->reltab.type = type; @@ -131,5 +137,18 @@ int segment_load(struct object *obj, struct segment *seg, size_t index) if (load_reltab(obj, seg)) return M_ERROR; + seg->off = B32(seg->phdr->p_offset); + seg->vaddr = B32(seg->phdr->p_vaddr); + seg->size = B32(seg->phdr->p_filesz); + seg->new_off = 0; + seg->new_vaddr = 0; + + seg->read = B32(seg->phdr->p_flags) & PF_R; + seg->write = B32(seg->phdr->p_flags) & PF_W; + seg->execute = B32(seg->phdr->p_flags) & PF_X; + seg->align = B32(seg->phdr->p_align); + + seg->obj = obj; + return M_SUCCESS; } |