* ldfile.c (ldfile_open_command): Don't try .ld extension.

It wasn't documented (or likely used) and wastes time.
	(try_open): If EXTEN is empty, don't try it.

	* ldctor.c, lderror.c, ldexp.c, ldfile.c, ldindr.c, ldlang.c,
	ldlex.l, ldmain.c, ldmisc.c, ldsym.c, ldver.c, ldwarn.c,
	ldwrite.c, lexsup.c, mri.c, relax.c: Replace DEFUN macro calls
	with normal function declarations.

	* Move *.em to emultempl/*.em.  Move *.sh to emulparams/*.sh.
	Move *.sc-sh to scripttempl/*.sc.
	* {emultempl,emulparams,scripttempl}/README: New files.
	* sh.em, st2000.em, z8ksim.em, h8300hms.em, h8500hms.em: Files
	removed, replaced with generic.em.
	* h8300.sh, h8500.sh, h8300.sc, h8500.sc: Renamed from
	 h8[35]00hms.s[ch].  Change their contents to omit the "hms".

	* *.em (*_get_script): Return script name instead of script contents.
	* ldlang.c (lang_process): Change caller.

	* ldlex.l, ldgram.y: Recognize -m option.
	Check for input files after *all* options in grammar.
	* ldmain.c (main): Check for -m options.  Add default directory
	for -m.

	* mkscript.c: File removed.
	* genscripts.sh: Take two more parameters, tooldirlib and libdir,
	to add to the default LIB_PATH.
	Look for input files in the new subdirectories.
	Create the scripts in emulations subdirectory and don't filter
	them through mkscript.
	* configure.in: Make the emulations subdirectory.

	* Makefile.in: Account for all of the above changes.
	Remove unused .SUFFIXES.  Get libgcc.a path with gcc
	-print-libgcc-file-name instead of $(libdir)/libgcc.a.
	Put CFLAGS last in the compilation rules.
	Add -I../bfd to INCLUDES so sysdep.h is found.

	* ldfile.c (try_open): If opening without the extension fails,
	try with the extension even if -v or -V was given.
	had_script is imported (from ldgram.y), not exported.
This commit is contained in:
David MacKenzie
1993-06-17 20:55:43 +00:00
parent 21cc14d850
commit 8ddef5528d
63 changed files with 1781 additions and 750 deletions

View File

@ -34,9 +34,6 @@ Makefile.in
NEWS NEWS
README README
TODO TODO
a29k.sc-sh
a29k.sh
aout.sc-sh
cdtest-foo.cc cdtest-foo.cc
cdtest-foo.h cdtest-foo.h
cdtest-func.cc cdtest-func.cc
@ -46,32 +43,10 @@ config
config.h config.h
configure.bat configure.bat
configure.in configure.in
ebmon29k.sc-sh
ebmon29k.sh
generic.em
genscripts.sh genscripts.sh
h8-doc.texi h8-doc.texi
ld.1 ld.1
gen-doc.texi gen-doc.texi
gld960.em
gld960.sh
go32.sh
hp300bsd.sh
hp3hpux.sh
hppaosf.em
hppaosf.sc-sh
hppaosf.sh
h8300hms.em
h8300hms.sc-sh
h8300hms.sh
h8500hms.em
h8500hms.sc-sh
h8500hms.sh
i386aout.sh
i386bsd.sh
i386coff.sc-sh
i386coff.sh
i960.sc-sh
ld.h ld.h
ld.texinfo ld.texinfo
ldctor.c ldctor.c
@ -105,44 +80,10 @@ ldwarn.h
ldwrite.c ldwrite.c
ldwrite.h ldwrite.h
lexsup.c lexsup.c
lnk960.em
lnk960.sh
m68kcoff.sc-sh
m68kcoff.sh
m88kbcs.sc-sh
m88kbcs.sh
mips.sc-sh
mipsbig.sh
mipsbsd.sc-sh
mipsbsd.sh
mipsidt.sh
mipsidtl.sh
mipslit.sh
mri.c mri.c
mri.h mri.h
go32.sh
mkscript.c
news.sh
relax.c relax.c
relax.h relax.h
sh.em
sh.sc-sh
sh.sh
st2000.em
st2000.sc-sh
st2000.sh
sa29200.sc-sh
sa29200.sh
scripts
sun3.sh
sun4.sh
vanilla.em
vanilla.sc-sh
vanilla.sh
vax.sh
z8ksim.em
z8ksim.sc-sh
z8ksim.sh
Things-to-lose: Things-to-lose:

View File

@ -1,3 +1,44 @@
Wed Jun 16 11:45:32 1993 David J. Mackenzie (djm@thepub.cygnus.com)
* ldfile.c (ldfile_open_command): Don't try .ld extension.
It wasn't documented (or likely used) and wastes time.
(try_open): If EXTEN is empty, don't try it.
* ldctor.c, lderror.c, ldexp.c, ldfile.c, ldindr.c, ldlang.c,
ldlex.l, ldmain.c, ldmisc.c, ldsym.c, ldver.c, ldwarn.c,
ldwrite.c, lexsup.c, mri.c, relax.c: Replace DEFUN macro calls
with normal function declarations.
* Move *.em to emultempl/*.em. Move *.sh to emulparams/*.sh.
Move *.sc-sh to scripttempl/*.sc.
* {emultempl,emulparams,scripttempl}/README: New files.
* sh.em, st2000.em, z8ksim.em, h8300hms.em, h8500hms.em: Files
removed, replaced with generic.em.
* h8300.sh, h8500.sh, h8300.sc, h8500.sc: Renamed from
h8[35]00hms.s[ch]. Change their contents to omit the "hms".
* *.em (*_get_script): Return script name instead of script contents.
* ldlang.c (lang_process): Change caller.
* ldlex.l, ldgram.y: Recognize -m option.
Check for input files after *all* options in grammar.
* ldmain.c (main): Check for -m options. Add default directory
for -m.
* mkscript.c: File removed.
* genscripts.sh: Take two more parameters, tooldirlib and libdir,
to add to the default LIB_PATH.
Look for input files in the new subdirectories.
Create the scripts in emulations subdirectory and don't filter
them through mkscript.
* configure.in: Make the emulations subdirectory.
* Makefile.in: Account for all of the above changes.
Remove unused .SUFFIXES. Get libgcc.a path with gcc
-print-libgcc-file-name instead of $(libdir)/libgcc.a.
Put CFLAGS last in the compilation rules.
Add -I../bfd to INCLUDES so sysdep.h is found.
Tue Jun 15 23:04:46 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) Tue Jun 15 23:04:46 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
* Makefile.in (INCLUDES): Look in ../include, not ../bfd. * Makefile.in (INCLUDES): Look in ../include, not ../bfd.
@ -6,6 +47,12 @@ Tue Jun 15 23:04:46 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
dependent on RELOCATING, not RELOCATION. dependent on RELOCATING, not RELOCATION.
* hp3hpux.sh (SHLIB_PATH): Define it. * hp3hpux.sh (SHLIB_PATH): Define it.
Mon Jun 14 19:06:15 1993 David J. Mackenzie (djm@thepub.cygnus.com)
* ldfile.c (try_open): If opening without the extension fails,
try with the extension even if -v or -V was given.
had_script is imported (from ldgram.y), not exported.
Mon Jun 14 16:26:10 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com) Mon Jun 14 16:26:10 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
* Makefile.in: remove parentdir support, use INSTALL_XFORM * Makefile.in: remove parentdir support, use INSTALL_XFORM
@ -362,6 +409,7 @@ Wed Dec 9 08:38:05 1992 Steve Chamberlain (sac@thepub.cygnus.com)
(lang_ini_script_file): initialize more parts of the command line (lang_ini_script_file): initialize more parts of the command line
bfd. bfd.
* ldlex.l: fix DEFINED start states. * ldlex.l: fix DEFINED start states.
Mon Dec 7 08:43:41 1992 Steve Chamberlain (sac@thepub.cygnus.com) Mon Dec 7 08:43:41 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-y support -y support
* ld.texinfo: new doc. * ld.texinfo: new doc.

View File

@ -41,6 +41,7 @@ man9dir = $(mandir)/man9
infodir = $(prefix)/info infodir = $(prefix)/info
includedir = $(prefix)/include includedir = $(prefix)/include
docdir = $(datadir)/doc docdir = $(datadir)/doc
scriptdir = $(datadir)/ld
gcclibdir = $(libdir)/gcc/$(target_alias) gcclibdir = $(libdir)/gcc/$(target_alias)
@ -75,7 +76,7 @@ LIB_PATH =
BASEDIR = ../.. BASEDIR = ../..
INCLUDE = $(srcdir)/../include INCLUDE = $(srcdir)/../include
INCLUDES = -I. -I$(srcdir) -I../include -I$(srcdir)/../bfd -I$(INCLUDE) INCLUDES = -I. -I$(srcdir) -I../include -I$(srcdir)/../bfd -I../bfd -I$(INCLUDE)
# What version of the manual to build # What version of the manual to build
DOCVER = gen DOCVER = gen
@ -95,8 +96,8 @@ ROFF = groff
#stuff for self hosting (can be overridden in config file). #stuff for self hosting (can be overridden in config file).
HOSTING_CRT0=/lib/crt0.o HOSTING_CRT0=/lib/crt0.o
HOSTING_LIBS=`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else echo $(libdir)/libgcc.a; fi` -lc HOSTING_LIBS=`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc
HOSTING_EMU=LDEMULATION=$(EMUL); export LDEMULATION HOSTING_EMU=-m $(EMUL)
C++ = g++ -fgnu-linker C++ = g++ -fgnu-linker
@ -105,13 +106,8 @@ C++ = g++ -fgnu-linker
LINTFLAGS = $(INCLUDES) $(EXTRA_DEF) LINTFLAGS = $(INCLUDES) $(EXTRA_DEF)
.SUFFIXES: .y .x .xr .xu .xn .xbn .sc .scu .scr .scn $(SUFFIXES) .cc
.c.o: .c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CDEFINES) $< $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CDEFINES) $(CFLAGS) $<
.cc.o:
$(C++) -c $(CFLAGS) -I$(srcdir) $<
# go directly to ld.new in case this ld isn't capable of # go directly to ld.new in case this ld isn't capable of
# linking native object on this host. It can be renamed on # linking native object on this host. It can be renamed on
@ -124,10 +120,10 @@ LIBIBERTY=./../libiberty/libiberty.a
ALL_EMULATIONS=em_lnk960.o em_sun3.o em_i386aout.o em_go32.o \ ALL_EMULATIONS=em_lnk960.o em_sun3.o em_i386aout.o em_go32.o \
em_m88kbcs.o em_a29k.o em_news.o em_hp300bsd.o em_hp3hpux.o \ em_m88kbcs.o em_a29k.o em_news.o em_hp300bsd.o em_hp3hpux.o \
em_h8300hms.o em_ebmon29k.o em_sun4.o em_gld960.o \ em_h8300.o em_ebmon29k.o em_sun4.o em_gld960.o \
em_m68kcoff.o em_st2000.o em_sa29200.o \ em_m68kcoff.o em_st2000.o em_sa29200.o \
em_vanilla.o em_i386coff.o em_z8ksim.o em_mipslit.o em_i386bsd.o \ em_vanilla.o em_i386coff.o em_z8ksim.o em_mipslit.o em_i386bsd.o \
em_mipsbig.o em_mipsbsd.o em_mipsidt.o em_vax.o em_h8500hms.o \ em_mipsbig.o em_mipsbsd.o em_mipsidt.o em_vax.o em_h8500.o \
em_hppaosf.o em_mipsidtl.o em_sh.o em_hppaosf.o em_mipsidtl.o em_sh.o
EMULATION_OFILES=${ALL_EMULATIONS} EMULATION_OFILES=${ALL_EMULATIONS}
@ -157,12 +153,10 @@ BFDSOURCES=../../bfd/common/*.c
SOURCES= $(LDSOURCES) $(BFDSOURCES) SOURCES= $(LDSOURCES) $(BFDSOURCES)
LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES) LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES)
STAGESTUFF = *.x *.x[runN] *.sc[runN] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) mkscript STAGESTUFF = emulations/* $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES)
all: $(LD_PROG) all: $(LD_PROG)
check: bootstrap check-cdtest
installcheck:
info: ld.info info: ld.info
ldgram.h ldgram.c: ldgram.y ldgram.h ldgram.c: ldgram.y
@ -179,7 +173,7 @@ DEF_EMUL = ` if [ -z "$(EMUL)" ] ; then \
fi` fi`
ldmain.o: ldmain.c ldmain.o: ldmain.c
$(CC) $(CFLAGS) $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CDEFINES) $(DEF_EMUL) -c $< $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CDEFINES) $(DEF_EMUL) -DSCRIPTDIR='"$(scriptdir)"' $(CFLAGS) $<
ldemul-list.h: ldemul-list.h:
(echo "/* This file is automatically generated. DO NOT EDIT! */";\ (echo "/* This file is automatically generated. DO NOT EDIT! */";\
@ -203,121 +197,129 @@ ldlex.c: ldlex.l ldgram.h
# These all start with em_ so 'make clean' can find them. # These all start with em_ so 'make clean' can find them.
GENSCRIPTS=sh $(srcdir)/genscripts.sh ${srcdir} ${host_alias} ${target_alias} GENSCRIPTS=sh $(srcdir)/genscripts.sh ${srcdir} ${tooldir}/lib ${libdir} ${host_alias} ${target_alias}
GEN_DEPENDS=mkscript $(srcdir)/genscripts.sh GEN_DEPENDS=$(srcdir)/genscripts.sh
em_sun4.c: $(srcdir)/sun4.sh \ em_sun4.c: $(srcdir)/emulparams/sun4.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} sun4.sh ${GENSCRIPTS} sun4.sh
em_sun3.c: $(srcdir)/sun3.sh \ em_sun3.c: $(srcdir)/emulparams/sun3.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} sun3.sh ${GENSCRIPTS} sun3.sh
em_go32.c: $(srcdir)/go32.sh \ em_go32.c: $(srcdir)/emulparams/go32.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} go32.sh ${GENSCRIPTS} go32.sh
em_news.c: $(srcdir)/news.sh \ em_news.c: $(srcdir)/emulparams/news.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} news.sh ${GENSCRIPTS} news.sh
em_vax.c: $(srcdir)/vax.sh \ em_vax.c: $(srcdir)/emulparams/vax.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} vax.sh ${GENSCRIPTS} vax.sh
em_hp300bsd.c: $(srcdir)/hp300bsd.sh \ em_hp300bsd.c: $(srcdir)/emulparams/hp300bsd.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} hp300bsd.sh ${GENSCRIPTS} hp300bsd.sh
em_hp3hpux.c: $(srcdir)/hp3hpux.sh \ em_hp3hpux.c: $(srcdir)/emulparams/hp3hpux.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} hp3hpux.sh ${GENSCRIPTS} hp3hpux.sh
em_hppaosf.c: $(srcdir)/hppaosf.sh \ em_hppaosf.c: $(srcdir)/emulparams/hppaosf.sh \
$(srcdir)/hppaosf.em $(srcdir)/hppaosf.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/hppaosf.em $(srcdir)/scripttempl/hppaosf.sc ${GEN_DEPENDS}
${GENSCRIPTS} hppaosf.sh ${GENSCRIPTS} hppaosf.sh
em_i386aout.c: $(srcdir)/i386aout.sh \ em_i386aout.c: $(srcdir)/emulparams/i386aout.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} i386aout.sh ${GENSCRIPTS} i386aout.sh
em_ebmon29k.c: $(srcdir)/ebmon29k.sh \ em_ebmon29k.c: $(srcdir)/emulparams/ebmon29k.sh \
$(srcdir)/generic.em $(srcdir)/ebmon29k.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/ebmon29k.sc ${GEN_DEPENDS}
${GENSCRIPTS} ebmon29k.sh ${GENSCRIPTS} ebmon29k.sh
em_sa29200.c: $(srcdir)/sa29200.sh \ em_sa29200.c: $(srcdir)/emulparams/sa29200.sh \
$(srcdir)/generic.em $(srcdir)/sa29200.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sa29200.sc ${GEN_DEPENDS}
${GENSCRIPTS} sa29200.sh ${GENSCRIPTS} sa29200.sh
em_a29k.c: $(srcdir)/a29k.sh \ em_a29k.c: $(srcdir)/emulparams/a29k.sh \
$(srcdir)/generic.em $(srcdir)/a29k.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/a29k.sc ${GEN_DEPENDS}
${GENSCRIPTS} a29k.sh ${GENSCRIPTS} a29k.sh
em_m88kbcs.c: $(srcdir)/m88kbcs.sh \ em_m88kbcs.c: $(srcdir)/emulparams/m88kbcs.sh \
$(srcdir)/generic.em $(srcdir)/h8300hms.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8300.sc ${GEN_DEPENDS}
${GENSCRIPTS} m88kbcs.sh ${GENSCRIPTS} m88kbcs.sh
em_h8300hms.c: $(srcdir)/h8300hms.sh \ em_h8300.c: $(srcdir)/emulparams/h8300.sh \
$(srcdir)/h8300hms.em $(srcdir)/h8300hms.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8300.sc ${GEN_DEPENDS}
${GENSCRIPTS} h8300hms.sh ${GENSCRIPTS} h8300.sh
em_h8500hms.c: $(srcdir)/h8500hms.sh \ em_h8500.c: $(srcdir)/emulparams/h8500.sh \
$(srcdir)/h8500hms.em $(srcdir)/h8500hms.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8500.sc ${GEN_DEPENDS}
${GENSCRIPTS} h8500hms.sh ${GENSCRIPTS} h8500.sh
em_sh.c: $(srcdir)/sh.sh \ em_sh.c: $(srcdir)/emulparams/sh.sh \
$(srcdir)/sh.em $(srcdir)/sh.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
${GENSCRIPTS} sh.sh ${GENSCRIPTS} sh.sh
em_st2000.c: $(srcdir)/st2000.sh \ em_st2000.c: $(srcdir)/emulparams/st2000.sh \
$(srcdir)/st2000.em $(srcdir)/st2000.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/st2000.sc ${GEN_DEPENDS}
${GENSCRIPTS} st2000.sh ${GENSCRIPTS} st2000.sh
em_z8ksim.c: $(srcdir)/z8ksim.sh \ em_z8ksim.c: $(srcdir)/emulparams/z8ksim.sh \
$(srcdir)/z8ksim.em $(srcdir)/z8ksim.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/z8ksim.sc ${GEN_DEPENDS}
${GENSCRIPTS} z8ksim.sh ${GENSCRIPTS} z8ksim.sh
em_vanilla.c: $(srcdir)/vanilla.sh \ em_vanilla.c: $(srcdir)/emulparams/vanilla.sh \
$(srcdir)/vanilla.em $(srcdir)/vanilla.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/vanilla.em $(srcdir)/scripttempl/vanilla.sc ${GEN_DEPENDS}
${GENSCRIPTS} vanilla.sh ${GENSCRIPTS} vanilla.sh
em_lnk960.c: $(srcdir)/lnk960.sh \ em_lnk960.c: $(srcdir)/emulparams/lnk960.sh \
$(srcdir)/lnk960.em $(srcdir)/i960.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/lnk960.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS}
${GENSCRIPTS} lnk960.sh ${GENSCRIPTS} lnk960.sh
em_gld960.c: $(srcdir)/gld960.sh \ em_gld960.c: $(srcdir)/emulparams/gld960.sh \
$(srcdir)/gld960.em $(srcdir)/i960.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/gld960.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS}
${GENSCRIPTS} gld960.sh ${GENSCRIPTS} gld960.sh
em_m68kcoff.c: $(srcdir)/m68kcoff.sh \ em_m68kcoff.c: $(srcdir)/emulparams/m68kcoff.sh \
$(srcdir)/generic.em $(srcdir)/m68kcoff.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m68kcoff.sc ${GEN_DEPENDS}
${GENSCRIPTS} m68kcoff.sh ${GENSCRIPTS} m68kcoff.sh
em_i386coff.c: $(srcdir)/i386coff.sh \ em_i386coff.c: $(srcdir)/emulparams/i386coff.sh \
$(srcdir)/generic.em $(srcdir)/i386coff.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386coff.sc ${GEN_DEPENDS}
${GENSCRIPTS} i386coff.sh ${GENSCRIPTS} i386coff.sh
em_mipslit.c: $(srcdir)/mipslit.sh \ em_mipslit.c: $(srcdir)/emulparams/mipslit.sh \
$(srcdir)/generic.em $(srcdir)/mips.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS}
${GENSCRIPTS} mipslit.sh ${GENSCRIPTS} mipslit.sh
em_i386bsd.c: $(srcdir)/i386bsd.sh \ em_i386bsd.c: $(srcdir)/emulparams/i386bsd.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} i386bsd.sh ${GENSCRIPTS} i386bsd.sh
em_mipsbig.c: $(srcdir)/mipsbig.sh \ em_mipsbig.c: $(srcdir)/emulparams/mipsbig.sh \
$(srcdir)/generic.em $(srcdir)/mips.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS}
${GENSCRIPTS} mipsbig.sh ${GENSCRIPTS} mipsbig.sh
em_mipsbsd.c: $(srcdir)/mipsbsd.sh \ em_mipsbsd.c: $(srcdir)/emulparams/mipsbsd.sh \
$(srcdir)/generic.em $(srcdir)/aout.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} mipsbsd.sh ${GENSCRIPTS} mipsbsd.sh
em_mipsidt.c: $(srcdir)/mipsidt.sh \ em_mipsidt.c: $(srcdir)/emulparams/mipsidt.sh \
$(srcdir)/generic.em $(srcdir)/mips.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS}
${GENSCRIPTS} mipsidt.sh ${GENSCRIPTS} mipsidt.sh
em_mipsidtl.c: $(srcdir)/mipsidtl.sh \ em_mipsidtl.c: $(srcdir)/emulparams/mipsidtl.sh \
$(srcdir)/generic.em $(srcdir)/mips.sc-sh ${GEN_DEPENDS} $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS}
${GENSCRIPTS} mipsidtl.sh ${GENSCRIPTS} mipsidtl.sh
$(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY)
$(CC) $(CFLAGS) $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CDEFINES) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES) $(CC) $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CDEFINES) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES) $(CFLAGS)
# CHECK TARGETS
check: bootstrap check-cdtest
installcheck:
# Rules for testing by relinking ld itself. # Rules for testing by relinking ld itself.
ld-partial.o: ld.new ld-partial.o: ld.new
$(HOSTING_EMU); ./ld.new -o ld-partial.o -r $(OFILES) ./ld.new -Lemulations $(HOSTING_EMU) -o ld-partial.o -r $(OFILES)
ld1: ld-partial.o ld1: ld-partial.o
$(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) ld-partial.o $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) ./ld.new -Lemulations $(HOSTING_EMU) -o ld1 $(HOSTING_CRT0) ld-partial.o $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
ld1-full: ld.new ld1-full: ld.new
$(HOSTING_EMU); ./ld.new -o ld1-full $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) ./ld.new -Lemulations $(HOSTING_EMU) -o ld1-full $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
ld2: ld1 ld2: ld1
$(HOSTING_EMU); ./ld1 -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) ./ld1 -Lemulations $(HOSTING_EMU) -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
ld3: ld2 ld3: ld2
$(HOSTING_EMU); ./ld2 -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) ./ld2 -Lemulations $(HOSTING_EMU) -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
bootstrap: ld3 bootstrap: ld3
cmp ld2 ld3 cmp ld2 ld3
# A test program for C++ constructors and destructors.
cdtest: cdtest-main.o cdtest-func.o cdtest-foo.o ld.new cdtest: cdtest-main.o cdtest-func.o cdtest-foo.o ld.new
$(HOSTING_EMU); ./ld.new -o cdtest $(HOSTING_CRT0) \ ./ld.new -Lemulations $(HOSTING_EMU) -o cdtest $(HOSTING_CRT0) \
cdtest-main.o cdtest-func.o cdtest-foo.o $(HOSTING_LIBS) cdtest-main.o cdtest-func.o cdtest-foo.o $(HOSTING_LIBS)
check-cdtest: cdtest $(srcdir)/cdtest.exp check-cdtest: cdtest $(srcdir)/cdtest.exp
@ -423,12 +425,6 @@ ld-index.me: ld.me
texi2index >ld-index.me texi2index >ld-index.me
mkscript.o: $(srcdir)/mkscript.c
$(CC_FOR_BUILD) -c $(srcdir)/mkscript.c
mkscript: mkscript.o
$(CC_FOR_BUILD) -o mkscript mkscript.o
ldlex.o: ldlex.c ldgram.h ldlex.o: ldlex.c ldgram.h
ldgram.o: ldgram.c ldgram.o: ldgram.c
ldgram.c:ldgram.y ldgram.c:ldgram.y
@ -441,7 +437,7 @@ lexsup.o: lexsup.c ldgram.h
mri.o: mri.c ldgram.h mri.o: mri.c ldgram.h
relax.o: relax.c ldgram.h relax.o: relax.c ldgram.h
h8300hms.o:h8300hms.c h8300.o:h8300.c
h8300xray.o:h8300xray.c h8300xray.o:h8300xray.c
st2000.o:st2000.c st2000.o:st2000.c
z8ksim.o:z8ksim.c z8ksim.o:z8ksim.c
@ -515,9 +511,9 @@ objdump:objdump.c
.PHONY: install .PHONY: install
install: install:
$(INSTALL_XFORM) ld.new $(bindir)/ld; \ $(INSTALL_XFORM) ld.new $(bindir)/ld
$(INSTALL_XFORM1) $(srcdir)/ld.1 $(man1dir)/ld.1; \ $(INSTALL_XFORM1) $(srcdir)/ld.1 $(man1dir)/ld.1
cd emulations; for f in *; do $(INSTALL_DATA) $$f $(scriptdir)/$$f; done
-n=`t='$(program_transform_name)'; echo ld | sed -e "" $$t`; \ -n=`t='$(program_transform_name)'; echo ld | sed -e "" $$t`; \
rm -f $(tooldir)/bin/ld; \ rm -f $(tooldir)/bin/ld; \
ln $(bindir)/$$n $(tooldir)/bin/ld \ ln $(bindir)/$$n $(tooldir)/bin/ld \

View File

@ -9,6 +9,8 @@ target_dependent=true
# per-host: # per-host:
. ${srcdir}/../bfd/configure.host
host_makefile_frag= host_makefile_frag=
if [ -f ${srcdir}/config/${my_host}.mh ] ; then if [ -f ${srcdir}/config/${my_host}.mh ] ; then
@ -122,3 +124,5 @@ if [ ! -r ${srcdir}/${target_makefile_frag} ]; then
echo '***' GNU LD does not support target ${target} 1>&2 echo '***' GNU LD does not support target ${target} 1>&2
exit 1 exit 1
fi fi
mkdir emulations 2>/dev/null

65
ld/emulparams/.Sanitize Normal file
View File

@ -0,0 +1,65 @@
# .Sanitize for devo/ld/config
# Each directory to survive its way into a release will need a file
# like this one called "./.Sanitize". All keyword lines must exist,
# and must exist in the order specified by this file. Each directory
# in the tree will be processed, top down, in the following order.
# Hash started lines like this one are comments and will be deleted
# before anything else is done. Blank lines will also be squashed
# out.
# The lines between the "Do-first:" line and the "Things-to-keep:"
# line are executed as a /bin/sh shell script before anything else is
# done in this directory.
Do-first:
# All files listed between the "Things-to-keep:" line and the
# "Do-last:" line will be kept. All other files will be removed.
# Directories listed in this section will have their own Sanitize
# called. Directories not listed will be removed in their entirety
# with rm -rf.
Things-to-keep:
README
a29k.sh
ebmon29k.sh
gld960.sh
go32.sh
h8300.sh
h8500.sh
hp300bsd.sh
hp3hpux.sh
hppaosf.sh
i386aout.sh
i386bsd.sh
i386coff.sh
lnk960.sh
m68kcoff.sh
m88kbcs.sh
mipsbig.sh
mipsbsd.sh
mipsidt.sh
mipsidtl.sh
mipslit.sh
news.sh
sa29200.sh
sh.sh
st2000.sh
sun3.sh
sun4.sh
vanilla.sh
vax.sh
z8ksim.sh
Things-to-lose:
# The lines between the "Do-last:" line and the end of the file
# are executed as a /bin/sh shell script after everything else is
# done.
Do-last:

2
ld/emulparams/README Normal file
View File

@ -0,0 +1,2 @@
The files in this directory are read by genscripts.sh as shell commands.
They set parameters for the emulations.

6
ld/emulparams/a29k.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=a29k
SCRIPT_NAME=a29k
OUTPUT_FORMAT="coff-a29k-big"
TEXT_START_ADDR=0x1000000
PAGE_SIZE=0x1000000
ARCH=a29k

View File

@ -0,0 +1,6 @@
EMULATION_NAME=ebmon29k
SCRIPT_NAME=ebmon29k
OUTPUT_FORMAT="coff-a29k-big"
TEXT_START_ADDR=0x8000
PAGE_SIZE=0x1000
ARCH=a29k

8
ld/emulparams/gld960.sh Normal file
View File

@ -0,0 +1,8 @@
EMULATION_NAME=gld960
SCRIPT_NAME=i960
OUTPUT_FORMAT=""
TEXT_START_ADDR=??
PAGE_SIZE=??
ARCH=i960
TEMPLATE_NAME=gld960
GLD_STYLE=1

9
ld/emulparams/go32.sh Normal file
View File

@ -0,0 +1,9 @@
EMULATION_NAME=go32
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-i386"
TEXT_START_ADDR=0x1020
PAGE_SIZE=0x1000
SEGMENT_SIZE=0x400000
NONPAGED_TEXT_START_ADDR=0x0
ARCH=i386

6
ld/emulparams/h8300.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=h8300
SCRIPT_NAME=h8300
OUTPUT_FORMAT="coff-h8300"
TEXT_START_ADDR=0x8000
PAGE_SIZE=128
ARCH=h8300

6
ld/emulparams/h8500.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=h8500
SCRIPT_NAME=h8500
OUTPUT_FORMAT="coff-h8500"
TEXT_START_ADDR=0x8000
PAGE_SIZE=128
ARCH=h8500

View File

@ -0,0 +1,6 @@
EMULATION_NAME=hp300bsd
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-hp300bsd"
TEXT_START_ADDR=0
PAGE_SIZE=4096
ARCH=m68k

9
ld/emulparams/hp3hpux.sh Normal file
View File

@ -0,0 +1,9 @@
EMULATION_NAME=hp3hpux
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-hp300hpux"
TEXT_START_ADDR=0
PAGE_SIZE=4096
ARCH=m68k
STACKZERO="___stack_zero = 0x2000;"
# This is needed for HPUX 9.0; it is unnecessary but harmless for 8.0.
SHLIB_PATH="___dld_shlib_path = 0;"

8
ld/emulparams/hppaosf.sh Normal file
View File

@ -0,0 +1,8 @@
EMULATION_NAME=hppaosf
SCRIPT_NAME=hppaosf
OUTPUT_FORMAT="elf-big"
TEXT_START_ADDR=0x1000
PAGE_SIZE=4096
ARCH=hppa
START="$START$"
TEMPLATE_NAME=hppaosf

View File

@ -0,0 +1,7 @@
EMULATION_NAME=i386aout
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-i386"
PAGE_SIZE=0x1000
TEXT_START_ADDR=0
NONPAGED_TEXT_START_ADDR=0x1000
ARCH=i386

7
ld/emulparams/i386bsd.sh Normal file
View File

@ -0,0 +1,7 @@
EMULATION_NAME=i386bsd
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-i386-bsd"
PAGE_SIZE=0x1000
TEXT_START_ADDR=0
NONPAGED_TEXT_START_ADDR=0x1000
ARCH=i386

View File

@ -0,0 +1,6 @@
EMULATION_NAME=i386coff
SCRIPT_NAME=i386coff
OUTPUT_FORMAT="coff-i386"
TEXT_START_ADDR=0x1000000
PAGE_SIZE=0x1000000
ARCH=i386

7
ld/emulparams/lnk960.sh Normal file
View File

@ -0,0 +1,7 @@
EMULATION_NAME=lnk960
SCRIPT_NAME=i960
OUTPUT_FORMAT=""
TEXT_START_ADDR=??
PAGE_SIZE=??
ARCH=i960
TEMPLATE_NAME=lnk960

View File

@ -0,0 +1,6 @@
EMULATION_NAME=m68kcoff
SCRIPT_NAME=m68kcoff
OUTPUT_FORMAT="coff-m68k"
TEXT_START_ADDR=0x1000000
PAGE_SIZE=0x1000000
ARCH=m68k

5
ld/emulparams/mipsbig.sh Normal file
View File

@ -0,0 +1,5 @@
EMULATION_NAME=mipsbig
SCRIPT_NAME=mips
OUTPUT_FORMAT="ecoff-bigmips"
PAGE_SIZE=0x1000000
ARCH=mips

6
ld/emulparams/mipsbsd.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=mipsbsd
SCRIPT_NAME=mipsbsd
OUTPUT_FORMAT="aout-mips-little"
TEXT_START_ADDR=0x1020
PAGE_SIZE=4096
ARCH=mips

9
ld/emulparams/mipsidt.sh Normal file
View File

@ -0,0 +1,9 @@
EMULATION_NAME=mipsidt
SCRIPT_NAME=mips
OUTPUT_FORMAT="ecoff-bigmips"
PAGE_SIZE=0x1000000
ARCH=mips
ENTRY=start
TEXT_START_ADDR=0xa0012000
DATA_ADDR=.
BSS_VAR="_fbss = .;"

View File

@ -0,0 +1,9 @@
EMULATION_NAME=mipsidtl
SCRIPT_NAME=mips
OUTPUT_FORMAT="ecoff-littlemips"
PAGE_SIZE=0x1000000
ARCH=mips
ENTRY=start
TEXT_START_ADDR=0xa0012000
DATA_ADDR=.
BSS_VAR="_fbss = .;"

5
ld/emulparams/mipslit.sh Normal file
View File

@ -0,0 +1,5 @@
EMULATION_NAME=mipslit
SCRIPT_NAME=mips
OUTPUT_FORMAT="ecoff-littlemips"
PAGE_SIZE=0x1000000
ARCH=mips

6
ld/emulparams/news.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=news
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-newsos3"
TEXT_START_ADDR=0
PAGE_SIZE=0x1000
ARCH=m68k

6
ld/emulparams/sa29200.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=sa29200
SCRIPT_NAME=sa29200
OUTPUT_FORMAT="coff-a29k-big"
TEXT_START_ADDR=0x40004000
PAGE_SIZE=0x1000
ARCH=a29k

6
ld/emulparams/sh.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=sh
SCRIPT_NAME=sh
OUTPUT_FORMAT="coff-sh"
TEXT_START_ADDR=0x8000
PAGE_SIZE=128
ARCH=sh

6
ld/emulparams/st2000.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=st2000
SCRIPT_NAME=st2000
OUTPUT_FORMAT="coff-m68k"
TEXT_START_ADDR=0x0
PAGE_SIZE=128
ARCH=m68k

8
ld/emulparams/sun3.sh Normal file
View File

@ -0,0 +1,8 @@
EMULATION_NAME=sun3
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-sunos-big"
TEXT_START_ADDR=0x2020
PAGE_SIZE=0x2000
SEGMENT_SIZE=0x20000
NONPAGED_TEXT_START_ADDR=0x2000
ARCH=m68k

6
ld/emulparams/vanilla.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=vanilla
SCRIPT_NAME=vanilla
TEXT_START_ADDR=??
PAGE_SIZE=??
ARCH=unknown
TEMPLATE_NAME=vanilla

6
ld/emulparams/vax.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=vax
SCRIPT_NAME=aout
OUTPUT_FORMAT="a.out-vax"
TEXT_START_ADDR=0
PAGE_SIZE=1024
ARCH=vax

6
ld/emulparams/z8ksim.sh Normal file
View File

@ -0,0 +1,6 @@
EMULATION_NAME=z8ksim
SCRIPT_NAME=z8ksim
OUTPUT_FORMAT="coff-z8k"
TEXT_START_ADDR=0x0
PAGE_SIZE=128
ARCH=z8k

41
ld/emultempl/.Sanitize Normal file
View File

@ -0,0 +1,41 @@
# .Sanitize for devo/ld/config
# Each directory to survive its way into a release will need a file
# like this one called "./.Sanitize". All keyword lines must exist,
# and must exist in the order specified by this file. Each directory
# in the tree will be processed, top down, in the following order.
# Hash started lines like this one are comments and will be deleted
# before anything else is done. Blank lines will also be squashed
# out.
# The lines between the "Do-first:" line and the "Things-to-keep:"
# line are executed as a /bin/sh shell script before anything else is
# done in this directory.
Do-first:
# All files listed between the "Things-to-keep:" line and the
# "Do-last:" line will be kept. All other files will be removed.
# Directories listed in this section will have their own Sanitize
# called. Directories not listed will be removed in their entirety
# with rm -rf.
Things-to-keep:
README
generic.em
gld960.em
hppaosf.em
lnk960.em
vanilla.em
Things-to-lose:
# The lines between the "Do-last:" line and the end of the file
# are executed as a /bin/sh shell script after everything else is
# done.
Do-last:

3
ld/emultempl/README Normal file
View File

@ -0,0 +1,3 @@
The files in this directory are sourced by genscripts.sh, after
setting some variables to substitute in, to produce
C source files that contain jump tables for each emulation.

115
ld/emultempl/hppaosf.em Normal file
View File

@ -0,0 +1,115 @@
cat >em_${EMULATION_NAME}.c <<EOF
/* An emulation for HP PA-RISC OSF/1 linkers.
Copyright (C) 1991 Free Software Foundation, Inc.
Written by Steve Chamberlain steve@cygnus.com
This file is part of GLD, the Gnu Linker.
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 of the License, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "ld.h"
#include "config.h"
#include "ldemul.h"
#include "ldfile.h"
#include "ldmisc.h"
extern boolean lang_float_flag;
extern enum bfd_architecture ldfile_output_architecture;
extern unsigned long ldfile_output_machine;
extern char *ldfile_output_machine_name;
extern bfd *output_bfd;
#ifdef HPPAOSF
static void hppaosf_before_parse()
{
static char *env_variables[] = { "HPPALIB", "HPPABASE", 0 };
char **p;
char *env ;
for ( p = env_variables; *p; p++ ){
env = (char *) getenv(*p);
if (env) {
ldfile_add_library_path(concat(env,"/lib/libbout",""));
}
}
ldfile_output_architecture = bfd_arch_hppa;
}
#else
static void hppaosf_before_parse()
{
char *env ;
env = getenv("HPPALIB");
if (env) {
ldfile_add_library_path(env);
}
env = getenv("HPPABASE");
if (env) {
ldfile_add_library_path(concat(env,"/lib",""));
}
ldfile_output_architecture = bfd_arch_hppa;
}
#endif /* HPPAOSF */
static void
hppaosf_set_output_arch()
{
/* Set the output architecture and machine if possible */
unsigned long machine = 0;
bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine);
}
static char *script =
"hppaosf.x"
;
static char *script_reloc =
"hppaosf.xr"
;
static char *hppaosf_get_script()
{
extern ld_config_type config;
if (config.relocateable_output)
return script_reloc;
return script;
}
struct ld_emulation_xfer_struct ld_hppaosf_emulation =
{
hppaosf_before_parse,
syslib_default,
hll_default,
after_parse_default,
after_allocation_default,
hppaosf_set_output_arch,
ldemul_default_target,
before_allocation_default,
hppaosf_get_script,
"hppaosf",
"elf-big"
};
EOF

74
ld/emultempl/vanilla.em Normal file
View File

@ -0,0 +1,74 @@
cat >em_${EMULATION_NAME}.c <<EOF
/* A vanilla emulation with no defaults
Copyright (C) 1991 Free Software Foundation, Inc.
Written by Steve Chamberlain steve@cygnus.com
This file is part of GLD, the Gnu Linker.
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 of the License, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "ld.h"
#include "config.h"
#include "ldemul.h"
#include "ldfile.h"
#include "ldmisc.h"
extern boolean lang_float_flag;
extern enum bfd_architecture ldfile_output_architecture;
extern unsigned long ldfile_output_machine;
extern char *ldfile_output_machine_name;
extern bfd *output_bfd;
static void vanilla_before_parse()
{
}
static void
vanilla_set_output_arch()
{
/* Set the output architecture and machine if possible */
unsigned long machine = 0;
bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine);
}
static char *vanilla_get_script()
{
return "/dev/null";
}
struct ld_emulation_xfer_struct ld_vanilla_emulation =
{
vanilla_before_parse,
syslib_default,
hll_default,
after_parse_default,
after_allocation_default,
vanilla_set_output_arch,
ldemul_default_target,
before_allocation_default,
vanilla_get_script,
"vanilla",
"a.out-sunos-big"
};
EOF

298
ld/ld.1
View File

@ -18,7 +18,7 @@ ld \- the GNU linker
.RB "[\|" \-o " .RB "[\|" \-o "
.I output\c .I output\c
\&\|] \c \&\|] \c
.I objfiles\c .I objfile\c
\&.\|.\|. \&.\|.\|.
.br .br
.RB "[\|" \-A\c .RB "[\|" \-A\c
@ -50,6 +50,9 @@ ld \- the GNU linker
.I input-format\c .I input-format\c
\&\|] \&\|]
.RB "[\|" \-g "\|]" .RB "[\|" \-g "\|]"
.RB "[\|" \-G\c
.I size\c
\&\|]
.RB "[\|" \-i "\|]" .RB "[\|" \-i "\|]"
.RB "[\|" \-l\c .RB "[\|" \-l\c
.I ar\c .I ar\c
@ -57,7 +60,10 @@ ld \- the GNU linker
.RB "[\|" \-L\c .RB "[\|" \-L\c
.I searchdir\c .I searchdir\c
\&\|] \&\|]
.RB "[\|" \-M | \-m "\|]" .RB "[\|" \-M "\|]"
.RB "[\|" \-m\c
.I emulation\c
\&\|]
.RB "[\|" \-n | \-N "\|]" .RB "[\|" \-n | \-N "\|]"
.RB "[\|" \-noinhibit-exec "\|]" .RB "[\|" \-noinhibit-exec "\|]"
.RB "[\|" "\-R\ "\c .RB "[\|" "\-R\ "\c
@ -83,6 +89,7 @@ ld \- the GNU linker
.RB "[\|" "\-u\ "\c .RB "[\|" "\-u\ "\c
.I sym\c .I sym\c
\&] \&]
.RB "[\|" \-V "\|]"
.RB "[\|" \-v "\|]" .RB "[\|" \-v "\|]"
.RB "[\|" \-X "\|]" .RB "[\|" \-X "\|]"
.RB "[\|" \-x "\|]" .RB "[\|" \-x "\|]"
@ -203,11 +210,11 @@ The exceptions\(em\&which may meaningfully be used more than once\(em\&are
\&. \&.
The list of object files to be linked together, shown as \c The list of object files to be linked together, shown as \c
.I objfiles\c .I objfile\c
\&, \&,
may follow, precede, or be mixed in with command-line options; save that may follow, precede, or be mixed in with command-line options; save that
an \c an \c
.I objfiles\c .I objfile\c
\& argument may not be placed between an option flag and \& argument may not be placed between an option flag and
its argument. its argument.
@ -229,12 +236,6 @@ Option arguments must either follow the option letter without intervening
whitespace, or be given as separate arguments immediately following the whitespace, or be given as separate arguments immediately following the
option that requires them. option that requires them.
.TP
.IR "objfiles" .\|.\|.
The object files \c
.I objfiles\c
\& to be linked.
.TP .TP
.BI "-A" "architecture"\c .BI "-A" "architecture"\c
\& \&
@ -453,6 +454,13 @@ Synonym for \c
.B \-g .B \-g
Accepted, but ignored; provided for compatibility with other tools. Accepted, but ignored; provided for compatibility with other tools.
.TP
.BI "\-G " "size"\c
Set the maximum size of objects to be optimized using the GP register
to
.I size
under MIPS ECOFF. Ignored for other object file formats.
.TP .TP
.B \-i .B \-i
Perform an incremental link (same as option \c Perform an incremental link (same as option \c
@ -502,14 +510,22 @@ command.
.TP .TP
.B \-M .B \-M
.TP
.B \-m
Print (to the standard output file) a link map\(em\&diagnostic information Print (to the standard output file) a link map\(em\&diagnostic information
about where symbols are mapped by \c about where symbols are mapped by \c
.B ld\c .B ld\c
\&, and information on global \&, and information on global
common storage allocation. common storage allocation.
.TP
.BI "\-m " "emulation"\c
Emulate the
.I emulation
linker. You can list the available emulations with the
.I \-V
option. This option overrides the compiled-in default, which is the
system for which you configured
.BR ld .
.TP .TP
.B \-N .B \-N
specifies readable and writable \c specifies readable and writable \c
@ -703,11 +719,19 @@ turn serve as input to \c
.B \-r\c .B \-r\c
\&. \&.
.TP
.B \-V
Display the version number for \c
.B ld
and list the supported emulations.
Print which input files can and can not be opened.
.TP .TP
.B \-v .B \-v
Display the version number for \c Display the version number for \c
.B ld\c .B ld\c
\&. \&.
Print which input files can and can not be opened.
.TP .TP
.B \-X .B \-X
@ -735,14 +759,11 @@ not just those beginning with `\|\c
.SH ENVIRONMENT .SH ENVIRONMENT
\c \c
You can change the behavior of
.B ld\c .B ld\c
\& always consults two environment variables: \c \& with the environment variable \c
.B GNUTARGET\c .B GNUTARGET\c
\& \&.
and \c
.B LDEMULATION\c
\&. Depending on the setting of the latter, other
environment variables may be used as well.
\c \c
.B GNUTARGET\c .B GNUTARGET\c
@ -770,247 +791,6 @@ unique. However, the configuration procedure for BFD on each system
places the conventional format for that system first in the search-list, places the conventional format for that system first in the search-list,
so ambiguities are resolved in favor of convention. so ambiguities are resolved in favor of convention.
\c
.B LDEMULATION\c
\& controls some aspects of \c
.B ld\c
\&'s dominant
personality. Although \c
.B ld\c
\& is flexible enough to permit its use
in many contexts regardless of configuration, you can use this variable
to make it act more like one or another older linker by default.
In particular, the value of \c
.B LDEMULATION\c
\& controls what default
linker script is used (thereby controlling the default input and output
formats; ; what default paths are searched for
archive libraries; and in some cases whether additional linker script
commands are available.
Here is the current set of emulations available:
.TP
.B LDEMULATION=gld
Emulate the older GNU linker. When this emulation is selected, the
default library search paths are
.sp
.br
/lib
.br
/usr/lib
.br
/usr/local/lib/lib
.br
.sp
The default output format is set to \c
.B a.out-generic-big\c
\&, and the
default machine is the system's configured BFD default.
.TP
.B LDEMULATION=gld68k
A variant of the \c
.B gld\c
\& emulation; only differs in specifically
setting the default BFD machine as \c
.B m68k\c
\&.
.TP
.B LDEMULATION=gld960
Emulate the Intel port of the older \c
.B gld\c
\& for the i960
architectures. The default library search paths are taken from two
other environment variables, \c
.B G960LIB\c
\& and \c
.B G960BASE\c
\&. The
default architecture is \c
.B i960\c
\&. The default output format is set
to \c
.B b.out.big\c
\&, and in fact the default output file name (if
\c
.B \-o\c
\& is not specified) is \c
.B b.out\c
\&, to reflect this variant
format, for this emulation.
This emulation can behave slightly differently depending on the setting
of the \c
.B ld\c
\& compile-time switch \c
.B GNU960\c
\&. If \c
.B ld\c
\& is
compiled with \c
.B GNU960\c
\& defined, then an additional environment
variable\(em\&\c
.B GNUTARGET\c
\&\(em\&is available; its value, if available,
specifies some other default output format than \c
.B b.out.big\c
\&.
.TP
.B LDEMULATION=gldm88kbcs
Sets the output format to \c
.B m88kbcs\c
\& and the architecture to
\c
.B m88k\c
\&. Default library search paths are
.sp
.br
/lib
.br
/usr/lib
.br
/usr/local/lib
.br
.sp
.TP
.B LDEMULATION=lnk960
Emulate the Intel linker \c
.B lnk960\c
\&. The default output format is
\c
.B coff-Intel-big\c
\&. With this emulation, \c
.B ld\c
\&
supports the additional script commands \c
.B HLL\c
\& and \c
.B SYSLIB\c
\& for
specification of library archives. This is the only emulation with
extensive support for the \c
.B \-A\c
\& (architecture) command-line option.
By default, the architecture \c
.B CORE\c
\& is assumed, but you can choose
additional features from the i960 architecture family by using one of
the following with \c
.B \-A\c
\& (or by using the \c
.B OUTPUT_ARCH\c
\& command
from a script):
.sp
.br
CORE
.br
KB
.br
SB
.br
MC
.br
XA
.br
CA
.br
KA
.br
SA
.br
.sp
The default libraries are chosen with some attention to the architecture
selected; the core library `\|\c
.B cg\c
\|' is always included, but the library
\c
.B fpg\c
\& is also used if you've specified any of the architectures
\c
.B KA\c
\&, \c
.B SA\c
\&, or \c
.B CA\c
\&.
Like \c
.B gld960\c
\&, this emulation uses additional environment variables
to set the default library search paths. Also like \c
.B gld960\c
\&, the
behavior of this emulation is slightly different depending on whether
\c
.B ld\c
\& itself was compiled with \c
.B GNU960\c
\& defined.
If your \c
.B ld\c
\& was compiled with \c
.B GNU960\c
\& defined, the default
paths are taken from all three of \c
.B G960LIB\c
\&, \c
.B G960BASE\c
\&, and
\c
.B I960BASE\c
\&. For the first two, paths you supply are automatically
suffixed with `\|\c
.B /lib/libcoff\c
\|'; for the last, your path is
automatically suffixed with `\|\c
.B /lib\c
\|'.
If your \c
.B ld\c
\& was \c
.I not\c
\& compiled with \c
.B GNU960\c
\& defined,
the default paths are taken from \c
.B I960BASE\c
\&, and \c
.B G960BASE\c
\& is
only consulted if \c
.B I960BASE\c
\& is undefined. In this case
\c
.B G960LIB\c
\& is not used at all.
.TP
.B LDEMULATION=vanilla
This is the least specific setting for \c
.B ld\c
\&. You can set
\c
.B LDEMULATION=vanilla\c
\& to disable emulation of other linkers. This
setting makes \c
.B ld\c
\& take the default machine from the BFD
configuration on your system; \c
.B a.out-generic-big\c
\& is the default
target. No other defaults are specified.
.PP .PP
.SH "SEE ALSO" .SH "SEE ALSO"

View File

@ -9,7 +9,7 @@
@ifinfo @ifinfo
@format @format
START-INFO-DIR-ENTRY START-INFO-DIR-ENTRY
* Ld: (ld). The GNU linker. * Ld:: The GNU linker.
END-INFO-DIR-ENTRY END-INFO-DIR-ENTRY
@end format @end format
@end ifinfo @end ifinfo
@ -163,17 +163,17 @@ line:
@c FIXME! -relax only avail h8/300, i960. Conditionals screwed in examples. @c FIXME! -relax only avail h8/300, i960. Conditionals screwed in examples.
@smallexample @smallexample
ld [-o @var{output} ] @var{objfile@dots{}} ld [-o @var{output} ] @var{objfile}@dots{}
[ -A@var{architecture} ] [ -b @var{input-format} ] [ -Bstatic ] [ -A@var{architecture} ] [ -b @var{input-format} ] [ -Bstatic ]
[ -c @var{MRI-commandfile} ] [ -d | -dc | -dp ] [ -c @var{MRI-commandfile} ] [ -d | -dc | -dp ]
[ -defsym @var{symbol}=@var{expression} ] [ -defsym @var{symbol}=@var{expression} ]
[ -e @var{entry} ] [ -F ] [ -F @var{format} ] [ -e @var{entry} ] [ -F ] [ -F @var{format} ]
[ -format @var{input-format} ] [ -g ] [ -i ] [ -format @var{input-format} ] [ -g ] [ -G @var{size} ] [ -i ]
[ -l@var{ar} ] [ -L@var{searchdir} ] [ -M | -m ] [ -l@var{ar} ] [ -L@var{searchdir} ] [ -M ] [ -m @var{emulation} ]
[ -n | -N ] [ -noinhibit-exec ] [ -R @var{filename} ] [ -N | -n ] [ -noinhibit-exec ] [ -R @var{filename} ]
[ -relax ] [ -r | -Ur ] [ -S ] [ -s ] [ -T @var{commandfile} ] [ -relax ] [ -r | -Ur ] [ -S ] [ -s ] [ -T @var{commandfile} ]
[ -Ttext @var{textorg} ] [ -Tdata @var{dataorg} ] [ -Tbss @var{bssorg} ] [ -Ttext @var{textorg} ] [ -Tdata @var{dataorg} ] [ -Tbss @var{bssorg} ]
[ -t ] [ -u @var{sym}] [-v] [ -X ] [ -x ] [ -y@var{symbol} ] [ -t ] [ -u @var{sym}] [-V] [-v] [ -X ] [ -x ] [ -y@var{symbol} ]
[ @{ @var{script} @} ] [ @{ @var{script} @} ]
@end smallexample @end smallexample
@ -210,7 +210,7 @@ The exceptions---which may meaningfully be used more than once---are
@end ifset @end ifset
@cindex object files @cindex object files
The list of object files to be linked together, shown as @var{objfile@dots{}}, The list of object files to be linked together, shown as @var{objfile}@dots{},
may follow, precede, or be mixed in with command-line options, except that may follow, precede, or be mixed in with command-line options, except that
an @var{objfile} argument may not be placed between an option and an @var{objfile} argument may not be placed between an option and
its argument. its argument.
@ -226,7 +226,7 @@ whitespace, or be given as separate arguments immediately following the
option that requires them. option that requires them.
@table @code @table @code
@item @var{objfile@dots{}} @item @var{objfile}@dots{}
The object files to be linked. The object files to be linked.
@ifset I960 @ifset I960
@ -286,6 +286,8 @@ files written in an alternate, restricted command language, described in
@ref{MRI,,MRI Compatible Script Files}. Introduce MRI script files with @ref{MRI,,MRI Compatible Script Files}. Introduce MRI script files with
the option @samp{-c}; use the @samp{-T} option to run linker the option @samp{-c}; use the @samp{-T} option to run linker
scripts written in the general-purpose @code{ld} scripting language. scripts written in the general-purpose @code{ld} scripting language.
If @var{MRI-cmdfile} does not exist, @code{ld} looks for it in the directories
specified by any @samp{-L} options.
@cindex common allocation @cindex common allocation
@kindex -d @kindex -d
@ -346,12 +348,18 @@ Synonym for @samp{-b @var{input-format}}.
@item -g @item -g
Ignored. Provided for compatibility with other tools. Ignored. Provided for compatibility with other tools.
@kindex -G
@cindex object size
@item -G@var{value}
@itemx -G @var{value}
Set the maximum size of objects to be optimized using the GP register to
@var{size} under MIPS ECOFF. Ignored for other object file formats.
@kindex -i @kindex -i
@cindex incremental link @cindex incremental link
@item -i @item -i
Perform an incremental link (same as option @samp{-r}). Perform an incremental link (same as option @samp{-r}).
@cindex archive files, from cmd line @cindex archive files, from cmd line
@kindex -l@var{ar} @kindex -l@var{ar}
@item -l@var{ar} @item -l@var{ar}
@ -364,7 +372,8 @@ specified.
@kindex -L@var{dir} @kindex -L@var{dir}
@item -L@var{searchdir} @item -L@var{searchdir}
Add path @var{searchdir} to the list of paths that @code{ld} will search Add path @var{searchdir} to the list of paths that @code{ld} will search
for archive libraries. You may use this option any number of times. for archive libraries and @code{ld} control scripts. You may use this
option any number of times.
@ifset UsesEnvVars @ifset UsesEnvVars
The default set of paths searched (without being specified with The default set of paths searched (without being specified with
@ -378,12 +387,18 @@ The paths can also be specified in a link script with the
@cindex link map @cindex link map
@kindex -M @kindex -M
@item -M @item -M
@kindex -m
@itemx -m
Print (to the standard output) a link map---diagnostic information Print (to the standard output) a link map---diagnostic information
about where symbols are mapped by @code{ld}, and information on global about where symbols are mapped by @code{ld}, and information on global
common storage allocation. common storage allocation.
@cindex emulation
@kindex -m @var{emulation}
@item -m@var{emulation}
@itemx -m @var{emulation}
Emulate the @var{emulation} linker. You can list the available
emulations with the @samp{-V} option. The
default is the system for which you configured @code{ld}.
@kindex -N @kindex -N
@cindex read/write from cmd line @cindex read/write from cmd line
@kindex OMAGIC @kindex OMAGIC
@ -499,6 +514,8 @@ Read link commands from the file
default link format (rather than adding to it); @var{commandfile} must default link format (rather than adding to it); @var{commandfile} must
specify everything necessary to describe the target format. specify everything necessary to describe the target format.
@xref{Commands}. @xref{Commands}.
If @var{commandfile} does not exist, @code{ld} looks for it in the directories
specified by any @samp{-L} options.
You may also include a script of link commands directly in the command You may also include a script of link commands directly in the command
line by bracketing it between @samp{@{} and @samp{@}}. line by bracketing it between @samp{@{} and @samp{@}}.
@ -527,10 +544,17 @@ For anything other than C++ programs, this option is equivalent to
turn serve as input to @code{ld}. When linking C++ programs, @samp{-Ur} turn serve as input to @code{ld}. When linking C++ programs, @samp{-Ur}
@emph{will} resolve references to constructors, unlike @samp{-r}. @emph{will} resolve references to constructors, unlike @samp{-r}.
@item -V
@kindex -V
@cindex version
Display the version number for @code{ld} and list the supported emulations.
Print which input files can and can not be opened.
@item -v @item -v
@kindex -v @kindex -v
@cindex version @cindex version
Display the version number for @code{ld}. Display the version number for @code{ld}.
Print which input files can and can not be opened.
@item -X @item -X
@kindex -X @kindex -X
@ -1316,7 +1340,7 @@ file have not yet been defined.
@kindex [ @var{sections} ] @kindex [ @var{sections} ]
This is an alternate notation to specify named sections from all This is an alternate notation to specify named sections from all
unallocated input files; its effect is exactly the same as that of unallocated input files; its effect is exactly the same as that of
@samp{* (@var{section@dots{}})} @samp{* (@var{section}@dots{})}
@item @var{filename}@code{( COMMON )} @item @var{filename}@code{( COMMON )}
@itemx ( COMMON ) @itemx ( COMMON )
@ -2194,7 +2218,7 @@ COFF (the @samp{coff-m68k} variant in BFD), if @var{output-format} is
@samp{COFF} @samp{COFF}
@end enumerate @end enumerate
@item LIST @var{@dots{}} @item LIST @var{anything}@dots{}
@cindex @code{LIST} (MRI) @cindex @code{LIST} (MRI)
Print (to the standard output file) a link map, as produced by the Print (to the standard output file) a link map, as produced by the
@code{ld} command-line option @samp{-M}. @code{ld} command-line option @samp{-M}.

View File

@ -14,9 +14,9 @@ extern bfd_error_vector_type bfd_error_vector;
/* BFD has failed to link something, give a better error message */ /* BFD has failed to link something, give a better error message */
static void static void
DEFUN(ld_undefined_symbol,(relent, seclet), ld_undefined_symbol (relent, seclet)
CONST arelent *relent AND CONST arelent *relent;
CONST bfd_seclet_type *seclet) CONST bfd_seclet_type *seclet;
{ {
asymbol *s = *(relent->sym_ptr_ptr); asymbol *s = *(relent->sym_ptr_ptr);
static asymbol *error_symbol; static asymbol *error_symbol;
@ -60,9 +60,9 @@ DEFUN(ld_undefined_symbol,(relent, seclet),
} }
} }
static void static void
DEFUN(ld_reloc_truncated,(relent, seclet), ld_reloc_truncated (relent, seclet)
CONST arelent *relent AND CONST arelent *relent;
bfd_seclet_type *seclet) bfd_seclet_type *seclet;
{ {
asymbol *s = *(relent->sym_ptr_ptr); asymbol *s = *(relent->sym_ptr_ptr);
asection *section = seclet->u.indirect.section; asection *section = seclet->u.indirect.section;
@ -75,7 +75,7 @@ DEFUN(ld_reloc_truncated,(relent, seclet),
void void
DEFUN_VOID(init_bfd_error_vector) init_bfd_error_vector ()
{ {
bfd_error_vector.undefined_symbol = ld_undefined_symbol; bfd_error_vector.undefined_symbol = ld_undefined_symbol;
bfd_error_vector.reloc_value_truncated = ld_reloc_truncated; bfd_error_vector.reloc_value_truncated = ld_reloc_truncated;

View File

@ -43,6 +43,7 @@ extern unsigned int lineno;
extern boolean trace_files; extern boolean trace_files;
extern boolean write_map; extern boolean write_map;
extern boolean option_longmap; extern boolean option_longmap;
extern int g_switch_value;
boolean hex_mode; boolean hex_mode;
static int typebits; static int typebits;
strip_symbols_type strip_symbols=STRIP_NONE; strip_symbols_type strip_symbols=STRIP_NONE;
@ -90,7 +91,7 @@ static int error_index;
char *name; char *name;
int token; int token;
union etree_union *etree; union etree_union *etree;
struct sec *section; struct sec *section;
struct lang_output_section_statement_struct *output_section_statement; struct lang_output_section_statement_struct *output_section_statement;
union lang_statement_union **statement_ptr; union lang_statement_union **statement_ptr;
int lineno; int lineno;
@ -138,11 +139,11 @@ struct sec *section;
%token NOLOAD DSECT COPY INFO OVERLAY %token NOLOAD DSECT COPY INFO OVERLAY
%token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY
%token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common %token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common
%token OPTION_EB OPTION_EL %token OPTION_EB OPTION_EL OPTION_G OPTION_Gval
%token OPTION_format OPTION_F OPTION_u OPTION_Bstatic OPTION_N %token OPTION_format OPTION_F OPTION_u OPTION_Bstatic OPTION_N
%token <integer> SIZEOF NEXT ADDR %token <integer> SIZEOF NEXT ADDR
%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym %token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym
%token OPTION_v OPTION_V OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT %token OPTION_v OPTION_V OPTION_m OPTION_memul OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT
%token OPTION_Map %token OPTION_Map
%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R OPTION_relax %token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R OPTION_relax
%token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp %token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp
@ -197,6 +198,14 @@ command_line_option:
write_map = true; write_map = true;
config.map_filename = $2; config.map_filename = $2;
} }
| OPTION_m NAME
{
/* Ignore. */
}
| OPTION_memul
{
/* Ignore. */
}
| OPTION_M | OPTION_M
{ {
config.map_filename = "-"; config.map_filename = "-";
@ -303,9 +312,6 @@ command_line_option:
{ {
/* Ignore */ /* Ignore */
} }
| NAME
{ lang_add_input_file($1,lang_input_file_is_file_enum,
(char *)NULL); }
| OPTION_c filename | OPTION_c filename
{ ldfile_open_command_file($2); } mri_script_file END { ldlex_command();} { ldfile_open_command_file($2); } mri_script_file END { ldlex_command();}
@ -348,9 +354,19 @@ command_line_option:
``produce a little-endian object file''. It could ``produce a little-endian object file''. It could
be used to select an output format. */ be used to select an output format. */
} }
| OPTION_G NAME
{
g_switch_value = atoi ($2);
}
| OPTION_Gval
{
g_switch_value = yylval.integer;
}
| '-' NAME | '-' NAME
{ info("%P%F Unrecognized option -%s\n", $2); } { einfo("%P%F illegal option -- %s\n", $2); }
| NAME
{ lang_add_input_file($1,lang_input_file_is_file_enum,
(char *)NULL); }
| '{' script_file '}' | '{' script_file '}'
; ;
@ -573,6 +589,11 @@ statement_list:
| statement | statement
; ;
statement_list_opt:
/* empty */
| statement_list
;
length: length:
LONG LONG
{ $$ = $1; } { $$ = $1; }
@ -801,7 +822,7 @@ section: NAME { ldlex_expression(); }
{ {
lang_enter_output_section_statement($1,$3,typebits,0,0,0,$4); lang_enter_output_section_statement($1,$3,typebits,0,0,0,$4);
} }
statement_list statement_list_opt
'}' {ldlex_expression();} fill_opt memspec_opt '}' {ldlex_expression();} fill_opt memspec_opt
{ {
ldlex_popstate(); ldlex_popstate();

View File

@ -48,9 +48,9 @@
static asymbol ** static asymbol **
DEFUN(move_it,(a_list, b_list), move_it (a_list, b_list)
asymbol **a_list AND asymbol **a_list;
asymbol **b_list) asymbol **b_list;
{ {
asymbol **head = a_list; asymbol **head = a_list;
asymbol **cursor = head; asymbol **cursor = head;
@ -71,15 +71,15 @@ asymbol **b_list)
#if 0 #if 0
void void
DEFUN(copy_over,(ldsym, bfdsym), copy_over (ldsym, bfdsym)
ldsym_type *ldsym AND ldsym_type *ldsym;
asymbol **bfdsym) asymbol **bfdsym;
{ {
while (list && *list) while (list && *list)
{ {
refize(Q_enter_global_ref(list, name); refize(Q_enter_global_ref(list, name));
list = (asymbol **)((*list)->udata); list = (asymbol **)((*list)->udata);
} }
} }
#endif #endif
@ -87,8 +87,8 @@ DEFUN(copy_over,(ldsym, bfdsym),
refs to the symbol are patched to know the alias - but we still refs to the symbol are patched to know the alias - but we still
have to fix all the old ones */ have to fix all the old ones */
void void
DEFUN(add_indirect,(ptr), add_indirect (ptr)
asymbol **ptr) asymbol **ptr;
{ {
asymbol **p; asymbol **p;
ldsym_type *lgs = ldsym_get((*ptr)->name); ldsym_type *lgs = ldsym_get((*ptr)->name);

View File

@ -115,34 +115,34 @@ etree_type *base; /* Relocation base - or null */
void lang_add_data PARAMS ((int type, union etree_union * exp)); void lang_add_data PARAMS ((int type, union etree_union * exp));
PTR PTR
DEFUN (stat_alloc, (size), stat_alloc (size)
size_t size) size_t size;
{ {
return obstack_alloc (&stat_obstack, size); return obstack_alloc (&stat_obstack, size);
} }
static void static void
DEFUN (print_size, (value), print_size (value)
size_t value) size_t value;
{ {
fprintf (config.map_file, "%5x", (unsigned) value); fprintf (config.map_file, "%5x", (unsigned) value);
} }
static void static void
DEFUN (print_alignment, (value), print_alignment (value)
unsigned int value) unsigned int value;
{ {
fprintf (config.map_file, "2**%1u", value); fprintf (config.map_file, "2**%1u", value);
} }
static void static void
DEFUN (print_fill, (value), DEFUN (print_fill, (value),
fill_type value) fill_type value)
{ {
fprintf (config.map_file, "%04x", (unsigned) value); fprintf (config.map_file, "%04x", (unsigned) value);
} }
static void static void
DEFUN (print_section, (name), print_section (name)
CONST char *CONST name) CONST char *CONST name;
{ {
fprintf (config.map_file, "%*s", -longest_section_name, name); fprintf (config.map_file, "%*s", -longest_section_name, name);
} }
@ -153,9 +153,9 @@ DEFUN (print_section, (name),
*/ */
static void static void
DEFUN (lang_for_each_statement_worker, (func, s), lang_for_each_statement_worker (func, s)
void (*func) ()AND void (*func) ();
lang_statement_union_type * s) lang_statement_union_type *s;
{ {
for (; s != (lang_statement_union_type *) NULL; s = s->next) for (; s != (lang_statement_union_type *) NULL; s = s->next)
{ {
@ -194,8 +194,8 @@ DEFUN (lang_for_each_statement_worker, (func, s),
} }
void void
DEFUN (lang_for_each_statement, (func), lang_for_each_statement (func)
void (*func) ()) void (*func) ();
{ {
lang_for_each_statement_worker (func, lang_for_each_statement_worker (func,
statement_list.head); statement_list.head);
@ -203,8 +203,8 @@ DEFUN (lang_for_each_statement, (func),
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
void void
DEFUN (lang_list_init, (list), lang_list_init (list)
lang_statement_list_type * list) lang_statement_list_type *list;
{ {
list->head = (lang_statement_union_type *) NULL; list->head = (lang_statement_union_type *) NULL;
list->tail = &list->head; list->tail = &list->head;
@ -218,10 +218,10 @@ DEFUN (lang_list_init, (list),
static static
lang_statement_union_type * lang_statement_union_type *
DEFUN (new_statement, (type, size, list), new_statement (type, size, list)
enum statement_enum type AND enum statement_enum type;
bfd_size_type size AND bfd_size_type size;
lang_statement_list_type * list) lang_statement_list_type * list;
{ {
lang_statement_union_type *new = (lang_statement_union_type *) lang_statement_union_type *new = (lang_statement_union_type *)
stat_alloc (size); stat_alloc (size);
@ -244,10 +244,10 @@ DEFUN (new_statement, (type, size, list),
*/ */
static lang_input_statement_type * static lang_input_statement_type *
DEFUN (new_afile, (name, file_type, target), new_afile (name, file_type, target)
CONST char *CONST name AND CONST char *CONST name;
CONST lang_input_file_enum_type file_type AND CONST lang_input_file_enum_type file_type;
CONST char *CONST target) CONST char *CONST target;
{ {
lang_input_statement_type *p = new_stat (lang_input_statement, lang_input_statement_type *p = new_stat (lang_input_statement,
@ -315,10 +315,10 @@ DEFUN (new_afile, (name, file_type, target),
} }
lang_input_statement_type * lang_input_statement_type *
DEFUN (lang_add_input_file, (name, file_type, target), lang_add_input_file (name, file_type, target)
CONST char *name AND CONST char *name;
lang_input_file_enum_type file_type AND lang_input_file_enum_type file_type;
CONST char *target) CONST char *target;
{ {
/* Look it up or build a new one */ /* Look it up or build a new one */
lang_has_input_file = true; lang_has_input_file = true;
@ -342,8 +342,8 @@ DEFUN (lang_add_input_file, (name, file_type, target),
} }
void void
DEFUN (lang_add_keepsyms_file, (filename), lang_add_keepsyms_file (filename)
CONST char *filename) CONST char *filename;
{ {
extern strip_symbols_type strip_symbols; extern strip_symbols_type strip_symbols;
if (keepsyms_file != 0) if (keepsyms_file != 0)
@ -356,7 +356,7 @@ DEFUN (lang_add_keepsyms_file, (filename),
/* Build enough state so that the parser can build its tree */ /* Build enough state so that the parser can build its tree */
void void
DEFUN_VOID (lang_init) lang_init ()
{ {
obstack_begin (&stat_obstack, 1000); obstack_begin (&stat_obstack, 1000);
@ -391,8 +391,8 @@ static lang_memory_region_type *lang_memory_region_list;
static lang_memory_region_type **lang_memory_region_list_tail = &lang_memory_region_list; static lang_memory_region_type **lang_memory_region_list_tail = &lang_memory_region_list;
lang_memory_region_type * lang_memory_region_type *
DEFUN (lang_memory_region_lookup, (name), lang_memory_region_lookup (name)
CONST char *CONST name) CONST char *CONST name;
{ {
lang_memory_region_type *p = lang_memory_region_list; lang_memory_region_type *p = lang_memory_region_list;
@ -424,7 +424,7 @@ DEFUN (lang_memory_region_lookup, (name),
*lang_memory_region_list_tail = new; *lang_memory_region_list_tail = new;
lang_memory_region_list_tail = &new->next; lang_memory_region_list_tail = &new->next;
new->origin = 0; new->origin = 0;
new->length = ~0; new->length = ~(bfd_size_type)0;
new->current = 0; new->current = 0;
new->had_full_message = false; new->had_full_message = false;
@ -434,8 +434,8 @@ DEFUN (lang_memory_region_lookup, (name),
lang_output_section_statement_type * lang_output_section_statement_type *
DEFUN (lang_output_section_find, (name), lang_output_section_find (name)
CONST char *CONST name) CONST char *CONST name;
{ {
lang_statement_union_type *u; lang_statement_union_type *u;
lang_output_section_statement_type *lookup; lang_output_section_statement_type *lookup;
@ -454,8 +454,8 @@ DEFUN (lang_output_section_find, (name),
} }
lang_output_section_statement_type * lang_output_section_statement_type *
DEFUN (lang_output_section_statement_lookup, (name), lang_output_section_statement_lookup (name)
CONST char *CONST name) CONST char *CONST name;
{ {
lang_output_section_statement_type *lookup; lang_output_section_statement_type *lookup;
@ -492,8 +492,8 @@ DEFUN (lang_output_section_statement_lookup, (name),
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
DEFUN (print_flags, (ignore_flags), print_flags (ignore_flags)
int *ignore_flags) int *ignore_flags;
{ {
fprintf (config.map_file, "("); fprintf (config.map_file, "(");
#if 0 #if 0
@ -510,7 +510,7 @@ DEFUN (print_flags, (ignore_flags),
} }
void void
DEFUN_VOID (lang_map) lang_map ()
{ {
lang_memory_region_type *m; lang_memory_region_type *m;
@ -529,9 +529,9 @@ DEFUN_VOID (lang_map)
fprintf (config.map_file, "%-16s", m->name); fprintf (config.map_file, "%-16s", m->name);
print_address (m->origin); print_address (m->origin);
print_space (); print_space ();
print_address (m->length); print_address ((bfd_vma)m->length);
print_space (); print_space ();
print_address (m->old_length); print_address ((bfd_vma)m->old_length);
print_space(); print_space();
print_address (m->current - m->origin); print_address (m->current - m->origin);
print_space(); print_space();
@ -552,8 +552,8 @@ DEFUN_VOID (lang_map)
* *
*/ */
static void static void
DEFUN (init_os, (s), init_os (s)
lang_output_section_statement_type * s) lang_output_section_statement_type * s;
{ {
/* asection *section = bfd_get_section_by_name(output_bfd, s->name);*/ /* asection *section = bfd_get_section_by_name(output_bfd, s->name);*/
section_userdata_type *new = section_userdata_type *new =
@ -593,11 +593,11 @@ DEFUN (init_os, (s),
*/ */
static void static void
DEFUN (wild_doit, (ptr, section, output, file), wild_doit (ptr, section, output, file)
lang_statement_list_type * ptr AND lang_statement_list_type * ptr;
asection * section AND asection * section;
lang_output_section_statement_type * output AND lang_output_section_statement_type * output;
lang_input_statement_type * file) lang_input_statement_type * file;
{ {
if (output->bfd_section == (asection *) NULL) if (output->bfd_section == (asection *) NULL)
{ {
@ -626,7 +626,10 @@ DEFUN (wild_doit, (ptr, section, output, file),
/* Be selective about what the output section inherits from the /* Be selective about what the output section inherits from the
input section */ input section */
section->output_section->flags |= section->flags & ~SEC_NEVER_LOAD; if ((section->flags & SEC_SHARED_LIBRARY) != 0)
section->output_section->flags |= section->flags;
else
section->output_section->flags |= section->flags & ~SEC_NEVER_LOAD;
if (!output->loadable) if (!output->loadable)
{ {
@ -647,19 +650,19 @@ DEFUN (wild_doit, (ptr, section, output, file),
} }
static asection * static asection *
DEFUN (our_bfd_get_section_by_name, (abfd, section), our_bfd_get_section_by_name (abfd, section)
bfd * abfd AND bfd * abfd;
CONST char *section) CONST char *section;
{ {
return bfd_get_section_by_name (abfd, section); return bfd_get_section_by_name (abfd, section);
} }
static void static void
DEFUN (wild_section, (ptr, section, file, output), wild_section (ptr, section, file, output)
lang_wild_statement_type * ptr AND lang_wild_statement_type * ptr;
CONST char *section AND CONST char *section;
lang_input_statement_type * file AND lang_input_statement_type * file;
lang_output_section_statement_type * output) lang_output_section_statement_type * output;
{ {
asection *s; asection *s;
@ -697,8 +700,8 @@ DEFUN (wild_section, (ptr, section, file, output),
*/ */
static static
lang_input_statement_type * lang_input_statement_type *
DEFUN (lookup_name, (name), lookup_name (name)
CONST char *CONST name) CONST char *CONST name;
{ {
lang_input_statement_type *search; lang_input_statement_type *search;
@ -731,12 +734,12 @@ DEFUN (lookup_name, (name),
} }
static void static void
DEFUN (wild, (s, section, file, target, output), wild (s, section, file, target, output)
lang_wild_statement_type * s AND lang_wild_statement_type * s;
CONST char *CONST section AND CONST char *CONST section;
CONST char *CONST file AND CONST char *CONST file;
CONST char *CONST target AND CONST char *CONST target;
lang_output_section_statement_type * output) lang_output_section_statement_type * output;
{ {
lang_input_statement_type *f; lang_input_statement_type *f;
@ -771,8 +774,8 @@ DEFUN (wild, (s, section, file, target, output),
read in all the files read in all the files
*/ */
static bfd * static bfd *
DEFUN (open_output, (name), open_output (name)
CONST char *CONST name) CONST char *CONST name;
{ {
extern unsigned long ldfile_output_machine; extern unsigned long ldfile_output_machine;
extern enum bfd_architecture ldfile_output_architecture; extern enum bfd_architecture ldfile_output_architecture;
@ -813,8 +816,8 @@ DEFUN (open_output, (name),
static void static void
DEFUN (ldlang_open_output, (statement), ldlang_open_output (statement)
lang_statement_union_type * statement) lang_statement_union_type * statement;
{ {
switch (statement->header.type) switch (statement->header.type)
{ {
@ -840,8 +843,8 @@ DEFUN (ldlang_open_output, (statement),
} }
static void static void
DEFUN (open_input_bfds, (statement), open_input_bfds (statement)
lang_statement_union_type * statement) lang_statement_union_type * statement;
{ {
switch (statement->header.type) switch (statement->header.type)
{ {
@ -910,8 +913,8 @@ typedef struct ldlang_undef_chain_list
static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head; static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head;
void void
DEFUN (ldlang_add_undef, (name), ldlang_add_undef (name)
CONST char *CONST name) CONST char *CONST name;
{ {
ldlang_undef_chain_list_type *new = ldlang_undef_chain_list_type *new =
(ldlang_undef_chain_list_type (ldlang_undef_chain_list_type
@ -928,7 +931,7 @@ DEFUN (ldlang_add_undef, (name),
script file. script file.
*/ */
static void static void
DEFUN_VOID (lang_place_undefineds) lang_place_undefineds ()
{ {
ldlang_undef_chain_list_type *ptr = ldlang_undef_chain_list_head; ldlang_undef_chain_list_type *ptr = ldlang_undef_chain_list_head;
@ -951,7 +954,7 @@ DEFUN_VOID (lang_place_undefineds)
*/ */
static void static void
DEFUN_VOID (lang_create_output_section_statements) lang_create_output_section_statements ()
{ {
lang_statement_union_type *os; lang_statement_union_type *os;
@ -968,7 +971,7 @@ DEFUN_VOID (lang_create_output_section_statements)
} }
static void static void
DEFUN_VOID (lang_init_script_file) lang_init_script_file ()
{ {
script_file = lang_add_input_file ("command line", script_file = lang_add_input_file ("command line",
lang_input_file_is_fake_enum, lang_input_file_is_fake_enum,
@ -991,10 +994,10 @@ DEFUN_VOID (lang_init_script_file)
/* Open input files and attatch to output sections */ /* Open input files and attatch to output sections */
static void static void
DEFUN (map_input_to_output_sections, (s, target, output_section_statement), map_input_to_output_sections (s, target, output_section_statement)
lang_statement_union_type * s AND lang_statement_union_type * s;
CONST char *target AND CONST char *target;
lang_output_section_statement_type * output_section_statement) lang_output_section_statement_type * output_section_statement;
{ {
for (; s != (lang_statement_union_type *) NULL; s = s->next) for (; s != (lang_statement_union_type *) NULL; s = s->next)
{ {
@ -1061,8 +1064,8 @@ DEFUN (map_input_to_output_sections, (s, target, output_section_statement),
static void static void
DEFUN (print_output_section_statement, (output_section_statement), print_output_section_statement (output_section_statement)
lang_output_section_statement_type * output_section_statement) lang_output_section_statement_type * output_section_statement;
{ {
asection *section = output_section_statement->bfd_section; asection *section = output_section_statement->bfd_section;
@ -1130,9 +1133,9 @@ DEFUN (print_output_section_statement, (output_section_statement),
} }
static void static void
DEFUN (print_assignment, (assignment, output_section), print_assignment (assignment, output_section)
lang_assignment_statement_type * assignment AND lang_assignment_statement_type * assignment;
lang_output_section_statement_type * output_section) lang_output_section_statement_type * output_section;
{ {
etree_value_type result; etree_value_type result;
@ -1163,8 +1166,8 @@ DEFUN (print_assignment, (assignment, output_section),
} }
static void static void
DEFUN (print_input_statement, (statm), print_input_statement (statm)
lang_input_statement_type * statm) lang_input_statement_type * statm;
{ {
if (statm->filename != (char *) NULL) if (statm->filename != (char *) NULL)
{ {
@ -1173,8 +1176,8 @@ DEFUN (print_input_statement, (statm),
} }
static void static void
DEFUN (print_symbol, (q), print_symbol (q)
asymbol * q) asymbol * q;
{ {
print_section (""); print_section ("");
fprintf (config.map_file, " "); fprintf (config.map_file, " ");
@ -1186,8 +1189,8 @@ DEFUN (print_symbol, (q),
} }
static void static void
DEFUN (print_input_section, (in), print_input_section (in)
lang_input_section_type * in) lang_input_section_type * in;
{ {
asection *i = in->section; asection *i = in->section;
int size = i->reloc_done ? int size = i->reloc_done ?
@ -1266,16 +1269,16 @@ DEFUN (print_input_section, (in),
} }
static void static void
DEFUN (print_fill_statement, (fill), print_fill_statement (fill)
lang_fill_statement_type * fill) lang_fill_statement_type * fill;
{ {
fprintf (config.map_file, "FILL mask "); fprintf (config.map_file, "FILL mask ");
print_fill (fill->fill); print_fill (fill->fill);
} }
static void static void
DEFUN (print_data_statement, (data), print_data_statement (data)
lang_data_statement_type * data) lang_data_statement_type * data;
{ {
/* bfd_vma value; */ /* bfd_vma value; */
print_section (""); print_section ("");
@ -1311,8 +1314,8 @@ DEFUN (print_data_statement, (data),
static void static void
DEFUN (print_padding_statement, (s), print_padding_statement (s)
lang_padding_statement_type * s) lang_padding_statement_type * s;
{ {
print_section (""); print_section ("");
print_space (); print_space ();
@ -1330,9 +1333,9 @@ DEFUN (print_padding_statement, (s),
} }
static void static void
DEFUN (print_wild_statement, (w, os), print_wild_statement (w, os)
lang_wild_statement_type * w AND lang_wild_statement_type * w;
lang_output_section_statement_type * os) lang_output_section_statement_type * os;
{ {
fprintf (config.map_file, " from "); fprintf (config.map_file, " from ");
if (w->filename != (char *) NULL) if (w->filename != (char *) NULL)
@ -1356,9 +1359,9 @@ DEFUN (print_wild_statement, (w, os),
} }
static void static void
DEFUN (print_statement, (s, os), print_statement (s, os)
lang_statement_union_type * s AND lang_statement_union_type * s;
lang_output_section_statement_type * os) lang_output_section_statement_type * os;
{ {
while (s) while (s)
{ {
@ -1421,7 +1424,7 @@ DEFUN (print_statement, (s, os),
static void static void
DEFUN_VOID (print_statements) print_statements ()
{ {
print_statement (statement_list.head, print_statement (statement_list.head,
abs_output_section); abs_output_section);
@ -1430,11 +1433,11 @@ DEFUN_VOID (print_statements)
static bfd_vma static bfd_vma
DEFUN (insert_pad, (this_ptr, fill, power, output_section_statement, dot), DEFUN (insert_pad, (this_ptr, fill, power, output_section_statement, dot),
lang_statement_union_type ** this_ptr AND lang_statement_union_type ** this_ptr AND
fill_type fill AND fill_type fill AND
unsigned int power AND unsigned int power AND
asection * output_section_statement AND asection * output_section_statement AND
bfd_vma dot) bfd_vma dot)
{ {
/* Align this section first to the /* Align this section first to the
input sections requirement, then input sections requirement, then
@ -1476,13 +1479,12 @@ DEFUN (insert_pad, (this_ptr, fill, power, output_section_statement, dot),
/* Work out how much this section will move the dot point */ /* Work out how much this section will move the dot point */
static bfd_vma static bfd_vma
DEFUN (size_input_section, (this_ptr, output_section_statement, fill, DEFUN (size_input_section, (this_ptr, output_section_statement, fill, dot, relax),
dot, relax), lang_statement_union_type ** this_ptr AND
lang_statement_union_type ** this_ptr AND lang_output_section_statement_type * output_section_statement AND
lang_output_section_statement_type * output_section_statement AND unsigned short fill AND
unsigned short fill AND bfd_vma dot AND
bfd_vma dot AND boolean relax)
boolean relax)
{ {
lang_input_section_type *is = &((*this_ptr)->input_section); lang_input_section_type *is = &((*this_ptr)->input_section);
asection *i = is->section; asection *i = is->section;
@ -1499,8 +1501,7 @@ DEFUN (size_input_section, (this_ptr, output_section_statement, fill,
/* remember the largest size so we can malloc the largest area /* remember the largest size so we can malloc the largest area
needed for the output stage. Only remember the size of sections needed for the output stage. Only remember the size of sections
which we will actually allocate */ which we will actually allocate */
if (((i->flags & if ((i->flags & SEC_HAS_CONTENTS) != 0
(SEC_HAS_CONTENTS | SEC_ALLOC)) == (SEC_HAS_CONTENTS | SEC_ALLOC))
&& (bfd_get_section_size_before_reloc (i) > largest_section)) && (bfd_get_section_size_before_reloc (i) > largest_section))
{ {
largest_section = bfd_get_section_size_before_reloc (i); largest_section = bfd_get_section_size_before_reloc (i);
@ -1537,14 +1538,13 @@ DEFUN (size_input_section, (this_ptr, output_section_statement, fill,
static boolean had_relax; static boolean had_relax;
static bfd_vma static bfd_vma
DEFUN (lang_size_sections, (s, output_section_statement, prev, fill, DEFUN (lang_size_sections, (s, output_section_statement, prev, fill, dot, relax),
dot, relax), lang_statement_union_type * s AND
lang_statement_union_type * s AND lang_output_section_statement_type * output_section_statement AND
lang_output_section_statement_type * output_section_statement AND lang_statement_union_type ** prev AND
lang_statement_union_type ** prev AND unsigned short fill AND
unsigned short fill AND bfd_vma dot AND
bfd_vma dot AND boolean relax)
boolean relax)
{ {
/* Size up the sections from their constituent parts */ /* Size up the sections from their constituent parts */
for (; s != (lang_statement_union_type *) NULL; s = s->next) for (; s != (lang_statement_union_type *) NULL; s = s->next)
@ -1617,7 +1617,7 @@ DEFUN (lang_size_sections, (s, output_section_statement, prev, fill,
/* align against */ /* align against */
after = ALIGN (os->bfd_section->vma + after = ALIGN_N (os->bfd_section->vma +
os->bfd_section->_raw_size, os->bfd_section->_raw_size,
os->block_value); os->block_value);
@ -1776,10 +1776,10 @@ DEFUN (lang_size_sections, (s, output_section_statement, prev, fill,
static bfd_vma static bfd_vma
DEFUN (lang_do_assignments, (s, output_section_statement, fill, dot), DEFUN (lang_do_assignments, (s, output_section_statement, fill, dot),
lang_statement_union_type * s AND lang_statement_union_type * s AND
lang_output_section_statement_type * output_section_statement AND lang_output_section_statement_type * output_section_statement AND
unsigned short fill AND unsigned short fill AND
bfd_vma dot) bfd_vma dot)
{ {
for (; s != (lang_statement_union_type *) NULL; s = s->next) for (; s != (lang_statement_union_type *) NULL; s = s->next)
@ -1882,9 +1882,8 @@ DEFUN (lang_do_assignments, (s, output_section_statement, fill, dot),
static void static void
DEFUN_VOID (lang_relocate_globals) lang_relocate_globals ()
{ {
/* /*
Each ldsym_type maintains a chain of pointers to asymbols which Each ldsym_type maintains a chain of pointers to asymbols which
references the definition. Replace each pointer to the referenence references the definition. Replace each pointer to the referenence
@ -1939,7 +1938,7 @@ DEFUN_VOID (lang_relocate_globals)
static void static void
DEFUN_VOID (lang_finish) lang_finish ()
{ {
ldsym_type *lgs; ldsym_type *lgs;
int warn = config.relocateable_output != true; int warn = config.relocateable_output != true;
@ -1985,7 +1984,7 @@ DEFUN_VOID (lang_finish)
/* By now we know the target architecture, and we may have an */ /* By now we know the target architecture, and we may have an */
/* ldfile_output_machine_name */ /* ldfile_output_machine_name */
static void static void
DEFUN_VOID (lang_check) lang_check ()
{ {
lang_statement_union_type *file; lang_statement_union_type *file;
bfd *input_bfd; bfd *input_bfd;
@ -2038,7 +2037,7 @@ DEFUN_VOID (lang_check)
*/ */
static void static void
DEFUN_VOID (lang_common) lang_common ()
{ {
ldsym_type *lgs; ldsym_type *lgs;
size_t power; size_t power;
@ -2123,7 +2122,7 @@ DEFUN_VOID (lang_common)
/* Fix the size of the common section */ /* Fix the size of the common section */
com->section->_raw_size = com->section->_raw_size =
ALIGN (com->section->_raw_size, align); ALIGN_N (com->section->_raw_size, align);
/* Remember if this is the biggest alignment ever seen */ /* Remember if this is the biggest alignment ever seen */
if (power_of_two > com->section->alignment_power) if (power_of_two > com->section->alignment_power)
@ -2166,7 +2165,7 @@ into the statement tree.
*/ */
static void static void
DEFUN_VOID (lang_place_orphans) lang_place_orphans ()
{ {
lang_input_statement_type *file; lang_input_statement_type *file;
@ -2220,9 +2219,9 @@ DEFUN_VOID (lang_place_orphans)
void void
DEFUN (lang_set_flags, (ptr, flags), lang_set_flags (ptr, flags)
int *ptr AND int *ptr;
CONST char *flags) CONST char *flags;
{ {
boolean state = false; boolean state = false;
@ -2262,8 +2261,8 @@ DEFUN (lang_set_flags, (ptr, flags),
void void
DEFUN (lang_for_each_file, (func), lang_for_each_file (func)
void (*func) PARAMS ((lang_input_statement_type *))) void (*func) PARAMS ((lang_input_statement_type *));
{ {
lang_input_statement_type *f; lang_input_statement_type *f;
@ -2277,8 +2276,8 @@ DEFUN (lang_for_each_file, (func),
void void
DEFUN (lang_for_each_input_section, (func), lang_for_each_input_section (func)
void (*func) PARAMS ((bfd * ab, asection * as))) void (*func) PARAMS ((bfd * ab, asection * as));
{ {
lang_input_statement_type *f; lang_input_statement_type *f;
@ -2300,8 +2299,8 @@ DEFUN (lang_for_each_input_section, (func),
void void
DEFUN (ldlang_add_file, (entry), ldlang_add_file (entry)
lang_input_statement_type * entry) lang_input_statement_type * entry;
{ {
lang_statement_append (&file_chain, lang_statement_append (&file_chain,
@ -2310,8 +2309,8 @@ DEFUN (ldlang_add_file, (entry),
} }
void void
DEFUN (lang_add_output, (name), lang_add_output (name)
CONST char *name) CONST char *name;
{ {
lang_output_statement_type *new = new_stat (lang_output_statement, lang_output_statement_type *new = new_stat (lang_output_statement,
stat_ptr); stat_ptr);
@ -2337,19 +2336,16 @@ static int topower(x)
return 0; return 0;
} }
void void
DEFUN (lang_enter_output_section_statement, lang_enter_output_section_statement (output_section_statement_name,
(output_section_statement_name, address_exp, flags, block_value,
address_exp, align, subalign, base)
flags, char *output_section_statement_name;
block_value, etree_type * address_exp;
align, subalign, base), int flags;
char *output_section_statement_name AND bfd_vma block_value;
etree_type * address_exp AND etree_type *align;
int flags AND etree_type *subalign;
bfd_vma block_value AND etree_type *base;
etree_type *align AND
etree_type *subalign AND
etree_type *base)
{ {
lang_output_section_statement_type *os; lang_output_section_statement_type *os;
@ -2391,7 +2387,7 @@ DEFUN (lang_enter_output_section_statement,
void void
DEFUN_VOID (lang_final) lang_final ()
{ {
if (had_output_filename == false) if (had_output_filename == false)
{ {
@ -2403,7 +2399,7 @@ DEFUN_VOID (lang_final)
/* Reset the current counters in the regions */ /* Reset the current counters in the regions */
static void static void
DEFUN_VOID (reset_memory_regions) reset_memory_regions ()
{ {
lang_memory_region_type *p = lang_memory_region_list; lang_memory_region_type *p = lang_memory_region_list;
@ -2411,7 +2407,7 @@ DEFUN_VOID (reset_memory_regions)
p != (lang_memory_region_type *) NULL; p != (lang_memory_region_type *) NULL;
p = p->next) p = p->next)
{ {
p->old_length = p->current - p->origin; p->old_length = (bfd_size_type) (p->current - p->origin);
p->current = p->origin; p->current = p->origin;
} }
} }
@ -2420,9 +2416,9 @@ DEFUN_VOID (reset_memory_regions)
asymbol * asymbol *
DEFUN (create_symbol, (name, flags, section), DEFUN (create_symbol, (name, flags, section),
CONST char *name AND CONST char *name AND
flagword flags AND flagword flags AND
asection * section) asection * section)
{ {
extern lang_input_statement_type *script_file; extern lang_input_statement_type *script_file;
asymbol **def_ptr = (asymbol **) stat_alloc ((bfd_size_type) (sizeof (asymbol **))); asymbol **def_ptr = (asymbol **) stat_alloc ((bfd_size_type) (sizeof (asymbol **)));
@ -2439,13 +2435,20 @@ DEFUN (create_symbol, (name, flags, section),
} }
void void
DEFUN_VOID (lang_process) lang_process ()
{ {
if (had_script == false) if (had_script == false)
{ {
parse_line (ldemul_get_script (), 1); /* Read the emulation's appropriate default script. */
char *scriptname = ldemul_get_script ();
size_t size = strlen (scriptname) + 3;
char *buf = (char *) ldmalloc(size);
sprintf (buf, "-T%s", scriptname);
parse_line (buf, 0);
free (buf);
} }
lang_reasonable_defaults (); lang_reasonable_defaults ();
current_target = default_target; current_target = default_target;
@ -2570,9 +2573,9 @@ DEFUN_VOID (lang_process)
/* EXPORTED TO YACC */ /* EXPORTED TO YACC */
void void
DEFUN (lang_add_wild, (section_name, filename), lang_add_wild (section_name, filename)
CONST char *CONST section_name AND CONST char *CONST section_name;
CONST char *CONST filename) CONST char *CONST filename;
{ {
lang_wild_statement_type *new = new_stat (lang_wild_statement, lang_wild_statement_type *new = new_stat (lang_wild_statement,
stat_ptr); stat_ptr);
@ -2591,9 +2594,9 @@ DEFUN (lang_add_wild, (section_name, filename),
} }
void void
DEFUN (lang_section_start, (name, address), lang_section_start (name, address)
CONST char *name AND CONST char *name;
etree_type * address) etree_type * address;
{ {
lang_address_statement_type *ad = new_stat (lang_address_statement, stat_ptr); lang_address_statement_type *ad = new_stat (lang_address_statement, stat_ptr);
@ -2602,15 +2605,15 @@ DEFUN (lang_section_start, (name, address),
} }
void void
DEFUN (lang_add_entry, (name), lang_add_entry (name)
CONST char *name) CONST char *name;
{ {
entry_symbol = name; entry_symbol = name;
} }
void void
DEFUN (lang_add_target, (name), lang_add_target (name)
CONST char *name) CONST char *name;
{ {
lang_target_statement_type *new = new_stat (lang_target_statement, lang_target_statement_type *new = new_stat (lang_target_statement,
stat_ptr); stat_ptr);
@ -2620,8 +2623,8 @@ DEFUN (lang_add_target, (name),
} }
void void
DEFUN (lang_add_map, (name), lang_add_map (name)
CONST char *name) CONST char *name;
{ {
while (*name) while (*name)
{ {
@ -2636,8 +2639,8 @@ DEFUN (lang_add_map, (name),
} }
void void
DEFUN (lang_add_fill, (exp), lang_add_fill (exp)
int exp) int exp;
{ {
lang_fill_statement_type *new = new_stat (lang_fill_statement, lang_fill_statement_type *new = new_stat (lang_fill_statement,
stat_ptr); stat_ptr);
@ -2646,9 +2649,9 @@ DEFUN (lang_add_fill, (exp),
} }
void void
DEFUN (lang_add_data, (type, exp), lang_add_data (type, exp)
int type AND int type;
union etree_union *exp) union etree_union *exp;
{ {
lang_data_statement_type *new = new_stat (lang_data_statement, lang_data_statement_type *new = new_stat (lang_data_statement,
@ -2660,8 +2663,8 @@ DEFUN (lang_add_data, (type, exp),
} }
void void
DEFUN (lang_add_assignment, (exp), lang_add_assignment (exp)
etree_type * exp) etree_type * exp;
{ {
lang_assignment_statement_type *new = new_stat (lang_assignment_statement, lang_assignment_statement_type *new = new_stat (lang_assignment_statement,
stat_ptr); stat_ptr);
@ -2670,15 +2673,15 @@ DEFUN (lang_add_assignment, (exp),
} }
void void
DEFUN (lang_add_attribute, (attribute), lang_add_attribute (attribute)
enum statement_enum attribute) enum statement_enum attribute;
{ {
new_statement (attribute, sizeof (lang_statement_union_type), stat_ptr); new_statement (attribute, sizeof (lang_statement_union_type), stat_ptr);
} }
void void
DEFUN (lang_startup, (name), lang_startup (name)
CONST char *name) CONST char *name;
{ {
if (startup_file != (char *) NULL) if (startup_file != (char *) NULL)
{ {
@ -2691,16 +2694,16 @@ DEFUN (lang_startup, (name),
} }
void void
DEFUN (lang_float, (maybe), lang_float (maybe)
boolean maybe) boolean maybe;
{ {
lang_float_flag = maybe; lang_float_flag = maybe;
} }
void void
DEFUN (lang_leave_output_section_statement, (fill, memspec), lang_leave_output_section_statement (fill, memspec)
bfd_vma fill AND bfd_vma fill;
CONST char *memspec) CONST char *memspec;
{ {
current_section->fill = fill; current_section->fill = fill;
current_section->region = lang_memory_region_lookup (memspec); current_section->region = lang_memory_region_lookup (memspec);
@ -2722,9 +2725,9 @@ DEFUN (lang_leave_output_section_statement, (fill, memspec),
If the symbol already exists, then do nothing. If the symbol already exists, then do nothing.
*/ */
void void
DEFUN (lang_abs_symbol_at_beginning_of, (section, name), lang_abs_symbol_at_beginning_of (section, name)
CONST char *section AND CONST char *section;
CONST char *name) CONST char *name;
{ {
if (ldsym_undefined (name)) if (ldsym_undefined (name))
{ {
@ -2751,9 +2754,9 @@ DEFUN (lang_abs_symbol_at_beginning_of, (section, name),
If the symbol already exists, then do nothing. If the symbol already exists, then do nothing.
*/ */
void void
DEFUN (lang_abs_symbol_at_end_of, (section, name), lang_abs_symbol_at_end_of (section, name)
CONST char *section AND CONST char *section;
CONST char *name) CONST char *name;
{ {
if (ldsym_undefined (name)) if (ldsym_undefined (name))
{ {
@ -2776,10 +2779,10 @@ DEFUN (lang_abs_symbol_at_end_of, (section, name),
} }
void void
DEFUN (lang_statement_append, (list, element, field), lang_statement_append (list, element, field)
lang_statement_list_type * list AND lang_statement_list_type * list;
lang_statement_union_type * element AND lang_statement_union_type * element;
lang_statement_union_type ** field) lang_statement_union_type ** field;
{ {
*(list->tail) = element; *(list->tail) = element;
list->tail = field; list->tail = field;
@ -2787,8 +2790,8 @@ DEFUN (lang_statement_append, (list, element, field),
/* Set the output format type */ /* Set the output format type */
void void
DEFUN (lang_add_output_format, (format), lang_add_output_format (format)
CONST char *format) CONST char *format;
{ {
output_target = format; output_target = format;
} }

View File

@ -119,6 +119,8 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
<COMMAND>"-d" { return OPTION_d; } <COMMAND>"-d" { return OPTION_d; }
<COMMAND>"-v" { return OPTION_v; } <COMMAND>"-v" { return OPTION_v; }
<COMMAND>"-V" { return OPTION_V; } <COMMAND>"-V" { return OPTION_V; }
<COMMAND>"-m" { return OPTION_m; }
<COMMAND>"-m"{FILENAME} { return OPTION_memul; }
<COMMAND>"-M" { return OPTION_M; } <COMMAND>"-M" { return OPTION_M; }
<COMMAND>"-Map" { return OPTION_Map;} <COMMAND>"-Map" { return OPTION_Map;}
<COMMAND>"-t" { return OPTION_t; } <COMMAND>"-t" { return OPTION_t; }
@ -184,12 +186,19 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
<COMMAND>"-retain-symbols-file" { return OPTION_RETAIN_SYMBOLS_FILE; } <COMMAND>"-retain-symbols-file" { return OPTION_RETAIN_SYMBOLS_FILE; }
<COMMAND>"-EB" { <COMMAND>"-EB" {
return OPTION_EB; return OPTION_EB;
} }
<COMMAND>"-EL" { <COMMAND>"-EL" {
return OPTION_EL; return OPTION_EL;
} }
<COMMAND>"-G" {
return OPTION_G;
}
<COMMAND>"-G"([0-9])+ {
yylval.integer = atoi (yytext + 2);
return OPTION_Gval;
}
<MRI,EXPRESSION>"$"([0-9A-Fa-f])+ { <MRI,EXPRESSION>"$"([0-9A-Fa-f])+ {
yylval.integer = strtoul(yytext+1, 0,16); yylval.integer = strtoul(yytext+1, 0,16);
return INT; return INT;
@ -400,9 +409,9 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
%% %%
void void
DEFUN(lex_push_file,(file,name), lex_push_file (file, name)
FILE *file AND FILE *file;
char *name) char *name;
{ {
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
{ {
@ -419,9 +428,9 @@ DEFUN(lex_push_file,(file,name),
} }
YY_BUFFER_STATE YY_BUFFER_STATE
DEFUN(yy_create_string_buffer,(string, size), yy_create_string_buffer (string, size)
CONST char *string AND CONST char *string;
int size ) int size;
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
@ -457,8 +466,8 @@ DEFUN(yy_create_string_buffer,(string, size),
void void
DEFUN(lex_redirect,( string), lex_redirect (string)
CONST char *string) CONST char *string;
{ {
YY_BUFFER_STATE tmp; YY_BUFFER_STATE tmp;
@ -482,7 +491,7 @@ int state_stack[20];
int *state_stack_p = state_stack; int *state_stack_p = state_stack;
void void
DEFUN_VOID(ldlex_script) ldlex_script ()
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
@ -491,41 +500,41 @@ DEFUN_VOID(ldlex_script)
void void
DEFUN_VOID(ldlex_mri_script) ldlex_mri_script ()
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(MRI); BEGIN(MRI);
} }
void void
DEFUN_VOID(ldlex_defsym) ldlex_defsym ()
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(DEFSYMEXP); BEGIN(DEFSYMEXP);
} }
void void
DEFUN_VOID(ldlex_expression) ldlex_expression ()
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(EXPRESSION); BEGIN(EXPRESSION);
} }
void void
DEFUN_VOID(ldlex_both) ldlex_both ()
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(BOTH); BEGIN(BOTH);
} }
void void
DEFUN_VOID(ldlex_command) ldlex_command ()
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(COMMAND); BEGIN(COMMAND);
} }
void void
DEFUN_VOID(ldlex_popstate) ldlex_popstate ()
{ {
yy_start = *(--state_stack_p); yy_start = *(--state_stack_p);
} }

View File

@ -95,8 +95,8 @@ static
#endif #endif
int int
DEFUN (hash_string, (key), hash_string (key)
CONST char *key) CONST char *key;
{ {
register CONST char *cp; register CONST char *cp;
register int k; register int k;
@ -116,9 +116,9 @@ static
__inline __inline
#endif #endif
ldsym_type * ldsym_type *
DEFUN (search, (key, hashval), search (key, hashval)
CONST char *key AND CONST char *key;
int hashval) int hashval;
{ {
ldsym_type *bp; ldsym_type *bp;
for (bp = global_symbol_hash_table[hashval]; bp; bp = bp->link) for (bp = global_symbol_hash_table[hashval]; bp; bp = bp->link)
@ -138,8 +138,8 @@ DEFUN (search, (key, hashval),
/* Get the symbol table entry for the global symbol named KEY. /* Get the symbol table entry for the global symbol named KEY.
Create one if there is none. */ Create one if there is none. */
ldsym_type * ldsym_type *
DEFUN (ldsym_get, (key), ldsym_get (key)
CONST char *key) CONST char *key;
{ {
register int hashval; register int hashval;
register ldsym_type *bp; register ldsym_type *bp;
@ -180,8 +180,8 @@ DEFUN (ldsym_get, (key),
/* Like `ldsym_get' but return 0 if the symbol is not already known. */ /* Like `ldsym_get' but return 0 if the symbol is not already known. */
ldsym_type * ldsym_type *
DEFUN (ldsym_get_soft, (key), ldsym_get_soft (key)
CONST char *key) CONST char *key;
{ {
register int hashval; register int hashval;
/* Determine which bucket. */ /* Determine which bucket. */
@ -313,8 +313,8 @@ list_file_locals (entry)
static void static void
DEFUN (print_file_stuff, (f), print_file_stuff (f)
lang_input_statement_type * f) lang_input_statement_type * f;
{ {
fprintf (config.map_file, " %s\n", f->filename); fprintf (config.map_file, " %s\n", f->filename);
if (f->just_syms_flag) if (f->just_syms_flag)
@ -659,8 +659,8 @@ return true if the supplied symbol name is not in the
linker symbol table linker symbol table
*/ */
boolean boolean
DEFUN (ldsym_undefined, (sym), ldsym_undefined (sym)
CONST char *sym) CONST char *sym;
{ {
ldsym_type *from_table = ldsym_get_soft (sym); ldsym_type *from_table = ldsym_get_soft (sym);
if (from_table != (ldsym_type *) NULL) if (from_table != (ldsym_type *) NULL)
@ -672,7 +672,7 @@ DEFUN (ldsym_undefined, (sym),
} }
void void
DEFUN_VOID (ldsym_init) ldsym_init ()
{ {
obstack_begin (&global_sym_obstack, 20000); obstack_begin (&global_sym_obstack, 20000);
} }

View File

@ -45,8 +45,8 @@ static warning_list_type *warning_list;
void void
DEFUN(add_warning,(sym), add_warning (sym)
asymbol *sym) asymbol *sym;
{ {
CONST char *name = ((asymbol *)(sym->value))->name; CONST char *name = ((asymbol *)(sym->value))->name;
warning_list_type *new; warning_list_type *new;
@ -64,8 +64,8 @@ DEFUN(add_warning,(sym),
/* run through the list we kept, and find the warning associated with /* run through the list we kept, and find the warning associated with
this symbol */ this symbol */
CONST char * CONST char *
DEFUN(fetch_warning,(sym), fetch_warning (sym)
asymbol *sym) asymbol *sym;
{ {
warning_list_type *ptr = warning_list; warning_list_type *ptr = warning_list;
while (ptr != (warning_list_type *)NULL) { while (ptr != (warning_list_type *)NULL) {
@ -79,9 +79,9 @@ asymbol *sym)
void void
DEFUN(produce_warnings,(lgs,it), produce_warnings (lgs, it)
ldsym_type *lgs AND ldsym_type *lgs;
asymbol *it) asymbol *it;
{ {
asymbol **ptr; asymbol **ptr;
ptr = lgs->srefs_chain; ptr = lgs->srefs_chain;

332
ld/mri.c
View File

@ -27,63 +27,284 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h" #include "bfd.h"
#include "sysdep.h" #include "sysdep.h"
#include "ld.h"
#include "ldlang.h" #include "ldlang.h"
#include "mri.h" #include "mri.h"
#include "ldgram.h"
#include "ldexp.h" #include "ldexp.h"
void
DEFUN(mri_output_section, (name, vma),
CONST char *name AND
etree_type *vma)
struct section_name_struct {
struct section_name_struct *next;
CONST char *name;
CONST char *alias;
etree_type *vma;
etree_type *align;
etree_type *subalign;
int ok_to_load;
} ;
int symbol_truncate = 10000;
struct section_name_struct *order;
struct section_name_struct *only_load;
struct section_name_struct *address;
struct section_name_struct *alias;
struct section_name_struct *alignment;
struct section_name_struct *subalignment;
extern char *strdup();
static struct section_name_struct **
lookup (name, list)
CONST char *name;
struct section_name_struct **list;
{ {
lang_output_section_statement_type *os;
os = lang_output_section_statement_lookup(name); struct section_name_struct **ptr = list;
while (*ptr)
if (os->addr_tree == (etree_type *)NULL) { {
os->addr_tree = vma; if (strcmp(name, (*ptr)->name) == 0) {
/* If this is a match, delete it, we only keep the last instance
of any name */
*ptr = (*ptr)->next;
}
else {
ptr = &((*ptr)->next);
}
} }
os->flags = 0; *ptr = (struct section_name_struct *)ldmalloc(sizeof(struct section_name_struct));
os->block_value = 0; return ptr;
}
static void
mri_add_to_list (list, name, vma, alias, align, subalign)
struct section_name_struct **list;
CONST char *name;
etree_type *vma;
CONST char *alias;
etree_type *align;
etree_type *subalign;
{
struct section_name_struct **ptr = lookup(name,list);
(*ptr)->name = name;
(*ptr)->vma = vma;
(*ptr)->next = (struct section_name_struct *)NULL;
(*ptr)->ok_to_load = 0;
(*ptr)->alias = alias;
(*ptr)->align = align;
(*ptr)->subalign = subalign;
}
void
mri_output_section (name, vma)
CONST char *name;
etree_type *vma;
{
mri_add_to_list(&address, name, vma, 0,0,0);
} }
/* if any ABSOLUTE <name> are in the script, only load those files /* if any ABSOLUTE <name> are in the script, only load those files
marked thus */ marked thus */
void DEFUN(mri_only_load,(name), CONST char *name) void
mri_only_load (name)
CONST char *name;
{ {
lang_output_section_statement_type *os; mri_add_to_list(&only_load, name, 0, 0,0,0);
}
os = lang_output_section_statement_lookup(name);
os->flags = 0; etree_type *base;
os->block_value = 0;
void
mri_base (exp)
etree_type *exp;
{
base = exp;
}
static int done_tree = 0;
static void
mri_draw_tree ()
{
if (done_tree) return;
/* Create the regions */
{
lang_memory_region_type *r;
r = lang_memory_region_lookup("long");
r->current = r->origin = exp_get_vma(base, (bfd_vma)0, "origin",
lang_first_phase_enum);
r->length = (bfd_size_type) exp_get_vma(0, (bfd_vma) ~((bfd_size_type)0),
"length", lang_first_phase_enum);
}
/* Now build the statements for the ldlang machine */
/* Attatch the addresses of any which have addresses, and add the
ones not mentioned */
if (address != (struct section_name_struct *)NULL) {
struct section_name_struct *alist;
struct section_name_struct *olist;
if (order == (struct section_name_struct *)NULL) {
order = address;
}
for (alist = address;
alist != (struct section_name_struct*)NULL;
alist = alist->next)
{
int done = 0;
for (olist = order;
done == 0 &&
olist != (struct section_name_struct *)NULL;
olist = olist->next)
{
if (strcmp(alist->name, olist->name) == 0)
{
olist->vma = alist->vma;
done = 1;
}
}
if (!done) {
/* add this onto end of order list */
mri_add_to_list(&order, alist->name, alist->vma, 0,0,0);
}
}
}
/* If we're only supposed to load a subset of them in, then prune
the list. */
if (only_load != (struct section_name_struct *)NULL)
{
struct section_name_struct *ptr1;
struct section_name_struct *ptr2;
if (order == (struct section_name_struct*)NULL)
order = only_load;
/* See if this name is in the list, if it is then we can load it
*/
for (ptr1 = only_load; ptr1; ptr1 = ptr1->next)
{
for (ptr2= order; ptr2; ptr2=ptr2->next)
{
if (strcmp(ptr2->name, ptr1->name)==0) {
ptr2->ok_to_load = 1;
}
}
}
}
else
{
/* No only load list, so everything is ok to load */
struct section_name_struct *ptr;
for (ptr = order; ptr; ptr=ptr->next) {
ptr->ok_to_load = 1;
}
}
/* Create the order of sections to load */
if (order != (struct section_name_struct *)NULL)
{
/* Been told to output the sections in a certain order */
struct section_name_struct *p = order;
while (p)
{
struct section_name_struct *aptr;
etree_type *align = 0;
etree_type *subalign = 0;
/* See if an alignment has been specified */
for (aptr = alignment; aptr; aptr= aptr->next)
{
if (strcmp(aptr->name, p->name)==0) {
align = aptr->align;
}
}
for (aptr = subalignment; aptr; aptr= aptr->next)
{
if (strcmp(aptr->name, p->name)==0) {
subalign = aptr->subalign;
}
}
if (base == 0) {
base = p->vma ? p->vma :exp_nameop(NAME, ".");
}
lang_enter_output_section_statement(p->name, base,
p->ok_to_load ? 0 :
SEC_NEVER_LOAD, 1,
align, subalign);
base = 0;
lang_add_wild(p->name, (char *)NULL);
/* If there is an alias for this section, add it too */
for (aptr = alias; aptr; aptr = aptr->next) {
if (strcmp(aptr->alias, p->name)== 0) {
lang_add_wild(aptr->name, (char *)NULL);
}
}
lang_leave_output_section_statement(0, "long");
p = p->next;
}
}
done_tree = 1;
}
void
mri_load (name)
CONST char *name;
{
mri_draw_tree();
base = 0;
lang_add_input_file(name,
lang_input_file_is_file_enum, (char *)NULL);
/* lang_leave_output_section_statement(0,"*default*");*/
}
void
mri_order (name)
CONST char *name;
{
mri_add_to_list(&order, name, 0, 0,0,0);
}
void
mri_alias (want, is, isn)
CONST char *want;
CONST char *is;
int isn;
{
if (!is) {
/* Some sections are digits - */
char buf[20];
sprintf(buf, "%d", isn);
is =strdup(buf);
}
mri_add_to_list(&alias, is, 0, want,0,0);
} }
void void
DEFUN(mri_load,(name), mri_name (name)
CONST char *name) CONST char *name;
{
lang_add_input_file(name, lang_input_file_is_file_enum, (char *)NULL);
}
void
DEFUN(mri_order,(name),
CONST char *name)
{
einfo("Ignoring ORDER %s for the moment\n", name);
}
void
DEFUN(mri_name,(name),
CONST char *name)
{ {
lang_add_output(name); lang_add_output(name);
@ -91,8 +312,8 @@ DEFUN(mri_name,(name),
void void
DEFUN(mri_format,(name), mri_format (name)
CONST char *name) CONST char *name;
{ {
if (strcmp(name, "S") == 0) if (strcmp(name, "S") == 0)
{ {
@ -102,7 +323,44 @@ DEFUN(mri_format,(name),
{ {
lang_add_output_format("ieee"); lang_add_output_format("ieee");
} }
else if (strcmp(name, "COFF") == 0)
{
lang_add_output_format("coff-m68k");
}
else { else {
einfo("%P%F: unknown format type %s\n", name); einfo("%P%F: unknown format type %s\n", name);
} }
} }
void
mri_public (name, exp)
CONST char *name;
etree_type *exp;
{
lang_add_assignment(exp_assop('=', name, exp));
}
void
mri_align (name, exp)
CONST char *name;
etree_type *exp;
{
mri_add_to_list(&alignment, name,0,0,exp,0);
}
void
mri_alignmod (name, exp)
CONST char *name;
etree_type *exp;
{
mri_add_to_list(&subalignment, name,0,0,0,exp);
}
void
mri_truncate (exp)
int exp;
{
symbol_truncate = exp;
}

View File

@ -39,8 +39,8 @@ Tie together all the interseting blocks
#include "ldgram.h" #include "ldgram.h"
#include "relax.h" #include "relax.h"
static void static void
DEFUN (build_it, (statement), build_it (statement)
lang_statement_union_type * statement) lang_statement_union_type * statement;
{ {
switch (statement->header.type) switch (statement->header.type)
{ {
@ -179,10 +179,10 @@ DEFUN (build_it, (statement),
void void
DEFUN (write_relax, (output_bfd, data, relocateable), write_relax (output_bfd, data, relocateable)
bfd * output_bfd AND bfd * output_bfd;
PTR data AND PTR data;
boolean relocateable) boolean relocateable;
{ {
/* Tie up all the statements to generate an output bfd structure which /* Tie up all the statements to generate an output bfd structure which
bfd can mull over */ bfd can mull over */
@ -203,8 +203,8 @@ DEFUN (write_relax, (output_bfd, data, relocateable),
symbols in it, and shift around the data too. symbols in it, and shift around the data too.
*/ */
boolean boolean
DEFUN (relax_section, (this_ptr), relax_section (this_ptr)
lang_statement_union_type ** this_ptr) lang_statement_union_type ** this_ptr;
{ {
extern lang_input_statement_type *script_file; extern lang_input_statement_type *script_file;
lang_input_section_type *is = &((*this_ptr)->input_section); lang_input_section_type *is = &((*this_ptr)->input_section);

53
ld/scripttempl/.Sanitize Normal file
View File

@ -0,0 +1,53 @@
# .Sanitize for devo/ld/config
# Each directory to survive its way into a release will need a file
# like this one called "./.Sanitize". All keyword lines must exist,
# and must exist in the order specified by this file. Each directory
# in the tree will be processed, top down, in the following order.
# Hash started lines like this one are comments and will be deleted
# before anything else is done. Blank lines will also be squashed
# out.
# The lines between the "Do-first:" line and the "Things-to-keep:"
# line are executed as a /bin/sh shell script before anything else is
# done in this directory.
Do-first:
# All files listed between the "Things-to-keep:" line and the
# "Do-last:" line will be kept. All other files will be removed.
# Directories listed in this section will have their own Sanitize
# called. Directories not listed will be removed in their entirety
# with rm -rf.
Things-to-keep:
README
a29k.sc
aout.sc
ebmon29k.sc
h8300.sc
h8500.sc
hppaosf.sc
i386coff.sc
i960.sc
m68kcoff.sc
m88kbcs.sc
mips.sc
mipsbsd.sc
sa29200.sc
sh.sc
st2000.sc
vanilla.sc
z8ksim.sc
Things-to-lose:
# The lines between the "Do-last:" line and the end of the file
# are executed as a /bin/sh shell script after everything else is
# done.
Do-last:

4
ld/scripttempl/README Normal file
View File

@ -0,0 +1,4 @@
The files in this directory are linker script templates.
genscripts.sh sets some shell variables, then sources
EMULATION.sc, to generate EMULATION.{x,xr,xu,xn,xbn} -- the script
files for default, -r, -Ur, -n, -N.

38
ld/scripttempl/a29k.sc Normal file
View File

@ -0,0 +1,38 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
INPUT(/lab3/u3/sym1/tools/usr/lib/segments.o) /* Has .rstack/.mstack */
${LIB_SEARCH_DIRS}
MEMORY {
text : ORIGIN = 0x1000000, LENGTH = 0x1000000
talias : ORIGIN = 0x2000000, LENGTH = 0x1000000
data : ORIGIN = 0x3000000, LENGTH = 0x1000000
mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000
rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000
}
SECTIONS
{
.text : {
*(.text)
${RELOCATING+ __etext = .};
*(.lit)
*(.shdata)
} ${RELOCATING+ > text}
.shbss SIZEOF(.text) + ADDR(.text) : {
*(.shbss)
}
.talias : { } ${RELOCATING+ > talias}
.data : {
*(.data)
${RELOCATING+ __edata = .};
} ${RELOCATING+ > data}
.bss SIZEOF(.data) + ADDR(.data) :
{
*(.bss)
*(COMMON)
${RELOCATING+ __end = ALIGN(0x8)};
}
.mstack : { } ${RELOCATING+ > mstack}
.rstack : { } ${RELOCATING+ > rstack}
}
EOF

View File

@ -0,0 +1,27 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
ENTRY(start)
SECTIONS {
.text ${RELOCATING+${TEXT_START_ADDR}} :
{
*(.text);
${RELOCATING+_etext = .};
}
data ${RELOCATING+0x80002000} :
{
*(.data);
*(.mstack);
*(.shbss);
*(.rstack);
*(.mstack);
${CONSTRUCTING+CONSTRUCTORS}
}
.bss . :
{
*(COMMON)
*(.bss);
${RELOCATING+_end = .};
}
}
EOF

43
ld/scripttempl/h8500.sc Normal file
View File

@ -0,0 +1,43 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})
MEMORY {
rom : o = 0x0000, l = 0x7fe0
duart : o = 0x7fe0, l = 16
ram : o = 0x8000, l = 28k
topram : o = 0x8000+28k, l = 1k
hmsram : o = 0xfb80, l = 512
}
SECTIONS
{
.text :
{
*(.text)
*(.strings)
${RELOCATING+ _etext = . ; }
} ${RELOCATING+ > ram}
.data :
{
*(.data)
${RELOCATING+ _edata = . ; }
} ${RELOCATING+ > ram}
.bss :
{
${RELOCATING+ _bss_start = . ;}
*(.bss)
*(COMMON)
${RELOCATING+ _end = . ; }
} ${RELOCATING+ >ram}
.stack :
{
${RELOCATING+ _stack = . ; }
*(.stack)
} ${RELOCATING+ > topram}
}
EOF

29
ld/scripttempl/hppaosf.sc Normal file
View File

@ -0,0 +1,29 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})
ENTRY("\$START\$")
${RELOCATING+${LIB_SEARCH_DIRS}}
SECTIONS
{
.text ${RELOCATING+${TEXT_START_ADDR}}:
{
${RELOCATING+__text_start = .};
CREATE_OBJECT_SYMBOLS
*(.text)
}
.data ${RELOCATING+ 0x40000000 } :
{
${RELOCATING+__data_start = .};
${RELOCATING+ . = . + 0x1000 };
*(.data)
${CONSTRUCTING+CONSTRUCTORS}
}
.bss ${RELOCATING+SIZEOF(.data) + ADDR(.data)} :
{
*(.bss)
*(COMMON)
${RELOCATING+_end = . };
${RELOCATING+__end = . };
}
}
EOF

View File

@ -0,0 +1,29 @@
# Linker script for 386 COFF. This works on SVR3.2 and SCO Unix 3.2.2.
# .data2 handles SCO, which uses two data sections.
# Ian Taylor <ian@cygnus.com>.
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
${LIB_SEARCH_DIRS}
ENTRY(_start)
SECTIONS
{
.text ${RELOCATING+ SIZEOF_HEADERS} : {
*(.init)
*(.text)
*(.fini)
${RELOCATING+ etext = .};
}
.data ${RELOCATING+ 0x400000 + (. & 0xffc00fff)} : {
*(.data .data2)
${RELOCATING+ edata = .};
}
.bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
{
*(.bss)
*(COMMON)
${RELOCATING+ end = .};
}
}
EOF

23
ld/scripttempl/i960.sc Normal file
View File

@ -0,0 +1,23 @@
cat <<EOF
SECTIONS
{
.text :
{
${GLD_STYLE+ CREATE_OBJECT_SYMBOLS}
*(.text)
${RELOCATING+ _etext = .};
}
.data SIZEOF(.text) + ADDR(.text):
{
*(.data)
${RELOCATING+ _edata = .};
}
.bss SIZEOF(.data) + ADDR(.data):
{
${RELOCATING+ _bss_start = .};
*(.bss)
*(COMMON)
${RELOCATING+ _end = .};
}
}
EOF

56
ld/scripttempl/mips.sc Normal file
View File

@ -0,0 +1,56 @@
# Linker script for MIPS systems.
# Ian Lance Taylor <ian@cygnus.com>.
# These variables may be overridden by the emulation file. The
# defaults are appropriate for a DECstation running Ultrix.
test -z "$ENTRY" && ENTRY=__start
test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x400000 + SIZEOF_HEADERS"
test -z "$DATA_ADDR" && DATA_ADDR=0x10000000
test -z "$BSS_VAR" && BSS_VAR=
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
${LIB_SEARCH_DIRS}
ENTRY(${ENTRY})
SECTIONS
{
.text ${RELOCATING+ ${TEXT_START_ADDR}} : {
*(.init)
${RELOCATING+ eprol = .};
*(.text)
*(.fini)
${RELOCATING+ etext = .};
${RELOCATING+ _etext = .};
}
.rdata ${RELOCATING+ ${DATA_ADDR}} : {
*(.rdata)
}
.data ${RELOCATING+ .} : {
*(.data)
${CONSTRUCTING+CONSTRUCTORS}
}
${RELOCATING+ _gp = . + 0x8000;}
.lit8 ${RELOCATING+ .} : {
*(.lit8)
}
.lit4 ${RELOCATING+ .} : {
*(.lit4)
}
.sdata ${RELOCATING+ .} : {
*(.sdata)
}
${RELOCATING+ edata = .;}
${RELOCATING+ _edata = .;}
${RELOCATING+ ${BSS_VAR}}
.sbss ${RELOCATING+ .} : {
*(.sbss)
*(.scommon)
}
.bss ${RELOCATING+ .} : {
*(.bss)
*(COMMON)
}
${RELOCATING+ end = .;}
${RELOCATING+ _end = .;}
}
EOF

28
ld/scripttempl/mipsbsd.sc Normal file
View File

@ -0,0 +1,28 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})
${RELOCATING+${LIB_SEARCH_DIRS}}
${RELOCATING+__DYNAMIC = 0;}
SECTIONS
{
.text ${RELOCATING+${TEXT_START_ADDR}}:
{
CREATE_OBJECT_SYMBOLS
*(.text)
${RELOCATING+etext = ${DATA_ALIGNMENT};}
}
.data ${RELOCATING+${DATA_ALIGNMENT}} :
{
*(.data)
${CONSTRUCTING+CONSTRUCTORS}
${RELOCATING+edata = .;}
}
.bss ${RELOCATING+SIZEOF(.data) + ADDR(.data)} :
{
*(.bss)
*(COMMON)
${RELOCATING+end = . };
}
}
EOF

44
ld/scripttempl/sa29200.sc Normal file
View File

@ -0,0 +1,44 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
ENTRY(start)
SECTIONS {
.text ${RELOCATING+${TEXT_START_ADDR}} :
{
*(.text);
*(.text1);
*(.text2);
${RELOCATING+_etext = .};
}
.lit . :
{
*(.lit);
${RELOCATING+_elit = .};
}
.data . :
{
*(.data);
*(.data1);
*(.data2);
${RELOCATING+_edata = .};
${CONSTRUCTING+CONSTRUCTORS}
${CONSTRUCTING+ ___CTOR_LIST__ = .;}
${CONSTRUCTING+ LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2)}
*(.ctors)
${CONSTRUCTING+ LONG(0)}
${CONSTRUCTING+ ___CTOR_END__ = .;}
${CONSTRUCTING+ ___DTOR_LIST__ = .;}
${CONSTRUCTING+ LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2)}
*(.dtors)
${CONSTRUCTING+ LONG(0)}
${CONSTRUCTING+ ___DTOR_END__ = .;}
}
.bss . :
{
*(COMMON)
*(.bss)
${RELOCATING+_end = .};
}
}
EOF

39
ld/scripttempl/sh.sc Normal file
View File

@ -0,0 +1,39 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})
MEMORY {
ram : o = 0x1000, l = 512k
}
SECTIONS
{
.text :
{
*(.text)
*(.strings)
${RELOCATING+ _etext = . ; }
} ${RELOCATING+ > ram}
.data :
{
*(.data)
${RELOCATING+ _edata = . ; }
} ${RELOCATING+ > ram}
.bss :
{
${RELOCATING+ _bss_start = . ;}
*(.bss)
*(COMMON)
${RELOCATING+ _end = . ; }
} ${RELOCATING+ >ram}
.stack :
{
${RELOCATING+ _stack = . ; }
*(.stack)
} ${RELOCATING+ > ram}
}
EOF

26
ld/scripttempl/st2000.sc Normal file
View File

@ -0,0 +1,26 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})
SECTIONS
{
.text :
{
*(.text)
*(.strings)
_etext = .;
*(.data)
_edata = .;
*(.bss)
*(COMMON)
_end = .;
}
}
EOF

View File

@ -0,0 +1 @@
# Nothing to do.

26
ld/scripttempl/z8ksim.sc Normal file
View File

@ -0,0 +1,26 @@
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})
SECTIONS
{
.text :
{
*(.text)
*(.strings)
_etext = .;
*(.data)
_edata = .;
*(.bss)
*(COMMON)
_end = .;
}
}
EOF