4 * (C) Copyright 1989-1995
11 * With contributions for the
12 * object libraries from
14 * kenh@cmf.nrl.navy.mil
18 #define EQ(A,B) !strcmp((A),(B))
19 #define MAXLINE 254 /*when using fgets*/
29 * The module lklibr.c contains the functions which
30 * (1) specify the path(s) to library files [.LIB]
31 * (2) specify the library file(s) [.LIB] to search
32 * (3) search the library files for specific symbols
33 * and link the module containing this symbol
35 * lklibr.c contains the following functions:
47 typedef struct slibrarysymbol mlibrarysymbol;
48 typedef struct slibrarysymbol *pmlibrarysymbol;
50 struct slibrarysymbol {
51 char * name; /*Warning: allocate memory before using*/
55 typedef struct slibraryfile mlibraryfile;
56 typedef struct slibraryfile *pmlibraryfile;
61 char * relfil; /*Warning: allocate memory before using*/
62 char * filename; /*Warning: allocate memory before using*/
63 long offset; //if > 0, the embedded file offset in the library file libspc
64 pmlibrarysymbol symbols;
68 /* First entry in the library object symbol cache */
69 pmlibraryfile libr=NULL;
71 int buildlibraryindex();
72 void freelibraryindex (void);
75 /*)Function VOID addpath()
77 * The function addpath() creates a linked structure containing
78 * the paths to various object module library files.
81 * lbpath *lbph pointer to new path structure
82 * lbpath *lbp temporary pointer
85 * lbpath *lbphead The pointer to the first
89 * char getnb() lklex.c
90 * VOID * new() lksym.c
91 * int strlen() c_library
92 * char * strcpy() c_library
93 * VOID unget() lklex.c
96 * An lbpath structure may be created.
102 struct lbpath *lbph, *lbp;
104 lbph = (struct lbpath *) new (sizeof(struct lbpath));
105 if (lbphead == NULL) {
114 lbph->path = (char *) new (strlen(ip)+1);
115 strcpy(lbph->path, ip);
118 /*)Function VOID addlib()
120 * The function addlib() tests for the existance of a
121 * library path structure to determine the method of
122 * adding this library file to the library search structure.
124 * This function calls the function addfile() to actually
125 * add the library file to the search list.
128 * lbpath *lbph pointer to path structure
131 * lbpath *lbphead The pointer to the first
133 * ip a pointer to the library name
136 * VOID addfile() lklibr.c
137 * char getnb() lklex.c
138 * VOID unget() lklex.c
141 * The function addfile() may add the file to
142 * the library search list.
155 foundcount=addfile(NULL, ip);
159 for (lbph=lbphead; lbph; lbph=lbph->next)
161 foundcount+=addfile(lbph->path, ip);
166 fprintf(stderr, "?ASlink-Warning-Couldn't find library '%s'\n", ip);
170 /*)Function int addfile(path,libfil)
172 * char *path library path specification
173 * char *libfil library file specification
175 * The function addfile() searches for the library file
176 * by concatenating the path and libfil specifications.
177 * if the library is found, an lbname structure is created
178 * and linked to any previously defined structures. This
179 * linked list is used by the function fndsym() to attempt
180 * to find any undefined symbols.
182 * The function does not give report an error on invalid
183 * path / file specifications or if the file is not found.
186 * lbname *lbnh pointer to new name structure
187 * lbname *lbn temporary pointer
190 * lbname *lbnhead The pointer to the first
194 * char getnb() lklex.c
195 * VOID * new() lksym.c
196 * int strlen() c_library
197 * char * strcpy() c_library
198 * VOID unget() lklex.c
201 * An lbname structure may be created.
204 * 1: the library was found
205 * 0: the library was not found
208 int addfile(char * path, char * libfil)
212 struct lbname *lbnh, *lbn;
219 str = (char *) new (strlen(path) + strlen(libfil) + 6);
222 if (str[strlen(str)-1] != '/')
230 str = (char *) new (strlen(libfil) + 5);
234 if (libfil[0] == '/')
242 if(strchr(libfil, FSEPX) == NULL)
244 sprintf(&str[strlen(str)], "%clib", FSEPX);
250 /*Ok, that didn't work. Try with the 'libfil' name only*/
252 if(libfilinc) libfil--;
254 fp=fopen(libfil, "r");
257 /*Bingo! 'libfil' is the absolute path of the library*/
259 path=NULL;/*This way 'libfil' and 'path' will be rebuilt from 'str'*/
265 /*'path' can not be null since it is needed to find the '.rel' files associated with
266 the library. So, get 'path' from 'str' and then chop it off and recreate 'libfil'.
267 That way putting 'path' and 'libfil' together will result into the original filepath
268 as contained in 'str'.*/
270 path = (char *) new (strlen(str));
272 for(j=strlen(path)-1; j>=0; j--)
274 if((path[j]=='\\')||(path[j]=='/'))
276 strcpy(libfil, &path[j+1]);
287 lbnh = (struct lbname *) new (sizeof(struct lbname));
301 lbnh->libfil = (char *) new (strlen(libfil) + 1);
302 strcpy(lbnh->libfil,libfil);
313 /*)Function VOID search()
315 * The function search() looks through all the symbol tables
316 * at the end of pass 1. If any undefined symbols are found
317 * then the function fndsym() is called. Function fndsym()
318 * searches any specified library files to automagically
319 * import the object modules containing the needed symbol.
321 * After a symbol is found and imported by the function
322 * fndsym() the symbol tables are again searched. The
323 * symbol tables are search until no more symbols can be
324 * resolved within the library files. This ensures that
325 * back references from one library module to another are
329 * int i temporary counter
330 * sym *sp pointer to a symbol structure
331 * int symfnd found a symbol flag
334 * sym *symhash[] array of pointers to symbol tables
337 * int fndsym() lklibr.c
340 * If a symbol is found then the library object module
341 * containing the symbol will be imported and linked.
347 register struct sym *sp;
348 register int i,symfnd;
351 * Look for undefined symbols. Keep
352 * searching until no more symbols are resolved.
358 * Look through all the symbols
360 for (i=0; i<NHASH; ++i) {
363 /* If we find an undefined symbol
364 * (one where S_DEF is not set), then
365 * try looking for it. If we find it
366 * in any of the libraries then
367 * increment symfnd. This will force
368 * another pass of symbol searching and
369 * make sure that back references work.
371 if ((sp->s_type & S_DEF) == 0) {
372 if (fndsym(sp->s_id)) {
382 /*Load a .rel file embedded in a sdcclib file*/
383 void LoadRel(char * libfname, FILE * libfp, char * ModName)
388 while (fgets(str, NINPUT, libfp) != NULL)
390 str[NINPUT+1] = '\0';
395 if(EQ(str, "<FILE>"))
397 fgets(str, NINPUT, libfp);
398 str[NINPUT+1] = '\0';
400 if(EQ(str, ModName)) state=1;
403 fprintf(stderr, "?Aslink-Error-Bad offset in library file %s(%s)\n",
410 if(EQ(str, "<REL>")) state=2;
413 if(EQ(str, "</REL>")) return;
421 /*Load an .adb file embedded in a sdcclib file. If there is
422 something between <ADB> and </ADB> returns 1, otherwise returns 0.
423 This way the aomf51 will not have uselless empty modules. */
425 int LoadAdb(FILE * libfp)
431 while (fgets(str, MAXLINE, libfp) != NULL)
433 str[NINPUT+1] = '\0';
438 if(EQ(str, "<ADB>")) state=1;
441 if(EQ(str, "</ADB>")) return ToReturn;
442 fprintf(dfp, "%s\n", str);
450 /*Check for a symbol in a SDCC library. If found, add the embedded .rel and
451 .adb files from the library. The library must be created with the SDCC
452 librarian 'sdcclib' since the linking process depends on the correct file offsets
453 embedded in the library file.*/
455 int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName)
457 struct lbfile *lbfh, *lbf;
458 char ModName[NCPS]="";
459 char FLine[MAXLINE+1];
461 long IndexOffset=0, FileOffset;
466 fgets(FLine, MAXLINE, libfp);
472 if(EQ(FLine, "<INDEX>"))
474 /*The next line has the size of the index*/
476 fgets(FLine, MAXLINE, libfp);
478 IndexOffset=atol(FLine);
483 if(EQ(FLine, "<MODULE>"))
485 /*The next line has the name of the module and the offset
486 of the corresponding embedded file in the library*/
488 fgets(FLine, MAXLINE, libfp);
490 sscanf(FLine, "%s %ld", ModName, &FileOffset);
493 else if(EQ(FLine, "</INDEX>"))
495 /*Reached the end of the index. The symbol is not in this library.*/
500 if(EQ(FLine, "</MODULE>"))
502 /*The symbol is not in this module, try the next one*/
507 /*Check if this is the symbol we are looking for.*/
508 if (strncmp(SymName, FLine, NCPS)==0)
510 /*The symbol is in this module.*/
512 /*As in the original library format, it is assumed that the .rel
513 files reside in the same directory as the lib files.*/
514 strcat(DirLib, ModName);
515 sprintf(&DirLib[strlen(DirLib)], "%crel", FSEPX);
517 /*If this module has been loaded already don't load it again.*/
521 if(EQ(DirLib, lbf->filspc)) return 1;/*Already loaded*/
525 /*Add the embedded file to the list of files to be loaded in
526 the second pass. That is performed latter by the function
528 lbfh = (struct lbfile *) new (sizeof(struct lbfile));
541 lbfh->libspc = PathLib;
542 lbfh->filspc = DirLib;
543 lbfh->relfil = (char *) new (strlen(ModName) + 1);
544 strcpy(lbfh->relfil, ModName);
545 /*Library embedded file, so lbfh->offset must be >=0*/
546 lbfh->offset = IndexOffset+FileOffset;
548 /*Jump to where the .rel begins and load it.*/
549 fseek(libfp, lbfh->offset, SEEK_SET);
550 LoadRel(PathLib, libfp, ModName);
552 /* if cdb information required & .adb file present */
556 SaveLinkedFilePath(DirLib);
558 return 1; /*Found the symbol, so success!*/
564 return 0; /*It should never reach this point, but just in case...*/
569 return 0; /*The symbol is not in this library*/
572 /*)Function VOID fndsym(name)
574 * char *name symbol name to find
576 * The function fndsym() searches through all combinations of the
577 * library path specifications (input by the -k option) and the
578 * library file specifications (input by the -l option) that
579 * lead to an existing file.
581 * The file specicifation may be formed in one of two ways:
583 * (1) If the library file contained an absolute
584 * path/file specification then this becomes filspc.
587 * (2) If the library file contains a relative path/file
588 * specification then the concatenation of the path
589 * and this file specification becomes filspc.
592 * The structure lbfile is created for the first library
593 * object file which contains the definition for the
594 * specified undefined symbol.
596 * If the library file [.LIB] contains file specifications for
597 * non existant files, no errors are returned.
600 * char buf[] [.REL] file input line
601 * char c [.REL] file input character
602 * FILE *fp file handle for object file
603 * lbfile *lbf temporary pointer
604 * lbfile *lbfh pointer to lbfile structure
605 * FILE *libfp file handle for library file
606 * lbname *lbnh pointer to lbname structure
607 * char *path file specification path
608 * char relfil[] [.REL] file specification
609 * char *str combined path and file specification
610 * char symname[] [.REL] file symbol string
613 * lbname *lbnhead The pointer to the first
615 * lbfile *lbfhead The pointer to the first
619 * int fclose() c_library
620 * int fgets() c_library
621 * FILE *fopen() c_library
622 * VOID free() c_library
623 * char getnb() lklex.c
624 * VOID lkexit() lkmain.c
625 * VOID loadfile() lklibr.c
626 * VOID * new() lksym.c
627 * char * sprintf() c_library
628 * int sscanf() c_library
629 * char * strcat() c_library
630 * char * strchr() c_library
631 * char * strcpy() c_library
632 * int strlen() c_library
633 * int strncmp() c_library
634 * VOID unget() lklex.c
637 * If the symbol is found then a new lbfile structure
638 * is created and added to the linked list of lbfile
639 * structures. The file containing the found symbol
645 int fndsym( char *name )
647 struct lbfile *lbfh, *lbf;
648 pmlibraryfile ThisLibr;
649 pmlibrarysymbol ThisSym = NULL;
651 pmlibraryfile FirstFound;
654 /* Build the index if this is the first call to fndsym */
655 if (libr==NULL) buildlibraryindex();
657 /* Iterate through all library object files */
659 FirstFound = libr; /*So gcc stops whining*/
662 /* Iterate through all symbols in an object file */
663 ThisSym = ThisLibr->symbols;
667 if (!strcmp(ThisSym->name, name))
669 if ((!ThisLibr->loaded) && (numfound==0))
671 /* Object file is not loaded - add it to the list */
672 lbfh = (struct lbfile *) new (sizeof(struct lbfile));
684 lbfh->libspc = ThisLibr->libspc;
685 lbfh->filspc = ThisLibr->filename;
686 lbfh->relfil = (char *) new (strlen(ThisLibr->relfil) + 1);
687 strcpy(lbfh->relfil, ThisLibr->relfil);
688 lbfh->offset = ThisLibr->offset;
690 { /*For an embedded object file in a library*/
691 void loadfile_SdccLib(char * libspc, char * module, long offset);
692 loadfile_SdccLib(lbfh->libspc, lbfh->relfil, lbfh->offset);
695 { /*For a stand alone object file*/
696 /* if cdb information required & adb file present */
699 FILE *xfp = afile(lbfh->filspc, "adb",0);
702 SaveLinkedFilePath(lbfh->filspc);
707 loadfile(lbfh->filspc);
719 char absPath1[PATH_MAX];
720 char absPath2[PATH_MAX];
721 #if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
724 _fullpath(absPath1, FirstFound->libspc, PATH_MAX);
725 _fullpath(absPath2, ThisLibr->libspc, PATH_MAX);
726 for(j=0; absPath1[j]!=0; j++) absPath1[j]=tolower(absPath1[j]);
727 for(j=0; absPath2[j]!=0; j++) absPath2[j]=tolower(absPath2[j]);
729 realpath(FirstFound->libspc, absPath1);
730 realpath(ThisLibr->libspc, absPath2);
732 if( !( EQ(absPath1, absPath2) && EQ(FirstFound->relfil, ThisLibr->relfil) ) )
736 fprintf(stderr, "?Aslink-Warning-Definition of public symbol '%s'"
737 " found more than once:\n", name);
738 fprintf(stderr, " Library: '%s', Module: '%s'\n",
739 FirstFound->libspc, FirstFound->relfil);
741 fprintf(stderr, " Library: '%s', Module: '%s'\n",
742 ThisLibr->libspc, ThisLibr->relfil);
747 ThisSym=ThisSym->next; /* Next sym in library */
749 ThisLibr=ThisLibr->next; /* Next library in list */
754 pmlibraryfile buildlibraryindex_SdccLib(char * PathLib, FILE * libfp, char * DirLib, pmlibraryfile This)
756 char ModName[NCPS]="";
757 char FLine[MAXLINE+1];
760 long IndexOffset=0, FileOffset;
761 pmlibrarysymbol ThisSym = NULL;
766 fgets(FLine, MAXLINE, libfp);
772 if(EQ(FLine, "<INDEX>"))
774 /*The next line has the size of the index*/
776 fgets(FLine, MAXLINE, libfp);
778 IndexOffset=atol(FLine);
783 if(EQ(FLine, "<MODULE>"))
785 /*The next line has the name of the module and the offset
786 of the corresponding embedded file in the library*/
788 fgets(FLine, MAXLINE, libfp);
790 sscanf(FLine, "%s %ld", ModName, &FileOffset);
793 /*Create a new libraryfile object for this module*/
796 libr=This=(pmlibraryfile)new( sizeof( mlibraryfile ));
800 This->next=(pmlibraryfile)new( sizeof( mlibraryfile ));
805 This->offset=FileOffset+IndexOffset;
806 This->libspc=PathLib;
808 This->relfil=(char *)new(strlen(ModName)+1);
809 strcpy(This->relfil, ModName);
811 sprintf(buff, "%s%s%crel", DirLib, ModName, FSEPX);
812 This->filename=(char *)new(strlen(buff)+1);
813 strcpy(This->filename, buff);
815 This->symbols=ThisSym=NULL; /*Start a new linked list of symbols*/
817 else if(EQ(FLine, "</INDEX>"))
819 return This; /*Finish, get out of here*/
823 if(EQ(FLine, "</MODULE>"))
826 /*Create the index for the next module*/
832 if(ThisSym==NULL) /*First symbol of the current module*/
834 ThisSym=This->symbols=(pmlibrarysymbol)new(sizeof(mlibrarysymbol));
838 ThisSym->next = (pmlibrarysymbol)new(sizeof(mlibrarysymbol));
839 ThisSym=ThisSym->next;
842 ThisSym->name=(char *)new(strlen(FLine)+1);
843 strcpy(ThisSym->name, FLine);
848 return This; /*State machine should never reach this point, but just in case...*/
853 return This; /*State machine should never reach this point, but just in case...*/
857 /* buildlibraryindex - build an in-memory cache of the symbols contained in
860 int buildlibraryindex(void)
864 char relfil[NINPUT+2], str[PATH_MAX], *path;
865 char buf[NINPUT+2], c;
866 char symname[NINPUT+2];
867 pmlibraryfile This=NULL;
868 pmlibrarysymbol ThisSym;
871 * Search through every library in the linked list "lbnhead".
874 for (lbnh=lbnhead; lbnh; lbnh=lbnh->next)
876 if ((libfp = fopen(lbnh->libspc, "r")) == NULL)
878 fprintf(stderr, "?Aslink-Error-Cannot open library file %s\n",
885 * Read in a line from the library file.
886 * This is the relative file specification
887 * for a .REL file in this library.
890 while (fgets(relfil, NINPUT, libfp) != NULL)
892 relfil[NINPUT+1] = '\0';
898 if (str[strlen(str)-1] != '/')
909 if(strcmp(relfil, "<SDCCLIB>")==0)
911 /*Get the built in index of this library*/
912 This=buildlibraryindex_SdccLib(lbnh->libspc, libfp, str, This);
913 break; /*get the index for next library*/
916 /*From here down, build the index for the original library format*/
918 if (relfil[0] == '\\')
920 strcat(str,relfil+1);
927 if(strchr(relfil, FSEPX) == NULL)
929 sprintf(&str[strlen(str)], "%crel", FSEPX);
932 if ((fp = fopen(str, "r")) != NULL)
934 /* Opened OK - create a new libraryfile object for it */
937 libr=This=(pmlibraryfile)new( sizeof( mlibraryfile ));
941 This->next=(pmlibraryfile)new( sizeof( mlibraryfile ));
946 This->offset=-1; /*We have a stand alone .rel file*/
947 This->libspc = lbnh->libspc;
949 This->relfil=(char *)new(strlen(relfil)+1);
950 strcpy(This->relfil, relfil);
952 This->filename=(char *)new(strlen(str)+1);
953 strcpy(This->filename, str);
955 /*Start a new linked list of symbols for this module:*/
956 This->symbols=ThisSym=NULL;
959 * Read in the object file. Look for lines that
960 * begin with "S" and end with "D". These are
961 * symbol table definitions. If we find one, see
962 * if it is our symbol. Make sure we only read in
963 * our object file and don't go into the next one.
966 while (fgets(buf, NINPUT, fp) != NULL)
968 buf[NINPUT+1] = '\0';
969 buf[strlen(buf) - 1] = '\0';
972 * Skip everything that's not a symbol record.
974 if (buf[0] != 'S') continue;
977 * When a 'T line' is found terminate file scan.
978 * All 'S line's preceed 'T line's in .REL files.
980 if (buf[0] == 'T') break;
982 sscanf(buf, "S %s %c", symname, &c);
984 /* If it's an actual symbol, record it */
989 ThisSym=This->symbols=(pmlibrarysymbol)new(sizeof(mlibrarysymbol));
993 ThisSym->next=(pmlibrarysymbol)new(sizeof(mlibrarysymbol));
994 ThisSym=ThisSym->next;
998 ThisSym->name=(char *)new(strlen(symname)+1);
999 strcpy(ThisSym->name, symname);
1001 } /* Closes while - read object file */
1003 } /* Closes if object file opened OK */
1006 fprintf(stderr, "?Aslink-Warning-Cannot open library module %s\n", str);
1008 } /* Ends while - processing all in libr */
1010 } /* Ends good open of libr file */
1014 /*Release all memory allocated for the in-memory library index*/
1015 void freelibraryindex (void)
1017 pmlibraryfile ThisLibr, ThisLibr2Free;
1018 pmlibrarysymbol ThisSym, ThisSym2Free;
1024 ThisSym = ThisLibr->symbols;
1028 free(ThisSym->name);
1029 ThisSym2Free=ThisSym;
1030 ThisSym=ThisSym->next;
1033 free(ThisLibr->filename);
1034 free(ThisLibr->relfil);
1035 ThisLibr2Free=ThisLibr;
1036 ThisLibr=ThisLibr->next;
1037 free(ThisLibr2Free);
1043 #else /* INDEXLIB */
1050 struct lbname *lbnh;
1051 struct lbfile *lbfh, *lbf;
1052 char relfil[NINPUT+2];
1054 char symname[NINPUT];
1060 * Search through every library in the linked list "lbnhead".
1063 for (lbnh=lbnhead; lbnh; lbnh=lbnh->next)
1065 if ((libfp = fopen(lbnh->libspc, "r")) == NULL)
1067 fprintf(stderr, "?Aslink-Error-Cannot open library file %s\n",
1074 * Read in a line from the library file.
1075 * This is the relative file specification
1076 * for a .REL file in this library.
1079 while (fgets(relfil, NINPUT, libfp) != NULL)
1081 relfil[NINPUT+1] = '\0';
1085 str = (char *) new (strlen(path)+strlen(relfil)+6);
1088 if (str[strlen(str)-1] != '/')
1096 str = (char *) new (strlen(relfil) + 5);
1099 if(strcmp(relfil, "<SDCCLIB>")==0)
1101 result=SdccLib(lbnh->libspc, libfp, str, name);
1102 if(result) return(1); /*Found the symbol*/
1104 /*The symbol is not in the current library,
1105 check the next library in the list*/
1109 /*From here down is the support for libraries in the original format*/
1110 if (relfil[0] == '\\')
1112 strcat(str,relfil+1);
1119 if(strchr(relfil, FSEPX) == NULL)
1121 sprintf(&str[strlen(str)], "%crel", FSEPX);
1124 if ((fp = fopen(str, "r")) != NULL)
1128 * Read in the object file. Look for lines that
1129 * begin with "S" and end with "D". These are
1130 * symbol table definitions. If we find one, see
1131 * if it is our symbol. Make sure we only read in
1132 * our object file and don't go into the next one.
1135 while (fgets(buf, NINPUT, fp) != NULL)
1137 buf[NINPUT+1] = '\0';
1140 * Skip everything that's not a symbol record.
1142 if (buf[0] != 'S') continue;
1145 * When a 'T line' is found terminate file scan.
1146 * All 'S line's preceed 'T line's in .REL files.
1148 if (buf[0] == 'T') break;
1150 sscanf(buf, "S %s %c", symname, &c);
1153 * If we find a symbol definition for the
1154 * symbol we're looking for, load in the
1155 * file and add it to lbfhead so it gets
1156 * loaded on pass number 2.
1158 if (strncmp(symname, name, NCPS) == 0 && c == 'D')
1160 lbfh = (struct lbfile *) new (sizeof(struct lbfile));
1161 if (lbfhead == NULL)
1173 lbfh->libspc = lbnh->libspc;
1175 lbfh->relfil = (char *) new (strlen(relfil) + 1);
1176 lbfh->offset = -1; /*Stand alone rel file*/
1177 strcpy(lbfh->relfil,relfil);
1181 /* if cdb information required & adb file present */
1184 FILE *xfp = afile(str,"adb",0); //JCF: Nov 30, 2002
1187 SaveLinkedFilePath(str);
1207 void loadfile_SdccLib(char * libspc, char * module, long offset)
1211 if ((fp = fopen(libspc,"r")) != NULL)
1213 fseek(fp, offset, SEEK_SET);
1214 LoadRel(libspc, fp, module);
1219 /*)Function VOID library()
1221 * The function library() links all the library object files
1222 * contained in the lbfile structures.
1225 * lbfile *lbfh pointer to lbfile structure
1228 * lbfile *lbfhead pointer to first lbfile structure
1231 * VOID loadfile lklibr.c
1234 * Links all files contained in the lbfile structures.
1240 struct lbfile *lbfh;
1242 for (lbfh=lbfhead; lbfh; lbfh=lbfh->next)
1246 /*Stand alone rel file (original lib format)*/
1247 loadfile(lbfh->filspc);
1251 /*rel file embedded in lib (new lib format)*/
1252 loadfile_SdccLib(lbfh->libspc, lbfh->relfil, lbfh->offset);
1260 /*)Function VOID loadfile(filspc)
1262 * char *filspc library object file specification
1264 * The function loadfile() links the library object module.
1267 * FILE *fp file handle
1268 * int i input line length
1269 * char str[] file input line
1272 * char *ip pointer to linker input string
1275 * int fclose() c_library
1276 * int fgets() c_library
1277 * FILE * fopen() c_library
1278 * VOID link_main() lkmain.c
1279 * int strlen() c_library
1282 * If file exists it is linked.
1292 if ((fp = fopen(filspc,"r")) != NULL) {
1293 while (fgets(str, NINPUT, fp) != NULL) {
1294 str[NINPUT+1] = '\0';