From e470009a16711555ae887fdacec061a7d092df17 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 4 Oct 2024 19:55:38 -0400 Subject: update mld,msim with new headers --- mld/link.c | 4 ++-- mld/link.h | 2 -- mld/obj.c | 29 ++--------------------------- 3 files changed, 4 insertions(+), 31 deletions(-) (limited to 'mld') diff --git a/mld/link.c b/mld/link.c index 8e61ce2..c56102a 100644 --- a/mld/link.c +++ b/mld/link.c @@ -8,9 +8,9 @@ #include #include #include +#include #include "link.h" -#include "mips.h" static int load_objects(struct linker *linker) { @@ -443,7 +443,7 @@ static int relocate_instruction_rela(struct linker *linker, uint32_t sym_vaddr = B32(new_sym->st_value); uint32_t *ins_raw = (uint32_t *) &seg->bytes[off]; - union mips_instruction_data ins; + union mips32_instruction ins; ins.raw = B32(*ins_raw); uint32_t ins_vaddr = seg->new_vaddr + off; diff --git a/mld/link.h b/mld/link.h index 93a2ccd..c0b99ce 100644 --- a/mld/link.h +++ b/mld/link.h @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -224,7 +223,6 @@ struct object { // program table Elf32_Phdr *phdr; size_t phdr_len; - bool phdr_local; // if phdr was created though malloc // phdr <=> shdr mappings uint32_t *phdr_to_shdr_mapping; diff --git a/mld/obj.c b/mld/obj.c index e986a75..a37527a 100644 --- a/mld/obj.c +++ b/mld/obj.c @@ -105,7 +105,6 @@ static int create_phdr(struct object *object) object->phdr = phdr; object->phdr_len = entries; - object->phdr_local = true; uint32_t *mapping = malloc(entries * sizeof(uint32_t)); if (mapping == NULL) { @@ -148,29 +147,6 @@ static int create_phdr(struct object *object) return M_SUCCESS; } -/** - * Map the phdr - */ -static int load_phdr(struct object *object) -{ - //size_t phdr_len = B16(object->ehdr->e_phentsize) * - // B16(object->ehdr->e_phnum); - - //if (phdr_len < 1) - return create_phdr(object); - - //size_t phdr_off = B32(object->ehdr->e_phoff); - //object->phdr = (Elf32_Phdr *) (object->mapped + phdr_off); - //object->phdr_len = B16(object->ehdr->e_phnum); - - //if (BOUND_CHK(object, phdr_len, phdr_off)) { - // ERROR("cannot read phdr"); - // return M_ERROR; - //} - - //return M_SUCCESS; -} - /** * Load the strtabs */ @@ -358,7 +334,6 @@ int object_load(struct object *object, char *path, uint32_t index) object->mapped = NULL; object->name = path; object->index = index; - object->phdr_local = false; object->phdr_to_shdr_mapping = NULL; /** load the file */ @@ -374,7 +349,7 @@ int object_load(struct object *object, char *path, uint32_t index) return M_ERROR; /* phdr */ - if (load_phdr(object)) + if (create_phdr(object)) return M_ERROR; /* strtabs */ @@ -404,7 +379,7 @@ void object_free(struct object *obj) free(obj->strtabs); if (obj->segments != NULL) free(obj->segments); - if (obj->phdr_local) + if (obj->phdr != NULL) free(obj->phdr); if (obj->phdr_to_shdr_mapping) free(obj->phdr_to_shdr_mapping); -- cgit v1.2.3-freya