scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit c2610cada127ad3f586bd2e0aace6230c9dcf8d1
parent 39928687d4b42e76cb93ae3a54b2ec0709231ef9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 23 Aug 2019 17:16:45 +0100

[libmach] Add write method to Objops

Diffstat:
Minclude/scc/scc/mach.h | 2+-
Msrc/cmd/ld/pass5.c | 2+-
Msrc/cmd/strip.c | 2+-
Msrc/libmach/coff32/coff32.c | 1+
Msrc/libmach/coff32/coff32.h | 1+
Msrc/libmach/libmach.h | 3+--
6 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/scc/scc/mach.h b/include/scc/scc/mach.h @@ -50,6 +50,7 @@ struct objops { int (*addr2line)(Obj *, unsigned long long , char *, int *); int (*strip)(Obj *obj); void (*del)(Obj *obj); + int (*write)(Obj *obj, FILE *fp); int (*setidx)(long nsyms, Objsymdef *def, FILE *fp); int (*getidx)(long *nsyms, Objsymdef **def, FILE *fp); }; @@ -74,7 +75,6 @@ extern int formember(FILE *fp, extern int objtype(FILE *fp, char **name); extern Obj *objnew(int type); extern Objsym *objlookup(Obj *obj, char *name, int install); -extern int objwrite(Obj *obj, FILE *fp); extern int objpos(Obj *obj, FILE *fp, long pos); extern int archive(FILE *fp); extern long armember(FILE *fp, char *member); diff --git a/src/cmd/ld/pass5.c b/src/cmd/ld/pass5.c @@ -48,5 +48,5 @@ pass5(int argc, char *argv[]) fp = fopen(output, "wb"); objsync(obj); - objwrite(obj, fp); + (obj->ops->write)(obj, fp); } diff --git a/src/cmd/strip.c b/src/cmd/strip.c @@ -65,7 +65,7 @@ strip(char *fname) if ((fp = fopen(fname, "wb")) == NULL) goto err1; - if (objwrite(obj, fp) < 0) { + if (ops->write(obj, fp) < 0) { error("error writing output"); goto err3; } diff --git a/src/libmach/coff32/coff32.c b/src/libmach/coff32/coff32.c @@ -13,4 +13,5 @@ Objops coff32 = { .addr2line = coff32addr2line, .strip = coff32strip, .del = coff32del, + .write = coff32write, }; diff --git a/src/libmach/coff32/coff32.h b/src/libmach/coff32/coff32.h @@ -31,6 +31,7 @@ extern int coff32getidx(long *nsyms, Objsymdef **def, FILE *fp); extern int coff32addr2line(Obj *, unsigned long long , char *, int *); extern int coff32strip(Obj *obj); extern void coff32del(Obj *obj); +extern int coff32write(Obj *obj, FILE *fp); extern int coff32xsetidx(int order, long nsyms, Objsymdef *head, FILE *fp); extern int coff32xgetidx(int order, long *nsyms, Objsymdef **def, FILE *fp); diff --git a/src/libmach/libmach.h b/src/libmach/libmach.h @@ -26,11 +26,10 @@ enum order { /* common functions */ extern int pack(int order, unsigned char *dst, char *fmt, ...); extern int unpack(int order, unsigned char *src, char *fmt, ...); -extern void objfree(Obj *obj); +extern void objdel(Obj *obj); /* coff32 functions */ /* TODO: Move this functions to a coff32 files */ -extern int coff32write(Obj *obj, FILE *fp); extern int coff32probe(unsigned char *buf, char **name); extern char *coff32namidx(void);