fixed bug #
2484677: Linker hangs
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5328
4a8a32a2-be11-0410-ad9d-
d568d2c75423
* .version, doc/sdccman.lyx: bumped sdcc version to 2.8.6
due changes in sdcc asxxxx linkers - it sholud be done 2 days ago :(
* doc/README.txt: updated John Hartman's e-mail address
* .version, doc/sdccman.lyx: bumped sdcc version to 2.8.6
due changes in sdcc asxxxx linkers - it sholud be done 2 days ago :(
* doc/README.txt: updated John Hartman's e-mail address
+ * as/link/lkrel.c, as/link/lksdcclib.c:
+ fixed bug #2484677: Linker hangs
2009-01-04 Philipp Klaus Krause <pkk AT spth.de>
2009-01-04 Philipp Klaus Krause <pkk AT spth.de>
2008-11-06 Borut Razem <borut.razem AT siol.net>
2008-11-06 Borut Razem <borut.razem AT siol.net>
- * src/SDCCmain.c: #fixed bug 2224960: sdcc -MM no working correctly
+ * src/SDCCmain.c: fixed bug #2224960: sdcc -MM no working correctly
pass system include paths with -isystem to sdcpp
* src/SDCCglue.c, src/pic/glue.c, src/pic16/glue.c: removed unneeded
functions (closePipes), (closeTmpFiles) and (rmTmpFiles)
pass system include paths with -isystem to sdcpp
* src/SDCCglue.c, src/pic/glue.c, src/pic16/glue.c: removed unneeded
functions (closePipes), (closeTmpFiles) and (rmTmpFiles)
+/*
+ * Extensions: P. Felber
+ */
+
#include <string.h>
#include <assert.h>
#include <string.h>
#include <assert.h>
-/* Load a .rel file embedded in a sdcclib file */
+/* Load a standalone or embedded .rel */
int
load_rel (FILE * libfp, long size)
{
int
load_rel (FILE * libfp, long size)
{
char str[NINPUT];
long end;
char str[NINPUT];
long end;
- if (size >= 0)
- end = ftell (libfp) + size;
- else
- end = -1;
+ end = (size >= 0) ? ftell (libfp) + size : -1;
while ((end < 0 || ftell (libfp) < end) && getline (str, sizeof (str), libfp) != NULL)
{
while ((end < 0 || ftell (libfp) < end) && getline (str, sizeof (str), libfp) != NULL)
{
}
/* Load a .rel file embedded in a sdcclib file */
}
/* Load a .rel file embedded in a sdcclib file */
LoadRel (char *libfname, FILE * libfp, char *ModName)
{
char str[NINPUT];
LoadRel (char *libfname, FILE * libfp, char *ModName)
{
char str[NINPUT];
case 0:
if (EQ (str, "<FILE>"))
{
case 0:
if (EQ (str, "<FILE>"))
{
- getline (str, sizeof (str), libfp);
- if (EQ (str, ModName))
+ if (NULL != getline (str, sizeof (str), libfp) && EQ (str, ModName))
- {
- fprintf (stderr, "?ASlink-Error-Bad offset in library file %s(%s)\n", libfname, ModName);
- lkexit (1);
- }
- if (EQ (str, "<REL>"))
- state = 2;
- break;
- case 2:
- load_rel (libfp, -1);
- break;
+ return EQ (str, "<REL>") ? load_rel (libfp, -1) : 0;
if (EQ (FLine, "<MODULE>"))
{
/* The next line has the name of the module and the offset
if (EQ (FLine, "<MODULE>"))
{
/* The next line has the name of the module and the offset
return This; /* Finish, get out of here */
}
break;
return This; /* Finish, get out of here */
}
break;
if (EQ (FLine, "</MODULE>"))
{
This->loaded = 0;
if (EQ (FLine, "</MODULE>"))
{
This->loaded = 0;
{
char str[MAXLINE];
int state = 0;
{
char str[MAXLINE];
int state = 0;
while (getline (str, sizeof (str), libfp) != NULL)
{
while (getline (str, sizeof (str), libfp) != NULL)
{
if (EQ (str, "<ADB>"))
state = 1;
break;
if (EQ (str, "<ADB>"))
state = 1;
break;
case 1:
if (EQ (str, "</ADB>"))
case 1:
if (EQ (str, "</ADB>"))
fprintf (dfp, "%s\n", str);
fprintf (dfp, "%s\n", str);
}
/* 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
if (EQ (FLine, "<MODULE>"))
{
/* The next line has the name of the module and the offset
if (EQ (FLine, "<MODULE>"))
{
/* The next line has the name of the module and the offset
if (EQ (FLine, "</MODULE>"))
{
/* The symbol is not in this module, try the next one */
if (EQ (FLine, "</MODULE>"))
{
/* The symbol is not in this module, try the next one */
/* Jump to where the .rel begins and load it. */
fseek (libfp, lbfh->offset, SEEK_SET);
/* Jump to where the .rel begins and load it. */
fseek (libfp, lbfh->offset, SEEK_SET);
- LoadRel (lbnh->libspc, libfp, ModName);
-
+ if (!LoadRel (lbnh->libspc, libfp, ModName))
+ {
+ fclose (libfp);
+ fprintf (stderr, "?ASlink-Error-Bad offset in library file %s(%s)\n", lbfh->libspc, ModName);
+ lkexit (1);
+ }
/* if cdb information required & .adb file present */
if (dflag && dfp)
{
/* if cdb information required & .adb file present */
if (dflag && dfp)
{
loadfile_sdcclib (struct lbfile *lbfh)
{
FILE *fp;
loadfile_sdcclib (struct lbfile *lbfh)
{
FILE *fp;
#ifdef __CYGWIN__
char posix_path[PATH_MAX];
void cygwin_conv_to_full_posix_path (char *win_path, char *posix_path);
#ifdef __CYGWIN__
char posix_path[PATH_MAX];
void cygwin_conv_to_full_posix_path (char *win_path, char *posix_path);
if (fp != NULL)
{
fseek (fp, lbfh->offset, SEEK_SET);
if (fp != NULL)
{
fseek (fp, lbfh->offset, SEEK_SET);
- LoadRel (lbfh->libspc, fp, lbfh->relfil);
+ res = LoadRel (lbfh->libspc, fp, lbfh->relfil);
+
+ if (!res)
+ {
+ fprintf (stderr, "?ASlink-Error-Bad offset in library file %s(%s)\n", lbfh->libspc, lbfh->relfil);
+ lkexit (1);
+ }
}
else
{
fprintf (stderr, "?ASlink-Error-Opening library '%s'\n", lbfh->libspc);
}
else
{
fprintf (stderr, "?ASlink-Error-Opening library '%s'\n", lbfh->libspc);