4 * (C) Copyright 1989-1995
11 * With contributions for the
12 * object libraries from
14 * kenh@cmf.nrl.navy.mil
19 * Extensions: P. Felber
36 /* buildlibraryindex - build an in-memory cache of the symbols contained in
40 buildlibraryindex_lib (struct lbname *lbnh, FILE * libfp, pmlibraryfile This, int type)
44 while (getline (relfil, sizeof (relfil), libfp) != NULL)
49 if (lbnh->path != NULL)
51 strcpy (str, lbnh->path);
53 if ((*str != '\0') && (str[strlen (str) - 1] != '/') && (str[strlen (str) - 1] != LKDIRSEP))
55 strcat (str, LKDIRSEPSTR);
62 if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP))
64 strcat (str, relfil + 1);
71 if (strchr (relfil, FSEPX) == NULL)
73 sprintf (&str[strlen (str)], "%c%s", FSEPX, LKOBJEXT);
76 if ((fp = fopen (str, "rb")) != NULL)
78 /* Opened OK - create a new libraryfile object for it */
81 libr = This = (pmlibraryfile) new (sizeof (mlibraryfile));
85 This->next = (pmlibraryfile) new (sizeof (mlibraryfile));
90 This->libspc = lbnh->libspc;
91 This->relfil = strdup (relfil);
92 This->filename = strdup (str);
95 /* Start a new linked list of symbols for this module: */
98 add_rel_index (fp, -1, This);
100 } /* Closes if object file opened OK */
103 fprintf (stderr, "?ASlink-Warning-Cannot open library module %s\n", str);
105 } /* Ends while - processing all in libr */
113 fndsym_lib (const char *name, struct lbname *lbnh, FILE * libfp, int type)
117 while (getline (relfil, sizeof (relfil), libfp) != NULL)
122 if (lbnh->path != NULL)
124 strcpy (str, lbnh->path);
126 if ((*str != '\0') && (str[strlen (str) - 1] != '/') && (str[strlen (str) - 1] != LKDIRSEP))
128 strcat (str, LKDIRSEPSTR);
135 if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP))
137 strcat (str, relfil + 1);
141 strcat (str, relfil);
144 if (strchr (relfil, FSEPX) == NULL)
146 sprintf (&str[strlen (str)], "%c%s", FSEPX, LKOBJEXT);
149 if ((fp = fopen (str, "rb")) != NULL)
151 /* Opened OK - create a new libraryfile object for it */
152 int ret = add_rel_file (name, lbnh, relfil, str, -1, fp, -1, type);
156 /* if cdb information required & adb file present */
159 FILE *xfp = afile (str, "adb", 0); //JCF: Nov 30, 2002
162 SaveLinkedFilePath (str);
167 return 1; /* Found the symbol, so success! */
169 } /* Closes if object file opened OK */
172 fprintf (stderr, "?ASlink-Warning-Cannot open library module %s\n", str);
174 } /* Ends while - processing all in libr */
176 return 0; /* The symbol is not in this library */
180 /*)Function VOID loadfile_lib(filspc)
182 * char *filspc library object file specification
184 * The function loadfile() links the library object module.
187 * FILE *fp file handle
188 * int i input line length
189 * char str[] file input line
192 * char *ip pointer to linker input string
195 * int fclose() c_library
196 * char *getline() getline.c
197 * FILE * fopen() c_library
198 * VOID link_main() lkmain.c
199 * int strlen() c_library
202 * If file exists it is linked.
206 loadfile_lib (struct lbfile *lbfh)
210 char posix_path[PATH_MAX];
211 void cygwin_conv_to_full_posix_path (char *win_path, char *posix_path);
212 cygwin_conv_to_full_posix_path (lbfh->filspc, posix_path);
213 fp = fopen (posix_path, "rb");
215 fp = fopen (lbfh->filspc, "rb");
225 fprintf (stderr, "?ASlink-Error-Opening library '%s'\n", lbfh->filspc);
231 struct aslib_target aslib_target_lib = {
234 &buildlibraryindex_lib,