commit 709f3944bfff1578b1393372e5d96a2c45008a1d
parent 748c08ed265010a52893183920edf958f7e9c987
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 17 Jan 2025 15:45:10 +0100
libmach/coff32write: Consider the string table for syms
Syms longer than 8 characters use the symbol table instead
of hardcoding the name directly in the symbol. The function
pack_ent() was ignoring this case and just assuming that the
name could fit in the symbol.
Diffstat:
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/libmach/coff32/coff32write.c b/src/libmach/coff32/coff32write.c
@@ -55,17 +55,21 @@ pack_ent(int order, unsigned char *buf, SYMENT *ent)
int n;
char *s;
- /* TODO: What happens with the union? */
+ if (ent->n_zeroes == 0)
+ pack(order, buf, "ll", ent->n_zeroes, ent->n_offset);
+ else
+ memcpy(buf, ent->n_name, 8);
n = pack(order,
buf,
- "'8lsscc",
- ent->n_name,
- ent->n_value,
- ent->n_scnum,
- ent->n_type,
- ent->n_sclass,
- ent->n_numaux);
+ "lsscc",
+ ent->n_value,
+ ent->n_scnum,
+ ent->n_type,
+ ent->n_sclass,
+ ent->n_numaux);
+ n += 8;
+
assert(n == SYMESZ);
}