Commit 39b40522 authored by Geert Stappers's avatar Geert Stappers

Import Upstream version 2.5.0

parent 81282852
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -30,6 +30,7 @@ man2dir = $(mandir)/man2
infodir = @infodir@
srcdir = @srcdir@
docdir = @docdir@
DESTDIR =
include_dir_suffix = @include_dir_suffix@
lib_dir_suffix = @lib_dir_suffix@
......
......@@ -10,18 +10,18 @@ all:
$(MAKE) -C hc08 all E=$(E) BUILDDIR=$(BUILDDIR)
install: all install-doc
$(INSTALL) $(PRJDIR)/bin/as-z80$(EXEEXT) `echo $(bindir)/as-z80$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(bindir)/as-z80$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(PRJDIR)/bin/as-gbz80$(EXEEXT) `echo $(bindir)/as-gbz80$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(bindir)/as-gbz80$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(PRJDIR)/bin/as-hc08$(EXEEXT) `echo $(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(PRJDIR)/bin/as-z80$(EXEEXT) `echo $(DESTDIR)$(bindir)/as-z80$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(DESTDIR)$(bindir)/as-z80$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(PRJDIR)/bin/as-gbz80$(EXEEXT) `echo $(DESTDIR)$(bindir)/as-gbz80$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(DESTDIR)$(bindir)/as-gbz80$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(PRJDIR)/bin/as-hc08$(EXEEXT) `echo $(DESTDIR)$(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(DESTDIR)$(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
install-doc:
$(INSTALL) -d $(docdir)/aslink
cp -f `find doc -maxdepth 1 -type f` $(docdir)/aslink
$(INSTALL) -d $(DESTDIR)$(docdir)/aslink
cp -f `find doc -maxdepth 1 -type f` $(DESTDIR)$(docdir)/aslink
uninstall:
cd $(bindir); rm -f as-z80$(EXEEXT) as-gbz80$(EXEEXT) as-hc08$(EXEEXT)
cd $(DESTDIR)$(bindir); rm -f as-z80$(EXEEXT) as-gbz80$(EXEEXT) as-hc08$(EXEEXT)
include clean.mk
......@@ -41,7 +41,7 @@ ASSOURCES = $(patsubst %.o,%.c,$(ASOBJECTS))
LKOBJECTS = lkmain.o lkhead.o lkarea.o lkdata.o \
lkeval.o lklex.o lksym.o lkrloc.o \
lklibr.o lklist.o lkihx.o lks19.o \
lklibr.o lklist.o lkihx.o lks19.o lkelf.o \
lkstore.o lknoice.o lkmem.o lkaomf51.o strcmpi.o
LKSOURCES = $(patsubst %.o,%.c,$(LKOBJECTS))
......@@ -63,15 +63,15 @@ $(ASLINK): $(LKOBJECTS)
# Compiling and installing everything and runing test
# ---------------------------------------------------
install: all installdirs
$(INSTALL) $(ASHC08) `echo $(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(ASLINK) `echo $(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(ASHC08) `echo $(DESTDIR)$(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(DESTDIR)$(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'`
$(INSTALL) $(ASLINK) `echo $(DESTDIR)$(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'`
$(STRIP) `echo $(DESTDIR)$(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'`
# Deleting all the installed files
# --------------------------------
uninstall:
rm -f $(bindir)/as-hc08$(EXEEXT) $(bindir)/link-hc08$(EXEEXT)
rm -f $(DESTDIR)$(bindir)/as-hc08$(EXEEXT) $(DESTDIR)$(bindir)/link-hc08$(EXEEXT)
# Performing self-test
......@@ -87,7 +87,7 @@ installcheck:
# Creating installation directories
# ---------------------------------
installdirs:
$(INSTALL) -d $(bindir)
$(INSTALL) -d $(DESTDIR)$(bindir)
# Creating dependencies
......
......@@ -186,6 +186,9 @@
#define A_XDATA 0100 /* external data space */
#define A_BIT 0200 /* bit addressable space */
#define A_NOLOAD 0400 /* nonloadable */
#define A_LOAD 0000 /* loadable (default) */
/*
* File types
*/
......@@ -245,8 +248,10 @@ struct area
Addr_T a_addr; /* Beginning address of area */
Addr_T a_size; /* Total size of the area */
char a_type; /* Area subtype */
char a_flag; /* Flag byte */
int a_flag; /* Flag byte */
char a_id[NCPS]; /* Name */
char *a_image;
char *a_used;
};
/*
......@@ -773,3 +778,6 @@ extern int summary(struct area * xp);
/* JCF: lkaomf51.c */
extern void SaveLinkedFilePath(char * filepath);
extern void CreateAOMF51(void);
/* EEP: lkelf.c */
extern VOID elf();
......@@ -175,6 +175,9 @@ struct area
#define A_XDATA 0100 /* external data space */
#define A_BIT 0200 /* bit addressable space */
#define A_NOLOAD 0400 /* nonloadable */
#define A_LOAD 0000 /* loadable (default) */
/*
* The "R_" relocation constants define values used in
* generating the assembler relocation output data for
......@@ -329,7 +332,8 @@ struct sym
#define S_ASCIS 26 /* .ascis */
#define S_FLAT24 27 /* .flat24 */
#define S_OPTSDCC 28 /* .optsdcc */
#define S_ULEB128 29 /* .uleb128 */
#define S_SLEB128 30 /* .sleb128 */
/*
* The tsym structure is a linked list of temporary
......
......@@ -740,6 +740,37 @@ loop:
} while ((c = getnb()) == ',');
unget(c);
break;
case S_ULEB128:
case S_SLEB128:
do {
Addr_T val = absexpr();
int bit = sizeof(val)*8 - 1;
int impliedBit;
if (mp->m_type == S_ULEB128) {
impliedBit = 0;
} else {
impliedBit = (val & (1 << bit)) ? 1 : 0;
}
while ((bit>0) && (((val & (1 << bit)) ? 1 : 0) == impliedBit)) {
bit--;
}
if (mp->m_type == S_SLEB128) {
bit++;
}
while (bit>=0) {
if (bit<7) {
outab(val & 0x7f);
} else {
outab(0x80 | (val & 0x7f));
}
bit -= 7;
val >>= 7;
}
} while ((c = getnb()) == ',');
unget(c);
break;
case S_ASCII:
case S_ASCIZ:
......
......@@ -42,15 +42,15 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# 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 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /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 /out:"..\..\bin_vc\link-hc08.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 /out:"..\..\bin_vc\link-hc08.exe"
!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug"
......@@ -65,16 +65,16 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# 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 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# 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 "..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /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 /out:"..\..\bin_vc\link-hc08.exe" /pdbtype:sept
# 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 /out:"..\..\bin_vc\link-hc08.exe" /pdbtype:sept
!ENDIF
......@@ -132,6 +132,10 @@ SOURCE=.\lkdata.c
# End Source File
# Begin Source File
SOURCE=.\lkelf.c
# End Source File
# Begin Source File
SOURCE=.\lkeval.c
!IF "$(CFG)" == "link_hc08 - Win32 Release"
......
......@@ -335,6 +335,7 @@ lnkarea()
} else {
/* Determine memory space */
locIndex = 0;
#if 0
if (ap->a_flag & A_CODE) {
locIndex = 1;
}
......@@ -344,11 +345,17 @@ lnkarea()
if (ap->a_flag & A_BIT) {
locIndex = 3;
}
#endif
/*
* Relocatable sections
*/
if (ap->a_type == 0) { /* JLH */
ap->a_addr = rloc[ locIndex ];
if (ap->a_flag & A_NOLOAD) {
locIndex = 2;
ap->a_addr = 0;
} else {
ap->a_addr = rloc[ locIndex ];
}
ap->a_type = 1;
}
lnksect(ap);
......
This diff is collapsed.
......@@ -201,6 +201,8 @@ ihx(i)
{
Addr_T n;
if (i) {
if (ap->a_flag & A_NOLOAD)
return;
if (hilo == 0) {
n = rtval[0];
rtval[0] = rtval[1];
......
......@@ -199,6 +199,9 @@ char *str;
if (p < &str[PATH_MAX-1])
*p++ = c;
c = get();
if (c == ';')
while (c)
c = get();
} while (c);
/* trim trailing spaces */
--p;
......
......@@ -359,6 +359,12 @@ char *argv[];
}
/* include NoICE command to load hex file */
if (jfp) fprintf( jfp, "LOAD %s.S19\n", linkp->f_idp );
} else
if (oflag == 3) {
ofp = afile(linkp->f_idp, "elf", 4);
if (ofp == NULL) {
lkexit(1);
}
}
} else {
/*
......@@ -369,7 +375,7 @@ char *argv[];
}
}
//JCF:
CreateAOMF51();
//CreateAOMF51();
#ifdef WIN32T
Timer(1, "Linker execution time");
......@@ -756,6 +762,8 @@ parse()
char fid[NINPUT];
while ((c = getnb()) != 0) {
if ( c == ';')
return(0);
if ( c == '-') {
while (ctype[c=get()] & LETTER) {
switch(c) {
......@@ -770,6 +778,11 @@ parse()
oflag = 2;
break;
case 't':
case 'T':
oflag = 3;
break;
case 'm':
case 'M':
++mflag;
......@@ -866,6 +879,8 @@ parse()
lkexit(1);
}
}
if ( c == ';')
return(0);
} else
if (ctype[c] & ILL) {
fprintf(stderr, "Invalid input");
......@@ -1154,12 +1169,22 @@ char *ft;
{
FILE *fp;
char fb[PATH_MAX];
char *omode = (wf ? (wf == 2 ? "a" : "w") : "r");
char *omode;
int i;
switch (wf) {
case 0: omode = "r"; break;
case 1: omode = "w"; break;
case 2: omode = "a"; break;
case 3: omode = "rb"; break;
case 4: omode = "wb"; break;
case 5: omode = "ab"; break;
default: omode = "r"; break;
}
/*Look backward the name path and get rid of the extension, if any*/
i=strlen(fn);
for(; (fn[i]!='.')&&(fn[i]!='\\')&&(fn[i]!='/')&&(i>=0); i--);
for(; (fn[i]!='.')&&(fn[i]!='\\')&&(fn[i]!='/')&&(i>0); i--);
if( (fn[i]=='.') && strcmp(ft, "lnk") )
{
strncpy(fb, fn, i);
......@@ -1171,9 +1196,12 @@ char *ft;
}
/*Add the extension*/
strcat(fb, ".");
strcat(fb, strlen(ft)?ft:"rel");
if (fb[i] != '.')
{