4 * (C) Copyright 1989-1995
11 * With contributions for the
12 * object libraries from
14 * kenh@cmf.nrl.navy.mil
19 * Extensions: P. Felber
22 #define EQ(A,B) !strcmp((A),(B))
23 #define MAXLINE 254 /*when using fgets*/
35 #define LKDIRSEPSTR "/"
38 #define LKDIRSEPSTR "\\"
42 #define LKDIRSEPSTR "\\"
49 #define LKOBJEXT "rel"
54 * The module lklibr.c contains the functions which
55 * (1) specify the path(s) to library files [.LIB]
56 * (2) specify the library file(s) [.LIB] to search
57 * (3) search the library files for specific symbols
58 * and link the module containing this symbol
60 * lklibr.c contains the following functions:
72 typedef struct slibrarysymbol mlibrarysymbol;
73 typedef struct slibrarysymbol *pmlibrarysymbol;
75 struct slibrarysymbol {
76 char * name; /*Warning: allocate memory before using*/
80 typedef struct slibraryfile mlibraryfile;
81 typedef struct slibraryfile *pmlibraryfile;
86 char * relfil; /*Warning: allocate memory before using*/
87 char * filename; /*Warning: allocate memory before using*/
88 long offset; //if > 0, the embedded file offset in the library file libspc
89 pmlibrarysymbol symbols;
93 /* First entry in the library object symbol cache */
94 pmlibraryfile libr=NULL;
96 int buildlibraryindex();
97 void freelibraryindex (void);
100 /*)Function VOID addpath()
102 * The function addpath() creates a linked structure containing
103 * the paths to various object module library files.
106 * lbpath *lbph pointer to new path structure
107 * lbpath *lbp temporary pointer
110 * lbpath *lbphead The pointer to the first
114 * char getnb() lklex.c
115 * VOID * new() lksym.c
116 * int strlen() c_library
117 * char * strcpy() c_library
118 * VOID unget() lklex.c
121 * An lbpath structure may be created.
127 struct lbpath *lbph, *lbp;
129 lbph = (struct lbpath *) new (sizeof(struct lbpath));
130 if (lbphead == NULL) {
139 lbph->path = (char *) new (strlen(ip)+1);
140 strcpy(lbph->path, ip);
143 /*)Function VOID addlib()
145 * The function addlib() tests for the existance of a
146 * library path structure to determine the method of
147 * adding this library file to the library search structure.
149 * This function calls the function addfile() to actually
150 * add the library file to the search list.
153 * lbpath *lbph pointer to path structure
156 * lbpath *lbphead The pointer to the first
158 * ip a pointer to the library name
161 * VOID addfile() lklibr.c
162 * char getnb() lklex.c
163 * VOID unget() lklex.c
166 * The function addfile() may add the file to
167 * the library search list.
180 foundcount=addfile(NULL, ip);
184 for (lbph=lbphead; lbph; lbph=lbph->next)
186 foundcount+=addfile(lbph->path, ip);
191 fprintf(stderr, "\n?ASlink-Warning-Couldn't find library '%s'", ip);
195 /*)Function int addfile(path,libfil)
197 * char *path library path specification
198 * char *libfil library file specification
200 * The function addfile() searches for the library file
201 * by concatenating the path and libfil specifications.
202 * if the library is found, an lbname structure is created
203 * and linked to any previously defined structures. This
204 * linked list is used by the function fndsym() to attempt
205 * to find any undefined symbols.
207 * The function does not give report an error on invalid
208 * path / file specifications or if the file is not found.
211 * lbname *lbnh pointer to new name structure
212 * lbname *lbn temporary pointer
215 * lbname *lbnhead The pointer to the first
219 * char getnb() lklex.c
220 * VOID * new() lksym.c
221 * int strlen() c_library
222 * char * strcpy() c_library
223 * VOID unget() lklex.c
226 * An lbname structure may be created.
229 * 1: the library was found
230 * 0: the library was not found
233 int addfile(char * path, char * libfil)
237 struct lbname *lbnh, *lbn;
242 str = (char *) new (strlen(path) + strlen(libfil) + 6);
245 if (str[strlen(str)-1] != LKDIRSEP)
247 strcat(str, LKDIRSEPSTR);
252 str = (char *) new (strlen(libfil) + 5);
255 if (libfil[0] == LKDIRSEP)
263 if(strchr(libfil, FSEPX) == NULL)
265 sprintf(&str[strlen(str)], "%clib", FSEPX);
271 /*Ok, that didn't work. Try with the 'libfil' name only*/
272 if(libfilinc) libfil--;
273 fp=fopen(libfil, "r");
276 /*Bingo! 'libfil' is the absolute path of the library*/
278 path=NULL;/*This way 'libfil' and 'path' will be rebuilt from 'str'*/
284 /*'path' can not be null since it is needed to find the '.o' files associated with
285 the library. So, get 'path' from 'str' and then chop it off and recreate 'libfil'.
286 That way putting 'path' and 'libfil' together will result into the original filepath
287 as contained in 'str'.*/
289 path = (char *) new (strlen(str));
291 for(j=strlen(path)-1; j>=0; j--)
293 if((path[j]=='\\')||(path[j]=='/'))
295 strcpy(libfil, &path[j+1]);
306 lbnh = (struct lbname *) new (sizeof(struct lbname));
320 lbnh->libfil = (char *) new (strlen(libfil) + 1);
321 strcpy(lbnh->libfil, libfil);
332 /*)Function VOID search()
334 * The function search() looks through all the symbol tables
335 * at the end of pass 1. If any undefined symbols are found
336 * then the function fndsym() is called. Function fndsym()
337 * searches any specified library files to automagically
338 * import the object modules containing the needed symbol.
340 * After a symbol is found and imported by the function
341 * fndsym() the symbol tables are again searched. The
342 * symbol tables are search until no more symbols can be
343 * resolved within the library files. This ensures that
344 * back references from one library module to another are
348 * int i temporary counter
349 * sym *sp pointer to a symbol structure
350 * int symfnd found a symbol flag
353 * sym *symhash[] array of pointers to symbol tables
356 * int fndsym() lklibr.c
359 * If a symbol is found then the library object module
360 * containing the symbol will be imported and linked.
366 register struct sym *sp;
367 register int i, symfnd;
370 * Look for undefined symbols. Keep
371 * searching until no more symbols are resolved.
377 * Look through all the symbols
379 for (i=0; i<NHASH; ++i) {
382 /* If we find an undefined symbol
383 * (one where S_DEF is not set), then
384 * try looking for it. If we find it
385 * in any of the libraries then
386 * increment symfnd. This will force
387 * another pass of symbol searching and
388 * make sure that back references work.
390 if ((sp->s_type & S_DEF) == 0) {
391 if (fndsym(sp->s_id)) {
401 /*Load a .rel file embedded in a sdcclib file*/
402 void LoadRel(char * libfname, FILE * libfp, char * ModName)
407 while (fgets(str, NINPUT, libfp) != NULL)
409 str[NINPUT+1] = '\0';
414 if(EQ(str, "<FILE>"))
416 fgets(str, NINPUT, libfp);
417 str[NINPUT+1] = '\0';
419 if(EQ(str, ModName)) state=1;
422 fprintf(stderr, "?Aslink-Error-Bad offset in library file %s(%s)\n",
429 if(EQ(str, "<REL>")) state=2;
432 if(EQ(str, "</REL>")) return;
440 /*)Function VOID fndsym(name)
442 * char *name symbol name to find
444 * The function fndsym() searches through all combinations of the
445 * library path specifications (input by the -k option) and the
446 * library file specifications (input by the -l option) that
447 * lead to an existing file.
449 * The file specicifation may be formed in one of two ways:
451 * (1) If the library file contained an absolute
452 * path/file specification then this becomes filspc.
455 * (2) If the library file contains a relative path/file
456 * specification then the concatenation of the path
457 * and this file specification becomes filspc.
460 * The structure lbfile is created for the first library
461 * object file which contains the definition for the
462 * specified undefined symbol.
464 * If the library file [.LIB] contains file specifications for
465 * non existant files, no errors are returned.
468 * char buf[] [.REL] file input line
469 * char c [.REL] file input character
470 * FILE *fp file handle for object file
471 * lbfile *lbf temporary pointer
472 * lbfile *lbfh pointer to lbfile structure
473 * FILE *libfp file handle for library file
474 * lbname *lbnh pointer to lbname structure
475 * char *path file specification path
476 * char relfil[] [.REL] file specification
477 * char *str combined path and file specification
478 * char symname[] [.REL] file symbol string
481 * lbname *lbnhead The pointer to the first
483 * lbfile *lbfhead The pointer to the first
487 * int fclose() c_library
488 * int fgets() c_library
489 * FILE *fopen() c_library
490 * VOID free() c_library
491 * char getnb() lklex.c
492 * VOID lkexit() lkmain.c
493 * VOID loadfile() lklibr.c
494 * VOID * new() lksym.c
495 * char * sprintf() c_library
496 * int sscanf() c_library
497 * char * strcat() c_library
498 * char * strchr() c_library
499 * char * strcpy() c_library
500 * int strlen() c_library
501 * int strncmp() c_library
502 * VOID unget() lklex.c
505 * If the symbol is found then a new lbfile structure
506 * is created and added to the linked list of lbfile
507 * structures. The file containing the found symbol
513 int fndsym( char *name )
515 struct lbfile *lbfh, *lbf;
516 pmlibraryfile ThisLibr;
517 pmlibrarysymbol ThisSym = NULL;
519 pmlibraryfile FirstFound;
522 /* Build the index if this is the first call to fndsym */
523 if (libr==NULL) buildlibraryindex();
525 /* Iterate through all library object files */
527 FirstFound = libr; /*So gcc stops whining*/
530 /* Iterate through all symbols in an object file */
531 ThisSym = ThisLibr->symbols;
535 //printf("ThisSym->name=%s\n", ThisSym->name);
536 if (!strcmp(ThisSym->name, name))
538 if ((!ThisLibr->loaded) && (numfound==0))
540 /* Object file is not loaded - add it to the list */
541 lbfh = (struct lbfile *) new (sizeof(struct lbfile));
553 lbfh->libspc = ThisLibr->libspc;
554 lbfh->filspc = ThisLibr->filename;
555 lbfh->relfil = (char *) new (strlen(ThisLibr->relfil) + 1);
556 strcpy(lbfh->relfil,ThisLibr->relfil);
557 lbfh->offset = ThisLibr->offset;
559 { /*For an embedded object file in a library*/
560 void loadfile_SdccLib(char * libspc, char * module, long offset);
561 loadfile_SdccLib(lbfh->libspc, lbfh->relfil, lbfh->offset);
564 { /*For a stand alone object file*/
565 loadfile(lbfh->filspc);
577 char absPath1[PATH_MAX];
578 char absPath2[PATH_MAX];
579 #if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
582 _fullpath(absPath1, FirstFound->libspc, PATH_MAX);
583 _fullpath(absPath2, ThisLibr->libspc, PATH_MAX);
584 for(j=0; absPath1[j]!=0; j++) absPath1[j]=tolower((unsigned char)absPath1[j]);
585 for(j=0; absPath2[j]!=0; j++) absPath2[j]=tolower((unsigned char)absPath2[j]);
587 realpath(FirstFound->libspc, absPath1);
588 realpath(ThisLibr->libspc, absPath2);
590 if( !( EQ(absPath1, absPath2) && EQ(FirstFound->relfil, ThisLibr->relfil) ) )
594 fprintf(stderr, "?Aslink-Warning-Definition of public symbol '%s'"
595 " found more than once:\n", name);
596 fprintf(stderr, " Library: '%s', Module: '%s'\n",
597 FirstFound->libspc, FirstFound->relfil);
599 fprintf(stderr, " Library: '%s', Module: '%s'\n",
600 ThisLibr->libspc, ThisLibr->relfil);
605 ThisSym=ThisSym->next; /* Next sym in library */
607 ThisLibr=ThisLibr->next; /* Next library in list */
612 pmlibraryfile buildlibraryindex_SdccLib(char * PathLib, FILE * libfp, char * DirLib, pmlibraryfile This)
614 char ModName[NCPS]="";
615 char FLine[MAXLINE+1];
618 long IndexOffset=0, FileOffset;
619 pmlibrarysymbol ThisSym = NULL;
624 fgets(FLine, MAXLINE, libfp);
630 if(EQ(FLine, "<INDEX>"))
632 /*The next line has the size of the index*/
634 fgets(FLine, MAXLINE, libfp);
636 IndexOffset=atol(FLine);
641 if(EQ(FLine, "<MODULE>"))
643 /*The next line has the name of the module and the offset
644 of the corresponding embedded file in the library*/
646 fgets(FLine, MAXLINE, libfp);
648 sscanf(FLine, "%s %ld", ModName, &FileOffset);
651 /*Create a new libraryfile object for this module*/
654 libr=This=(pmlibraryfile)new( sizeof( mlibraryfile ));
658 This->next=(pmlibraryfile)new( sizeof( mlibraryfile ));
663 This->offset=FileOffset+IndexOffset;
664 This->libspc=PathLib;
666 This->relfil=(char *)new(strlen(ModName)+1);
667 strcpy(This->relfil, ModName);
669 sprintf(buff, "%s%s%c%s", DirLib, ModName, FSEPX, LKOBJEXT);
670 This->filename=(char *)new(strlen(buff)+1);
671 strcpy(This->filename, buff);
673 This->symbols=ThisSym=NULL; /*Start a new linked list of symbols*/
675 else if(EQ(FLine, "</INDEX>"))
677 return This; /*Finish, get out of here*/
681 if(EQ(FLine, "</MODULE>"))
684 /*Create the index for the next module*/
690 if(ThisSym==NULL) /*First symbol of the current module*/
692 ThisSym=This->symbols=(pmlibrarysymbol)new(sizeof(mlibrarysymbol));
696 ThisSym->next = (pmlibrarysymbol)new(sizeof(mlibrarysymbol));
697 ThisSym=ThisSym->next;
700 ThisSym->name=(char *)new(strlen(FLine)+1);
701 strcpy(ThisSym->name, FLine);
706 return This; /*State machine should never reach this point, but just in case...*/
711 return This; /*State machine should never reach this point, but just in case...*/
715 /* buildlibraryindex - build an in-memory cache of the symbols contained in
718 int buildlibraryindex(void)
722 char relfil[NINPUT+2], str[PATH_MAX], *path;
723 char buf[NINPUT+2], c;
724 char symname[NINPUT+2];
725 pmlibraryfile This=NULL;
726 pmlibrarysymbol ThisSym;
728 /* Iterate through all library files */
729 for (lbnh=lbnhead; lbnh; lbnh=lbnh->next)
731 if ((libfp = fopen(lbnh->libspc, "r")) == NULL)
733 fprintf(stderr, "?Aslink-Error-Cannot open library file %s\n",
741 * Read in a line from the library file.
742 * This is the relative file specification
743 * for a .REL file in this library.
746 while (fgets(relfil, NINPUT, libfp) != NULL)
748 relfil[NINPUT+1] = '\0';
754 if (str[strlen(str)-1] != LKDIRSEP)
756 strcat(str, LKDIRSEPSTR);
765 if(strcmp(relfil, "<SDCCLIB>")==0)
767 /*Get the built in index of a library*/
768 This=buildlibraryindex_SdccLib(lbnh->libspc, libfp, str, This);
769 break; /*get the index for next library*/
772 /*From here down, build the index for the original library format*/
774 if (relfil[0] == LKDIRSEP)
776 strcat(str, relfil+1);
783 if(strchr(relfil, FSEPX) == NULL)
785 sprintf(&str[strlen(str)], "%c%s", FSEPX, LKOBJEXT);
788 if ((fp = fopen(str, "r")) != NULL)
790 /* Opened OK - create a new libraryfile object for it */
793 libr=This=(pmlibraryfile)new( sizeof( mlibraryfile ));
797 This->next=(pmlibraryfile)new( sizeof( mlibraryfile ));
803 This->offset=-1; /*There should be a rel file*/
804 This->libspc = lbnh->libspc;
805 This->relfil=(char *)new(strlen(relfil)+1);
806 strcpy(This->relfil, relfil);
807 This->filename=(char *)new(strlen(str)+1);
808 strcpy(This->filename, str);
810 ThisSym = This->symbols = NULL;
813 * Read in the object file. Look for lines that
814 * begin with "S" and end with "D". These are
815 * symbol table definitions. If we find one, see
816 * if it is our symbol. Make sure we only read in
817 * our object file and don't go into the next one.
820 while (fgets(buf, NINPUT, fp) != NULL)
822 buf[NINPUT+1] = '\0';
823 buf[strlen(buf) - 1] = '\0';
826 * Skip everything that's not a symbol record.
828 if (buf[0] != 'S') continue;
831 * When a 'T line' is found terminate file scan.
832 * All 'S line's preceed 'T line's in .REL files.
834 if (buf[0] == 'T') break;
836 sscanf(buf, "S %s %c", symname, &c);
838 /* If it's an actual symbol, record it */
843 ThisSym=This->symbols=(pmlibrarysymbol)new(sizeof(mlibrarysymbol));
847 ThisSym->next=(pmlibrarysymbol)new(sizeof(mlibrarysymbol));
848 ThisSym=ThisSym->next;
852 ThisSym->name=(char *)new(strlen(symname)+1);
853 strcpy(ThisSym->name, symname);
855 } /* Closes while - read object file */
857 } /* Closes if object file opened OK */
858 } /* Ends while - processing all in libr */
860 } /* Ends good open of libr file */
864 /*Release all memory allocated for the in-memory library index*/
865 void freelibraryindex (void)
867 pmlibraryfile ThisLibr, ThisLibr2Free;
868 pmlibrarysymbol ThisSym, ThisSym2Free;
874 ThisSym = ThisLibr->symbols;
879 ThisSym2Free=ThisSym;
880 ThisSym=ThisSym->next;
883 free(ThisLibr->filename);
884 free(ThisLibr->relfil);
885 ThisLibr2Free=ThisLibr;
886 ThisLibr=ThisLibr->next;
896 /*Check for a symbol in a SDCC library. If found, add the embedded .rel.
897 The library must be created with the SDCC librarian 'sdcclib' since the
898 linking process depends on the correct file offsets embedded in the library
901 int SdccLib(char * PathLib, FILE * libfp, char * DirLib, char * SymName)
903 struct lbfile *lbfh, *lbf;
904 char ModName[NCPS]="";
905 char FLine[MAXLINE+1];
907 long IndexOffset=0, FileOffset;
912 fgets(FLine, MAXLINE, libfp);
918 if(EQ(FLine, "<INDEX>"))
920 /*The next line has the size of the index*/
922 fgets(FLine, MAXLINE, libfp);
924 IndexOffset=atol(FLine);
929 if(EQ(FLine, "<MODULE>"))
931 /*The next line has the name of the module and the offset
932 of the corresponding embedded file in the library*/
934 fgets(FLine, MAXLINE, libfp);
936 sscanf(FLine, "%s %ld", ModName, &FileOffset);
939 else if(EQ(FLine, "</INDEX>"))
941 /*Reached the end of the index. The symbol is not in this library.*/
946 if(EQ(FLine, "</MODULE>"))
948 /*The symbol is not in this module, try the next one*/
953 /*Check if this is the symbol we are looking for.*/
954 if (strncmp(SymName, FLine, NCPS)==0)
956 /*The symbol is in this module.*/
958 /*As in the original library format, it is assumed that the .rel
959 files reside in the same directory as the lib files.*/
960 strcat(DirLib, ModName);
961 sprintf(&DirLib[strlen(DirLib)], "%c%s", FSEPX, LKOBJEXT);
963 /*If this module has been loaded already don't load it again.*/
967 if(EQ(DirLib, lbf->filspc)) return 1;/*Already loaded*/
971 /*Add the embedded file to the list of files to be loaded in
972 the second pass. That is performed latter by the function
974 lbfh = (struct lbfile *) new (sizeof(struct lbfile));
987 lbfh->libspc = PathLib;
988 lbfh->filspc = DirLib;
989 lbfh->relfil = (char *) new (strlen(ModName) + 1);
990 strcpy(lbfh->relfil, ModName);
991 /*Library embedded file, so lbfh->offset must be >=0*/
992 lbfh->offset = IndexOffset+FileOffset;
994 /*Jump to where the .rel begins and load it.*/
995 fseek(libfp, lbfh->offset, SEEK_SET);
996 LoadRel(PathLib, libfp, ModName);
998 return 1; /*Found the symbol, so success!*/
1004 return 0; /*It should never reach this point, but just in case...*/
1009 return 0; /*The symbol is not in this library*/
1017 struct lbname *lbnh;
1018 struct lbfile *lbfh, *lbf;
1019 char relfil[NINPUT+2];
1021 char symname[NINPUT];
1027 * Search through every library in the linked list "lbnhead".
1030 /*1*/ for (lbnh=lbnhead; lbnh; lbnh=lbnh->next) {
1031 if ((libfp = fopen(lbnh->libspc, "r")) == NULL) {
1032 fprintf(stderr, "Cannot open library file %s\n",
1039 * Read in a line from the library file.
1040 * This is the relative file specification
1041 * for a .REL file in this library.
1044 /*2*/ while (fgets(relfil, NINPUT, libfp) != NULL) {
1045 relfil[NINPUT+1] = '\0';
1048 str = (char *) new (strlen(path)+strlen(relfil)+6);
1053 if (str[strlen(str)-1] != '/') {
1056 if (str[strlen(str)-1] != '\\') {
1060 if (str[strlen(str)-1] != '\\') {
1066 str = (char *) new (strlen(relfil) + 5);
1069 /*See if this is a library with embedded files*/
1070 if(strcmp(relfil, "<SDCCLIB>")==0)
1072 result=SdccLib(lbnh->libspc, libfp, str, name);
1073 if(result) return(1); /*Found the symbol*/
1075 /*The symbol is not in the current library,
1076 check the next library in the list*/
1080 /*From here down is the support for libraries in the original format*/
1083 if (relfil[0] == '/') {
1085 if (relfil[0] == '\\') {
1088 if (relfil[0] == '\\') {
1090 strcat(str,relfil+1);
1094 if(strchr(relfil, FSEPX) == NULL)
1096 sprintf(&str[strlen(str)], "%c%s", FSEPX, LKOBJEXT);
1099 /*3*/ if ((fp = fopen(str, "r")) != NULL) {
1102 * Read in the object file. Look for lines that
1103 * begin with "S" and end with "D". These are
1104 * symbol table definitions. If we find one, see
1105 * if it is our symbol. Make sure we only read in
1106 * our object file and don't go into the next one.
1109 /*4*/ while (fgets(buf, NINPUT, fp) != NULL) {
1111 buf[NINPUT+1] = '\0';
1112 buf[strlen(buf) - 1] = '\0';
1115 * Skip everything that's not a symbol record.
1121 * When a 'T line' is found terminate file scan.
1122 * All 'S line's preceed 'T line's in .REL files.
1127 sscanf(buf, "S %s %c", symname, &c);
1130 * If we find a symbol definition for the
1131 * symbol we're looking for, load in the
1132 * file and add it to lbfhead so it gets
1133 * loaded on pass number 2.
1135 /*5*/ if (strncmp(symname, name, NCPS) == 0 && c == 'D') {
1137 lbfh = (struct lbfile *) new (sizeof(struct lbfile));
1138 if (lbfhead == NULL) {
1146 lbfh->libspc = lbnh->libspc;
1148 lbfh->relfil = (char *) new (strlen(relfil) + 1);
1149 lbfh->offset = -1; /*Stand alone rel file*/
1150 strcpy(lbfh->relfil,relfil);
1168 #endif /* INDEXLIB */
1170 void loadfile_SdccLib(char * libspc, char * module, long offset)
1175 char posix_path[PATH_MAX];
1176 void cygwin_conv_to_full_posix_path(char * win_path, char * posix_path);
1177 cygwin_conv_to_full_posix_path(libspc, posix_path);
1178 fp = fopen(posix_path, "r");
1180 fp = fopen(libspc,"r");
1185 fseek(fp, offset, SEEK_SET);
1186 LoadRel(libspc, fp, module);
1191 fprintf(stderr, "?Aslink-Error-Opening library '%s'\n", libspc);
1196 /*)Function VOID library()
1198 * The function library() links all the library object files
1199 * contained in the lbfile structures.
1202 * lbfile *lbfh pointer to lbfile structure
1205 * lbfile *lbfhead pointer to first lbfile structure
1208 * VOID loadfile lklibr.c
1211 * Links all files contained in the lbfile structures.
1217 struct lbfile *lbfh;
1219 for (lbfh=lbfhead; lbfh; lbfh=lbfh->next)
1223 /*Stand alone rel file (original lib format)*/
1224 loadfile(lbfh->filspc);
1228 /*rel file embedded in lib (new lib format)*/
1229 loadfile_SdccLib(lbfh->libspc, lbfh->relfil, lbfh->offset);
1237 /*)Function VOID loadfile(filspc)
1239 * char *filspc library object file specification
1241 * The function loadfile() links the library object module.
1244 * FILE *fp file handle
1245 * int i input line length
1246 * char str[] file input line
1249 * char *ip pointer to linker input string
1252 * int fclose() c_library
1253 * int fgets() c_library
1254 * FILE * fopen() c_library
1255 * VOID link() lkmain.c
1256 * int strlen() c_library
1259 * If file exists it is linked.
1271 char posix_path[PATH_MAX];
1272 void cygwin_conv_to_full_posix_path(char * win_path, char * posix_path);
1273 cygwin_conv_to_full_posix_path(filspc, posix_path);
1274 fp = fopen(posix_path, "r");
1276 fp = fopen(filspc,"r");
1281 while (fgets(str, NINPUT, fp) != NULL)
1283 str[NINPUT+1] = '\0';
1284 i = strlen(str) - 1;
1294 fprintf(stderr, "?Aslink-Error-Opening library '%s'\n", filspc);