* ldlnk960.c: Use new naming convention for *.x{,u,r} include scripts.
authorPer Bothner <per@bothner.com>
Fri, 27 Sep 1991 20:09:23 +0000 (20:09 +0000)
committerPer Bothner <per@bothner.com>
Fri, 27 Sep 1991 20:09:23 +0000 (20:09 +0000)
* ldm88k.sc: "Clean up" script, so that ldm88kUr.sc and ldm88kr.sc
can be automatically generated.
* ldemul.c, configure.in, config.h, Makefile.in:
Add support for Sony NewsOS3.
* Makefile.in: Re-do the way ldemulation scipts and structures
are done. do we only need one or two files for each emulation
target (a TARGET.sc and optionally TARGET.c, if ldtemplate
isn't suitable).  This gets rid of lots of extra source files.

ld/Makefile.in
ld/config.h
ld/ldlnk960.c
ld/ldm88k.sc

index 5f8f262a7f3fbc7430fb566fbe4922aa49db8255..ee96a54addbb7a5f5c61d814d7d564efe8eab1b3 100644 (file)
@@ -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.
index 931c8bf2d6ed010bd6cd9a0dfe8a47a92bb89610..c3a24441cc6d0200a398927a103c0e22d62ca98b 100644 (file)
@@ -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"
+
 
 
 
index ea4df268be48a7606223f8d1ff65b24ee9a105d7..ff862f99273ca59df16e2c0ee2663ea9cd2d67b8 100755 (executable)
@@ -263,7 +263,7 @@ static char *lnk960_script =
 
 
 static char *lnk960_script_relocateable = 
-#include "ldlnk960r.x"
+#include "ldlnk960.xr"
 ;
 
 static char *lnk960_get_script()
index c4cb37ee1dba28ca9e2f5c21a798061c1d9a673d..408cfde04302d2005fd719670f7dd1d709438b00 100755 (executable)
@@ -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) : 
     {