aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/Makefile.in90
-rw-r--r--ld/config.h3
-rwxr-xr-xld/ldlnk960.c2
-rwxr-xr-xld/ldm88k.sc12
4 files changed, 81 insertions, 26 deletions
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 5f8f262..ee96a54 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -26,16 +26,9 @@ DEBUG = -g
BISON = bison
BISONFLAGS = -v
-SCRIPTS = ldgld68k.sc ldgld68kUr.sc ldgld68kr.sc \
- ldgld.sc ldgldUr.sc ldgldr.sc ldlnk960.sc \
- ldlnk960r.sc ldgld960.sc \
- ldm88k.sc ldm88kUr.sc ldm88kr.sc \
- ldglda29k.sc ldglda29kUr.sc ldglda29kr.sc
-
-PROCESSED_SCRIPTS = ldgld68k.x ldgld68kUr.x ldgld68kr.x ldgld.x \
- ldgldUr.x ldgldr.x ldlnk960.x ldlnk960r.x ldgld960.x \
- ldm88k.x ldm88kUr.x ldm88kr.x \
- ldglda29k.x ldglda29kUr.x ldglda29kr.x
+SCRIPTS = ldgld68k.sc ldgld.sc \
+ ldlnk960.sc ldlnk960r.sc ldgld960.sc \
+ ldm88k.sc ldglda29k.sc news.sc
#### target and host dependent Makefile fragments come in here.
###
@@ -43,16 +36,46 @@ PROCESSED_SCRIPTS = ldgld68k.x ldgld68kUr.x ldgld68kr.x ldgld.x \
CFLAGS = $(INCLUDES) $(DEBUG) $(HDEFINES) $(TDEFINES) $(CDEFINES)
LINTFLAGS = $(INCLUDES) $(EXTRA_DEF)
-.SUFFIXES: .y .x .sc $(SUFFIXES)
-
+.SUFFIXES: .y .x .xr .xu .sc .scu .scr $(SUFFIXES)
# go directly to ld.new in case this ld isn't capable of
# linking native object on this host. It can be renamed on
# install.
LD_PROG = ld.new
+# A .sc script file is needed for each emulation mode.
+# sed is used to transform this script into two variant forms:
+# A .scr script is for linking without relocation (-r flag).
+# A .scu script is like .scr, but *do* create constructors.
+
+# A sed pattern to translate .sc to .scu:
+SED_MAKE_RELOC_WITH_CONSTRUCTORS=\
+ -e "/If relocating/,/End if relocating/d" \
+ -e "/=/s/[_a-z.]* *= .*//g" \
+ -e '/>/s/} *> *[a-z]*/}/' \
+ -e "/text/s/[.]text .*:/.text :/" \
+ -e "/data/s/[.]data .*:/.data :/"
+# A sed pattern to translate .scu to .scr:
+SED_REMOVE_CONSTRUCTORS= -e /CONSTRUCTORS/d
+
+.sc.scu:
+ sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $< >$*.scu
+.scu.scr:
+ sed $(SED_REMOVE_CONSTRUCTORS) < $< >$*.scr
+
+# Each .sc .scr or .scu script is filtered by mkscript
+# into a string literal that can be included in a .c program.
.sc.x:
- ./mkscript < $< >$*.x
+ ./mkscript < $< >$*.x
+.scu.xu:
+ ./mkscript < $< >$*.xu
+.scr.xr:
+ ./mkscript < $< >$*.xr
+.sc.xu:
+ sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) < $< | ./mkscript >$*.xu
+.sc.xr:
+ sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $(SED_REMOVE_CONSTRUCTORS) \
+ < $< | ./mkscript >$*.xr
# for self hosting
GNUTARGET=a.out-sunos-big
@@ -61,7 +84,7 @@ BFDLIB=$(srcdir)/../bfd$(subdir)/libbfd.a
LIBIBERTY=$(srcdir)/../libiberty$(subdir)/libiberty.a
OFILES= ldgram.o ldlex.o ldlang.o ldmain.o ldwarn.o ldwrite.o ldexp.o ldlnk960.o ldgld68k.o ldindr.o \
- ldm88k.o ldglda29k.o \
+ ldm88k.o ldglda29k.o news.o \
ldgld.o ldgld960.o ldemul.o ldver.o ldmisc.o ldsym.o ldvanilla.o ldfile.o
HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h ldsym.h ldlang.h ldexp.h \
@@ -83,11 +106,9 @@ BFDSOURCES=../../bfd/common/*.c
SOURCES= $(LDSOURCES) $(BFDSOURCES)
LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES)
-STAGESTUFF = $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(PROCESSED_SCRIPTS) $(OFILES) $(LD_PROG) mkscript
-
-all: Makefile $(PROCESSED_SCRIPTS) $(LD_PROG)
+STAGESTUFF = *.x *.x[ru] *.sc[ru] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript
-$(PROCESSED_SCRIPTS): mkscript $(SCRIPTS)
+all: Makefile $(LD_PROG)
ldgram.c:ldgram.y
$(BISON) $(BISONFLAGS) -d $(VPATH)/ldgram.y -o ldgram.c
@@ -96,6 +117,33 @@ ldlex.c:ldlex.l
lex -t $(VPATH)/ldlex.l >ldlex.c
+ldgld.c: ldtemplate
+ sed -e s/"<ldtarget>"/ldgld/g -e s/"<arch>"/m68k/g \
+ -e s/"<target>"//g -e s/"<TARGET>"//g < $< > ldgld.c
+news.c: ldtemplate
+ sed -e s/"<ldtarget>"/news/g -e s/"<arch>"/m68k/g \
+ -e s/"<target>"/news/g -e s/"<TARGET>"/NEWS/g < $< > news.c
+ldgld68k.c: ldtemplate
+ sed -e s/"<ldtarget>"/ldgld68k/g -e s/"<arch>"/m68k/g \
+ -e s/"<target>"/68k/g -e s/"<TARGET>"/68K/g < $< > ldgld68k.c
+ldglda29k.c: ldtemplate
+ sed -e s/"<ldtarget>"/ldglda29k/g -e s/"<arch>"/a29k/g \
+ -e s/"<target>"/29k/g -e s/"<TARGET>"/29K/g < $< > ldglda29k.c
+ldm88k.c: ldtemplate
+ sed -e s/"<ldtarget>"/ldm88k/g -e s/"<arch>"/m88k/g \
+ -e s/"<target>"/m88kbcs/g -e s/"<TARGET>"/M88KBCS/g < $< > ldm88k.c
+
+# The .c files for these are generated from ldtemplete.
+ldgld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu
+news.o: ./mkscript news.x news.xr news.xu
+ldgld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu
+ldglda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu
+ldm88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu
+
+# The .c files for these are (for now) specially written (not ldtemplete).
+ldgld960.o: ./mkscript ldgld960.x
+ldlnk960.o: ./mkscript ldlnk960.x ldlnk960.xr
+
#$(BFDLIB): $(BFDSOURCES)
# (cd ../bfd; make)
@@ -124,8 +172,6 @@ ld.dvi:ld.tex
mkscript: $(srcdir)/mkscript.c
$(CC) $(CFLAGS) $(LDFLAGS) -o mkscript $(srcdir)/mkscript.c $(LOADLIBES)
-ldgld.o: $(PROCESSED_SCRIPTS) ldgld.c
-
ldlex.c: ldlex.l ldgram.h
ldlex.o: ldlex.c ldgram.h
ldgram.o: ldgram.c
@@ -185,7 +231,7 @@ de-stage3: force
clean:
- rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS)
- - rm -f $(PROCESSED_SCRIPTS)
+ - rm -f *.x *.x[ru] *.sc[ur]
- rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output
lintlog:$(SOURCES) Makefile
@@ -235,7 +281,7 @@ roll:
echo Version $$V
-dep: $(LDSOURCES) $(PROCESSED_SCRIPTS)
+dep: $(LDSOURCES)
mkdep $(CFLAGS) $?
# Dummy target to force execution of dependent targets.
diff --git a/ld/config.h b/ld/config.h
index 931c8bf..c3a2444 100644
--- a/ld/config.h
+++ b/ld/config.h
@@ -27,6 +27,7 @@
#define GLD68K_EMULATION_NAME "gld68k"
#define GLD960_EMULATION_NAME "gld960"
#define GLD29K_EMULATION_NAME "gld29k"
+#define GLDNEWS_EMULATION_NAME "gldnews"
#define LNK960_EMULATION_NAME "lnk960"
/* Otherwise default to this emulation */
#ifndef DEFAULT_EMULATION
@@ -47,6 +48,8 @@
#define VANILLA_TARGET "a.out-sunos-big"
#define GLDM88KBCS_TARGET "m88kbcs"
#define GLD29K_TARGET "coff-a29k-big"
+#define GLDNEWS_TARGET "a.out-newsos3"
+
diff --git a/ld/ldlnk960.c b/ld/ldlnk960.c
index ea4df26..ff862f9 100755
--- a/ld/ldlnk960.c
+++ b/ld/ldlnk960.c
@@ -263,7 +263,7 @@ static char *lnk960_script =
static char *lnk960_script_relocateable =
-#include "ldlnk960r.x"
+#include "ldlnk960.xr"
;
static char *lnk960_get_script()
diff --git a/ld/ldm88k.sc b/ld/ldm88k.sc
index c4cb37e..408cfde 100755
--- a/ld/ldm88k.sc
+++ b/ld/ldm88k.sc
@@ -8,12 +8,16 @@ SEARCH_DIR(/usr/local/lib)
SECTIONS
{
.text 0x10000 + SIZEOF_HEADERS :
- {
+ {
+ CREATE_OBJECT_SYMBOLS
+ /* If relocating */
__.text.start = .;
__.init.start = .;
LONG(0xf400c001)
__.init.end = .;
+ /* End if relocating */
*(.text)
+ /* If relocating */
__.tdesc_start = .;
*(.tdesc)
__.text_end = .;
@@ -21,11 +25,13 @@ SECTIONS
__.initp.end =.;
_etext =.;
+ /* End if relocating */
}
.data SIZEOF(.text) + ADDR(.text) + 0x400000:
{
- *(.data)
- _edata = .;
+ *(.data)
+ CONSTRUCTORS;
+ _edata = .;
}
.bss SIZEOF(.data) + ADDR(.data) :
{