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