From 9042c226157d2df53066d2e249a1de6427d62a68 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Sun, 11 Nov 2007 13:25:15 +0000 Subject: [PATCH] * as/hc08/asmain.c, * as/z80/asmain.c: cosmetic changes * as/hc08/alloc.h, * as/mcs51/alloc.h, * as/z80/alloc.h: removed * as/hc08/assym.c, * as/mcs51/assym.c: replaced alloc.h with stdlib.h * as/link/aslink.h: added LKDIRSEP and, LKDIRSEPSTR * as/link/hc08/Makefile.in, * as/link/mcs51/Makefile.in, * as/link/z80/Makefile.in: added -DUNIX to CFLAGS * as/link/lklex.c, * as/link/mcs51/lkarea.c, * as/link/mcs51/lkmain.c: cosmetic changes * as/link/hc08/lklibr.c, * as/link/z80/lklibr.c, * as/link/mcs51/lklibr.c: used LKDIRSEP, LKDIRSEPSTR and LKOBJEXT, used cygwin_conv_to_full_posix_path, added warnings, cosmetic changes, brought more in sync changed old K&R into ANSI function declarations * as/link/z80/lklibr.c (loadAdb): added * as/link/z80/lkmain.c: removed -- option from usage text git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4960 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 25 +++ as/hc08/alloc.h | 4 - as/hc08/asmain.c | 2 +- as/hc08/assym.c | 10 +- as/link/aslink.h | 35 +-- as/link/hc08/Makefile.in | 2 +- as/link/hc08/lklibr.c | 147 ++++++++----- as/link/lklex.c | 2 +- as/link/mcs51/Makefile.in | 2 +- as/link/mcs51/lkarea.c | 2 +- as/link/mcs51/lklibr.c | 173 +++++++++------ as/link/mcs51/lkmain.c | 4 +- as/link/z80/Makefile.in | 2 +- as/link/z80/lklibr.c | 441 +++++++++++++++++--------------------- as/link/z80/lkmain.c | 3 - as/mcs51/alloc.h | 4 - as/mcs51/assym.c | 10 +- as/z80/alloc.h | 10 - as/z80/asmain.c | 4 +- 19 files changed, 463 insertions(+), 419 deletions(-) delete mode 100644 as/hc08/alloc.h delete mode 100644 as/mcs51/alloc.h delete mode 100644 as/z80/alloc.h diff --git a/ChangeLog b/ChangeLog index c0f83b77..eec19768 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2007-11-10 Maarten Brock + + * as/hc08/asmain.c, + * as/z80/asmain.c: cosmetic changes + * as/hc08/alloc.h, + * as/mcs51/alloc.h, + * as/z80/alloc.h: removed + * as/hc08/assym.c, + * as/mcs51/assym.c: replaced alloc.h with stdlib.h + * as/link/aslink.h: added LKDIRSEP and, LKDIRSEPSTR + * as/link/hc08/Makefile.in, + * as/link/mcs51/Makefile.in, + * as/link/z80/Makefile.in: added -DUNIX to CFLAGS + * as/link/lklex.c, + * as/link/mcs51/lkarea.c, + * as/link/mcs51/lkmain.c: cosmetic changes + * as/link/hc08/lklibr.c, + * as/link/z80/lklibr.c, + * as/link/mcs51/lklibr.c: used LKDIRSEP, LKDIRSEPSTR and LKOBJEXT, + used cygwin_conv_to_full_posix_path, + added warnings, cosmetic changes, brought more in sync + changed old K&R into ANSI function declarations + * as/link/z80/lklibr.c (loadAdb): added + * as/link/z80/lkmain.c: removed -- option from usage text + 2007-11-03 Maarten Brock * src/mcs51/gen.c (outBitC): optimized for no result diff --git a/as/hc08/alloc.h b/as/hc08/alloc.h deleted file mode 100644 index dd404a86..00000000 --- a/as/hc08/alloc.h +++ /dev/null @@ -1,4 +0,0 @@ -/* alloc.h */ -/* DECUS C */ - -#include diff --git a/as/hc08/asmain.c b/as/hc08/asmain.c index 53691ee6..633786b7 100644 --- a/as/hc08/asmain.c +++ b/as/hc08/asmain.c @@ -1022,7 +1022,7 @@ loop: */ default: machine(mp); - /* if cdb information the generate the line info */ + /* if cdb information then generate the line info */ if (cflag && (pass == 1)) DefineCDB_Line(); diff --git a/as/hc08/assym.c b/as/hc08/assym.c index 21d718d5..996cd323 100644 --- a/as/hc08/assym.c +++ b/as/hc08/assym.c @@ -8,7 +8,7 @@ * 721 Berkeley St. * Kent, Ohio 44240 * - * 28-Oct-97 JLH: + * 28-Oct-97 JLH: * - lookup: Use StoreString for sym construction * - change symeq() to do length-independent string compare * - change hash() to do length-independent hash calculation @@ -21,11 +21,7 @@ #include #include #include -#if defined(_MSC_VER) -#include -#else -#include -#endif +#include #include "asm.h" /*)Module assym.c @@ -385,7 +381,7 @@ register char *p1, *p2; * side effects: * none */ - + int hash(p) register char *p; diff --git a/as/link/aslink.h b/as/link/aslink.h index 15d6e0f9..409235ea 100644 --- a/as/link/aslink.h +++ b/as/link/aslink.h @@ -56,29 +56,40 @@ $(STACK) = 2000 */ +#if defined decus /* DECUS C void definition */ /* File/extension seperator */ -#ifdef decus -#define VOID char -#define FSEPX '.' -#endif +#define VOID char +#define FSEPX '.' +#elif defined PDOS /* PDOS C void definition */ /* File/extension seperator */ -#ifdef PDOS -#define VOID char -#define FSEPX ':' -#endif +#define VOID char +#define FSEPX ':' + +#elif defined UNIX +/* UNIX void definition */ +/* File/extension seperator */ -/* Default void definition */ +#define VOID void +#define FSEPX '.' +#define LKDIRSEP '/' +#define LKDIRSEPSTR "/" +#define OTHERSYSTEM + +#else +/* DOS/WINDOWS void definition */ /* File/extension seperator */ -#ifndef VOID -#define VOID void -#define FSEPX '.' +#define VOID void +#define FSEPX '.' +#define LKDIRSEP '\\' +#define LKDIRSEPSTR "\\" #define OTHERSYSTEM + #endif /* diff --git a/as/link/hc08/Makefile.in b/as/link/hc08/Makefile.in index 1bcdf47f..12bdd6cf 100644 --- a/as/link/hc08/Makefile.in +++ b/as/link/hc08/Makefile.in @@ -34,7 +34,7 @@ EXEEXT = @EXEEXT@ VPATH = @srcdir@ CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/.. -CFLAGS = @CFLAGS@ -Wall +CFLAGS = @CFLAGS@ -Wall -DUNIX M_OR_MM = @M_OR_MM@ LDFLAGS = @LDFLAGS@ diff --git a/as/link/hc08/lklibr.c b/as/link/hc08/lklibr.c index f7614d28..0f9d08a3 100644 --- a/as/link/hc08/lklibr.c +++ b/as/link/hc08/lklibr.c @@ -67,7 +67,7 @@ */ VOID -addpath() +addpath(void) { struct lbpath *lbph, *lbp; @@ -77,7 +77,9 @@ addpath() } else { lbp = lbphead; while (lbp->next) + { lbp = lbp->next; + } lbp->next = lbph; } unget(getnb()); @@ -113,7 +115,7 @@ addpath() */ VOID -addlib() +addlib(void) { struct lbpath *lbph; int foundcount=0; @@ -187,11 +189,11 @@ int addfile(char * path, char * libfil) if (path != NULL) { str = (char *) new (strlen(path) + strlen(libfil) + 6); - strcpy(str,path); + strcpy(str, path); #ifdef OTHERSYSTEM - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { - strcat(str,"/"); + strcat(str, LKDIRSEPSTR); } #endif } @@ -201,7 +203,7 @@ int addfile(char * path, char * libfil) } #ifdef OTHERSYSTEM - if ((libfil[0] == '/') || (libfil[0] == '\\')) + if ((libfil[0] == '/') || (libfil[0] == LKDIRSEP)) { libfil++; libfilinc=1; @@ -232,7 +234,7 @@ int addfile(char * path, char * libfil) if(path==NULL) { - /*'path' can not be null since it is needed to find the '.rel' files associated with + /*'path' can not be null since it is needed to find the object files associated with the library. So, get 'path' from 'str' and then chop it off and recreate 'libfil'. That way putting 'path' and 'libfil' together will result into the original filepath as contained in 'str'.*/ @@ -241,7 +243,7 @@ int addfile(char * path, char * libfil) strcpy(path, str); for(j=strlen(path)-1; j>=0; j--) { - if((path[j] == '/') || (path[j] == '\\')) + if((path[j] == '/') || (path[j] == LKDIRSEP)) { strcpy(libfil, &path[j+1]); path[j+1]=0; @@ -263,13 +265,15 @@ int addfile(char * path, char * libfil) { lbn = lbnhead; while (lbn->next) + { lbn = lbn->next; + } lbn->next = lbnh; } lbnh->path = path; lbnh->libfil = (char *) new (strlen(libfil) + 1); - strcpy(lbnh->libfil,libfil); + strcpy(lbnh->libfil, libfil); lbnh->libspc = str; return 1; } @@ -312,10 +316,10 @@ int addfile(char * path, char * libfil) */ VOID -search() +search(void) { register struct sym *sp; - register int i,symfnd; + register int i, symfnd; /* * Look for undefined symbols. Keep @@ -350,7 +354,7 @@ search() } /*Load a .rel file embedded in a sdcclib file*/ -void LoadRel(FILE * libfp, char * ModName) +void LoadRel(char * libfname, FILE * libfp, char * ModName) { char str[NINPUT+2]; int state=0; @@ -370,8 +374,8 @@ void LoadRel(FILE * libfp, char * ModName) if(EQ(str, ModName)) state=1; else { - fprintf(stderr, "?ASlink-Error-Bad offset in library file str=%s, Modname=%s\n", - str, ModName); + fprintf(stderr, "?ASlink-Error-Bad offset in library file %s(%s)\n", + libfname, ModName); lkexit(1); } } @@ -388,9 +392,9 @@ void LoadRel(FILE * libfp, char * ModName) } } -/*Load an .adb file embedded in a sdcclib file. If there is +/*Load an .adb file embedded in a sdcclib file. If there is something between and returns 1, otherwise returns 0. -This way the aomf51 will not have uselless empty modules. */ +This way the aomf51 will not have useless empty modules. */ int LoadAdb(FILE * libfp) { @@ -417,7 +421,7 @@ int LoadAdb(FILE * libfp) return ToReturn; } -/*Check for a symbol in a SDCC library. If found, add the embedded .rel and +/*Check for a symbol in a SDCC library. If found, add the embedded .rel and .adb files from the library. The library must be created with the SDCC librarian 'sdcclib' since the linking process depends on the correct file offsets embedded in the library file.*/ @@ -482,7 +486,7 @@ int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) /*As in the original library format, it is assumed that the .rel files reside in the same directory as the lib files.*/ strcat(DirLib, ModName); - sprintf(&DirLib[strlen(DirLib)], "%crel", FSEPX); + sprintf(&DirLib[strlen(DirLib)], "%c%s", FSEPX, LKOBJEXT); /*If this module has been loaded already don't load it again.*/ lbf = lbfhead; @@ -504,7 +508,9 @@ int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) { lbf = lbfhead; while (lbf->next) - lbf = lbf->next; + { + lbf = lbf->next; + } lbf->next = lbfh; } @@ -517,7 +523,7 @@ int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) /*Jump to where the .rel begins and load it.*/ fseek(libfp, lbfh->offset, SEEK_SET); - LoadRel(libfp, ModName); + LoadRel(PathLib, libfp, ModName); /* if cdb information required & .adb file present */ if (dflag && dfp) @@ -611,8 +617,7 @@ int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) */ int -fndsym(name) -char *name; +fndsym(char *name) { FILE *libfp, *fp; struct lbname *lbnh; @@ -632,7 +637,7 @@ char *name; { if ((libfp = fopen(lbnh->libspc, "r")) == NULL) { - fprintf(stderr, "ASlink-Error-Cannot open library file %s\n", + fprintf(stderr, "?ASlink-Error-Cannot open library file %s\n", lbnh->libspc); lkexit(1); } @@ -653,9 +658,9 @@ char *name; str = (char *) new (strlen(path)+strlen(relfil)+6); strcpy(str,path); #ifdef OTHERSYSTEM - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { - strcat(str,"/"); + strcat(str, LKDIRSEPSTR); } #endif } @@ -664,10 +669,10 @@ char *name; str = (char *) new (strlen(relfil) + 5); } + /*See if this is a library with embedded files*/ if(strcmp(relfil, "")==0) { result=SdccLib(lbnh->libspc, libfp, str, name); - fclose(libfp); if(result) return(1); /*Found the symbol*/ free(str); /*The symbol is not in the current library, @@ -676,23 +681,22 @@ char *name; } /*From here down is the support for libraries in the original format*/ - if (relfil[0] == '\\') + if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP)) { - strcat(str,relfil+1); + strcat(str, relfil+1); } else { - strcat(str,relfil); + strcat(str, relfil); } if(strchr(relfil, FSEPX) == NULL) { - sprintf(&str[strlen(str)], "%crel", FSEPX); + sprintf(&str[strlen(str)], "%c%s", FSEPX, LKOBJEXT); } if ((fp = fopen(str, "r")) != NULL) { - /* * Read in the object file. Look for lines that * begin with "S" and end with "D". These are @@ -708,22 +712,24 @@ char *name; /* * Skip everything that's not a symbol record. */ - if (buf[0] != 'S') continue; + if (buf[0] != 'S') + continue; /* - * When a 'T line' is found terminate file scan. - * All 'S line's preceed 'T line's in .REL files. - */ - if (buf[0] == 'T') break; + * When a 'T line' is found terminate file scan. + * All 'S line's preceed 'T line's in .REL files. + */ + if (buf[0] == 'T') + break; sscanf(buf, "S %s %c", symname, &c); /* - * If we find a symbol definition for the - * symbol we're looking for, load in the - * file and add it to lbfhead so it gets - * loaded on pass number 2. - */ + * If we find a symbol definition for the + * symbol we're looking for, load in the + * file and add it to lbfhead so it gets + * loaded on pass number 2. + */ if (strncmp(symname, name, NCPS) == 0 && c == 'D') { lbfh = (struct lbfile *) new (sizeof(struct lbfile)); @@ -735,7 +741,9 @@ char *name; { lbf = lbfhead; while (lbf->next) - lbf = lbf->next; + { + lbf = lbf->next; + } lbf->next = lbfh; } @@ -761,13 +769,17 @@ char *name; loadfile(str); return (1); } - } + } /* Closes while - read object file */ fclose(fp); + } /* Closes if object file opened OK */ + else + { + fprintf(stderr, "?ASlink-Warning-Cannot open library module %s\n", str); } free(str); - } + } /* Ends while - processing all in libr */ fclose(libfp); - } + } /* Ends good open of libr file */ return(0); } @@ -775,12 +787,26 @@ void loadfile_SdccLib(char * libspc, char * module, long offset) { FILE *fp; - if ((fp = fopen(libspc,"r")) != NULL) +#ifdef __CYGWIN__ + char posix_path[PATH_MAX]; + void cygwin_conv_to_full_posix_path(char * win_path, char * posix_path); + cygwin_conv_to_full_posix_path(libspc, posix_path); + fp = fopen(posix_path, "r"); +#else + fp = fopen(libspc,"r"); +#endif + + if (fp != NULL) { fseek(fp, offset, SEEK_SET); - LoadRel(fp, module); + LoadRel(libspc, fp, module); fclose(fp); } + else + { + fprintf(stderr, "?ASlink-Error-Opening library '%s'\n", libspc); + lkexit(1); + } } /*)Function VOID library() @@ -802,7 +828,7 @@ void loadfile_SdccLib(char * libspc, char * module, long offset) */ VOID -library() +library(void) { struct lbfile *lbfh; @@ -833,7 +859,7 @@ library() * char str[] file input line * * global variables: - * char *ip pointer to linker input string + * char *ip pointer to linker input string * * functions called: * int fclose() c_library @@ -847,14 +873,24 @@ library() */ VOID -loadfile(filspc) -char *filspc; +loadfile(char *filspc) { FILE *fp; char str[NINPUT+2]; - if ((fp = fopen(filspc,"r")) != NULL) { - while (fgets(str, NINPUT, fp) != NULL) { +#ifdef __CYGWIN__ + char posix_path[PATH_MAX]; + void cygwin_conv_to_full_posix_path(char * win_path, char * posix_path); + cygwin_conv_to_full_posix_path(filspc, posix_path); + fp = fopen(posix_path, "r"); +#else + fp = fopen(filspc,"r"); +#endif + + if (fp != NULL) + { + while (fgets(str, NINPUT, fp) != NULL) + { str[NINPUT+1] = '\0'; chop_crlf(str); ip = str; @@ -862,4 +898,9 @@ char *filspc; } fclose(fp); } + else + { + fprintf(stderr, "?ASlink-Error-Opening library '%s'\n", filspc); + lkexit(1); + } } diff --git a/as/link/lklex.c b/as/link/lklex.c index bac4a3b7..c29066ed 100644 --- a/as/link/lklex.c +++ b/as/link/lklex.c @@ -508,7 +508,7 @@ loop: if (pflag && cfp && cfp->f_type == F_STD) } else if (ftype == F_REL) { sfp = afile(fid, LKOBJEXT, 0); - /* if a .cdb file exists then copy it over */ + /* if a .adb file exists then copy it over */ if (dflag && sfp && dfp && pass == 0) { FILE *xfp = afile(fid,"adb",0); //JCF: Nov 30, 2002 if (xfp) { diff --git a/as/link/mcs51/Makefile.in b/as/link/mcs51/Makefile.in index 4cd7c082..31116f00 100644 --- a/as/link/mcs51/Makefile.in +++ b/as/link/mcs51/Makefile.in @@ -34,7 +34,7 @@ EXEEXT = @EXEEXT@ VPATH = @srcdir@ CPPFLAGS = @CPPFLAGS@ -I.. -I$(srcdir)/.. -CFLAGS = @CFLAGS@ -Wall -DINDEXLIB +CFLAGS = @CFLAGS@ -Wall -DINDEXLIB -DUNIX M_OR_MM = @M_OR_MM@ LDFLAGS = @LDFLAGS@ diff --git a/as/link/mcs51/lkarea.c b/as/link/mcs51/lkarea.c index 3fb5963c..1135e83e 100644 --- a/as/link/mcs51/lkarea.c +++ b/as/link/mcs51/lkarea.c @@ -1043,7 +1043,7 @@ Addr_T lnksect2 (struct area *tap, int locIndex) { taxp->a_addr = j-k+1; for(j=taxp->a_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (j<0x30); j++) - idatamap[j]=fchar; + idatamap[j]=fchar; } else /*Couldn't find a chunk big enough: report the problem.*/ { diff --git a/as/link/mcs51/lklibr.c b/as/link/mcs51/lklibr.c index e87c9ec3..e63df72b 100644 --- a/as/link/mcs51/lklibr.c +++ b/as/link/mcs51/lklibr.c @@ -24,7 +24,7 @@ #include #include "aslink.h" -/*)Module lklibr.c +/*)Module lklibr.c * * The module lklibr.c contains the functions which * (1) specify the path(s) to library files [.LIB] @@ -68,7 +68,7 @@ struct slibraryfile { /* First entry in the library object symbol cache */ pmlibraryfile libr=NULL; -int buildlibraryindex(); +int buildlibraryindex(void); void freelibraryindex (void); #endif /* INDEXLIB */ @@ -97,7 +97,7 @@ void freelibraryindex (void); */ VOID -addpath() +addpath(void) { struct lbpath *lbph, *lbp; @@ -107,7 +107,9 @@ addpath() } else { lbp = lbphead; while (lbp->next) + { lbp = lbp->next; + } lbp->next = lbph; } unget(getnb()); @@ -143,7 +145,7 @@ addpath() */ VOID -addlib() +addlib(void) { struct lbpath *lbph; int foundcount=0; @@ -217,11 +219,11 @@ int addfile(char * path, char * libfil) if (path != NULL) { str = (char *) new (strlen(path) + strlen(libfil) + 6); - strcpy(str,path); + strcpy(str, path); #ifdef OTHERSYSTEM - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { - strcat(str,"/"); + strcat(str, LKDIRSEPSTR); } #endif } @@ -231,7 +233,7 @@ int addfile(char * path, char * libfil) } #ifdef OTHERSYSTEM - if ((libfil[0] == '/') || (libfil[0] == '\\')) + if ((libfil[0] == '/') || (libfil[0] == LKDIRSEP)) { libfil++; libfilinc=1; @@ -255,14 +257,14 @@ int addfile(char * path, char * libfil) if(fp != NULL) { /*Bingo! 'libfil' is the absolute path of the library*/ - strcpy(str, libfil); + strcpy(str, libfil); path=NULL;/*This way 'libfil' and 'path' will be rebuilt from 'str'*/ } } if(path==NULL) { - /*'path' can not be null since it is needed to find the '.rel' files associated with + /*'path' can not be null since it is needed to find the object files associated with the library. So, get 'path' from 'str' and then chop it off and recreate 'libfil'. That way putting 'path' and 'libfil' together will result into the original filepath as contained in 'str'.*/ @@ -271,7 +273,7 @@ int addfile(char * path, char * libfil) strcpy(path, str); for(j=strlen(path)-1; j>=0; j--) { - if((path[j] == '/') || (path[j] == '\\')) + if((path[j] == '/') || (path[j] == LKDIRSEP)) { strcpy(libfil, &path[j+1]); path[j+1]=0; @@ -293,13 +295,15 @@ int addfile(char * path, char * libfil) { lbn = lbnhead; while (lbn->next) + { lbn = lbn->next; + } lbn->next = lbnh; } lbnh->path = path; lbnh->libfil = (char *) new (strlen(libfil) + 1); - strcpy(lbnh->libfil,libfil); + strcpy(lbnh->libfil, libfil); lbnh->libspc = str; return 1; } @@ -342,10 +346,10 @@ int addfile(char * path, char * libfil) */ VOID -search() +search(void) { register struct sym *sp; - register int i,symfnd; + register int i, symfnd; /* * Look for undefined symbols. Keep @@ -400,7 +404,7 @@ void LoadRel(char * libfname, FILE * libfp, char * ModName) if(EQ(str, ModName)) state=1; else { - fprintf(stderr, "?Aslink-Error-Bad offset in library file %s(%s)\n", + fprintf(stderr, "?ASlink-Error-Bad offset in library file %s(%s)\n", libfname, ModName); lkexit(1); } @@ -418,9 +422,9 @@ void LoadRel(char * libfname, FILE * libfp, char * ModName) } } -/*Load an .adb file embedded in a sdcclib file. If there is +/*Load an .adb file embedded in a sdcclib file. If there is something between and returns 1, otherwise returns 0. -This way the aomf51 will not have uselless empty modules. */ +This way the aomf51 will not have useless empty modules. */ int LoadAdb(FILE * libfp) { @@ -447,7 +451,7 @@ int LoadAdb(FILE * libfp) return ToReturn; } -/*Check for a symbol in a SDCC library. If found, add the embedded .rel and +/*Check for a symbol in a SDCC library. If found, add the embedded .rel and .adb files from the library. The library must be created with the SDCC librarian 'sdcclib' since the linking process depends on the correct file offsets embedded in the library file.*/ @@ -512,7 +516,7 @@ int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) /*As in the original library format, it is assumed that the .rel files reside in the same directory as the lib files.*/ strcat(DirLib, ModName); - sprintf(&DirLib[strlen(DirLib)], "%crel", FSEPX); + sprintf(&DirLib[strlen(DirLib)], "%c%s", FSEPX, LKOBJEXT); /*If this module has been loaded already don't load it again.*/ lbf = lbfhead; @@ -534,7 +538,9 @@ int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) { lbf = lbfhead; while (lbf->next) - lbf = lbf->next; + { + lbf = lbf->next; + } lbf->next = lbfh; } @@ -678,7 +684,9 @@ int fndsym( char *name ) { lbf = lbfhead; while (lbf->next) - lbf = lbf->next; + { + lbf = lbf->next; + } lbf->next = lbfh; } lbfh->libspc = ThisLibr->libspc; @@ -733,7 +741,7 @@ int fndsym( char *name ) { if(numfound==1) { - fprintf(stderr, "?Aslink-Warning-Definition of public symbol '%s'" + fprintf(stderr, "?ASlink-Warning-Definition of public symbol '%s'" " found more than once:\n", name); fprintf(stderr, " Library: '%s', Module: '%s'\n", FirstFound->libspc, FirstFound->relfil); @@ -808,7 +816,7 @@ pmlibraryfile buildlibraryindex_SdccLib(char * PathLib, FILE * libfp, char * Dir This->relfil=(char *)new(strlen(ModName)+1); strcpy(This->relfil, ModName); - sprintf(buff, "%s%s%crel", DirLib, ModName, FSEPX); + sprintf(buff, "%s%s%c%s", DirLib, ModName, FSEPX, LKOBJEXT); This->filename=(char *)new(strlen(buff)+1); strcpy(This->filename, buff); @@ -870,12 +878,11 @@ int buildlibraryindex(void) /* * Search through every library in the linked list "lbnhead". */ - for (lbnh=lbnhead; lbnh; lbnh=lbnh->next) { if ((libfp = fopen(lbnh->libspc, "r")) == NULL) { - fprintf(stderr, "?Aslink-Error-Cannot open library file %s\n", + fprintf(stderr, "?ASlink-Error-Cannot open library file %s\n", lbnh->libspc); lkexit(1); } @@ -895,9 +902,9 @@ int buildlibraryindex(void) { strcpy(str, path); #ifdef OTHERSYSTEM - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { - strcat(str,"/"); + strcat(str, LKDIRSEPSTR); } #endif } @@ -915,18 +922,18 @@ int buildlibraryindex(void) /*From here down, build the index for the original library format*/ - if (relfil[0] == '\\') + if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP)) { - strcat(str,relfil+1); + strcat(str, relfil+1); } else { - strcat(str,relfil); + strcat(str, relfil); } if(strchr(relfil, FSEPX) == NULL) { - sprintf(&str[strlen(str)], "%crel", FSEPX); + sprintf(&str[strlen(str)], "%c%s", FSEPX, LKOBJEXT); } if ((fp = fopen(str, "r")) != NULL) @@ -953,7 +960,7 @@ int buildlibraryindex(void) strcpy(This->filename, str); /*Start a new linked list of symbols for this module:*/ - This->symbols=ThisSym=NULL; + This->symbols = ThisSym = NULL; /* * Read in the object file. Look for lines that @@ -1003,7 +1010,7 @@ int buildlibraryindex(void) } /* Closes if object file opened OK */ else { - fprintf(stderr, "?Aslink-Warning-Cannot open library module %s\n", str); + fprintf(stderr, "?ASlink-Warning-Cannot open library module %s\n", str); } } /* Ends while - processing all in libr */ fclose(libfp); @@ -1043,8 +1050,7 @@ void freelibraryindex (void) #else /* INDEXLIB */ int -fndsym(name) -char *name; +fndsym(char *name) { FILE *libfp, *fp; struct lbname *lbnh; @@ -1064,7 +1070,7 @@ char *name; { if ((libfp = fopen(lbnh->libspc, "r")) == NULL) { - fprintf(stderr, "?Aslink-Error-Cannot open library file %s\n", + fprintf(stderr, "?ASlink-Error-Cannot open library file %s\n", lbnh->libspc); lkexit(1); } @@ -1085,9 +1091,9 @@ char *name; str = (char *) new (strlen(path)+strlen(relfil)+6); strcpy(str,path); #ifdef OTHERSYSTEM - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { - strcat(str,"/"); + strcat(str, LKDIRSEPSTR); } #endif } @@ -1096,6 +1102,7 @@ char *name; str = (char *) new (strlen(relfil) + 5); } + /*See if this is a library with embedded files*/ if(strcmp(relfil, "")==0) { result=SdccLib(lbnh->libspc, libfp, str, name); @@ -1107,23 +1114,22 @@ char *name; } /*From here down is the support for libraries in the original format*/ - if (relfil[0] == '\\') + if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP)) { - strcat(str,relfil+1); + strcat(str, relfil+1); } else { - strcat(str,relfil); + strcat(str, relfil); } if(strchr(relfil, FSEPX) == NULL) { - sprintf(&str[strlen(str)], "%crel", FSEPX); + sprintf(&str[strlen(str)], "%c%s", FSEPX, LKOBJEXT); } if ((fp = fopen(str, "r")) != NULL) { - /* * Read in the object file. Look for lines that * begin with "S" and end with "D". These are @@ -1139,22 +1145,24 @@ char *name; /* * Skip everything that's not a symbol record. */ - if (buf[0] != 'S') continue; + if (buf[0] != 'S') + continue; /* - * When a 'T line' is found terminate file scan. - * All 'S line's preceed 'T line's in .REL files. - */ - if (buf[0] == 'T') break; + * When a 'T line' is found terminate file scan. + * All 'S line's preceed 'T line's in .REL files. + */ + if (buf[0] == 'T') + break; sscanf(buf, "S %s %c", symname, &c); /* - * If we find a symbol definition for the - * symbol we're looking for, load in the - * file and add it to lbfhead so it gets - * loaded on pass number 2. - */ + * If we find a symbol definition for the + * symbol we're looking for, load in the + * file and add it to lbfhead so it gets + * loaded on pass number 2. + */ if (strncmp(symname, name, NCPS) == 0 && c == 'D') { lbfh = (struct lbfile *) new (sizeof(struct lbfile)); @@ -1166,7 +1174,9 @@ char *name; { lbf = lbfhead; while (lbf->next) - lbf = lbf->next; + { + lbf = lbf->next; + } lbf->next = lbfh; } @@ -1192,28 +1202,46 @@ char *name; loadfile(str); return (1); } - } + } /* Closes while - read object file */ fclose(fp); + } /* Closes if object file opened OK */ + else + { + fprintf(stderr, "?ASlink-Warning-Cannot open library module %s\n", str); } free(str); - } + } /* Ends while - processing all in libr */ fclose(libfp); - } + } /* Ends good open of libr file */ return(0); } -#endif /*INDEXLIB*/ +#endif /* INDEXLIB */ void loadfile_SdccLib(char * libspc, char * module, long offset) { FILE *fp; - if ((fp = fopen(libspc,"r")) != NULL) +#ifdef __CYGWIN__ + char posix_path[PATH_MAX]; + void cygwin_conv_to_full_posix_path(char * win_path, char * posix_path); + cygwin_conv_to_full_posix_path(libspc, posix_path); + fp = fopen(posix_path, "r"); +#else + fp = fopen(libspc,"r"); +#endif + + if (fp != NULL) { fseek(fp, offset, SEEK_SET); LoadRel(libspc, fp, module); fclose(fp); } + else + { + fprintf(stderr, "?ASlink-Error-Opening library '%s'\n", libspc); + lkexit(1); + } } /*)Function VOID library() @@ -1235,7 +1263,7 @@ void loadfile_SdccLib(char * libspc, char * module, long offset) */ VOID -library() +library(void) { struct lbfile *lbfh; @@ -1269,7 +1297,7 @@ library() * char str[] file input line * * global variables: - * char *ip pointer to linker input string + * char *ip pointer to linker input string * * functions called: * int fclose() c_library @@ -1283,14 +1311,24 @@ library() */ VOID -loadfile(filspc) -char *filspc; +loadfile(char *filspc) { FILE *fp; char str[NINPUT+2]; - if ((fp = fopen(filspc,"r")) != NULL) { - while (fgets(str, NINPUT, fp) != NULL) { +#ifdef __CYGWIN__ + char posix_path[PATH_MAX]; + void cygwin_conv_to_full_posix_path(char * win_path, char * posix_path); + cygwin_conv_to_full_posix_path(filspc, posix_path); + fp = fopen(posix_path, "r"); +#else + fp = fopen(filspc,"r"); +#endif + + if (fp != NULL) + { + while (fgets(str, NINPUT, fp) != NULL) + { str[NINPUT+1] = '\0'; chop_crlf(str); ip = str; @@ -1298,4 +1336,9 @@ char *filspc; } fclose(fp); } + else + { + fprintf(stderr, "?ASlink-Error-Opening library '%s'\n", filspc); + lkexit(1); + } } diff --git a/as/link/mcs51/lkmain.c b/as/link/mcs51/lkmain.c index 3c2adc6d..e470adb0 100644 --- a/as/link/mcs51/lkmain.c +++ b/as/link/mcs51/lkmain.c @@ -289,7 +289,7 @@ main(int argc, char *argv[]) break; if (pflag && sfp != stdin) fprintf(stdout, "%s\n", ip); - if (*ip == '\0' || parse()) + if (*ip == '\0' || parse()) break; } @@ -308,7 +308,7 @@ main(int argc, char *argv[]) SaveLinkedFilePath(linkp->f_idp); //Must be the first one... dfp = afile(linkp->f_idp,"cdb",1); //JCF: Nov 30, 2002 if (dfp == NULL) - lkexit(1); + lkexit(1); } for (pass=0; pass<2; ++pass) { diff --git a/as/link/z80/Makefile.in b/as/link/z80/Makefile.in index 87519302..607143d3 100644 --- a/as/link/z80/Makefile.in +++ b/as/link/z80/Makefile.in @@ -23,7 +23,7 @@ SLIBOBJS = $(SLIBSRC:%.c=$(OBJDIR)/%.o) BINS = $(BUILDDIR)link$(EXT)$(EXEEXT) CPPFLAGS+= -I.. -I$(srcdir)/.. -CFLAGS += $(CPPFLAGS) $(OPTS) -DINDEXLIB -DMLH_MAP -DUNIX -DSDK +CFLAGS += $(CPPFLAGS) $(OPTS) -DINDEXLIB -DMLH_MAP -DSDK CFLAGS += -funsigned-char -DUNIX CFLAGS += -I$(top_builddir)/as/$(PORT) -I$(SLIB) diff --git a/as/link/z80/lklibr.c b/as/link/z80/lklibr.c index f852386e..d2dfcb47 100644 --- a/as/link/z80/lklibr.c +++ b/as/link/z80/lklibr.c @@ -28,21 +28,6 @@ #include #include "aslink.h" -#ifdef OTHERSYSTEM -#ifdef SDK -#ifdef UNIX - #define LKDIRSEP '/' - #define LKDIRSEPSTR "/" -#else /* UNIX */ - #define LKDIRSEP '\\' - #define LKDIRSEPSTR "\\" -#endif /* UNIX */ -#else /* SDK */ - #define LKDIRSEP '\\' - #define LKDIRSEPSTR "\\" -#endif /* SDK */ -#endif - /*)Module lklibr.c * * The module lklibr.c contains the functions which @@ -87,7 +72,7 @@ struct slibraryfile { /* First entry in the library object symbol cache */ pmlibraryfile libr=NULL; -int buildlibraryindex(); +int buildlibraryindex(void); void freelibraryindex (void); #endif /* INDEXLIB */ @@ -116,7 +101,7 @@ void freelibraryindex (void); */ VOID -addpath() +addpath(void) { struct lbpath *lbph, *lbp; @@ -126,7 +111,9 @@ addpath() } else { lbp = lbphead; while (lbp->next) + { lbp = lbp->next; + } lbp->next = lbph; } unget(getnb()); @@ -162,7 +149,7 @@ addpath() */ VOID -addlib() +addlib(void) { struct lbpath *lbph; int foundcount=0; @@ -229,30 +216,35 @@ int addfile(char * path, char * libfil) FILE *fp; char *str; struct lbname *lbnh, *lbn; +#ifdef OTHERSYSTEM int libfilinc=0; +#endif if (path != NULL) { str = (char *) new (strlen(path) + strlen(libfil) + 6); strcpy(str, path); - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) +#ifdef OTHERSYSTEM + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { strcat(str, LKDIRSEPSTR); } +#endif } else { str = (char *) new (strlen(libfil) + 5); } - if ((libfil[0] == '/') || (libfil[0] == '\\')) +#ifdef OTHERSYSTEM + if ((libfil[0] == '/') || (libfil[0] == LKDIRSEP)) { libfil++; libfilinc=1; } +#endif strcat(str, libfil); - if(strchr(libfil, FSEPX) == NULL) { sprintf(&str[strlen(str)], "%clib", FSEPX); @@ -262,7 +254,9 @@ int addfile(char * path, char * libfil) if(fp == NULL) { /*Ok, that didn't work. Try with the 'libfil' name only*/ +#ifdef OTHERSYSTEM if(libfilinc) libfil--; +#endif fp=fopen(libfil, "r"); if(fp != NULL) { @@ -274,7 +268,7 @@ int addfile(char * path, char * libfil) if(path==NULL) { - /*'path' can not be null since it is needed to find the .rel/.o files associated with + /*'path' can not be null since it is needed to find the object files associated with the library. So, get 'path' from 'str' and then chop it off and recreate 'libfil'. That way putting 'path' and 'libfil' together will result into the original filepath as contained in 'str'.*/ @@ -283,7 +277,7 @@ int addfile(char * path, char * libfil) strcpy(path, str); for(j=strlen(path)-1; j>=0; j--) { - if((path[j] == '/') || (path[j] == '\\')) + if((path[j] == '/') || (path[j] == LKDIRSEP)) { strcpy(libfil, &path[j+1]); path[j+1]=0; @@ -305,7 +299,9 @@ int addfile(char * path, char * libfil) { lbn = lbnhead; while (lbn->next) + { lbn = lbn->next; + } lbn->next = lbnh; } @@ -354,7 +350,7 @@ int addfile(char * path, char * libfil) */ VOID -search() +search(void) { register struct sym *sp; register int i, symfnd; @@ -430,6 +426,153 @@ void LoadRel(char * libfname, FILE * libfp, char * ModName) } } +/*Load an .adb file embedded in a sdcclib file. If there is +something between and returns 1, otherwise returns 0. +This way the aomf51 will not have useless empty modules. */ + +int LoadAdb(FILE * libfp) +{ + char str[MAXLINE+1]; + int state=0; + int ToReturn=0; + + while (fgets(str, MAXLINE, libfp) != NULL) + { + str[NINPUT+1] = '\0'; + chop_crlf(str); + switch(state) + { + case 0: + if(EQ(str, "")) state=1; + break; + case 1: + if(EQ(str, "")) return ToReturn; + fprintf(dfp, "%s\n", str); + ToReturn=1; + break; + } + } + return ToReturn; +} + +/*Check for a symbol in a SDCC library. If found, add the embedded .rel and +.adb files from the library. The library must be created with the SDCC +librarian 'sdcclib' since the linking process depends on the correct file offsets +embedded in the library file.*/ + +int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) +{ + struct lbfile *lbfh, *lbf; + char ModName[NCPS]=""; + char FLine[MAXLINE+1]; + int state=0; + long IndexOffset=0, FileOffset; + + while(!feof(libfp)) + { + FLine[0]=0; + fgets(FLine, MAXLINE, libfp); + chop_crlf(FLine); + + switch(state) + { + case 0: + if(EQ(FLine, "")) + { + /*The next line has the size of the index*/ + FLine[0]=0; + fgets(FLine, MAXLINE, libfp); + chop_crlf(FLine); + IndexOffset=atol(FLine); + state=1; + } + break; + case 1: + if(EQ(FLine, "")) + { + /*The next line has the name of the module and the offset + of the corresponding embedded file in the library*/ + FLine[0]=0; + fgets(FLine, MAXLINE, libfp); + chop_crlf(FLine); + sscanf(FLine, "%s %ld", ModName, &FileOffset); + state=2; + } + else if(EQ(FLine, "")) + { + /*Reached the end of the index. The symbol is not in this library.*/ + return 0; + } + break; + case 2: + if(EQ(FLine, "")) + { + /*The symbol is not in this module, try the next one*/ + state=1; + } + else + { + /*Check if this is the symbol we are looking for.*/ + if (strncmp(SymName, FLine, NCPS)==0) + { + /*The symbol is in this module.*/ + + /*As in the original library format, it is assumed that the .rel + files reside in the same directory as the lib files.*/ + strcat(DirLib, ModName); + sprintf(&DirLib[strlen(DirLib)], "%c%s", FSEPX, LKOBJEXT); + + /*If this module has been loaded already don't load it again.*/ + lbf = lbfhead; + while (lbf) + { + if(EQ(DirLib, lbf->filspc)) return 1;/*Already loaded*/ + lbf=lbf->next; + } + + /*Add the embedded file to the list of files to be loaded in + the second pass. That is performed latter by the function + library() below.*/ + lbfh = (struct lbfile *) new (sizeof(struct lbfile)); + if (lbfhead == NULL) + { + lbfhead = lbfh; + } + else + { + lbf = lbfhead; + while (lbf->next) + { + lbf = lbf->next; + } + lbf->next = lbfh; + } + + lbfh->libspc = PathLib; + lbfh->filspc = DirLib; + lbfh->relfil = (char *) new (strlen(ModName) + 1); + strcpy(lbfh->relfil, ModName); + /*Library embedded file, so lbfh->offset must be >=0*/ + lbfh->offset = IndexOffset+FileOffset; + + /*Jump to where the .rel begins and load it.*/ + fseek(libfp, lbfh->offset, SEEK_SET); + LoadRel(PathLib, libfp, ModName); + + return 1; /*Found the symbol, so success!*/ + } + } + break; + + default: + return 0; /*It should never reach this point, but just in case...*/ + break; + } + } + + return 0; /*The symbol is not in this library*/ +} + /*)Function VOID fndsym(name) * * char *name symbol name to find @@ -477,8 +620,8 @@ void LoadRel(char * libfname, FILE * libfp, char * ModName) * file structure * * functions called: - * int fclose() c_library - * int fgets() c_library + * int fclose() c_library + * int fgets() c_library * FILE *fopen() c_library * VOID free() c_library * char getnb() lklex.c @@ -486,12 +629,12 @@ void LoadRel(char * libfname, FILE * libfp, char * ModName) * VOID loadfile() lklibr.c * VOID * new() lksym.c * char * sprintf() c_library - * int sscanf() c_library + * int sscanf() c_library * char * strcat() c_library * char * strchr() c_library * char * strcpy() c_library - * int strlen() c_library - * int strncmp() c_library + * int strlen() c_library + * int strncmp() c_library * VOID unget() lklex.c * * side effects: @@ -539,7 +682,9 @@ int fndsym( char *name ) { lbf = lbfhead; while (lbf->next) - lbf = lbf->next; + { + lbf = lbf->next; + } lbf->next = lbfh; } lbfh->libspc = ThisLibr->libspc; @@ -583,7 +728,7 @@ int fndsym( char *name ) { if(numfound==1) { - fprintf(stderr, "?Aslink-Warning-Definition of public symbol '%s'" + fprintf(stderr, "?ASlink-Warning-Definition of public symbol '%s'" " found more than once:\n", name); fprintf(stderr, " Library: '%s', Module: '%s'\n", FirstFound->libspc, FirstFound->relfil); @@ -705,7 +850,7 @@ pmlibraryfile buildlibraryindex_SdccLib(char * PathLib, FILE * libfp, char * Dir /* buildlibraryindex - build an in-memory cache of the symbols contained in - * the libraries + * the libraries */ int buildlibraryindex(void) { @@ -724,7 +869,7 @@ int buildlibraryindex(void) { if ((libfp = fopen(lbnh->libspc, "r")) == NULL) { - fprintf(stderr, "?Aslink-Error-Cannot open library file %s\n", + fprintf(stderr, "?ASlink-Error-Cannot open library file %s\n", lbnh->libspc); lkexit(1); } @@ -744,7 +889,7 @@ int buildlibraryindex(void) { strcpy(str, path); #ifdef OTHERSYSTEM - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { strcat(str, LKDIRSEPSTR); } @@ -764,7 +909,7 @@ int buildlibraryindex(void) /*From here down, build the index for the original library format*/ - if ((relfil[0] == '/') || (relfil[0] == '\\')) + if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP)) { strcat(str, relfil+1); } @@ -852,7 +997,7 @@ int buildlibraryindex(void) } /* Closes if object file opened OK */ else { - fprintf(stderr, "?Aslink-Warning-Cannot open library module %s\n", str); + fprintf(stderr, "?ASlink-Warning-Cannot open library module %s\n", str); } } /* Ends while - processing all in libr */ fclose(libfp); @@ -891,197 +1036,8 @@ void freelibraryindex (void) #else /* INDEXLIB */ - -/*Check for a symbol in a SDCC library. If found, add the embedded .rel. -The library must be created with the SDCC librarian 'sdcclib' since the -linking process depends on the correct file offsets embedded in the library -file.*/ - -int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName) -{ - struct lbfile *lbfh, *lbf; - char ModName[NCPS]=""; - char FLine[MAXLINE+1]; - int state=0; - long IndexOffset=0, FileOffset; - - while(!feof(libfp)) - { - FLine[0]=0; - fgets(FLine, MAXLINE, libfp); - chop_crlf(FLine); - - switch(state) - { - case 0: - if(EQ(FLine, "")) - { - /*The next line has the size of the index*/ - FLine[0]=0; - fgets(FLine, MAXLINE, libfp); - chop_crlf(FLine); - IndexOffset=atol(FLine); - state=1; - } - break; - case 1: - if(EQ(FLine, "")) - { - /*The next line has the name of the module and the offset - of the corresponding embedded file in the library*/ - FLine[0]=0; - fgets(FLine, MAXLINE, libfp); - chop_crlf(FLine); - sscanf(FLine, "%s %ld", ModName, &FileOffset); - state=2; - } - else if(EQ(FLine, "")) - { - /*Reached the end of the index. The symbol is not in this library.*/ - return 0; - } - break; - case 2: - if(EQ(FLine, "")) - { - /*The symbol is not in this module, try the next one*/ - state=1; - } - else - { - /*Check if this is the symbol we are looking for.*/ - if (strncmp(SymName, FLine, NCPS)==0) - { - /*The symbol is in this module.*/ - - /*As in the original library format, it is assumed that the .rel - files reside in the same directory as the lib files.*/ - strcat(DirLib, ModName); - sprintf(&DirLib[strlen(DirLib)], "%c%s", FSEPX, LKOBJEXT); - - /*If this module has been loaded already don't load it again.*/ - lbf = lbfhead; - while (lbf) - { - if(EQ(DirLib, lbf->filspc)) return 1;/*Already loaded*/ - lbf=lbf->next; - } - - /*Add the embedded file to the list of files to be loaded in - the second pass. That is performed latter by the function - library() below.*/ - lbfh = (struct lbfile *) new (sizeof(struct lbfile)); - if (lbfhead == NULL) - { - lbfhead = lbfh; - } - else - { - lbf = lbfhead; - while (lbf->next) - lbf = lbf->next; - lbf->next = lbfh; - } - - lbfh->libspc = PathLib; - lbfh->filspc = DirLib; - lbfh->relfil = (char *) new (strlen(ModName) + 1); - strcpy(lbfh->relfil, ModName); - /*Library embedded file, so lbfh->offset must be >=0*/ - lbfh->offset = IndexOffset+FileOffset; - - /*Jump to where the .rel begins and load it.*/ - fseek(libfp, lbfh->offset, SEEK_SET); - LoadRel(PathLib, libfp, ModName); - - return 1; /*Found the symbol, so success!*/ - } - } - break; - - default: - return 0; /*It should never reach this point, but just in case...*/ - break; - } - } - - return 0; /*The symbol is not in this library*/ -} - -/*)Function VOID fndsym(name) - * - * char *name symbol name to find - * - * The function fndsym() searches through all combinations of the - * library path specifications (input by the -k option) and the - * library file specifications (input by the -l option) that - * lead to an existing file. - * - * The file specicifation may be formed in one of two ways: - * - * (1) If the library file contained an absolute - * path/file specification then this becomes filspc. - * (i.e. C:\...) - * - * (2) If the library file contains a relative path/file - * specification then the concatenation of the path - * and this file specification becomes filspc. - * (i.e. \...) - * - * The structure lbfile is created for the first library - * object file which contains the definition for the - * specified undefined symbol. - * - * If the library file [.LIB] contains file specifications for - * non existant files, no errors are returned. - * - * local variables: - * char buf[] [.REL] file input line - * char c [.REL] file input character - * FILE *fp file handle for object file - * lbfile *lbf temporary pointer - * lbfile *lbfh pointer to lbfile structure - * FILE *libfp file handle for library file - * lbname *lbnh pointer to lbname structure - * char *path file specification path - * char relfil[] [.REL] file specification - * char *str combined path and file specification - * char symname[] [.REL] file symbol string - * - * global variables: - * lbname *lbnhead The pointer to the first - * name structure - * lbfile *lbfhead The pointer to the first - * file structure - * - * functions called: - * int fclose() c_library - * int fgets() c_library - * FILE *fopen() c_library - * VOID free() c_library - * char getnb() lklex.c - * VOID lkexit() lkmain.c - * VOID loadfile() lklibr.c - * VOID * new() lksym.c - * char * sprintf() c_library - * int sscanf() c_library - * char * strcat() c_library - * char * strchr() c_library - * char * strcpy() c_library - * int strlen() c_library - * int strncmp() c_library - * VOID unget() lklex.c - * - * side effects: - * If the symbol is found then a new lbfile structure - * is created and added to the linked list of lbfile - * structures. The file containing the found symbol - * is linked. - */ - int -fndsym(name) -char *name; +fndsym(char *name) { FILE *libfp, *fp; struct lbname *lbnh; @@ -1122,17 +1078,9 @@ char *name; str = (char *) new (strlen(path)+strlen(relfil)+6); strcpy(str,path); #ifdef OTHERSYSTEM - if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != '\\')) + if (strlen(str) && (str[strlen(str)-1] != '/') && (str[strlen(str)-1] != LKDIRSEP)) { -#ifdef SDK -#ifdef UNIX - strcat(str,"/"); -#else /* UNIX */ - strcat(str,"\\"); -#endif /* UNIX */ -#else /* SDK */ - strcat(str,"\\"); -#endif /* SDK */ + strcat(str, LKDIRSEPSTR); } #endif } @@ -1153,7 +1101,7 @@ char *name; } /*From here down is the support for libraries in the original format*/ - if ((relfil[0] == '/') || (relfil[0] == '\\')) + if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP)) { strcat(str, relfil+1); } @@ -1180,7 +1128,7 @@ char *name; while (fgets(buf, NINPUT, fp) != NULL) { buf[NINPUT+1] = '\0'; - chop_crlf(buf); + chop_crlf(buf); /* * Skip everything that's not a symbol record. */ @@ -1213,7 +1161,9 @@ char *name; { lbf = lbfhead; while (lbf->next) + { lbf = lbf->next; + } lbf->next = lbfh; } @@ -1227,13 +1177,17 @@ char *name; loadfile(str); return (1); } - } + } /* Closes while - read object file */ fclose(fp); + } /* Closes if object file opened OK */ + else + { + fprintf(stderr, "?ASlink-Warning-Cannot open library module %s\n", str); } free(str); - } + } /* Ends while - processing all in libr */ fclose(libfp); - } + } /* Ends good open of libr file */ return(0); } @@ -1284,7 +1238,7 @@ void loadfile_SdccLib(char * libspc, char * module, long offset) */ VOID -library() +library(void) { struct lbfile *lbfh; @@ -1332,8 +1286,7 @@ library() */ VOID -loadfile(filspc) -char *filspc; +loadfile(char *filspc) { FILE *fp; char str[NINPUT+2]; diff --git a/as/link/z80/lkmain.c b/as/link/z80/lkmain.c index efec9bab..0c6d5c75 100644 --- a/as/link/z80/lkmain.c +++ b/as/link/z80/lkmain.c @@ -1420,9 +1420,6 @@ char *usetxt[] = { "\n", #endif "Startup:", -#ifdef SDK - " -- [Commands] Non-interactive command line input", -#endif /* SDK */ " -c Command line input", " -f file[LNK] File input", " -p Prompt and echo of file[LNK] to stdout (default)", diff --git a/as/mcs51/alloc.h b/as/mcs51/alloc.h deleted file mode 100644 index dd404a86..00000000 --- a/as/mcs51/alloc.h +++ /dev/null @@ -1,4 +0,0 @@ -/* alloc.h */ -/* DECUS C */ - -#include diff --git a/as/mcs51/assym.c b/as/mcs51/assym.c index 21d718d5..996cd323 100644 --- a/as/mcs51/assym.c +++ b/as/mcs51/assym.c @@ -8,7 +8,7 @@ * 721 Berkeley St. * Kent, Ohio 44240 * - * 28-Oct-97 JLH: + * 28-Oct-97 JLH: * - lookup: Use StoreString for sym construction * - change symeq() to do length-independent string compare * - change hash() to do length-independent hash calculation @@ -21,11 +21,7 @@ #include #include #include -#if defined(_MSC_VER) -#include -#else -#include -#endif +#include #include "asm.h" /*)Module assym.c @@ -385,7 +381,7 @@ register char *p1, *p2; * side effects: * none */ - + int hash(p) register char *p; diff --git a/as/z80/alloc.h b/as/z80/alloc.h deleted file mode 100644 index f4ee1b95..00000000 --- a/as/z80/alloc.h +++ /dev/null @@ -1,10 +0,0 @@ -/* alloc.h */ -/* DECUS C */ - -#ifndef SDK -//extern char *alloc(); -//extern char *malloc(); -//extern char *calloc(); -//extern char *realloc(); -#endif - diff --git a/as/z80/asmain.c b/as/z80/asmain.c index 50ccb2b2..8e3041f2 100644 --- a/as/z80/asmain.c +++ b/as/z80/asmain.c @@ -567,7 +567,7 @@ loop: goto loop; } /* - * If the first character is a letter then assume a lable, + * If the first character is a letter then assume a label, * symbol, assembler directive, or assembler mnemonic is * being processed. */ @@ -577,7 +577,7 @@ loop: } else { qerr(); } - } + } getid(id, c); c = getnb(); /* -- 2.30.2