1#!/bin/sh 2# 3# $NetBSD: sunldgen.sh,v 1.1 2013/03/15 12:12:16 pooka Exp $ 4# 5 6# To support the Sun linker we need to make it behave like the GNU linker 7# for orphaned sections. That means generating __start/__stop symbols 8# for them and that means some nopoly-atheist-withoutfood level trickery. 9# We enumerate all the section names we wish to generate symbols for. 10# The good news is that it's unlikely for NetBSD to grow any more 11# link sets, and even if it does, it'll be a build-time failure 12# on Sun platforms so it's easy to catch and mend the list below. 13 14LINKSETS='rump_components evcnts prop_linkpools modules sysctl_funcs 15 bufq_strats domains dkwedge_methods ieee80211_funcs' 16 17exec 1> ldscript_sun.rump 18printf '# $NetBSD: sunldgen.sh,v 1.1 2013/03/15 12:12:16 pooka Exp $\n\n$mapfile_version 2\nLOAD_SEGMENT rumpkern_linksets {' 19for lset in ${LINKSETS}; do 20 printf '\n\tASSIGN_SECTION { IS_NAME= link_set_start_%s };\n' $lset 21 printf '\tASSIGN_SECTION { IS_NAME= link_set_%s };\n' $lset 22 printf '\tASSIGN_SECTION { IS_NAME= link_set_stop_%s };\n' $lset 23 printf '\tOS_ORDER+= link_set_start_%s\n' $lset 24 printf '\t link_set_%s\n' $lset 25 printf '\t link_set_stop_%s;\n' $lset 26done 27echo '};' 28 29exec 1> linksyms_sun.c 30printf '/* $NetBSD: sunldgen.sh,v 1.1 2013/03/15 12:12:16 pooka Exp $ */\n\n' 31for lset in ${LINKSETS}; do 32 printf 'int __start_link_set_%s[0]\n' $lset 33 printf '\t__attribute__((__section__("link_set_start_%s")));\n' $lset 34 printf 'int __link_set_dummy_%s[0]\n' $lset 35 printf '\t__attribute__((__section__("link_set_%s")));\n' $lset 36 printf 'int __stop_link_set_%s[0]\n' $lset 37 printf '\t__attribute__((__section__("link_set_stop_%s")));\n\n' $lset 38done 39