commit fb59273a4d69ca038ef6f5bd9d6b738254720943
parent 099548f9e14488bce21d9f894637e9a2905c3efe
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 17 Jan 2025 20:19:31 +0100
libmach/coff32: Set 0 file pointers when no data
The line and relocation pointers of sections must be 0
if there is not data. It is not a big problem because
the number of items is check before, but it is better
to output a cleaner object.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libmach/coff32/coff32write.c b/src/libmach/coff32/coff32write.c
@@ -502,13 +502,13 @@ coff32write(Obj *obj, Map *map, FILE *fp)
n = hdr->f_nscns;
for (scn = coff->scns; n--; scn++) {
- scn->s_relptr = ptr;
+ scn->s_relptr = (scn->s_nrelloc > 0) ? ptr : 0;
ptr += scn->s_nrelloc * RELSZ;
}
n = hdr->f_nscns;
for (scn = coff->scns; n--; scn++) {
- scn->s_lnnoptr = ptr;
+ scn->s_lnnoptr = (scn->s_nlnno > 0) ? ptr : 0;
ptr += scn->s_nlnno * RELSZ;
}