Fix previous fix.
[deliverable/binutils-gdb.git] / ld / genscripts.sh
1 # genscripts.sh
2 # This shell script does the work of generating the ld-emulation-target
3 # specific information from a specific file of paramaters.
4 # Usage: genscripts.sh srcdir libdir host_alias target_alias emulation_name
5 # Sample usage:
6 # genscripts.sh /offsite/djm/work/devo/ld /usr/local/lib sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sun3.sh
7 # produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c
8
9 srcdir=$1
10 libdir=$2
11 host_alias=$3
12 target_alias=$4
13
14 # Include the emulation-specific parameters:
15 . ${srcdir}/emulparams/$5
16
17 # Set the library search path, for libraries named by -lfoo.
18 # If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
19 # Otherwise, the default is set here.
20 #
21 # The format is the usual list of colon-separated directories.
22 # To force a logically empty LIB_PATH, do LIBPATH=":".
23
24 if [ "x${LIB_PATH}" = "x" ] ; then
25 if [ "x${host_alias}" = "x${target_alias}" ] ; then
26 # Native.
27 LIB_PATH=/lib:/usr/lib:${libdir}
28 if [ "${libdir}" != /usr/local/lib ] ; then
29 LIB_PATH=${LIB_PATH}:/usr/local/lib
30 fi
31 else
32 # Cross.
33 LIB_PATH=
34 fi
35 fi
36 LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'`
37
38 # Generate 5 script files from a master script template in
39 # ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 script files
40 # is actually used depends on command line options given to ld.
41 #
42 # A .x script file is the default script.
43 # A .xr script is for linking without relocation (-r flag).
44 # A .xu script is like .xr, but *do* create constructors (-Ur flag).
45 # A .xn script is for linking with -n flag (mix text and data on same page).
46 # A .xbn script is for linking with -N flag (mix text and data on same page).
47
48 SEGMENT_SIZE=${SEGMENT_SIZE-${PAGE_SIZE}}
49
50 # Determine DATA_ALIGNMENT for the 5 variants, using
51 # values specified in the emulparams/<emulation>.sh file or default.
52
53 DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}"
54 DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}"
55 DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}"
56 DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}"
57 DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
58
59 LD_FLAG=r
60 DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
61 DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
62 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
63 ldscripts/${EMULATION_NAME}.xr
64
65 LD_FLAG=u
66 DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
67 CONSTRUCTING=
68 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
69 ldscripts/${EMULATION_NAME}.xu
70
71 LD_FLAG=
72 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
73 RELOCATING=
74 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
75 ldscripts/${EMULATION_NAME}.x
76
77 LD_FLAG=n
78 DATA_ALIGNMENT=${DATA_ALIGNMENT_n}
79 TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}}
80 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
81 ldscripts/${EMULATION_NAME}.xn
82
83 LD_FLAG=N
84 DATA_ALIGNMENT=${DATA_ALIGNMENT_N}
85 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
86 ldscripts/${EMULATION_NAME}.xbn
87
88 #sed -e s/"<ldtarget>"/${EMULATION_NAME}/g -e s/"<arch>"/${ARCH}/g \
89 # -e s/"<target>"/${EMULATION_NAME}/g -e s/"<target_name>"/${OUTPUT_FORMAT}/g \
90 # <${srcdir}/${TEMPLATE_NAME-ldtemplate} >em_${EMULATION_NAME}.c
91
92 # Generate em_${EMULATION_NAME}.c.
93 . ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
This page took 0.035889 seconds and 5 git commands to generate.