From f918f8fe1c1844749d75e5b874972bdd73a6b5bf Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 23 Sep 2024 10:25:01 -0400 Subject: fix symtab map bad offset --- mld/symtab.c | 5 +++-- mld/vgcore.4024670 | Bin 0 -> 8847360 bytes test/msim/test | Bin 9591 -> 9591 bytes 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 mld/vgcore.4024670 diff --git a/mld/symtab.c b/mld/symtab.c index 5abad2a..992802c 100644 --- a/mld/symtab.c +++ b/mld/symtab.c @@ -55,12 +55,13 @@ int symtab_get(struct symbol_table *symtab, Elf32_Sym **res, const char *name, const char *symname = symtab->strtab->data + B32(sym->st_name); if (strcmp(name, symname) != 0) continue; - // only allow retrevial of local variables from the // same object if (sym->st_info >> 4 != STB_GLOBAL && symtab->map != NULL && obj_idx >= 0) { - struct object *obj = symtab->map->meta[i]; + // we need to change the index by one since + // symbol tables always start will a NULl symbol + struct object *obj = symtab->map->meta[i - 1]; if (obj->index != (uint32_t)obj_idx) continue; } else if (obj_idx < 0 && sym->st_info >> 4 != STB_GLOBAL) { diff --git a/mld/vgcore.4024670 b/mld/vgcore.4024670 new file mode 100644 index 0000000..4c6b5c4 Binary files /dev/null and b/mld/vgcore.4024670 differ diff --git a/test/msim/test b/test/msim/test index 293d241..86953db 100644 Binary files a/test/msim/test and b/test/msim/test differ -- cgit v1.2.3-freya