CFLAGS = $(INCLUDES) $(DEBUG) $(HDEFINES) $(TDEFINES) $(CDEFINES)
LINTFLAGS = $(INCLUDES) $(EXTRA_DEF)
-.SUFFIXES: .y .x .xr .xu .xn .sc .scu .scr .scn $(SUFFIXES)
+.SUFFIXES: .y .x .xr .xu .xn .xN .sc .scu .scr .scn $(SUFFIXES)
# go directly to ld.new in case this ld isn't capable of
# linking native object on this host. It can be renamed on
# sed is used to transform this script into two variant forms:
# A .scr script is for linking without relocation (-r flag).
# A .scu script is like .scr, but *do* create constructors.
-# A .scu script is for linking to non-demand-paged output (-N or -n).
+# A .scn script is for linking with -N flag (mix text and data on same page).
+# A .scN script is for linking with -N flag (mix text and data on same page).
# The diference is that segments should (need) not be page aligned.
# A sed pattern to translate .sc to .scu:
-e "/data/s/[.]data .*:/.data :/"
# A sed pattern to translate .scu to .scr:
SED_REMOVE_CONSTRUCTORS= -e /CONSTRUCTORS/d
-# A sed pattern to translate .sc to .scn:
-# We assume that any reasonable page size ends with 00
-# (Some things are aligned on 8-byte boundaries; ignore those.)
-SED_DONT_ALIGN= -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./'
.sc.scu:
sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $< >$*.scu
-.sc.scn:
- sed $(SED_DONT_ALIGN) $< >$*.scn
.scu.scr:
sed $(SED_REMOVE_CONSTRUCTORS) < $< >$*.scr
-# Each .sc .scr .scu or .scn script is filtered by mkscript
-# into a string literal that can be included in a .c program.
+# Each builtin script file is included as a C string literal.
+# These are generated by the mkscript filter.
.sc.x:
if [ "x"$(LIB_PATH) = "x" ]; then ./mkscript < $< >$*.x ; \
else \
(sed <$< -e '/SEARCH_DIR(.*)/d' ; \
echo $(LIB_PATH) | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | ./mkscript >$*.x;\
fi
-# ./mkscript < $< >$*.x
-.scu.xu:
- ./mkscript < $< >$*.xu
-.scr.xr:
- ./mkscript < $< >$*.xr
-.scn.xn:
- ./mkscript < $< >$*.xn
+
+# The .xn script is used if the -n flag is given (write-protect text)..
+# Sunos starts the text segment for demand-paged binaries at 0x2020
+# and other binaries at 0x2000, since the exec header is paged in
+# with the text. Some other Unix variants do the same.
+# For -n and -N flags the offset of the exec header must be removed.
+# This sed script does this if the master script contains
+# a line of the form ".text 0xAAAA BLOCK(0xBBBB):" - the
+# output will contain ".text 0xBBBB:". (For Sunos AAAA=2020 and BBBB=2000.)
+.x.xn:
+ sed -e '/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
+
+# The .xN script is used if the -N flag is given (don't write-protect text).
+# This is like -n, except that the data segment need not be page-aligned.
+# So get rid of commands for page-alignment: We assume these use ALIGN
+# with a hex constant that end with 00, since any normal page size is be
+# at least divisible by 256. We use the 00 to avoid matching
+# anything that tries to align of (say) 8-byte boundaries.
+.xn.xN:
+ sed -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
+
+# The xu and xr scripts don't search libraries, so LIB_PATH doesn't matter.
.sc.xu:
sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) < $< | ./mkscript >$*.xu
.sc.xr:
sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $(SED_REMOVE_CONSTRUCTORS) \
< $< | ./mkscript >$*.xr
-.sc.xn:
- sed $(SED_DONT_ALIGN) < $< | ./mkscript >$*.xn
# for self hosting
BFDLIB=$(unsubdir)/../bfd$(subdir)/libbfd.a
-e s/"<target>"/m88kbcs/g -e s/"<TARGET>"/M88KBCS/g <$(srcdir)/ldtemplate >$@
# The .c files for these are generated from ldtemplete.
-ldgld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu ldgld.xn
-news.o: ./mkscript news.x news.xr news.xu news.xn
-ebmon29k.o: ./mkscript ebmon29k.x ebmon29k.xr ebmon29k.xu ebmon29k.xn
-ldgld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu ldgld68k.xn
-ldglda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu ldglda29k.xn
-ldm88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu ldm88k.xn
+ldgld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu ldgld.xn ldgld.xN
+news.o: ./mkscript news.x news.xr news.xu news.xn news.xN
+ebmon29k.o: ./mkscript ebmon29k.x ebmon29k.xr ebmon29k.xu \
+ ebmon29k.xn ebmon29k.xN
+ldgld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu \
+ ldgld68k.xn ldgld68k.xN
+ldglda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu \
+ ldglda29k.xn ldglda29k.xN
+ldm88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu ldm88k.xn ldm88k.xN
# The .c files for these are (for now) specially written (not ldtemplete).
ldgld960.o: ./mkscript ldgld960.x
clean:
- rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS)
- - rm -f *.x *.x[ru] *.sc[ur]
+ - rm -f *.x *.x[runN] *.sc[runN]
- rm -f ld.?? ld.???
- rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output