Home
libmach: Fix objprobe() - scc - simple c99 compiler HTML git clone git://git.simple-cc.org/scc DIR Log DIR Files DIR Refs DIR Submodules DIR README DIR LICENSE --- DIR commit b0a24eced82c3e643a2722a1d8560338b653a51e DIR parent 0743502801e60e87b15b2af32a314684f66fb472 HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Thu, 15 Feb 2024 16:09:15 +0100 libmach: Fix objprobe() It was supposed to return the type encoding but it was returning only the object position in the object array that just happened to have the correct byte order that we are testing and no arch, but as we are not using arch for anything yet then it didn't fail. Diffstat: M src/libmach/elf64/elf64probe.c | 2 +- M src/libmach/objprobe.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) --- DIR diff --git a/src/libmach/elf64/elf64probe.c b/src/libmach/elf64/elf64probe.c @@ -53,7 +53,7 @@ elf64probe(unsigned char *buf, char **name) if (ap->mach == hdr.e_machine && ap->endian == endian) { if (name) *name = ap->name; - return 0; + return ap->type; } } DIR diff --git a/src/libmach/objprobe.c b/src/libmach/objprobe.c @@ -7,7 +7,7 @@ int objprobe(FILE *fp, char **name) { - int n, i; + int n, t; fpos_t pos; Objops **opsp, *ops; unsigned char buf[NBYTES]; @@ -20,9 +20,10 @@ objprobe(FILE *fp, char **name) return -1; for (opsp = objops; ops = *opsp; ++opsp) { - if ((*ops->probe)(buf, name) < 0) + t = (*ops->probe)(buf, name); + if (t < 0) continue; - return opsp - objops; + return t; } return -1;