11.1Stsutsui#!/bin/sh 21.3Schristos# $NetBSD: mkldscript.sh,v 1.3 2014/11/12 13:23:41 christos Exp $ 31.3Schristos# 41.3Schristos# This script is used by cats, luna68k and shark to produce 51.3Schristos# a kernel linker script that merges link sets for a.out kernels 61.3Schristos# (without -t). It is also used for the same reason by kernel modules 71.3Schristos# (with -t). 81.1Stsutsui 91.3SchristosPROG="$(basename "$0")" 101.3SchristosTEMPLATE= 111.1Stsutsui 121.2Schristosmksets() { 131.2Schristos "${OBJDUMP:-objdump}" -x "$@" | fgrep "RELOCATION RECORDS FOR [link_set" | \ 141.2Schristos sort -u | sed 's/^.*\[\(.*\)\]:$/\1/' 151.2Schristos} 161.3Schristos 171.3Schristoswhile getopts "t:" f; do 181.3Schristos case "$f" in 191.3Schristos t) 201.3Schristos TEMPLATE=${OPTARG};; 211.3Schristos *) 221.3Schristos echo "Usage: $PROG [-t <template>] objs" 1>^&2 231.3Schristos exit 1;; 241.3Schristos esac 251.3Schristosdone 261.3Schristos 271.3Schristosshift $((OPTIND - 1)) 281.3Schristos 291.2SchristosSETS=$(mksets "$@") 301.1Stsutsui 311.3Schristosif [ -n "${TEMPLATE}" ]; then 321.3Schristos grep -v '^}$' "${TEMPLATE}" 331.3Schristosfi 341.2Schristos 351.1Stsutsuifor s in $SETS; do 361.2Schristos printf ' . = ALIGN(4);\n' 371.2Schristos printf ' PROVIDE (__start_%s = .);\n' $s 381.3Schristos if [ -n "${TEMPLATE}" ]; then 391.3Schristos printf ' %s : { *(%s) }\n' $s $s 401.3Schristos else 411.3Schristos printf ' *(%s)\n' $s 421.3Schristos fi 431.2Schristos printf ' PROVIDE (__stop_%s = .);\n' $s 441.2Schristosdone 451.3Schristos 461.3Schristosif [ -n "${TEMPLATE}" ]; then 471.3Schristos printf '}\n' 481.3Schristosfi 49