scc

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

commit a3cd0a32f3a32fc590f9ba2e87e018e044f13664
parent 0b90a3871919aa0ecc04b30e174d55fe9c692c9d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 29 Aug 2019 21:46:08 +0100

[libmach] Use int as index in symbols and sections

It is very unlikely that we will be able to link
a program with more than 30000 symbols in a machine
where int is 16 bits.

Diffstat:
Minclude/scc/scc/mach.h | 7+++----
Msrc/cmd/ld/pass1.c | 7+++----
Msrc/cmd/nm.c | 3+--
Msrc/cmd/ranlib.c | 3+--
Msrc/cmd/size.c | 2+-
Msrc/libmach/coff32/coff32.h | 4++--
Msrc/libmach/coff32/coff32getsec.c | 2+-
Msrc/libmach/coff32/coff32getsym.c | 2+-
Msrc/libmach/getsec.c | 2+-
Msrc/libmach/getsym.c | 2+-
Msrc/libmach/libmach.h | 4++--
Msrc/libmach/rebase.c | 2+-
12 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/include/scc/scc/mach.h b/include/scc/scc/mach.h @@ -65,12 +65,11 @@ extern int writeobj(Obj *obj, FILE *fp); extern int strip(Obj *obj); extern int pc2line(Obj *obj, unsigned long long pc, char *fname, int *ln); -extern int rebase(Obj *obj, long index, unsigned long offset); +extern int rebase(Obj *obj, int index, unsigned long long offset); extern int mapsec(Obj *obj, int idx, FILE *fp); -/* TODO: Change index to int */ -extern Symbol *getsym(Obj *obj, long *index, Symbol *sym); -extern Section *getsec(Obj *obj, long *index, Section *sec); +extern Symbol *getsym(Obj *obj, int *index, Symbol *sym); +extern Section *getsec(Obj *obj, int *index, Section *sec); extern int setindex(int, long, char **, long *, FILE *); extern int getindex(int, long *, char ***, long **, FILE *); diff --git a/src/cmd/ld/pass1.c b/src/cmd/ld/pass1.c @@ -21,7 +21,7 @@ int bintype = -1; static int is_needed(Obj *obj) { - long i; + int i; Symbol sym; for (i = 0; getsym(obj, &i, &sym); i++) { @@ -65,7 +65,7 @@ newsec(Section *osec, Obj *obj) static void newsym(Symbol *sym, Obj *obj) { - long id; + int id; Section sec; if (sym->type == 'U' || islower(sym->type)) @@ -80,8 +80,7 @@ newsym(Symbol *sym, Obj *obj) static void load(FILE *fp, int inlib) { - int t; - long i; + int t, i; Obj *obj; Section sec; Symbol sym; diff --git a/src/cmd/nm.c b/src/cmd/nm.c @@ -152,8 +152,7 @@ newsym(Symbol *sym, struct symtbl *tbl) static void nmobj(FILE *fp, int type) { - int err = 1; - long i; + int i, err = 1; Obj *obj; Symbol sym; struct symtbl tbl = {NULL, 0}; diff --git a/src/cmd/ranlib.c b/src/cmd/ranlib.c @@ -137,8 +137,7 @@ freehash(void) static int newmember(FILE *fp) { - int t, ret = 0; - long i; + int i,t, ret = 0; Obj *obj; Symbol sym; diff --git a/src/cmd/size.c b/src/cmd/size.c @@ -40,7 +40,7 @@ error(char *fmt, ...) static void sizeobj(FILE *fp, int type) { - long i; + int i; Obj *obj; unsigned long long total, *p; struct sizes siz; diff --git a/src/libmach/coff32/coff32.h b/src/libmach/coff32/coff32.h @@ -39,5 +39,5 @@ extern int coff32xsetidx(int order, extern int coff32xgetidx(int order, long *nsyms, char ***namep, long **offsp, FILE *fp); -extern Symbol *coff32getsym(Obj *obj, long *idx, Symbol *sym); -extern Section *coff32getsec(Obj *obj, long *idx, Section *sec); +extern Symbol *coff32getsym(Obj *obj, int *idx, Symbol *sym); +extern Section *coff32getsec(Obj *obj, int *idx, Section *sec); diff --git a/src/libmach/coff32/coff32getsec.c b/src/libmach/coff32/coff32getsec.c @@ -6,7 +6,7 @@ #include "coff32.h" Section * -coff32getsec(Obj *obj, long *idx, Section *sec) +coff32getsec(Obj *obj, int *idx, Section *sec) { long n = *idx; int type; diff --git a/src/libmach/coff32/coff32getsym.c b/src/libmach/coff32/coff32getsym.c @@ -54,7 +54,7 @@ symname(Coff32 *coff, SYMENT *ent) } Symbol * -coff32getsym(Obj *obj, long *idx, Symbol *sym) +coff32getsym(Obj *obj, int *idx, Symbol *sym) { long n = *idx; SYMENT *ent; diff --git a/src/libmach/getsec.c b/src/libmach/getsec.c @@ -5,7 +5,7 @@ #include "libmach.h" Section * -getsec(Obj *obj, long *idx, Section *sec) +getsec(Obj *obj, int *idx, Section *sec) { return (*obj->ops->getsec)(obj, idx, sec); } diff --git a/src/libmach/getsym.c b/src/libmach/getsym.c @@ -5,7 +5,7 @@ #include "libmach.h" Symbol * -getsym(Obj *obj, long *index, Symbol *sym) +getsym(Obj *obj, int *index, Symbol *sym) { return (*obj->ops->getsym)(obj, index, sym); } diff --git a/src/libmach/libmach.h b/src/libmach/libmach.h @@ -36,8 +36,8 @@ struct objops { int (*strip)(Obj *obj); int (*pc2line)(Obj *, unsigned long long , char *, int *); - Symbol *(*getsym)(Obj *obj, long *index, Symbol *sym); - Section *(*getsec)(Obj *obj, long *index, Section *sec); + Symbol *(*getsym)(Obj *obj, int *index, Symbol *sym); + Section *(*getsec)(Obj *obj, int *index, Section *sec); int (*setidx)(long nsyms, char *names[], long offset[], FILE *fp); int (*getidx)(long *nsyms, char ***names, long **offset, FILE *fp); diff --git a/src/libmach/rebase.c b/src/libmach/rebase.c @@ -5,7 +5,7 @@ #include "libmach.h" int -rebase(Obj *obj, long idx, unsigned long base) +rebase(Obj *obj, int idx, unsigned long long base) { return 0; }