From 1f5eb81a621295b45fa5ca82aaf94449abb27098 Mon Sep 17 00:00:00 2001 From: borutr Date: Fri, 9 Jan 2009 23:04:14 +0000 Subject: [PATCH] * as/asranlib/Makefile.in, as/asranlib/asranlib.dsp, as/asranlib/asranlib.c: added asranlib * as/link/lkar.c, as/link/lkar.h: added support for ar format libraries * Makefile.in, as/link/hc08/Makefile.in, as/link/hc08/link_hc08.dsp, as/link/lklib.c, as/link/lklibr.c, as/link/lklibr.h, as/link/lkrel.c, as/link/lkrel.h, as/link/lksdcclib.c, as/link/mcs51/Makefile.in, as/link/mcs51/aslink.dsp, as/link/z80/Makefile.in, as/link/z80/linkgbz80.dsp, as/link/z80/linkz80.dsp, configure, configure.in, sdcc.dsw: modified to support ar format libraries git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5336 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 15 +- Makefile.in | 32 +- as/asranlib/Makefile.in | 67 ++++ as/asranlib/asranlib.c | 442 +++++++++++++++++++++++++ as/asranlib/asranlib.dsp | 132 ++++++++ as/link/hc08/Makefile.in | 2 +- as/link/hc08/link_hc08.dsp | 8 + as/link/lkar.c | 642 +++++++++++++++++++++++++++++++++++++ as/link/lkar.h | 86 +++++ as/link/lklib.c | 32 +- as/link/lklibr.c | 124 ++++--- as/link/lklibr.h | 44 ++- as/link/lkrel.c | 73 +++-- as/link/lkrel.h | 33 +- as/link/lksdcclib.c | 72 +++-- as/link/mcs51/Makefile.in | 2 +- as/link/mcs51/aslink.dsp | 8 + as/link/z80/Makefile.in | 2 +- as/link/z80/linkgbz80.dsp | 8 + as/link/z80/linkz80.dsp | 8 + configure | 3 +- configure.in | 1 + sdcc.dsw | 82 +++-- 23 files changed, 1735 insertions(+), 183 deletions(-) create mode 100644 as/asranlib/Makefile.in create mode 100644 as/asranlib/asranlib.c create mode 100644 as/asranlib/asranlib.dsp create mode 100644 as/link/lkar.c create mode 100644 as/link/lkar.h diff --git a/ChangeLog b/ChangeLog index 9dc2e5c1..1f62ac88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-01-08 Borut Razem + + * as/asranlib/Makefile.in, as/asranlib/asranlib.dsp, + as/asranlib/asranlib.c: added asranlib + * as/link/lkar.c, as/link/lkar.h: added support for ar format libraries + * Makefile.in, as/link/hc08/Makefile.in, + as/link/hc08/link_hc08.dsp, as/link/lklib.c, as/link/lklibr.c, + as/link/lklibr.h, as/link/lkrel.c, as/link/lkrel.h, + as/link/lksdcclib.c, as/link/mcs51/Makefile.in, + as/link/mcs51/aslink.dsp, as/link/z80/Makefile.in, + as/link/z80/linkgbz80.dsp, as/link/z80/linkz80.dsp, configure, + configure.in, sdcc.dsw: modified to support ar format libraries + 2009-01-08 Maarten Brock * src/SDCCast.c (decorateType RETURN): use RESULT_TYPE_GPTR for generic @@ -6,7 +19,7 @@ 2009-01-05 Philipp Klaus Krause * sim/ucsim/z80.src/inst_ed.cc: - Fixed bug #2488074, which made regression tests fail. + Fixed bug #2488074, which made regression tests fail. 2009-01-05 Philipp Klaus Krause diff --git a/Makefile.in b/Makefile.in index 0cf60ef7..b6884fd1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ # # -SHELL = /bin/sh +SHELL = /bin/sh VPATH = @srcdir@ srcdir = @srcdir@ @@ -11,14 +11,17 @@ top_srcdir = @top_srcdir@ include Makefile.common -SDCC_LIBS = support/makebin +SDCC_LIBS = support/makebin SDCC_DOC = doc # Parts that are not normally compiled but need to be cleaned SDCC_EXTRA = support/regression support/valdiag -SDCC_PACKIHX = support/packihx -SDCC_LIBRARIAN = support/librarian +SDCC_PACKIHX = support/packihx +SDCC_LIBRARIAN = support/librarian +SDCC_ASRANLIB = as/asranlib + +TARGETS = sdcc-librarian sdcc-asranlib ifeq ($(OPT_DISABLE_HC08), 0) SDCC_ASLINK += as/hc08 as/link/hc08 @@ -26,7 +29,7 @@ endif ifeq ($(OPT_DISABLE_MCS51), 0) SDCC_ASLINK += as/mcs51 as/link/mcs51 -SDCC_MISC += debugger/mcs51 +SDCC_MISC += debugger/mcs51 endif ifeq ($(OPT_DISABLE_Z80), 0) @@ -59,14 +62,14 @@ ifeq ($(OPT_DISABLE_SDCPP), 0) SDCC_LIBS += support/cpp endif -TARGETS += sdcc-libs sdcc-cc sdcc-device-inc sdcc-aslink sdcc-librarian +TARGETS += sdcc-libs sdcc-cc sdcc-device-inc sdcc-aslink -PKGS += $(SDCC_LIBS) src device/include $(SDCC_ASLINK) $(SDCC_LIBRARIAN) +PKGS += $(SDCC_LIBS) src device/include $(SDCC_ASLINK) $(SDCC_LIBRARIAN) -PKGS_TINI = $(SDCC_LIBS) $(SDCC_ASLINK) \ - src device/include $(SDCC_PACKIHX) $(SDCC_LIBRARIAN) -PORTS = $(shell cat ports.build) -ALLPORTS = $(shell cat ports.all) +PKGS_TINI = $(SDCC_LIBS) $(SDCC_ASLINK) \ + src device/include $(SDCC_PACKIHX) $(SDCC_LIBRARIAN) +PORTS = $(shell cat ports.build) +ALLPORTS = $(shell cat ports.all) # Compiling entire program or any subproject # ------------------------------------------ @@ -92,11 +95,14 @@ sdcc-packihx: sdcc-librarian: $(MAKE) -C $(SDCC_LIBRARIAN) +sdcc-asranlib: + $(MAKE) -C $(SDCC_ASRANLIB) + sdcc-device-inc: $(MAKE) -C device/include sdcc-device-lib: sdcc-cc sdcc-aslink - $(MAKE) -C device/lib + $(MAKE) -C device/lib LIB_TYPE=SDCCLIB sdcc-device-tini: $(MAKE) -C device/include @@ -108,7 +114,7 @@ sdcc-doc: sdcc: $(TARGETS) -sdcc-tini: sdcc-cc sdcc-aslink sdcc-device-tini sdcc-packihx sdcc-librarian +sdcc-tini: sdcc-librarian sdcc-asranlib sdcc-cc sdcc-aslink sdcc-device-tini sdcc-packihx $(MAKE) -f main.mk all # Some interesting sub rules diff --git a/as/asranlib/Makefile.in b/as/asranlib/Makefile.in new file mode 100644 index 00000000..5889a67f --- /dev/null +++ b/as/asranlib/Makefile.in @@ -0,0 +1,67 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ +top_builddir = @top_builddir@ + +include $(top_builddir)/Makefile.common + +CFLAGS += -Wall -I$(srcdir)/../link + +OBJECTS = asranlib.o + +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) + +TARGET = $(top_builddir)/bin/asranlib$(EXEEXT) + +all: $(TARGET) + +install: all installdirs + $(INSTALL) $(TARGET) `echo $(DESTDIR)$(bindir)/asranlib$(EXEEXT)|sed '$(transform)'` + $(STRIP) `echo $(DESTDIR)$(bindir)/asranlib$(EXEEXT)|sed '$(transform)'` + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(DESTDIR)$(bindir)/asranlib$(EXEEXT) + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(DESTDIR)$(bindir) + + +# Creating dependencies +# --------------------- +dep: + +$(TARGET): $(OBJECTS) dbuf.o dbuf_string.o + $(CC) $(LDFLAGS) -o $@ $(OBJECTS) dbuf.o dbuf_string.o + +dbuf.o: $(srcdir)/../../support/Util/dbuf.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +dbuf_string.o: $(srcdir)/../../support/Util/dbuf_string.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + + +checkconf: + +clean: + rm -f *core *[%~] *.[oa] *.output + rm -f .[a-z]*~ \#* + rm -f $(top_builddir)/bin/asranlib$(EXEEXT) + +distclean realclean: clean + rm -f Makefile diff --git a/as/asranlib/asranlib.c b/as/asranlib/asranlib.c new file mode 100644 index 00000000..01977beb --- /dev/null +++ b/as/asranlib/asranlib.c @@ -0,0 +1,442 @@ +/* asranlib.c - ranlib for asxxxx arvhives + version 1.0.0, April 27th, 2008 + + Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include "dbuf_string.h" +#include "lkar.h" + +#ifdef _WIN32 +#include +#define mktemp _mktemp +#endif + +#define NELEM(x) (sizeof (x) / sizeof (*x)) + + +int +is_ar (FILE * libfp) +{ + char buf[SARMAG]; + int ret; + + if (!(ret = fread (buf, 1, sizeof (buf), libfp) == sizeof (buf) && memcmp (buf, ARMAG, SARMAG) == 0)) + rewind (libfp); + + return ret; +} + +static struct ar_hdr * +ar_get_header (struct ar_hdr *hdr, FILE * libfp) +{ + char header[ARHDR_LEN]; + char buf[AR_DATE_LEN + 1]; + + if (fread (header, 1, sizeof (header), libfp) != sizeof (header) || + memcmp (header + AR_FMAG_OFFSET, ARFMAG, AR_FMAG_LEN) != 0) + { + /* not an ar archive */ + return NULL; + } + + memcpy (hdr->ar_name, &header[AR_NAME_OFFSET], AR_NAME_LEN); + hdr->ar_name[AR_NAME_LEN] = '\0'; + + memcpy (buf, &header[AR_DATE_OFFSET], AR_DATE_LEN); + buf[AR_DATE_LEN] = '\0'; + hdr->ar_date = strtol (buf, NULL, 0); + + memcpy (buf, &header[AR_UID_OFFSET], AR_GID_LEN); + buf[AR_GID_LEN] = '\0'; + hdr->ar_uid = (uid_t) strtol (buf, NULL, 0); + + memcpy (buf, &header[AR_GID_OFFSET], AR_DATE_LEN); + buf[AR_DATE_LEN] = '\0'; + hdr->ar_gid = (gid_t) strtol (buf, NULL, 0); + + memcpy (buf, &header[AR_MODE_OFFSET], AR_MODE_LEN); + buf[AR_MODE_LEN] = '\0'; + hdr->ar_mode = (mode_t) strtoul (buf, NULL, 0); + + memcpy (buf, &header[AR_SIZE_OFFSET], AR_SIZE_LEN); + buf[AR_SIZE_LEN] = '\0'; + hdr->ar_size = strtol (buf, NULL, 0); + + return hdr; +} + + +struct symbol_s + { + const char *name; + off_t offset; + struct symbol_s *next; + }; + +struct symbol_s *symlist, *lastsym; +off_t offset, first_member_offset; + +int +add_symbol (const char *sym, void *param) +{ + struct symbol_s *s; + + if ((s = (struct symbol_s *) malloc (sizeof (struct symbol_s))) == NULL) + return 0; + + s->name = strdup (sym); + s->offset = offset - first_member_offset; + s->next = NULL; + + if (NULL == symlist) + { + lastsym = symlist = s; + } + else + { + lastsym->next = s; + lastsym = s; + } + + return 0; +} + + +int +is_rel (FILE * libfp) +{ + int c; + long pos = ftell (libfp); + int ret = 0; + + /* [XDQ][HL] */ + if (((c = getc (libfp)) == 'X' || c == 'D' || c == 'Q') && ((c = getc (libfp)) == 'H' || c == 'L')) + { + switch (getc (libfp)) + { + case '\r': + if (getc (libfp) == '\n') + ret = 1; + break; + + case '\n': + ret = 1; + } + } + else if (c == ';') + { + char buf[6]; + + if (fread (buf, 1, sizeof (buf), libfp) == sizeof (buf) && memcmp (buf, "!FILE ", 6) == 0) + ret = 1; + } + fseek (libfp, pos, SEEK_SET); + return ret; +} + +int +enum_symbols (FILE * fp, long size, int (*func) (const char *sym, void *param), void *param) +{ + long end; + struct dbuf_s buf; + struct dbuf_s symname; + + assert (func != NULL); + + dbuf_init (&buf, 512); + dbuf_init (&symname, 32); + + end = (size >= 0) ? ftell (fp) + size : -1; + + /* + * Read in the object file. Look for lines that + * begin with "S" and end with "D". These are + * symbol table definitions. If we find one, see + * if it is our symbol. Make sure we only read in + * our object file and don't go into the next one. + */ + + while (end < 0 || ftell (fp) < end) + { + const char *p; + + dbuf_set_length (&buf, 0); + if (dbuf_getline (&buf, fp) == 0) + break; + + p = dbuf_c_str (&buf); + + if ('T' == p[0]) + break; + + /* + * Skip everything that's not a symbol record. + */ + if ('S' == p[0] && ' ' == p[1]) + { + dbuf_set_length (&symname, 0); + + for (p += 2; *p && ' ' != *p; ++p) + dbuf_append_char (&symname, *p); + + /* If it's an actual symbol, record it */ + if (' ' == p[0] && 'D' == p[1]) + if (func != NULL) + if ((*func) (dbuf_c_str (&symname), NULL)) + return 1; + } + } + + dbuf_destroy (&buf); + dbuf_destroy (&symname); + + return 0; +} + +int +get_symbols (FILE * fp, const char *archive) +{ + struct ar_hdr hdr; + + if (!is_ar (fp) || !ar_get_header (&hdr, fp)) + { + fprintf (stderr, "asranlib: %s: File format not recognized\n", archive); + exit (1); + } + + if (AR_IS_SYMBOL_TABLE (hdr)) + { + /* skip the symbol table */ + fseek (fp, hdr.ar_size + (hdr.ar_size & 1), SEEK_CUR); + } + + first_member_offset = ftell (fp) - ARHDR_LEN; + + /* walk trough all archive members */ + do + { + if (is_rel (fp)) + { + long mdule_offset = ftell (fp); + + offset = mdule_offset - ARHDR_LEN; + + enum_symbols (fp, hdr.ar_size, add_symbol, NULL); + + fseek (fp, mdule_offset + hdr.ar_size, SEEK_SET); + + if (hdr.ar_size & 1) + { + int c = getc (fp); + assert (c == EOF || c == '\n'); + } + } + else + { + /* skip if the member is not a .REL format */ + fseek (fp, hdr.ar_size + (hdr.ar_size & 1), SEEK_CUR); + } + } + while (ar_get_header (&hdr, fp)); + + return 1; +} + + +void +do_ranlib (const char *archive) +{ + FILE *infp; + + if (NULL == (infp = fopen (archive, "rb"))) + { + fprintf (stderr, "asranlib: %s: ", archive); + perror (NULL); + exit (1); + } + + if (get_symbols (infp, archive)) + { + FILE *outfp = NULL; + struct symbol_s *symp; + char buf[4]; + int str_length = 0; + int pad = 0; + int nsym; + int symtab_size; + char tmpfile[] = "arXXXXXX"; + + if (NULL == mktemp (tmpfile) || NULL == (outfp = fopen (tmpfile, "wb"))) + { + fclose (infp); + fprintf (stderr, "asranlib: %s: ", tmpfile); + perror (NULL); + exit (1); + } + + /* calculate the size of symbol table */ + for (nsym = 0, symp = symlist; symp; ++nsym, symp = symp->next) + { + str_length += strlen (symp->name) + 1; + } + + symtab_size = 4 + 4 * nsym + str_length; + + fprintf (outfp, ARMAG AR_SYMBOL_TABLE_NAME "%-12d%-6d%-6d%-8d%-10d" ARFMAG, (int) time (NULL), 0, 0, 0, symtab_size); + + if (symtab_size & 1) + { + pad = 1; + ++symtab_size; + } + else + pad = 0; + + symtab_size += SARMAG + ARHDR_LEN; + + sputl (nsym, buf); + fwrite (buf, 1, sizeof (buf), outfp); + + for (symp = symlist; symp; symp = symp->next) + { + sputl (symp->offset + symtab_size, buf); + fwrite (buf, 1, sizeof (buf), outfp); + } + + + for (symp = symlist; symp; symp = symp->next) + { + fputs (symp->name, outfp); + putc ('\0', outfp); + } + + if (pad) + putc ('\n', outfp); + + fseek (infp, first_member_offset, SEEK_SET); + + while (EOF != (pad = getc (infp))) + putc (pad, outfp); + + fclose (outfp); + fclose (infp); + + if (0 != remove (archive)) + { + fprintf (stderr, "asranlib: can't remove %s to %s: ", tmpfile, archive); + perror (NULL); + } + else if (0 != rename (tmpfile, archive)) + { + fprintf (stderr, "asranlib: can't rename %s to %s: ", tmpfile, archive); + perror (NULL); + } + } + else + fclose (infp); +} + + +void +print_version (void) +{ + printf ("SDCC asxxxx ranlib 1.0.0 $Revision$\n"); + exit (0); +} + + +void +usage (void) +{ + printf ("Usage: asranlib [options] archive\n" + " Generate an index to speed access to archives\n" + " The options are:\n" + " -h --help Print this help message\n" + " -V --version Print version information\n" + "asranlib: supported targets: asxxxx\n"); + + exit (1); +} + + +struct opt_s + { + const char *opt; + void (*optfnc) (void); + } +opts[] = + { + { "-v", &print_version, }, + { "-V", &print_version, }, + { "--version", &print_version, }, + { "-h", &usage, }, + { "--help", &usage, }, + }; + + +void +process_options (int argc, char *argv[]) +{ + char **argp; + int noopts = 0; + int narch = 0; + for (argp = argv + 1; *argp; ++argp) + { + if (!noopts && (*argp)[0] == '-') + { + int i; + + if ((*argp)[1] == '-' && (*argp)[2] == '\0') + { + noopts = 1; + continue; + } + + for (i = 0; i < NELEM (opts); ++i) + { + if (0 == strcmp (*argp, opts[i].opt)) + { + if (NULL != opts[i].optfnc) + { + (*opts[i].optfnc) (); + continue; + } + } + } + } + + do_ranlib (*argp); + ++narch; + } + + if (!narch) + usage (); +} + + +int +main (int argc, char *argv[]) +{ + process_options (argc, argv); + + return 0; +} diff --git a/as/asranlib/asranlib.dsp b/as/asranlib/asranlib.dsp new file mode 100644 index 00000000..be1e0b4b --- /dev/null +++ b/as/asranlib/asranlib.dsp @@ -0,0 +1,132 @@ +# Microsoft Developer Studio Project File - Name="asranlib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=asranlib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "asranlib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "asranlib.mak" CFG="asranlib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "asranlib - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "asranlib - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "asranlib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../link" /I "../../support/Util" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x424 /d "NDEBUG" +# ADD RSC /l 0x424 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "asranlib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../link" /I "../../support/Util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x424 /d "_DEBUG" +# ADD RSC /l 0x424 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "asranlib - Win32 Release" +# Name "asranlib - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\asranlib.c +# End Source File +# Begin Source File + +SOURCE=..\..\support\Util\dbuf.c +# End Source File +# Begin Source File + +SOURCE=..\..\support\Util\dbuf_string.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\link\aslink.h +# End Source File +# Begin Source File + +SOURCE=..\link\asxxxx_config.h +# End Source File +# Begin Source File + +SOURCE=..\..\support\Util\dbuf.h +# End Source File +# Begin Source File + +SOURCE=..\..\support\Util\dbuf_string.h +# End Source File +# Begin Source File + +SOURCE=..\link\lkar.h +# End Source File +# Begin Source File + +SOURCE=..\link\lkrel.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/as/link/hc08/Makefile.in b/as/link/hc08/Makefile.in index d2398537..c74d260d 100644 --- a/as/link/hc08/Makefile.in +++ b/as/link/hc08/Makefile.in @@ -46,7 +46,7 @@ LKLIB = $(srcdir)/.. ASXXLIBSRC = strcmpi.c -LKLIBSRC = getline.c lkaomf51.c lkdata.c lkeval.c \ +LKLIBSRC = getline.c lkaomf51.c lkar.c lkdata.c lkeval.c \ lkhead.c lklex.c lklib.c lklibr.c lklist.c \ lknoice.c lkrel.c lksdcclib.c lkstore.c lksym.c diff --git a/as/link/hc08/link_hc08.dsp b/as/link/hc08/link_hc08.dsp index 7a2359ac..1099f614 100644 --- a/as/link/hc08/link_hc08.dsp +++ b/as/link/hc08/link_hc08.dsp @@ -95,6 +95,10 @@ SOURCE=..\lkaomf51.c # End Source File # Begin Source File +SOURCE=..\lkar.c +# End Source File +# Begin Source File + SOURCE=.\lkarea.c # End Source File # Begin Source File @@ -191,6 +195,10 @@ SOURCE=..\getline.h # End Source File # Begin Source File +SOURCE=..\lkar.h +# End Source File +# Begin Source File + SOURCE=..\lklibr.h # End Source File # Begin Source File diff --git a/as/link/lkar.c b/as/link/lkar.c new file mode 100644 index 00000000..6a9cc374 --- /dev/null +++ b/as/link/lkar.c @@ -0,0 +1,642 @@ +/* lkar.c - ar library format handling + + Copyright (C) 1989-1995 Alan R. Baldwin + 721 Berkeley St., Kent, Ohio 44240 + Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* + * With contributions for the + * object libraries from + * Ken Hornstein + * kenh@cmf.nrl.navy.mil + * + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include +#include + +#include "aslink.h" +#include "lklibr.h" +#include "lkrel.h" +#include "lkar.h" + + +#ifndef max +# define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef min +# define min(a,b) ((a) < (b) ? (a) : (b)) +#endif + + +static int +is_ar (FILE * libfp) +{ + char buf[SARMAG]; + int ret; + + if (!(ret = fread (buf, 1, sizeof (buf), libfp) == sizeof (buf) && memcmp (buf, ARMAG, SARMAG) == 0)) + rewind (libfp); + + return ret; +} + +static struct ar_hdr * +ar_get_header (struct ar_hdr *hdr, FILE * libfp) +{ + char header[ARHDR_LEN]; + char buf[AR_DATE_LEN + 1]; + + if (fread (header, 1, sizeof (header), libfp) != sizeof (header) + || memcmp (header + AR_FMAG_OFFSET, ARFMAG, AR_FMAG_LEN) != 0) + { + /* not an ar archive */ + return NULL; + } + + memcpy (hdr->ar_name, &header[AR_NAME_OFFSET], AR_NAME_LEN); + hdr->ar_name[AR_NAME_LEN] = '\0'; + + memcpy (buf, &header[AR_DATE_OFFSET], AR_DATE_LEN); + buf[AR_DATE_LEN] = '\0'; + hdr->ar_date = strtol (buf, NULL, 0); + + memcpy (buf, &header[AR_UID_OFFSET], AR_GID_LEN); + buf[AR_GID_LEN] = '\0'; + hdr->ar_uid = (uid_t) strtol (buf, NULL, 0); + + memcpy (buf, &header[AR_GID_OFFSET], AR_DATE_LEN); + buf[AR_DATE_LEN] = '\0'; + hdr->ar_gid = (gid_t) strtol (buf, NULL, 0); + + memcpy (buf, &header[AR_MODE_OFFSET], AR_MODE_LEN); + buf[AR_MODE_LEN] = '\0'; + hdr->ar_mode = (mode_t) strtoul (buf, NULL, 0); + + memcpy (buf, &header[AR_SIZE_OFFSET], AR_SIZE_LEN); + buf[AR_SIZE_LEN] = '\0'; + hdr->ar_size = strtol (buf, NULL, 0); + + return hdr; +} + +static char *sym_tab; +static int sym_tab_size; + +static void +loadfile_ar (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); + cygwin_conv_to_full_posix_path (lbfh->libspc, posix_path); + fp = fopen (posix_path, "rb"); +#else + fp = fopen (lbfh->libspc, "rb"); +#endif + + if (fp != NULL) + { + struct ar_hdr hdr; + + fseek (fp, lbfh->offset, SEEK_SET); + if (ar_get_header (&hdr, fp)) + { + D ("Loading module %s from file %s.\n", hdr.ar_name, lbfh->libspc); + load_rel (fp, hdr.ar_size); + fclose (fp); + } + else + { + fprintf (stderr, "?ASlink-Error-Bad offset in library file %s(%s)\n", lbfh->libspc, lbfh->relfil); + fclose (fp); + lkexit (1); + } + } + else + { + fprintf (stderr, "?ASlink-Error-Opening library '%s'\n", lbfh->libspc); + lkexit (1); + } +} + +#if INDEXLIB +char * +get_member_name (char *name) +{ + if (name[0] == '/') + { + if (NULL != sym_tab) + { + char *p; + + int name_offset = strtol (++name, &p, 0); + if (p != name && name_offset < sym_tab_size) + { + int len = p - name + 1; + while (len < AR_NAME_LEN && name[len++] == ' ') + ; + if (len == AR_NAME_LEN) + { + char *n; + + /* long name: get it from the symbol table */ + name = &sym_tab[name_offset]; + for (p = name; *p != '/' && *p != '\n'; ++p) + assert (p < &sym_tab[sym_tab_size]); + + if (p[0] != '/' || p[1] != '\n') + while (*++p != '\n') + assert (p < &sym_tab[sym_tab_size]); + + n = (char *) malloc (p - name + 1); + memcpy (n, name, p - name); + n[p - name] = '\0'; + return n; + } + } + } + } + else + { + char *p = strrchr (name, '/'); + + if (NULL != p) + { + int len = p - name; + while (name[++len] == ' ') + ; + if (len == AR_NAME_LEN) + { + char *n = (char *) malloc (p - name + 1); + memcpy (n, name, p - name); + n[p - name] = '\0'; + return n; + } + } + } + + /* bad formed member name: + just return it */ + + return strdup (name); +} + +static char * +get_member_name_by_offset (FILE * fp, long offset) +{ + struct ar_hdr hdr; + + fseek (fp, offset, SEEK_SET); + + /* walk trough all archive members */ + return (NULL != ar_get_header (&hdr, fp)) ? get_member_name (hdr.ar_name) : NULL; +} + +static pmlibraryfile +find_member_by_offset (const char *libspc, long offset) +{ + pmlibraryfile p; + + for (p = libr; p; p = p->next) + { + if (0 == strcmp (libspc, p->libspc) && p->offset == offset) + return p; + } + + return NULL; +} + +static pmlibraryfile +buildlibraryindex_ar (struct lbname *lbnh, FILE * libfp, pmlibraryfile This, int type) +{ + struct ar_hdr hdr; + + /* walk trough all archive members */ + while (ar_get_header (&hdr, libfp)) + { + if (AR_IS_SYMBOL_TABLE (hdr)) + { + char *buf, *po, *ps; + int i; + long nsym; + + buf = (char *) new (hdr.ar_size); + + if ((off_t) fread (buf, 1, hdr.ar_size, libfp) != hdr.ar_size) + { + free (buf); + return This; + } + + nsym = sgetl (buf); + + po = buf + 4; + ps = po + nsym * 4; + + for (i = 0; i < nsym; ++i) + { + pmlibrarysymbol ThisSym; + char *sym; + long offset; + pmlibraryfile entry; + + offset = sgetl (po); + po += 4; + + sym = strdup (ps); + while (*ps++ != '\0') + ; + + if ((entry = find_member_by_offset (lbnh->libspc, offset)) != NULL) + { + for (ThisSym = entry->symbols; ThisSym->next != NULL; ThisSym = ThisSym->next) + ; + } + else + { + /* Opened OK - create a new libraryfile object for it */ + if (This == NULL) + { + assert (libr == NULL); + libr = This = (pmlibraryfile) new (sizeof (mlibraryfile)); + } + else + { + This->next = (pmlibraryfile) new (sizeof (mlibraryfile)); + This = This->next; + } + This->next = NULL; + This->loaded = -1; + This->libspc = lbnh->libspc; + This->offset = offset; + This->relfil = get_member_name_by_offset (libfp, offset); /* member name */ + This->filspc = strdup (This->relfil); /* member file name */ + This->type = type; + + /* start a new linked list of symbols for this module. */ + This->symbols = ThisSym = NULL; + } + + if (ThisSym == NULL) + ThisSym = This->symbols = (pmlibrarysymbol) new (sizeof (mlibrarysymbol)); + else + { + ThisSym->next = (pmlibrarysymbol) new (sizeof (mlibrarysymbol)); + ThisSym = ThisSym->next; + } + This->loaded = 0; + ThisSym->next = NULL; + ThisSym->name = sym; + } + free (buf); + + break; + } + else if (AR_IS_STRING_TABLE (hdr)) + { + if (sym_tab) + free (sym_tab); + + sym_tab = (char *) new (hdr.ar_size); + + if ((off_t) fread (sym_tab, 1, hdr.ar_size, libfp) != hdr.ar_size) + { + free (sym_tab); + sym_tab_size = 0; + return This; + } + sym_tab_size = hdr.ar_size; + } + else + { + long moduleOffset = ftell (libfp); + + /* Opened OK - create a new libraryfile object for it */ + if (This == NULL) + { + assert (libr == NULL); + libr = This = (pmlibraryfile) new (sizeof (mlibraryfile)); + } + else + { + This->next = (pmlibraryfile) new (sizeof (mlibraryfile)); + This = This->next; + } + This->next = NULL; + This->loaded = -1; + This->libspc = lbnh->libspc; + This->offset = moduleOffset - ARHDR_LEN; + + This->relfil = get_member_name (hdr.ar_name); /* member name */ + This->filspc = strdup (This->relfil); /* member file name */ + + D (" Indexing module: %s\n", This->relfil); + + This->type = type; + + /* start a new linked list of symbols for this module. */ + This->symbols = NULL; + + add_rel_index (libfp, hdr.ar_size, This); + + fseek (libfp, moduleOffset + hdr.ar_size, SEEK_SET); + } + + if (hdr.ar_size & 1) + { + int c = getc (libfp); + assert (c == EOF || c == '\n'); + } + } + + if (NULL != sym_tab) + { + free (sym_tab); + sym_tab = NULL; + sym_tab_size = 0; + } + + return This; +} + +#else + +#if 0 +static int +load_adb (FILE * libfp, struct lbfile *lbfh) +{ + struct ar_hdr hdr; + char *adb_name; + + /* check if it is a .rel file */ + if (0 != stricmp (&lbfh->relfil[strlen (lbfh->relfil) - 4], ".rel")) + return 0; + + + adb_name = (char *) new (strlen (lbfh->relfil) + 1); + memcpy (adb_name, lbfh->relfil, strlen (lbfh->relfil) - 4); + memcpy (&adb_name[strlen (lbfh->relfil) - 4], ".adb", 5); + + if (!is_ar (libfp)) + { + fprintf (stderr, "?ASlink-Error-%s is not an archive\n", lbfh->libspc); + fclose (libfp); + lkexit (1); + } + + + /* walk trough all archive members */ + while (ar_get_header (&hdr, libfp)) + { + if (AR_IS_STRING_TABLE (hdr)) + { + if (sym_tab) + free (sym_tab); + + sym_tab = (char *) new (hdr.ar_size); + + if ((off_t) fread (sym_tab, 1, hdr.ar_size, libfp) != hdr.ar_size) + { + free (sym_tab); + sym_tab_size = 0; + return 0; + } + sym_tab_size = hdr.ar_size; + } + if (AR_IS_SYMBOL_TABLE (hdr) || 0 != stricmp (get_member_name (hdr.ar_name), adb_name)) + { + /* skip the mamber */ + fseek (libfp, hdr.ar_size + (hdr.ar_size & 1), SEEK_CUR); + } + else + { + long left = hdr.ar_size; + char buf[4096]; + + while (left) + { + size_t n = min (left, sizeof buf); + + if (fread (buf, 1, n, libfp) != n) + { + assert (0); + } + + fwrite (buf, 1, n, dfp); + + left -= n; + } + + if (hdr.ar_size & 1) + { + int c = getc (libfp); + assert (c == EOF || c == '\n'); + } + + free (adb_name); + return 1; + } + } + + free (adb_name); + return 0; +} +#endif + +static int +fndsym_ar (const char *name, struct lbname *lbnh, FILE * libfp, int type) +{ + struct ar_hdr hdr; + int ret = 0; + + /* walk trough all archive members */ + while (ar_get_header (&hdr, libfp)) + { + char filspc[PATH_MAX]; + + if (lbnh->path != NULL) + { + strcpy (filspc, lbnh->path); +#ifdef OTHERSYSTEM + if (*filspc != '\0' && (filspc[strlen (filspc) - 1] != '/') && (filspc[strlen (filspc) - 1] != LKDIRSEP)) + { + strcat (filspc, LKDIRSEPSTR); + } +#endif + } + + if (AR_IS_SYMBOL_TABLE (hdr)) + { + char *buf, *po, *ps; + int i; + long nsym; + + buf = (char *) new (hdr.ar_size); + + if ((off_t) fread (buf, 1, hdr.ar_size, libfp) != hdr.ar_size) + { + free (buf); + return 0; + } + + nsym = sgetl (buf); + + po = buf + 4; + ps = po + nsym * 4; + + for (i = 0; i < nsym; ++i) + { + char *sym; + long offset; + + offset = sgetl (po); + po += 4; + + sym = ps; + while (*ps++ != '\0') + ; + + if (0 == strcmp (name, sym)) + { + fseek (libfp, offset, SEEK_SET); + if (ar_get_header (&hdr, libfp)) + { + sprintf (&filspc[strlen (filspc)], "%s", hdr.ar_name); + + /* If this module has been loaded already don't load it again. */ + if (!is_module_loaded (filspc)) + { + struct lbfile *lbfh, *lbf; + + lbfh = (struct lbfile *) new (sizeof (struct lbfile)); + lbfh->libspc = strdup (lbnh->libspc); + lbfh->relfil = strdup (hdr.ar_name); + lbfh->filspc = strdup (filspc); + lbfh->offset = offset; + lbfh->type = type; + + if (lbfhead == NULL) + { + lbfhead = lbfh; + } + else + { + for (lbf = lbfhead; lbf->next != NULL; lbf = lbf->next) + ; + + lbf->next = lbfh; + } + + D ("Loading module %s from file %s.\n", hdr.ar_name, lbfh->libspc); + load_rel (libfp, hdr.ar_size); + ///* if cdb information required & .adb file present */ + //if (dflag && dfp) + // { + // if (load_adb(FILE *libfp, struct lbfile *lbfh)) + // SaveLinkedFilePath (filspc); + // } + ret = 1; + break; + } + } + else + { + fprintf (stderr, "?ASlink-Error-Bad offset in library file %s(%s)\n", lbnh->libspc, name); + fclose (libfp); + lkexit (1); + } + } + } + free (buf); + + break; + } + else if (AR_IS_STRING_TABLE (hdr)) + { + if (sym_tab) + free (sym_tab); + + sym_tab = (char *) new (hdr.ar_size); + + if ((off_t) fread (sym_tab, 1, hdr.ar_size, libfp) != hdr.ar_size) + { + free (sym_tab); + sym_tab = NULL; + sym_tab_size = 0; + return 0; + } + sym_tab_size = hdr.ar_size; + } + else + { + long moduleOffset = ftell (libfp); + + D (" Module: %s\n", hdr.ar_name); + + sprintf (&filspc[strlen (filspc)], "%s", hdr.ar_name); + + /* Opened OK - create a new libraryfile object for it */ + ret = add_rel_file (name, lbnh, hdr.ar_name, filspc, moduleOffset - ARHDR_LEN, libfp, hdr.ar_size, type); + ///* if cdb information required & .adb file present */ + //if (dflag && dfp) + // { + // if (load_adb(FILE *libfp, struct lbfile *lbfh)) + // SaveLinkedFilePath (filspc); + // } + if (ret) + break; + + fseek (libfp, moduleOffset + hdr.ar_size, SEEK_SET); + } + + if (hdr.ar_size & 1) + { + int c = getc (libfp); + assert (c == EOF || c == '\n'); + } + } + + if (NULL != sym_tab) + { + free (sym_tab); + sym_tab = NULL; + sym_tab_size = 0; + } + + return ret; +} +#endif + +struct aslib_target aslib_target_ar = { + &is_ar, +#ifdef INDEXLIB + &buildlibraryindex_ar, +#else + &fndsym_ar, +#endif + &loadfile_ar, +}; diff --git a/as/link/lkar.h b/as/link/lkar.h new file mode 100644 index 00000000..586c1b00 --- /dev/null +++ b/as/link/lkar.h @@ -0,0 +1,86 @@ +/* lkar.h - ar library format handling + + Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef __LKAR_H +#define __LKAR_H + +#include +#include + + +#ifdef _WIN32 +typedef unsigned short mode_t; +typedef short uid_t; +typedef short gid_t; +typedef _off_t off_t; +#endif + +#ifdef WORDS_BIGENDIAN +#define sgetl(buf) (((((((unsigned char)(buf)[3] << 8) + (unsigned char)(buf)[2]) << 8) + (unsigned char)(buf)[1]) << 8) + (unsigned char)(buf)[0]) +#define sputl(value, buf) ((buf)[3] = ((value) >> 24, (buf)[2] = (value) >> 16, (buf)[1] = (value) >> 8, (buf)[0] = (value)) +#else +#define sgetl(buf) (((((((unsigned char)(buf)[0] << 8) + (unsigned char)(buf)[1]) << 8) + (unsigned char)(buf)[2]) << 8) + (unsigned char)(buf)[3]) +#define sputl(value, buf) ((buf)[0] = (value) >> 24, (buf)[1] = (value) >> 16, (buf)[2] = (value) >> 8, (buf)[3] = (value)) +#endif + +#define ARMAG "!\n" /* magic string */ +#define SARMAG (sizeof (ARMAG) - 1) /* length of magic string */ + +#define ARFMAG "`\n" /* header trailer string */ + +#define AR_NAME_OFFSET 0 +#define AR_NAME_LEN 16 + +#define AR_DATE_OFFSET 16 +#define AR_DATE_LEN 12 + +#define AR_UID_OFFSET 28 +#define AR_UID_LEN 6 + +#define AR_GID_OFFSET 34 +#define AR_GID_LEN 6 + +#define AR_MODE_OFFSET 40 +#define AR_MODE_LEN 8 + +#define AR_SIZE_OFFSET 48 +#define AR_SIZE_LEN 10 + +#define AR_FMAG_OFFSET 58 +#define AR_FMAG_LEN (sizeof (ARFMAG) - 1) + +#define ARHDR_LEN (AR_NAME_LEN + AR_DATE_LEN + AR_UID_LEN + AR_GID_LEN + AR_MODE_LEN + AR_SIZE_LEN + AR_FMAG_LEN) + +#define AR_SYMBOL_TABLE_NAME "/ " +#define AR_STRING_TABLE_NAME "// " + +#define AR_IS_SYMBOL_TABLE(hdr) (0 == strcmp((hdr).ar_name, AR_SYMBOL_TABLE_NAME)) +#define AR_IS_STRING_TABLE(hdr) (0 == strcmp((hdr).ar_name, AR_STRING_TABLE_NAME)) + + +struct ar_hdr /* archive member header */ +{ + char ar_name[AR_NAME_LEN + 1]; /* archive member name */ + time_t ar_date; /* archive member date */ + uid_t ar_uid; /* archive member user identification */ + gid_t ar_gid; /* archive member group identification */ + mode_t ar_mode; /* archive member mode (octal) */ + off_t ar_size; /* archive member size */ +}; + +#endif /* __LKAR_H */ diff --git a/as/link/lklib.c b/as/link/lklib.c index b0743519..cab38d9a 100644 --- a/as/link/lklib.c +++ b/as/link/lklib.c @@ -1,13 +1,24 @@ -/* lklib.c */ +/* lklib.c + + Copyright (C) 1989-1995 Alan R. Baldwin + 721 Berkeley St., Kent, Ohio 44240 + Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * * With contributions for the * object libraries from * Ken Hornstein @@ -89,7 +100,7 @@ buildlibraryindex_lib (struct lbname *lbnh, FILE * libfp, pmlibraryfile This, in This->loaded = -1; This->libspc = lbnh->libspc; This->relfil = strdup (relfil); - This->filename = strdup (str); + This->filspc = strdup (str); This->type = type; /* Start a new linked list of symbols for this module: */ @@ -114,6 +125,8 @@ fndsym_lib (const char *name, struct lbname *lbnh, FILE * libfp, int type) { char relfil[NINPUT]; + D ("Searching symbol: %s\n", name); + while (getline (relfil, sizeof (relfil), libfp) != NULL) { char str[PATH_MAX]; @@ -153,6 +166,7 @@ fndsym_lib (const char *name, struct lbname *lbnh, FILE * libfp, int type) fclose (fp); if (ret) { + D ("Loaded module %s from file %s.\n", str, str); /* if cdb information required & adb file present */ if (dflag && dfp) { diff --git a/as/link/lklibr.c b/as/link/lklibr.c index b15fd8a8..219e7e33 100644 --- a/as/link/lklibr.c +++ b/as/link/lklibr.c @@ -1,13 +1,24 @@ -/* lklibr.c */ +/* lklibr.c + + Copyright (C) 1989-1995 Alan R. Baldwin + 721 Berkeley St., Kent, Ohio 44240 + Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * * With contributions for the * object libraries from * Ken Hornstein @@ -61,6 +72,7 @@ void freelibraryindex (void); struct aslib_target *aslib_targets[] = { &aslib_target_sdcclib, + &aslib_target_ar, &aslib_target_lib, }; @@ -464,19 +476,18 @@ fndsym (char *name) pmlibraryfile FirstFound; int numfound = 0; + D ("Searching symbol: %s\n", name); + /* Build the index if this is the first call to fndsym */ if (libr == NULL) buildlibraryindex (); /* Iterate through all library object files */ - ThisLibr = libr; - FirstFound = libr; /*So gcc stops whining */ - while (ThisLibr) + FirstFound = libr; /* So gcc stops whining */ + for (ThisLibr = libr; ThisLibr != NULL; ThisLibr = ThisLibr->next) { /* Iterate through all symbols in an object file */ - ThisSym = ThisLibr->symbols; - - while (ThisSym) + for (ThisSym = ThisLibr->symbols; ThisSym != NULL; ThisSym = ThisSym->next) { if (!strcmp (ThisSym->name, name)) { @@ -490,15 +501,13 @@ fndsym (char *name) } else { - lbf = lbfhead; - while (lbf->next) - { - lbf = lbf->next; - } + for (lbf = lbfhead; lbf->next != NULL; lbf = lbf->next) + ; + lbf->next = lbfh; } lbfh->libspc = ThisLibr->libspc; - lbfh->filspc = ThisLibr->filename; + lbfh->filspc = ThisLibr->filspc; lbfh->relfil = strdup (ThisLibr->relfil); lbfh->offset = ThisLibr->offset; lbfh->type = ThisLibr->type; @@ -542,9 +551,7 @@ fndsym (char *name) } } } - ThisSym = ThisSym->next; /* Next sym in library */ } - ThisLibr = ThisLibr->next; /* Next library in list */ } return numfound; } @@ -561,6 +568,8 @@ add_sybmol (const char *sym, void *param) struct add_sym_s *as = (struct add_sym_s *) param; pmlibrarysymbol ps = (pmlibrarysymbol) new (sizeof (mlibrarysymbol)); + D (" Indexing symbol: %s\n", sym); + as->plf->loaded = 0; ps->next = NULL; ps->name = strdup (sym); @@ -609,6 +618,8 @@ buildlibraryindex (void) FILE *libfp; int i; + D ("Indexing library: %s\n", lbnh->libspc); + if ((libfp = fopen (lbnh->libspc, "rb")) == NULL) { fprintf (stderr, "?ASlink-Error-Cannot open library file %s\n", lbnh->libspc); @@ -633,7 +644,7 @@ buildlibraryindex (void) return 0; } -/*Release all memory allocated for the in-memory library index*/ +/* Release all memory allocated for the in-memory library index */ void freelibraryindex (void) { @@ -653,7 +664,7 @@ freelibraryindex (void) ThisSym = ThisSym->next; free (ThisSym2Free); } - free (ThisLibr->filename); + free (ThisLibr->filspc); free (ThisLibr->relfil); ThisLibr2Free = ThisLibr; ThisLibr = ThisLibr->next; @@ -680,10 +691,14 @@ load_sybmol (const char *sym, void *params) { struct load_sym_s *ls = (struct load_sym_s *) params; + D (" Symbol: %s\n", sym); + if (strcmp (ls->name, sym) == 0) { struct lbfile *lbfh, *lbf; + D (" Symbol %s found in module %s!\n", sym, ls->relfil); + lbfh = (struct lbfile *) new (sizeof (struct lbfile)); lbfh->libspc = ls->lbnh->libspc; lbfh->relfil = strdup (ls->relfil); @@ -692,19 +707,13 @@ load_sybmol (const char *sym, void *params) lbfh->type = ls->type; if (lbfhead == NULL) - { - lbfhead = lbfh; - } + lbfhead = lbfh; else { - lbf = lbfhead; - while (lbf->next) - { - lbf = lbf->next; - } + for (lbf = lbfhead; lbf->next != NULL; lbf = lbf->next) + ; lbf->next = lbfh; } - (*aslib_targets[ls->type]->loadfile) (lbfh); return 1; @@ -713,19 +722,47 @@ load_sybmol (const char *sym, void *params) return 0; } +/*)Function int is_module_loaded(filspc) + * + * If this module has been already loaded + */ + +int +is_module_loaded (const char *filspc) +{ + struct lbfile *lbf; + + for (lbf = lbfhead; lbf != NULL; lbf = lbf->next) + { + if (EQ (filspc, lbf->filspc)) + { + D (" Module %s already loaded!\n", filspc); + return 1; /* Module already loaded */ + } + } + return 0; +} + int add_rel_file (const char *name, struct lbname *lbnh, const char *relfil, const char *filspc, int offset, FILE * fp, long size, int type) { struct load_sym_s ls; - ls.name = name; - ls.lbnh = lbnh; - ls.relfil = relfil; - ls.filspc = filspc; - ls.offset = offset; - ls.type = type; - - return enum_symbols (fp, size, &load_sybmol, &ls); + + /* If this module has been loaded already don't load it again. */ + if (is_module_loaded (filspc)) + return 0; + else + { + ls.name = name; + ls.lbnh = lbnh; + ls.relfil = relfil; + ls.filspc = filspc; + ls.offset = offset; + ls.type = type; + + return enum_symbols (fp, size, &load_sybmol, &ls); + } } int @@ -738,10 +775,15 @@ fndsym (const char *name) /* * Search through every library in the linked list "lbnhead". */ + + D ("Searching symbol: %s\n", name); + for (lbnh = lbnhead; lbnh; lbnh = lbnh->next) { int ret = 0; + D ("Library: %s\n", lbnh->libspc); + if ((libfp = fopen (lbnh->libspc, "rb")) == NULL) { fprintf (stderr, "?ASlink-Error-Cannot open library file %s\n", lbnh->libspc); diff --git a/as/link/lklibr.h b/as/link/lklibr.h index 47dafe2f..040fc17b 100644 --- a/as/link/lklibr.h +++ b/as/link/lklibr.h @@ -1,13 +1,24 @@ -/* lklibr.h */ +/* lklibr.h + + Copyright (C) 1989-1995 Alan R. Baldwin + 721 Berkeley St., Kent, Ohio 44240 + Copyright (C) 2008 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * * With contributions for the * object libraries from * Ken Hornstein @@ -24,12 +35,13 @@ #include +#ifdef INDEXLIB typedef struct slibrarysymbol mlibrarysymbol; typedef struct slibrarysymbol *pmlibrarysymbol; struct slibrarysymbol { - char *name; /*Warning: allocate memory before using */ + char *name; /* Warning: allocate memory before using */ pmlibrarysymbol next; }; @@ -41,7 +53,7 @@ struct slibraryfile int loaded; char *libspc; char *relfil; /* Warning: allocate memory before using */ - char *filename; /* Warning: allocate memory before using */ + char *filspc; /* Warning: allocate memory before using */ long offset; /* The embedded file offset in the library file libspc */ unsigned int type; pmlibrarysymbol symbols; @@ -50,9 +62,9 @@ struct slibraryfile extern pmlibraryfile libr; -#ifdef INDEXLIB pmlibrarysymbol add_rel_index (FILE * fp, long size, pmlibraryfile This); #else +int is_module_loaded (const char *filspc); int add_rel_file (const char *name, struct lbname *lbnh, const char *relfil, const char *filspc, int offset, FILE * fp, long size, int type); #endif @@ -69,6 +81,16 @@ struct aslib_target }; extern struct aslib_target aslib_target_sdcclib; +extern struct aslib_target aslib_target_ar; extern struct aslib_target aslib_target_lib; +//// +//#define DEBUG_PRINT + +#ifdef DEBUG_PRINT +# define D printf +#else +# define D 1 ? (void)0 : (*(void (*)(const char *, ...))0) +#endif + #endif /* __LKLIBR_H */ diff --git a/as/link/lkrel.c b/as/link/lkrel.c index 3914aced..7b5a931c 100644 --- a/as/link/lkrel.c +++ b/as/link/lkrel.c @@ -1,13 +1,24 @@ -/* lkrel.c */ +/* lkrel.c - .rel object file handling + + Copyright (C) 1989-1995 Alan R. Baldwin + 721 Berkeley St., Kent, Ohio 44240 + Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * * With contributions for the * object libraries from * Ken Hornstein @@ -37,22 +48,22 @@ is_rel (FILE * libfp) if (((c = getc (libfp)) == 'X' || c == 'D' || c == 'Q') && ((c = getc (libfp)) == 'H' || c == 'L')) { switch (getc (libfp)) - { - case '\r': - if (getc (libfp) == '\n') - ret = 1; - break; - - case '\n': - ret = 1; - } + { + case '\r': + if (getc (libfp) == '\n') + ret = 1; + break; + + case '\n': + ret = 1; + } } else if (c == ';') { char buf[6]; if (fread (buf, 1, sizeof (buf), libfp) == sizeof (buf) && memcmp (buf, "!FILE ", 6) == 0) - ret = 1; + ret = 1; } fseek (libfp, pos, SEEK_SET); return ret; @@ -70,13 +81,13 @@ load_rel (FILE * libfp, long size) end = (size >= 0) ? ftell (libfp) + size : -1; while ((end < 0 || ftell (libfp) < end) && getline (str, sizeof (str), libfp) != NULL) - { - if (0 == strcmp (str, "")) - return 1; + { + if (0 == strcmp (str, "")) + return 1; - ip = str; - link_main (); - } + ip = str; + link_main (); + } return 1; } @@ -100,7 +111,7 @@ enum_symbols (FILE * fp, long size, int (*func) (const char *symvoid, void *para * our object file and don't go into the next one. */ - while ((end <= 0 || ftell (fp) < end) && getline (buf, sizeof (buf), fp) != NULL) + while ((end < 0 || ftell (fp) < end) && getline (buf, sizeof (buf), fp) != NULL) { char symname[NINPUT]; char c; @@ -110,22 +121,22 @@ enum_symbols (FILE * fp, long size, int (*func) (const char *symvoid, void *para * All 'S line's preceed 'T line's in .REL files. */ if (buf[0] == 'T') - break; + break; /* * Skip everything that's not a symbol record. */ if (buf[0] != 'S') - continue; + continue; sscanf (buf, "S %s %c", symname, &c); /* If it's an actual symbol, record it */ if (c == 'D') - { - if ((*func) (symname, param)) - return 1; - } + { + if ((*func) (symname, param)) + return 1; + } } return 0; diff --git a/as/link/lkrel.h b/as/link/lkrel.h index 68e84c24..3d88d63a 100644 --- a/as/link/lkrel.h +++ b/as/link/lkrel.h @@ -1,13 +1,24 @@ -/* lkrel.h */ +/* lkrel.h - .rel object file handling + + Copyright (C) 1989-1995 Alan R. Baldwin + 721 Berkeley St., Kent, Ohio 44240 + Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * * With contributions for the * object libraries from * Ken Hornstein @@ -15,6 +26,10 @@ * */ +/* + * Extensions: P. Felber + */ + #ifndef __LKREL_H #define __LKREL_H @@ -34,4 +49,4 @@ extern "C" } #endif -#endif /* __LKREL_H */ +#endif /* __LKREL_H */ diff --git a/as/link/lksdcclib.c b/as/link/lksdcclib.c index a1c781c6..d45c0c39 100644 --- a/as/link/lksdcclib.c +++ b/as/link/lksdcclib.c @@ -1,13 +1,24 @@ -/* lksdcclib.c */ +/* lksdcclib.c - sdcc library format handling + + Copyright (C) 1989-1995 Alan R. Baldwin + 721 Berkeley St., Kent, Ohio 44240 + Copyright (C) 2008 Borut Razem, borut dot razem at siol dot net + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * * With contributions for the * object libraries from * Ken Hornstein @@ -90,11 +101,9 @@ LoadRel (char *libfname, FILE * libfp, char *ModName) static pmlibraryfile buildlibraryindex_sdcclib (struct lbname *lbnh, FILE * libfp, pmlibraryfile This, int type) { - char ModName[NCPS] = ""; char FLine[MAXLINE]; - char buff[PATH_MAX]; int state = 0; - long IndexOffset = 0, FileOffset; + long IndexOffset = 0; pmlibrarysymbol ThisSym = NULL; while (getline (FLine, sizeof (FLine), libfp)) @@ -114,6 +123,10 @@ buildlibraryindex_sdcclib (struct lbname *lbnh, FILE * libfp, pmlibraryfile This case 1: if (EQ (FLine, "")) { + char buff[PATH_MAX]; + char ModName[NCPS] = ""; + long FileOffset; + /* The next line has the name of the module and the offset of the corresponding embedded file in the library */ getline (FLine, sizeof (FLine), libfp); @@ -136,7 +149,7 @@ buildlibraryindex_sdcclib (struct lbname *lbnh, FILE * libfp, pmlibraryfile This This->libspc = lbnh->libspc; This->relfil = strdup (ModName); sprintf (buff, "%s%s%c%s", lbnh->path, ModName, FSEPX, LKOBJEXT); - This->filename = strdup (buff); + This->filspc = strdup (buff); This->type = type; This->symbols = ThisSym = NULL; /* Start a new linked list of symbols */ @@ -221,7 +234,7 @@ LoadAdb (FILE * libfp) static int findsym_sdcclib (const char *name, struct lbname *lbnh, FILE * libfp, int type) { - struct lbfile *lbfh, *lbf; + struct lbfile *lbfh; char ModName[NCPS] = ""; char FLine[MAXLINE]; int state = 0; @@ -229,15 +242,15 @@ findsym_sdcclib (const char *name, struct lbname *lbnh, FILE * libfp, int type) while (getline (FLine, sizeof (FLine), libfp)) { - char str[PATH_MAX]; + char filspc[PATH_MAX]; if (lbnh->path != NULL) { - strcpy (str, lbnh->path); + strcpy (filspc, lbnh->path); #ifdef OTHERSYSTEM - if (*str != '\0' && (str[strlen (str) - 1] != '/') && (str[strlen (str) - 1] != LKDIRSEP)) + if (*filspc != '\0' && (filspc[strlen (filspc) - 1] != '/') && (filspc[strlen (filspc) - 1] != LKDIRSEP)) { - strcat (str, LKDIRSEPSTR); + strcat (filspc, LKDIRSEPSTR); } #endif } @@ -285,16 +298,11 @@ findsym_sdcclib (const char *name, struct lbname *lbnh, FILE * libfp, int type) /* As in the original library format, it is assumed that the .rel files reside in the same directory as the lib files. */ - sprintf (&str[strlen (str)], "%s%c%s", ModName, FSEPX, LKOBJEXT); + sprintf (&filspc[strlen (filspc)], "%s%c%s", ModName, FSEPX, LKOBJEXT); /* If this module has been loaded already don't load it again. */ - lbf = lbfhead; - while (lbf) - { - if (EQ (str, lbf->filspc)) - return 1; /* Already loaded */ - lbf = lbf->next; - } + if (is_module_loaded (filspc)) + return 1; /* Add the embedded file to the list of files to be loaded in the second pass. That is performed latter by the function @@ -306,16 +314,16 @@ findsym_sdcclib (const char *name, struct lbname *lbnh, FILE * libfp, int type) } else { - lbf = lbfhead; - while (lbf->next) - { - lbf = lbf->next; - } + struct lbfile *lbf; + + for (lbf = lbfhead; lbf->next; lbf = lbf->next) + ; + lbf->next = lbfh; } lbfh->libspc = lbnh->libspc; - lbfh->filspc = strdup (str); + lbfh->filspc = strdup (filspc); lbfh->relfil = strdup (ModName); /* Library embedded file, so lbfh->offset must be >=0 */ lbfh->offset = IndexOffset + FileOffset; @@ -332,7 +340,7 @@ findsym_sdcclib (const char *name, struct lbname *lbnh, FILE * libfp, int type) if (dflag && dfp) { if (LoadAdb (libfp)) - SaveLinkedFilePath (str); + SaveLinkedFilePath (filspc); } return 1; /* Found the symbol, so success! */ } diff --git a/as/link/mcs51/Makefile.in b/as/link/mcs51/Makefile.in index 1935f360..e14498d0 100644 --- a/as/link/mcs51/Makefile.in +++ b/as/link/mcs51/Makefile.in @@ -46,7 +46,7 @@ LKLIB = $(srcdir)/.. ASXXLIBSRC = strcmpi.c -LKLIBSRC = getline.c lkaomf51.c lkdata.c lkeval.c \ +LKLIBSRC = getline.c lkaomf51.c lkar.c lkdata.c lkeval.c \ lkhead.c lklex.c lklib.c lklibr.c lklist.c \ lknoice.c lkrel.c lksdcclib.c lkstore.c lksym.c diff --git a/as/link/mcs51/aslink.dsp b/as/link/mcs51/aslink.dsp index 481fc000..4ac3540a 100644 --- a/as/link/mcs51/aslink.dsp +++ b/as/link/mcs51/aslink.dsp @@ -96,6 +96,10 @@ SOURCE=..\lkaomf51.c # End Source File # Begin Source File +SOURCE=..\lkar.c +# End Source File +# Begin Source File + SOURCE=.\lkarea.c # End Source File # Begin Source File @@ -188,6 +192,10 @@ SOURCE=..\getline.h # End Source File # Begin Source File +SOURCE=..\lkar.h +# End Source File +# Begin Source File + SOURCE=..\lklibr.h # End Source File # Begin Source File diff --git a/as/link/z80/Makefile.in b/as/link/z80/Makefile.in index dcb32026..35374ec7 100644 --- a/as/link/z80/Makefile.in +++ b/as/link/z80/Makefile.in @@ -13,7 +13,7 @@ ASXXLIBSRC = strcmpi.c LKLIB = $(srcdir)/.. -LKLIBSRC = getline.c lkaomf51.c lkdata.c lkeval.c \ +LKLIBSRC = getline.c lkaomf51.c lkar.c lkdata.c lkeval.c \ lkhead.c lklex.c lklib.c lklibr.c lklist.c \ lknoice.c lkrel.c lksdcclib.c lkstore.c lksym.c diff --git a/as/link/z80/linkgbz80.dsp b/as/link/z80/linkgbz80.dsp index 3f82f08f..e762ed78 100644 --- a/as/link/z80/linkgbz80.dsp +++ b/as/link/z80/linkgbz80.dsp @@ -97,6 +97,10 @@ SOURCE=..\lkaomf51.c # End Source File # Begin Source File +SOURCE=..\lkar.c +# End Source File +# Begin Source File + SOURCE=.\lkarea.c # End Source File # Begin Source File @@ -193,6 +197,10 @@ SOURCE=..\getline.h # End Source File # Begin Source File +SOURCE=..\lkar.h +# End Source File +# Begin Source File + SOURCE=..\lklibr.h # End Source File # Begin Source File diff --git a/as/link/z80/linkz80.dsp b/as/link/z80/linkz80.dsp index 499e974c..4f9e44bb 100644 --- a/as/link/z80/linkz80.dsp +++ b/as/link/z80/linkz80.dsp @@ -97,6 +97,10 @@ SOURCE=..\lkaomf51.c # End Source File # Begin Source File +SOURCE=..\lkar.c +# End Source File +# Begin Source File + SOURCE=.\lkarea.c # End Source File # Begin Source File @@ -193,6 +197,10 @@ SOURCE=..\getline.h # End Source File # Begin Source File +SOURCE=..\lkar.h +# End Source File +# Begin Source File + SOURCE=..\lklibr.h # End Source File # Begin Source File diff --git a/configure b/configure index 613a3b66..d8f3cdf9 100755 --- a/configure +++ b/configure @@ -7681,7 +7681,7 @@ fi test $OPT_DISABLE_DEVICE_LIB = 0 && ac_config_files="$ac_config_files device/lib/Makefile" -ac_config_files="$ac_config_files main.mk:main_in.mk src/Makefile device/include/Makefile support/librarian/Makefile support/makebin/Makefile support/regression/Makefile support/valdiag/Makefile Makefile Makefile.common:Makefile.common.in" +ac_config_files="$ac_config_files main.mk:main_in.mk src/Makefile device/include/Makefile as/asranlib/Makefile support/librarian/Makefile support/makebin/Makefile support/regression/Makefile support/valdiag/Makefile Makefile Makefile.common:Makefile.common.in" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -8311,6 +8311,7 @@ do "main.mk") CONFIG_FILES="$CONFIG_FILES main.mk:main_in.mk" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "device/include/Makefile") CONFIG_FILES="$CONFIG_FILES device/include/Makefile" ;; + "as/asranlib/Makefile") CONFIG_FILES="$CONFIG_FILES as/asranlib/Makefile" ;; "support/librarian/Makefile") CONFIG_FILES="$CONFIG_FILES support/librarian/Makefile" ;; "support/makebin/Makefile") CONFIG_FILES="$CONFIG_FILES support/makebin/Makefile" ;; "support/regression/Makefile") CONFIG_FILES="$CONFIG_FILES support/regression/Makefile" ;; diff --git a/configure.in b/configure.in index d7c6d337..0de9b1af 100644 --- a/configure.in +++ b/configure.in @@ -767,6 +767,7 @@ test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/Makefile]) AC_CONFIG_FILES([main.mk:main_in.mk src/Makefile device/include/Makefile +as/asranlib/Makefile support/librarian/Makefile support/makebin/Makefile support/regression/Makefile diff --git a/sdcc.dsw b/sdcc.dsw index 3d5a6ad8..3f89a7ce 100644 --- a/sdcc.dsw +++ b/sdcc.dsw @@ -3,7 +3,7 @@ Microsoft Developer Studio Workspace File, Format Version 6.00 ############################################################################### -Project: "all"=".\all.dsp" - Package Owner=<4> +Project: "all"=.\all.dsp - Package Owner=<4> Package=<5> {{{ @@ -51,7 +51,7 @@ Package=<4> ############################################################################### -Project: "as_gbz80"=".\as\z80\as_gbz80.dsp" - Package Owner=<4> +Project: "as_gbz80"=.\as\z80\as_gbz80.dsp - Package Owner=<4> Package=<5> {{{ @@ -63,7 +63,7 @@ Package=<4> ############################################################################### -Project: "as_hc08"=".\as\hc08\as_hc08.dsp" - Package Owner=<4> +Project: "as_hc08"=.\as\hc08\as_hc08.dsp - Package Owner=<4> Package=<5> {{{ @@ -75,7 +75,7 @@ Package=<4> ############################################################################### -Project: "as_z80"=".\as\z80\as_z80.dsp" - Package Owner=<4> +Project: "as_z80"=.\as\z80\as_z80.dsp - Package Owner=<4> Package=<5> {{{ @@ -90,7 +90,7 @@ Package=<4> ############################################################################### -Project: "aslink"=".\as\link\mcs51\aslink.dsp" - Package Owner=<4> +Project: "aslink"=.\as\link\mcs51\aslink.dsp - Package Owner=<4> Package=<5> {{{ @@ -105,7 +105,7 @@ Package=<4> ############################################################################### -Project: "asx8051"=".\as\mcs51\asx8051.dsp" - Package Owner=<4> +Project: "asranlib"=.\as\asranlib\asranlib.dsp - Package Owner=<4> Package=<5> {{{ @@ -113,11 +113,26 @@ Package=<5> Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name config + End Project Dependency }}} ############################################################################### -Project: "avr"=".\src\avr\avr.dsp" - Package Owner=<4> +Project: "asx8051"=.\as\mcs51\asx8051.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "avr"=.\src\avr\avr.dsp - Package Owner=<4> Package=<5> {{{ @@ -138,7 +153,7 @@ Package=<4> ############################################################################### -Project: "avra"=".\src\avr\avra.dsp" - Package Owner=<4> +Project: "avra"=.\src\avr\avra.dsp - Package Owner=<4> Package=<5> {{{ @@ -150,7 +165,7 @@ Package=<4> ############################################################################### -Project: "config"=".\config.dsp" - Package Owner=<4> +Project: "config"=.\config.dsp - Package Owner=<4> Package=<5> {{{ @@ -162,7 +177,7 @@ Package=<4> ############################################################################### -Project: "ds390"=".\src\ds390\ds390.dsp" - Package Owner=<4> +Project: "ds390"=.\src\ds390\ds390.dsp - Package Owner=<4> Package=<5> {{{ @@ -183,7 +198,7 @@ Package=<4> ############################################################################### -Project: "ds390a"=".\src\ds390\ds390a.dsp" - Package Owner=<4> +Project: "ds390a"=.\src\ds390\ds390a.dsp - Package Owner=<4> Package=<5> {{{ @@ -195,7 +210,7 @@ Package=<4> ############################################################################### -Project: "hc08"=".\src\hc08\hc08.dsp" - Package Owner=<4> +Project: "hc08"=.\src\hc08\hc08.dsp - Package Owner=<4> Package=<5> {{{ @@ -210,7 +225,7 @@ Package=<4> ############################################################################### -Project: "hc08a"=".\src\hc08\hc08a.dsp" - Package Owner=<4> +Project: "hc08a"=.\src\hc08\hc08a.dsp - Package Owner=<4> Package=<5> {{{ @@ -222,7 +237,7 @@ Package=<4> ############################################################################### -Project: "librarian"=".\support\librarian\librarian.dsp" - Package Owner=<4> +Project: "librarian"=.\support\librarian\librarian.dsp - Package Owner=<4> Package=<5> {{{ @@ -234,7 +249,7 @@ Package=<4> ############################################################################### -Project: "link_hc08"=".\as\link\hc08\link_hc08.dsp" - Package Owner=<4> +Project: "link_hc08"=.\as\link\hc08\link_hc08.dsp - Package Owner=<4> Package=<5> {{{ @@ -242,11 +257,14 @@ Package=<5> Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name config + End Project Dependency }}} ############################################################################### -Project: "linkgbz80"=".\as\link\z80\linkgbz80.dsp" - Package Owner=<4> +Project: "linkgbz80"=.\as\link\z80\linkgbz80.dsp - Package Owner=<4> Package=<5> {{{ @@ -258,7 +276,7 @@ Package=<4> ############################################################################### -Project: "linkz80"=".\as\link\z80\linkz80.dsp" - Package Owner=<4> +Project: "linkz80"=.\as\link\z80\linkz80.dsp - Package Owner=<4> Package=<5> {{{ @@ -270,7 +288,7 @@ Package=<4> ############################################################################### -Project: "mcs51"=".\src\mcs51\mcs51.dsp" - Package Owner=<4> +Project: "mcs51"=.\src\mcs51\mcs51.dsp - Package Owner=<4> Package=<5> {{{ @@ -294,7 +312,7 @@ Package=<4> ############################################################################### -Project: "mcs51a"=".\src\mcs51\mcs51a.dsp" - Package Owner=<4> +Project: "mcs51a"=.\src\mcs51\mcs51a.dsp - Package Owner=<4> Package=<5> {{{ @@ -306,7 +324,7 @@ Package=<4> ############################################################################### -Project: "packihx"=".\support\packihx\PackIhx.dsp" - Package Owner=<4> +Project: "packihx"=.\support\packihx\PackIhx.dsp - Package Owner=<4> Package=<5> {{{ @@ -318,7 +336,7 @@ Package=<4> ############################################################################### -Project: "pic"=".\src\pic\pic.dsp" - Package Owner=<4> +Project: "pic"=.\src\pic\pic.dsp - Package Owner=<4> Package=<5> {{{ @@ -339,7 +357,7 @@ Package=<4> ############################################################################### -Project: "pic16"=".\src\pic16\pic16.dsp" - Package Owner=<4> +Project: "pic16"=.\src\pic16\pic16.dsp - Package Owner=<4> Package=<5> {{{ @@ -354,7 +372,7 @@ Package=<4> ############################################################################### -Project: "pic16a"=".\src\pic16\pic16a.dsp" - Package Owner=<4> +Project: "pic16a"=.\src\pic16\pic16a.dsp - Package Owner=<4> Package=<5> {{{ @@ -366,7 +384,7 @@ Package=<4> ############################################################################### -Project: "pica"=".\src\pic\pica.dsp" - Package Owner=<4> +Project: "pica"=.\src\pic\pica.dsp - Package Owner=<4> Package=<5> {{{ @@ -378,7 +396,7 @@ Package=<4> ############################################################################### -Project: "sdcpp"=".\support\cpp\sdcpp.dsp" - Package Owner=<4> +Project: "sdcpp"=.\support\cpp\sdcpp.dsp - Package Owner=<4> Package=<5> {{{ @@ -393,7 +411,7 @@ Package=<4> ############################################################################### -Project: "sdcppa"=".\support\cpp\sdcppa.dsp" - Package Owner=<4> +Project: "sdcppa"=.\support\cpp\sdcppa.dsp - Package Owner=<4> Package=<5> {{{ @@ -405,7 +423,7 @@ Package=<4> ############################################################################### -Project: "src"=".\src\src.dsp" - Package Owner=<4> +Project: "src"=.\src\src.dsp - Package Owner=<4> Package=<5> {{{ @@ -447,7 +465,7 @@ Package=<4> ############################################################################### -Project: "xa51"=".\src\xa51\xa51.dsp" - Package Owner=<4> +Project: "xa51"=.\src\xa51\xa51.dsp - Package Owner=<4> Package=<5> {{{ @@ -468,7 +486,7 @@ Package=<4> ############################################################################### -Project: "xa51a"=".\src\xa51\xa51a.dsp" - Package Owner=<4> +Project: "xa51a"=.\src\xa51\xa51a.dsp - Package Owner=<4> Package=<5> {{{ @@ -480,7 +498,7 @@ Package=<4> ############################################################################### -Project: "yacc"=".\src\yacc.dsp" - Package Owner=<4> +Project: "yacc"=.\src\yacc.dsp - Package Owner=<4> Package=<5> {{{ @@ -492,7 +510,7 @@ Package=<4> ############################################################################### -Project: "z80"=".\src\z80\z80.dsp" - Package Owner=<4> +Project: "z80"=.\src\z80\z80.dsp - Package Owner=<4> Package=<5> {{{ @@ -513,7 +531,7 @@ Package=<4> ############################################################################### -Project: "z80a"=".\src\z80\z80a.dsp" - Package Owner=<4> +Project: "z80a"=.\src\z80\z80a.dsp - Package Owner=<4> Package=<5> {{{ -- 2.30.2