3 Copyright (C) 1989-1995 Alan R. Baldwin
4 721 Berkeley St., Kent, Ohio 44240
5 Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3, or (at your option) any
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 * With contributions for the
22 * object libraries from
24 * kenh@cmf.nrl.navy.mil
29 * Extensions: P. Felber
46 /* buildlibraryindex - build an in-memory cache of the symbols contained in
50 buildlibraryindex_lib (struct lbname *lbnh, FILE * libfp, pmlibraryfile This, int type)
54 while (getline (relfil, sizeof (relfil), libfp) != NULL)
59 if (lbnh->path != NULL)
61 strcpy (str, lbnh->path);
63 if ((*str != '\0') && (str[strlen (str) - 1] != '/') && (str[strlen (str) - 1] != LKDIRSEP))
65 strcat (str, LKDIRSEPSTR);
72 if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP))
74 strcat (str, relfil + 1);
81 if (strchr (relfil, FSEPX) == NULL)
83 sprintf (&str[strlen (str)], "%c%s", FSEPX, LKOBJEXT);
86 if ((fp = fopen (str, "rb")) != NULL)
88 /* Opened OK - create a new libraryfile object for it */
91 libr = This = (pmlibraryfile) new (sizeof (mlibraryfile));
95 This->next = (pmlibraryfile) new (sizeof (mlibraryfile));
100 This->libspc = lbnh->libspc;
101 This->relfil = strdup (relfil);
102 This->filspc = strdup (str);
105 /* Start a new linked list of symbols for this module: */
106 This->symbols = NULL;
108 add_rel_index (fp, -1, This);
110 } /* Closes if object file opened OK */
113 fprintf (stderr, "?ASlink-Warning-Cannot open library module %s\n", str);
115 } /* Ends while - processing all in libr */
123 fndsym_lib (const char *name, struct lbname *lbnh, FILE * libfp, int type)
127 D ("Searching symbol: %s\n", name);
129 while (getline (relfil, sizeof (relfil), libfp) != NULL)
134 if (lbnh->path != NULL)
136 strcpy (str, lbnh->path);
138 if ((*str != '\0') && (str[strlen (str) - 1] != '/') && (str[strlen (str) - 1] != LKDIRSEP))
140 strcat (str, LKDIRSEPSTR);
147 if ((relfil[0] == '/') || (relfil[0] == LKDIRSEP))
149 strcat (str, relfil + 1);
153 strcat (str, relfil);
156 if (strchr (relfil, FSEPX) == NULL)
158 sprintf (&str[strlen (str)], "%c%s", FSEPX, LKOBJEXT);
161 if ((fp = fopen (str, "rb")) != NULL)
163 /* Opened OK - create a new libraryfile object for it */
164 int ret = add_rel_file (name, lbnh, relfil, str, -1, fp, -1, type);
168 D ("Loaded module %s from file %s.\n", str, str);
169 /* if cdb information required & adb file present */
172 FILE *xfp = afile (str, "adb", 0); //JCF: Nov 30, 2002
175 SaveLinkedFilePath (str);
180 return 1; /* Found the symbol, so success! */
182 } /* Closes if object file opened OK */
185 fprintf (stderr, "?ASlink-Warning-Cannot open library module %s\n", str);
187 } /* Ends while - processing all in libr */
189 return 0; /* The symbol is not in this library */
193 /*)Function VOID loadfile_lib(filspc)
195 * char *filspc library object file specification
197 * The function loadfile() links the library object module.
200 * FILE *fp file handle
201 * int i input line length
202 * char str[] file input line
205 * char *ip pointer to linker input string
208 * int fclose() c_library
209 * char *getline() getline.c
210 * FILE * fopen() c_library
211 * VOID link_main() lkmain.c
212 * int strlen() c_library
215 * If file exists it is linked.
219 loadfile_lib (struct lbfile *lbfh)
223 char posix_path[PATH_MAX];
224 void cygwin_conv_to_full_posix_path (char *win_path, char *posix_path);
225 cygwin_conv_to_full_posix_path (lbfh->filspc, posix_path);
226 fp = fopen (posix_path, "rb");
228 fp = fopen (lbfh->filspc, "rb");
238 fprintf (stderr, "?ASlink-Error-Opening library '%s'\n", lbfh->filspc);
244 struct aslib_target aslib_target_lib = {
247 &buildlibraryindex_lib,