ref: f8fbc1dd568bb33610e5f11ac459d58476eb0643
dir: /src/libmach/coff32/coff32xsetidx.c/
#include <stdio.h> #include <string.h> #include <scc/mach.h> #include "../libmach.h" int coff32xsetidx(int order, long nsyms, Objsymdef *head, FILE *fp) { long i, n; size_t len; Objsymdef *def; unsigned char buff[4]; pack(order, buff, "l", nsyms); fwrite(buff, 4, 1, fp); n = 4; for (def = head; def; def = def->next) { pack(order, buff, "l", (long) def->offset); fwrite(buff, 4, 1, fp); n += 4; } for (def = head; def; def = def->next) { len = strlen(def->name) + 1; fwrite(def->name, len, 1, fp); n += len; } return fflush(fp) == EOF ? -1 : 0; }