genscripts.sh revision 52939
1#!/bin/sh 2# genscripts.sh - generate the ld-emulation-target specific files 3# 4# Usage: genscripts.sh srcdir libdir host target target_alias \ 5# default_emulation native_lib_dirs this_emulation 6# 7# Sample usage: 8# genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib sparc-sun-sunos4.1.3 \ 9# sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sun4 "" sun3 sparc-sun-sunos4.1.3 10# produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c 11# 12# $FreeBSD: head/gnu/usr.bin/binutils/ld/genscripts.sh 52939 1999-11-06 22:40:15Z jb $ 13# 14# This is a cut-down version of the GNU script. Instead of jumping through 15# hoops for all possible combinations of paths, just use the libdir 16# argument in place of LIB_PATH. 17# 18# The host, target and target_alias arguments are not used in this version. 19# 20 21srcdir=$1 22libdir=$2 23host=$3 24target=$4 25target_alias=$5 26DEFAULT_EMULATION=$6 27NATIVE_LIB_DIRS=$7 28EMULATION_NAME=$8 29 30# Include the emulation-specific parameters: 31. ${srcdir}/emulparams/${EMULATION_NAME}.sh 32 33if test -d ldscripts; then 34 true 35else 36 mkdir ldscripts 37fi 38 39LIB_SEARCH_DIRS=`echo ${libdir} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'` 40 41# Generate 5 or 6 script files from a master script template in 42# ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 or 6 43# script files is actually used depends on command line options given 44# to ld. (SCRIPT_NAME was set in the emulparams_file.) 45# 46# A .x script file is the default script. 47# A .xr script is for linking without relocation (-r flag). 48# A .xu script is like .xr, but *do* create constructors (-Ur flag). 49# A .xn script is for linking with -n flag (mix text and data on same page). 50# A .xbn script is for linking with -N flag (mix text and data on same page). 51# A .xs script is for generating a shared library with the --shared 52# flag; it is only generated if $GENERATE_SHLIB_SCRIPT is set by the 53# emulation parameters. 54 55SEGMENT_SIZE=${SEGMENT_SIZE-${TARGET_PAGE_SIZE}} 56 57# Determine DATA_ALIGNMENT for the 5 variants, using 58# values specified in the emulparams/<emulation>.sh file or default. 59 60DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}" 61DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}" 62DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}" 63DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}" 64DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}" 65 66LD_FLAG=r 67DATA_ALIGNMENT=${DATA_ALIGNMENT_r} 68DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" 69(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ 70 ldscripts/${EMULATION_NAME}.xr 71 72LD_FLAG=u 73DATA_ALIGNMENT=${DATA_ALIGNMENT_u} 74CONSTRUCTING=" " 75(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ 76 ldscripts/${EMULATION_NAME}.xu 77 78LD_FLAG= 79DATA_ALIGNMENT=${DATA_ALIGNMENT_} 80RELOCATING=" " 81(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ 82 ldscripts/${EMULATION_NAME}.x 83 84LD_FLAG=n 85DATA_ALIGNMENT=${DATA_ALIGNMENT_n} 86TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}} 87(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ 88 ldscripts/${EMULATION_NAME}.xn 89 90LD_FLAG=N 91DATA_ALIGNMENT=${DATA_ALIGNMENT_N} 92(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ 93 ldscripts/${EMULATION_NAME}.xbn 94 95if test -n "$GENERATE_SHLIB_SCRIPT"; then 96 LD_FLAG=shared 97 DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}} 98 CREATE_SHLIB=" " 99 # Note that TEXT_START_ADDR is set to NONPAGED_TEXT_START_ADDR. 100 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ 101 ldscripts/${EMULATION_NAME}.xs 102fi 103 104test "$DEFAULT_EMULATION" = "$EMULATION_NAME" && COMPILE_IN=true 105 106# Generate e${EMULATION_NAME}.c. 107. ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em 108