scc

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

commit 492bdeef9be770876a3c11f4d2a1202b04e02825
parent 3c28376f3976488528e07c50e839326bf4b77605
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 18 Jan 2025 19:49:17 +0100

libmach: Add optional parameter to armember()

This parameter if different than NULL points to a struct ar_hdr
where a copy of the archive member header is copied.

Diffstat:
Minclude/bits/scc/mach.h | 4+++-
Msrc/cmd/scc-ld/pass1.c | 4++--
Msrc/cmd/scc-nm.c | 2+-
Msrc/cmd/scc-ranlib.c | 4++--
Msrc/cmd/scc-size.c | 2+-
Msrc/libmach/armember.c | 5++++-
6 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/include/bits/scc/mach.h b/include/bits/scc/mach.h @@ -68,6 +68,8 @@ enum symtype { SYMCOMMON, }; +struct ar_hdr; + struct obj { char *index; Objops *ops; @@ -120,7 +122,7 @@ struct symbol { #ifdef stdin extern int archive(FILE *); -extern long armember(FILE *, char *); +extern long armember(FILE *, char *, struct ar_hdr *); extern int objprobe(FILE *, char **); diff --git a/src/cmd/scc-ld/pass1.c b/src/cmd/scc-ld/pass1.c @@ -179,7 +179,7 @@ scanlib(FILE *fp) } cur = ftell(fp); - if ((off = armember(fp, memb)) < 0) + if ((off = armember(fp, memb, NULL)) < 0) goto corrupted; if (strcmp(memb, "/") == 0 || strcmp(memb, "__.SYMDEF") == 0) { @@ -190,7 +190,7 @@ scanlib(FILE *fp) fseek(fp, cur, SEEK_SET); for (;;) { cur = ftell(fp); - off = armember(fp, memb); + off = armember(fp, memb, NULL); switch (off) { case -1: goto corrupted; diff --git a/src/cmd/scc-nm.c b/src/cmd/scc-nm.c @@ -193,7 +193,7 @@ nmlib(FILE *fp) for (;;) { cur = ftell(fp); - off = armember(fp, memb); + off = armember(fp, memb, NULL); switch (off) { case -1: error("library corrupted"); diff --git a/src/cmd/scc-ranlib.c b/src/cmd/scc-ranlib.c @@ -192,7 +192,7 @@ readsyms(FILE *fp) } cur = ftell(fp); - if ((off = armember(fp, memb)) < 0) + if ((off = armember(fp, memb, NULL)) < 0) goto corrupted; if (strcmp(memb, "/") == 0 || strcmp(memb, "__.SYMDEF") == 0) @@ -201,7 +201,7 @@ readsyms(FILE *fp) fseek(fp, cur, SEEK_SET); for (;;) { cur = ftell(fp); - off = armember(fp, memb); + off = armember(fp, memb, NULL); switch (off) { case -1: goto corrupted; diff --git a/src/cmd/scc-size.c b/src/cmd/scc-size.c @@ -106,7 +106,7 @@ sizelib(FILE *fp) for (;;) { cur = ftell(fp); - off = armember(fp, memb); + off = armember(fp, memb, NULL); switch (off) { case -1: error("library corrupted"); diff --git a/src/libmach/armember.c b/src/libmach/armember.c @@ -24,7 +24,7 @@ getfname(struct ar_hdr *hdr, char *dst) } long -armember(FILE *fp, char *member) +armember(FILE *fp, char *member, struct ar_hdr *phdr) { struct ar_hdr hdr; long siz; @@ -47,5 +47,8 @@ armember(FILE *fp, char *member) getfname(&hdr, member); + if (phdr) + *phdr = hdr; + return sizeof(hdr) + siz; }