aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1992-02-15 23:13:00 +0000
committerPer Bothner <per@bothner.com>1992-02-15 23:13:00 +0000
commit7e5c1057bb33fb6be25ada95ba7f58066d88de80 (patch)
tree7c9c733b223dcb3ab608e93fd9c0f13afffee7ff /ld
parent15c5ec2e272c81d2358a96a21dd9cd038f18d61b (diff)
downloadfsf-binutils-gdb-7e5c1057bb33fb6be25ada95ba7f58066d88de80.zip
fsf-binutils-gdb-7e5c1057bb33fb6be25ada95ba7f58066d88de80.tar.gz
fsf-binutils-gdb-7e5c1057bb33fb6be25ada95ba7f58066d88de80.tar.bz2
* Makefile.in: Major changes. Removed some the sed
magic to converts scripts, since that is now handled by genscripts.sh and the *.sc-sh scipt generators. * config.h: Remove a bunch of macros defining emulations and targets. This becomes one less file to edit when adding emulations or targets. * ldemul.h (struct ld_emulation_xfer_struct): Add emulation_name and target_name fields. * ldemul.c, ldemul.h: Define some default functions used by most emulations (and remove from the *.em scripts). * ldemul.c (ldemul_choose_target): Search the new ld_emulations array using a loop (instead of a hardwired nested if statement). Define the ld_emulation from the automatically-geenrated ldemul-list.h. This means you no longer have to edit ldemul.c to add a new emulation. * ldmain.c: Replace {GLD,LNK}960_EMULATION_NAME by their expansions, since the former no longer exist. * PORTING: A very rough first draft of a porting guide.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog63
-rw-r--r--ld/Makefile.in242
-rw-r--r--ld/PORTING63
-rwxr-xr-xld/a29k.sc-sh48
-rw-r--r--ld/config.h30
-rwxr-xr-xld/h8300hms.sc-sh6
6 files changed, 232 insertions, 220 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 6b3bd54..7274d7a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,66 @@
+Sat Feb 15 13:59:54 1992 Per Bothner (bothner at cygnus.com)
+
+ Major rewrite of how ld is configured. The major idea
+ is to use shell scripts to generate everything.
+ * generic.em replaces ldtemplate.
+ * Other *.em files replace various *.c files.
+ A *.em file is a shell script that generates the corresponding
+ ld__*.c file that implements an emulation. This is usually
+ a straight 'cat' of a here-document, possibly with substitutions.
+ * Script files (*.sc) are places by *.sc-sh scripts.
+ Again, these are simple shell scripts that 'cat'
+ here-documents, usually with some substitutions.
+ The output a *.sc-sh is a script file.
+ * Each emulation is defined by a short shell script with
+ extension *.sh that specifies the emulation-specific
+ parameters (such as the name of the *.sh-sc and *.em
+ files to use).
+ * genscript.sh is the master shell script used to generate
+ an emulation. It is passed various argument, including
+ the name a the emulation-speciic *.sh file that it
+ "sources" to set variables to emulation-specifc parameters.
+ * config/mt-foo: Changed EMUL=GLDFOO_EMULATION_NAME
+ to EMUL=foo. (The GLDFOO_EMULATION_NAMEs have bee removed.)
+ * config/mh-foo: Rename LDEMULATION names as appropriate
+ (usually 'gldfoo' -> plain 'foo').
+ * ldwrite.c: Fixed a typo in a comment.
+ * Makefile.in: Major changes. Removed some the sed
+ magic to converts scripts, since that is now handled
+ by genscripts.sh and the *.sc-sh scipt generators.
+ * config.h: Remove a bunch of macros defining emulations
+ and targets. This becomes one less file to edit when
+ adding emulations or targets.
+ * ldemul.h (struct ld_emulation_xfer_struct): Add
+ emulation_name and target_name fields.
+ * ldemul.c, ldemul.h: Define some default functions used
+ by most emulations (and remove from the *.em scripts).
+ * ldemul.c (ldemul_choose_target): Search the new
+ ld_emulations array using a loop (instead of a hardwired
+ nested if statement).
+ Define the ld_emulation from the automatically-geenrated
+ ldemul-list.h. This means you no longer have to edit ldemul.c
+ to add a new emulation.
+ * ldmain.c: Replace {GLD,LNK}960_EMULATION_NAME by
+ their expansions, since the former no longer exist.
+ * PORTING: A very rough first draft of a porting guide.
+
+ * ldgram.y, ldlex.l, lexsup.c: Changes to allow an assignment
+ to be terminated by a new-line (instead of requiring a semicolon).
+
+Mon Feb 10 16:21:02 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * ldexp.c, ldlang.c: added new idea "abs_output_section", removes
+ tests for NULL pointers all over the place.
+ * ldlang.c (lang_process): remember to relocate global symbols
+ *after* relaxing has done it stuff.
+
+Thu Feb 6 11:40:15 1992 Steve Chamberlain (sac at rtl.cygnus.com)
+
+ * config/mt-coff-h8300: use EMUL like everything else
+ * ldlang.c: (print_padding_statement): print the right address.
+ * Makefile.in, config.h, ldemul.c: renamed h8300hds to h8300hms
+
+
Tue Feb 4 15:28:01 1992 Steve Chamberlain (sac at rtl.cygnus.com)
* ldlex.l: Put pack -noinhibit-exec and -sort-common
diff --git a/ld/Makefile.in b/ld/Makefile.in
index c4ff521..411b981 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -80,11 +80,7 @@ TEXI2ROFF=texi2roff
# Which roff program to use to generate index for texi2roff'd doc
ROFF = groff
-SCRIPTS = ldgld68k.sc ldgld.sc \
- ldlnk960.sc ldlnk960r.sc ldgld960.sc \
- i386aout.sc ldm88k.sc ldglda29k.sc news.sc h8300hds.sc ebmon29k.sc
-
-#### Host, target, and site specific Makefile fragments come in here.
+### Host, target, and site specific Makefile fragments come in here.
###
CFLAGS = $(INCLUDES) $(MINUS_G) $(HDEFINES) $(TDEFINES) $(CDEFINES)
@@ -97,75 +93,20 @@ LINTFLAGS = $(INCLUDES) $(EXTRA_DEF)
# 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 .scn script is for linking with -N flag (mix text and data on same page).
-# A .scN script is for linking with -N flag (mix text and data on same page).
-# The diference is that segments should (need) not be page aligned.
-
-# A sed pattern to translate .sc to .scu:
-SED_MAKE_RELOC_WITH_CONSTRUCTORS=\
- -e "/If relocating/,/End if relocating/d" \
- -e "/=/s/[_a-zA-Z.]* *= .*//g" \
- -e '/>/s/} *> *[a-zA-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 builtin script file is included as a C string literal.
-# These are generated by the mkscript filter.
-.sc.x:
- if [ "x"$(LIB_PATH) = "x" ]; then ./mkscript < $< >$*.x ; \
- else \
- (sed <$< -e '/SEARCH_DIR(.*)/d' ; \
- echo $(LIB_PATH) | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | ./mkscript >$*.x;\
- fi
-
-# The .xn script is used if the -n flag is given (write-protect text)..
-# Sunos starts the text segment for demand-paged binaries at 0x2020
-# and other binaries at 0x2000, since the exec header is paged in
-# with the text. Some other Unix variants do the same.
-# For -n and -N flags the offset of the exec header must be removed.
-# This sed script does this if the master script contains
-# a line of the form ".text 0xAAAA BLOCK(0xBBBB):" - the
-# output will contain ".text 0xBBBB:". (For Sunos AAAA=2020 and BBBB=2000.)
-.x.xn:
- sed -e '/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
-
-# The .xN script is used if the -N flag is given (don't write-protect text).
-# This is like -n, except that the data segment need not be page-aligned.
-# So get rid of commands for page-alignment: We assume these use ALIGN
-# with a hex constant that end with 00, since any normal page size is be
-# at least divisible by 256. We use the 00 to avoid matching
-# anything that tries to align of (say) 8-byte boundaries.
-.xn.xN:
- sed -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
-
-# The xu and xr scripts don't search libraries, so LIB_PATH doesn't matter.
-.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
BFDLIB=$(unsubdir)/../bfd$(subdir)/libbfd.a
LIBIBERTY=$(unsubdir)/../libiberty$(subdir)/libiberty.a
+ALL_EMULATIONS=ld__lnk960.o ld__sun3.o ld__i386aout.o \
+ ld__m88kbcs.o ld__a29k.o ld__news.o ld__h8300hms.o ld__ebmon29k.o \
+ ld__sun4.o ld__gld960.o ld__vanilla.o
+
+EMULATION_OFILES=${ALL_EMULATIONS}
+#EMULATION_OFILES=ld__${EMUL}.o ${OTHER_EMULATIONS}
+
OFILES= ldgram.o ldlex.o lexsup.o ldlang.o ldctor.o ldmain.o ldindr.o \
- ldwarn.o ldwrite.o ldexp.o ldlnk960.o ld__gld68k.o ld__i386aout.o \
- ld__m88k.o ld__glda29k.o ld__news.o h8300hds.o ld__ebmon29k.o \
- ld__gld.o ldgld960.o ldemul.o ldver.o ldmisc.o ldsym.o \
- ldvanilla.o ldfile.o \
- relax.o lderror.o
+ ldwarn.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldsym.o \
+ ldfile.o relax.o lderror.o ${EMULATION_OFILES}
HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h \
ldsym.h ldctor.h ldlang.h ldexp.h \
@@ -174,12 +115,12 @@ HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h \
MANSOURCES=ld.tex
LDCSOURCES=ldlang.c lexsup.c ldctor.c ldindr.c ldmain.c ldwrite.c ldwarn.c ldlnk960.c \
- ld__gld.c ld__gld68k.c ld__m88k.c ld__ebmon29k.c \
+ ld__gld.c ld__sun3.c ld__m88k.c ld__ebmon29k.c \
ldgld960.c ldemul.c ldver.c ldmisc.c ldexp.c ldsym.c ldfile.c \
- ldvanilla.c relax.c lderror.c
+ relax.c lderror.c
-GENERATED_SOURCES=ldgram.c ldlex.c ldgram.h ld__*.c
-GENERATED_HEADERS=ldgram.h
+GENERATED_SOURCES=ldgram.c ldlex.c ld__*.c ldemul-list.h
+GENERATED_HEADERS=ldgram.h ldemul-list.h
LDSOURCES=$(LDCSOURCES) ldgram.y ldlex.l ldgram.h
@@ -188,7 +129,7 @@ BFDSOURCES=../../bfd/common/*.c
SOURCES= $(LDSOURCES) $(BFDSOURCES)
LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES)
-STAGESTUFF = *.x *.x[ru] *.sc[ru] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript
+STAGESTUFF = *.x *.x[runN] *.sc[runN] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript
all: Makefile $(LD_PROG)
@@ -200,7 +141,23 @@ ldgram.h ldgram.c: ldgram.y
mv -f y.tab.h ldgram.h
ldmain.o: ldmain.c
- $(CC) $(CFLAGS) -DDEFAULT_EMULATION=$(EMUL) -c $<
+ $(CC) $(CFLAGS) -DDEFAULT_EMULATION='"$(EMUL)"' -c $<
+
+ldemul-list.h: Makefile
+ (echo "/* This file is automatically generated. DO NOT EDIT! */";\
+ for f in `echo " " ${EMULATION_OFILES} "" \
+ | sed -e 's/ld__/ld/g' -e 's/ ld/ /g' -e 's/[.]o//g'`; do \
+ echo "extern ld_emulation_xfer_type ld_$${f}_emulation;"; \
+ done;\
+ echo "";\
+ echo "#define EMULATION_LIST \\";\
+ for f in `echo " " ${EMULATION_OFILES} "" \
+ | sed -e 's/ld__/ld/g' -e 's/ ld/ /g' -e 's/[.]o//g'`; do \
+ echo " &ld_$${f}_emulation, \\"; \
+ done;\
+ echo " 0") >ldemul-list.h
+
+ldemul.o: ldemul-list.h
ldlex.c: ldlex.l
/lib/cpp -E -P $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CDEFINES) $(VPATH)/ldlex.l >ldlex.p
@@ -213,67 +170,55 @@ ldlex.c: ldlex.l
# These all start with ld__ so 'make clean' can find them.
-ld__gld.c: $(srcdir)/ldtemplate
- sed -e s/"<ldtarget>"/ldgld/g -e s/"<arch>"/m68k/g \
- -e s/"<target>"//g -e s/"<TARGET>"//g <$(srcdir)/ldtemplate >$@
-ld__news.c: $(srcdir)/ldtemplate
- sed -e s/"<ldtarget>"/news/g -e s/"<arch>"/m68k/g \
- -e s/"<target>"/news/g -e s/"<TARGET>"/NEWS/g <$(srcdir)/ldtemplate >$@
-
-ld__i386aout.c: $(srcdir)/ldtemplate
- sed -e s/"<ldtarget>"/i386aout/g -e s/"<arch>"/i386/g \
- -e s/"<target>"/i386aout/g -e s/"<TARGET>"/I386AOUT/g <$(srcdir)/ldtemplate >$@
-
-
-ld__ebmon29k.c: $(srcdir)/ldtemplate
- sed -e s/"<ldtarget>"/ebmon29k/g -e s/"<arch>"/a29k/g \
- -e s/"gld<target>"/ebmon29k/g -e s/"GLD<TARGET>"/EBMON29K/g \
- -e s/"<ldtarget>.x"/ebmon.x/ <$(srcdir)/ldtemplate >$@
-
-ld__gld68k.c: $(srcdir)/ldtemplate
- sed -e s/"<ldtarget>"/ldgld68k/g -e s/"<arch>"/m68k/g \
- -e s/"<target>"/68k/g -e s/"<TARGET>"/68K/g <$(srcdir)/ldtemplate >$@
-ld__glda29k.c: $(srcdir)/ldtemplate
- sed -e s/"<ldtarget>"/ldglda29k/g -e s/"<arch>"/a29k/g \
- -e s/"<target>"/29k/g -e s/"<TARGET>"/29K/g <$(srcdir)/ldtemplate >$@
-ld__m88k.c: $(srcdir)/ldtemplate
- sed -e s/"<ldtarget>"/ldm88k/g -e s/"<arch>"/m88k/g \
- -e s/"<target>"/m88kbcs/g -e s/"<TARGET>"/M88KBCS/g <$(srcdir)/ldtemplate >$@
-
-# The .c files for these are generated from ldtemplete.
-ld__gld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu ldgld.xn ldgld.xN
-ld__news.o: ./mkscript news.x news.xr news.xu news.xn news.xN
-ld__i386aout.o: ./mkscript i386aout.x i386aout.xr i386aout.xu i386aout.xn i386aout.xN
-ld__ebmon29k.o: ./mkscript ebmon29k.x ebmon29k.xr ebmon29k.xu \
- ebmon29k.xn ebmon29k.xN
-ld__gld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu \
- ldgld68k.xn ldgld68k.xN
-ld__glda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu \
- ldglda29k.xn ldglda29k.xN
-ld__m88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu ldm88k.xn ldm88k.xN
-
-# The .c files for these are (for now) specially written (not ldtemplete).
-ldgld960.o: ./mkscript ldgld960.x
-ldlnk960.o: ./mkscript ldlnk960.x ldlnk960.xr
-h8300hds.o: ./mkscript h8300hds.x
-
-
-#$(BFDLIB): $(BFDSOURCES)
-# (cd ../bfd; make)
+GENSCRIPTS=sh $(srcdir)/genscripts.sh ${srcdir} ${host_alias} ${target_alias}
+GEN_DEPENDS=./mkscript $(srcdir)/genscripts.sh
+
+ld__sun4.c: $(srcdir)/sun4.sh \
+ $(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} sun4.sh
+ld__sun3.c: $(srcdir)/sun3.sh \
+ $(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} sun3.sh
+ld__news.c: $(srcdir)/news.sh \
+ $(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} news.sh
+ld__i386aout.c: $(srcdir)/i386aout.sh \
+ $(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} i386aout.sh
+ld__ebmon29k.c: $(srcdir)/ebmon29k.sh \
+ $(srcdir)/generic.em $(srcdir)/ebmon29k.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} ebmon29k.sh
+ld__a29k.c: $(srcdir)/a29k.sh \
+ $(srcdir)/generic.em $(srcdir)/a29k.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} a29k.sh
+ld__m88kbcs.c: $(srcdir)/m88kbcs.sh \
+ $(srcdir)/generic.em $(srcdir)/h8300hms.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} m88kbcs.sh
+ld__h8300hms.c: $(srcdir)/h8300hms.sh \
+ $(srcdir)/h8300hms.em $(srcdir)/h8300hms.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} h8300hms.sh
+ld__vanilla.c: $(srcdir)/vanilla.sh \
+ $(srcdir)/vanilla.em $(srcdir)/vanilla.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} vanilla.sh
+ld__lnk960.c: $(srcdir)/lnk960.sh \
+ $(srcdir)/lnk960.em $(srcdir)/i960.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} lnk960.sh
+ld__gld960.c: $(srcdir)/gld960.sh \
+ $(srcdir)/gld960.em $(srcdir)/i960.sc-sh ${GEN_DEPENDS}
+ ${GENSCRIPTS} gld960.sh
$(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES)
-# (cd ../bfd; make)
-# LDEMULATION=gld; export LDEMULATION; GNUTARGET=a.out-sunos-big;./ldok -format a.out-sunos-big -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib
-# gld -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib
-# $(CC) -Bstatic -o ld.new $(OFILES) $(BFDLIB) $(LIBIBERTY)
-
+# Rules for testing by relinking ld itself.
-ld1: ld.new
- $(HOSTING_EMU); ./ld.new -o foo.o -r $(OFILES)
- $(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) foo.o $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
+ld-partial.o: ld.new
+ $(HOSTING_EMU); ./ld.new -o ld-partial.o -r $(OFILES)
+ld1: ld-partial.o
+ $(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) ld-partial.o $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
+ld1-full: ld.new
+ $(HOSTING_EMU); ./ld.new -o ld1-full $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
ld2: ld1
$(HOSTING_EMU); ./ld1 -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
@@ -381,32 +326,7 @@ ldlex.o: ldlex.c ldgram.h
ldgram.o: ldgram.c
ldgram.c:ldgram.y
-ldgld68k.x :ldgld68k.sc
-ldgld68kUr.x :ldgld68kUr.sc
-ldgld68kr.x :ldgld68kr.sc
-h8300hds.x:h8300hds.sc
-ldgld.x :ldgld.sc
-ldgldUr.x :ldgldUr.sc
-ldgldr.x :ldgldr.sc
-ldlnk960.x :ldlnk960.sc
-ldlnk960r.x :ldlnk960r.sc
-ldgld960.x :ldgld960.sc
-ldgldm88k.x :ldgldm88k.sc
-ldm88kUr.x :ldm88kUr.sc
-ldm88kr.x:ldm88kr.sc
-ldm88k.x:ldm88k.sc
-news.x:news.sc
-i386aout.x:i386aout.sc
-h8300hds.x:h8300hds.sc
-h8300hds.o:h8300hds.c
-ldgld68k.x:ldgld68k.sc
-ldglda29k.x :ldglda29k.sc
-ldglda29kr.x :ldglda29kr.sc
-ldglda29kUr.x :ldglda29kUr.sc
-
-ebmon29k.x :ebmon29k.sc
-ebmon29kr.x :ebmon29kr.sc
-ebmon29kUr.x :ebmon29kUr.sc
+h8300hms.o:h8300hms.c
stage1: force
-mkdir stage1
@@ -444,10 +364,9 @@ de-stage3: force
-rmdir stage3
clean:
- -rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS)
- -rm -f *.x *.x[runN] *.sc[runN]
- -rm -f ld.?? ld.???
- -rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output
+ -rm -f TAGS $(STAGESTUFF)
+ -rm -f ld.?? ld.??? ldlex.[qp]
+ -rm -f ld ld1 ld2 ld3 *.o y.output
lintlog:$(SOURCES) Makefile
$(LINT) -abhxzn $(LINTFLAGS) $(LINTSOURCES) \
@@ -469,9 +388,6 @@ objdump:objdump.c
install: $(LD_PROG)
$(INSTALL_PROGRAM) ld.new $(bindir)/ld
- -if [ -d "$(gcclibdir)" ] ; then \
- $(INSTALL_PROGRAM) ld.new $(gcclibdir)/ld ; \
- fi
install-info: info
for i in ld.info* ; do \
diff --git a/ld/PORTING b/ld/PORTING
new file mode 100644
index 0000000..706172b
--- /dev/null
+++ b/ld/PORTING
@@ -0,0 +1,63 @@
+Some incomplete notes about porting GNU ld
+-----------------------------------------
+
+Before porting ld itself, you will need to port the BFD library.
+
+We tarlk about the 'host' system as the machine and software
+nevironment where ld runs (generates an execuitble *on*),
+while the 'target' is the machine ld generates an executable *for*.
+Most often, host==target, but ld supports cross-linking
+(and to some extent the same ld binary can be used a linker
+for multiple target rachitectures).
+
+Doing a 'host' port means working around broken or missing
+include files or libraries. ...
+
+Porting to a new target
+-----------------------
+
+Writing a new script script
+---------------------------
+
+You may need to write a new script file for your emulation.
+
+The variable RELOCATING is only set if relocation is happening
+(i.e. unless the linker is invoked with -r).
+Thus your script should has an action ACTION
+that should only be done when relocating,
+express that as:
+ ${RELOCATING+ ACTION}
+In general, this is the case for most assignments, which should look like:
+ ${RELOCATING+ _end = .}
+
+Also, you should assign absolute addresses to sections only
+when relocating, so:
+ .text ${RELOCATING+ ${TEXT_START_ADDR}}:
+
+The forms:
+ .section { ... } > section
+should be:
+ .section { ... } > ${RELOCATING+ section}
+
+Old Makefile comments (re-write - FXIME!)
+-----------------------------------------
+
+# The .xn script is used if the -n flag is given (write-protect text)..
+# Sunos starts the text segment for demand-paged binaries at 0x2020
+# and other binaries at 0x2000, since the exec header is paged in
+# with the text. Some other Unix variants do the same.
+# For -n and -N flags the offset of the exec header must be removed.
+# This sed script does this if the master script contains
+# a line of the form ".text 0xAAAA BLOCK(0xBBBB):" - the
+# output will contain ".text 0xBBBB:". (For Sunos AAAA=2020 and BBBB=2000.)
+.x.xn:
+ sed -e '/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
+
+# The .xN script is used if the -N flag is given (don't write-protect text).
+# This is like -n, except that the data segment need not be page-aligned.
+# So get rid of commands for page-alignment: We assume these use ALIGN
+# with a hex constant that end with 00, since any normal page size is be
+# at least divisible by 256. We use the 00 to avoid matching
+# anything that tries to align of (say) 8-byte boundaries.
+.xn.xN:
+ sed -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
diff --git a/ld/a29k.sc-sh b/ld/a29k.sc-sh
index ffc4219..e58af43 100755
--- a/ld/a29k.sc-sh
+++ b/ld/a29k.sc-sh
@@ -1,9 +1,8 @@
cat <<EOF
-OUTPUT_FORMAT("coff-a29k-big")
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
INPUT(/lab3/u3/sym1/tools/usr/lib/segments.o) /* Has .rstack/.mstack */
-SEARCH_DIR(/lib)
-SEARCH_DIR(/usr/lib)
-SEARCH_DIR(/usr/local/lib)
+${LIB_SEARCH_DIRS}
+
MEMORY {
text : ORIGIN = 0x1000000, LENGTH = 0x1000000
talias : ORIGIN = 0x2000000, LENGTH = 0x1000000
@@ -11,30 +10,29 @@ MEMORY {
mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000
rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000
}
-SECTIONS
-{
- .text : {
+SECTIONS
+{
+ .text : {
*(.text)
- __etext = .;
- *(.lit)
- *(.shdata)
- } > text
+ ${RELOCATING+ __etext = .}
+ *(.lit)
+ *(.shdata)
+ } ${RELOCATING+ > text}
.shbss SIZEOF(.text) + ADDR(.text) : {
- *(.shbss)
+ *(.shbss)
}
- .talias : { } > talias
- .data : {
- *(.data)
- __edata = .;
- } > data
- .bss SIZEOF(.data) + ADDR(.data) :
+ .talias : { } ${RELOCATING+ > talias}
+ .data : {
+ *(.data)
+ ${RELOCATING+ __edata = .}
+ } ${RELOCATING+ > data}
+ .bss SIZEOF(.data) + ADDR(.data) :
{
- *(.bss)
- *(COMMON)
- __end = ALIGN(0x8);
- }
- .mstack : { } > mstack
- .rstack : { } > rstack
+ *(.bss)
+ *(COMMON)
+ ${RELOCATING+ __end = ALIGN(0x8)}
+ }
+ .mstack : { } ${RELOCATING+ > mstack}
+ .rstack : { } ${RELOCATING+ > rstack}
}
-
EOF
diff --git a/ld/config.h b/ld/config.h
index 0d6d1f2..6cf7613 100644
--- a/ld/config.h
+++ b/ld/config.h
@@ -21,44 +21,16 @@
/* Look in this environment name for the linker to pretend to be */
#define EMULATION_ENVIRON "LDEMULATION"
/* If in there look for the strings: */
-#define GLD_EMULATION_NAME "gld"
-#define VANILLA_EMULATION_NAME "vanilla"
-#define GLDM88KBCS_EMULATION_NAME "gldm88kbcs"
-#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"
-#define H8300HMS_EMULATION_NAME "h8300hms"
-#define EBMON29K_EMULATION_NAME "ebmon29k"
-#define GLDI386AOUT_EMULATION_NAME "gldi386aout"
/* Otherwise default to this emulation */
#ifndef DEFAULT_EMULATION
-#ifdef GNU960
-#define DEFAULT_EMULATION GLD960_EMULATION_NAME
-#else
-#define DEFAULT_EMULATION GLD68K_EMULATION_NAME
-#endif
+#define DEFAULT_EMULATION "unknown"
#endif /* DEFAULT_EMULATION */
/* Look in this variable for a target format */
#define TARGET_ENVIRON "GNUTARGET"
-/* If not there then choose this */
-#define GLD_TARGET "a.out-sunos-big"
-#define GLD68K_TARGET "a.out-sunos-big"
-#define LNK960_TARGET "coff-Intel-big"
-#define LNK960_TARGET_LITTLE "coff-Intel-little"
-#define GLD960_TARGET "b.out.big"
-#define VANILLA_TARGET "a.out-sunos-big"
-#define GLDM88KBCS_TARGET "m88kbcs"
-#define GLD29K_TARGET "coff-a29k-big"
-#define GLDI386AOUT_TARGET "a.out-i386"
-#define GLDNEWS_TARGET "a.out-newsos3"
-#define H8300HMS_TARGET "coff-h8300"
-#define EBMON29K_TARGET "coff-a29k-big"
diff --git a/ld/h8300hms.sc-sh b/ld/h8300hms.sc-sh
index 8aa7ee1..f48b11b 100755
--- a/ld/h8300hms.sc-sh
+++ b/ld/h8300hms.sc-sh
@@ -15,17 +15,17 @@ SECTIONS
{
*(.text)
*(.strings)
- } > ram
+ } ${RELOCATING+ > ram}
.data :
{
*(.data)
- } > ram
+ } ${RELOCATING+ > ram}
.bss :
{
${RELOCATING+ _bss_start = .}
*(.bss)
*(COMMON)
${RELOCATING+ _end = .}
- } >ram
+ } ${RELOCATING+ >ram}
}
EOF