17c478bd9Sstevel@tonic-gate#! /usr/bin/ksh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
63edf445cSab# Common Development and Distribution License (the "License").
73edf445cSab# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
2270087ad3SRichard Lowe
237c478bd9Sstevel@tonic-gate#
243edf445cSab# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate# Use is subject to license terms.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gateusage()
297c478bd9Sstevel@tonic-gate{
303edf445cSab	echo "usage: bld_vernote -R <revision> -r <release> -o <outfile.s>"
317c478bd9Sstevel@tonic-gate}
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gatepad_notestring()
347c478bd9Sstevel@tonic-gate{
357c478bd9Sstevel@tonic-gate	extra=$1
367c478bd9Sstevel@tonic-gate	len=$(( ${#notestring} + $extra ))
377c478bd9Sstevel@tonic-gate	padlen=$(( $len % 4 ))
387c478bd9Sstevel@tonic-gate	while [[ $(( $len % 4)) != 0 ]]
397c478bd9Sstevel@tonic-gate	do
407c478bd9Sstevel@tonic-gate		notestring="${notestring}\0"
417c478bd9Sstevel@tonic-gate		len=$(( $len + 1 ))
427c478bd9Sstevel@tonic-gate	done
437c478bd9Sstevel@tonic-gate}
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gatebuild_sparcnote()
477c478bd9Sstevel@tonic-gate{
4870087ad3SRichard Lowe	notestring="Solaris Link Editors: $release-$revision (illumos)\0"
497c478bd9Sstevel@tonic-gate	#
50c6c9aed4Sab	# The 'adjustment' is for the '\0'
517c478bd9Sstevel@tonic-gate	#
52c6c9aed4Sab	pad_notestring -1
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gatecat > $notefile <<EOF
557c478bd9Sstevel@tonic-gate	.section	".note"
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate#include <sgs.h>
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate	.align	4
607c478bd9Sstevel@tonic-gate	.word	.endname - .startname	/* note name size */
617c478bd9Sstevel@tonic-gate	.word	0			/* note desc size */
627c478bd9Sstevel@tonic-gate	.word	0			/* note type */
637c478bd9Sstevel@tonic-gate.startname:
647c478bd9Sstevel@tonic-gate	.ascii	"$notestring"
657c478bd9Sstevel@tonic-gate.endname:
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate	.section	".rodata", #alloc
687c478bd9Sstevel@tonic-gate	.global		link_ver_string
697c478bd9Sstevel@tonic-gatelink_ver_string:
707c478bd9Sstevel@tonic-gate	.type		link_ver_string, #object
7170087ad3SRichard Lowe	.ascii	"${release}-${revision} (illumos)\0"
727c478bd9Sstevel@tonic-gate	.size	link_ver_string, .-link_ver_string
737c478bd9Sstevel@tonic-gateEOF
747c478bd9Sstevel@tonic-gate}
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gatebuild_i386note()
777c478bd9Sstevel@tonic-gate{
7870087ad3SRichard Lowe	notestring="Solaris Link Editors: $release-$revision (illumos)"
797c478bd9Sstevel@tonic-gate	#
80c6c9aed4Sab	# The 'adjustment' is for the the fact that the x86/amd64
81c6c9aed4Sab	# assembler automatically append a '\0' at the end of a string.
827c478bd9Sstevel@tonic-gate	#
837c478bd9Sstevel@tonic-gate	pad_notestring -1
847c478bd9Sstevel@tonic-gatecat > $notefile <<EOF
857c478bd9Sstevel@tonic-gate	.section	.note
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gate#include <sgs.h>
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate	.align	4
907c478bd9Sstevel@tonic-gate	.long	.endname - .startname	/* note name size */
917c478bd9Sstevel@tonic-gate	.long	0			/* note desc size */
927c478bd9Sstevel@tonic-gate	.long	0			/* note type */
937c478bd9Sstevel@tonic-gate.startname:
947c478bd9Sstevel@tonic-gate	.string	"$notestring"
957c478bd9Sstevel@tonic-gate.endname:
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate	.section	.rodata, "a"
987c478bd9Sstevel@tonic-gate	.globl		link_ver_string
997c478bd9Sstevel@tonic-gatelink_ver_string:
1007c478bd9Sstevel@tonic-gate	.type	link_ver_string,@object
10170087ad3SRichard Lowe	.string	"${release}-${revision} (illumos)\0"
1027c478bd9Sstevel@tonic-gate	.size	link_ver_string, .-link_ver_string
1037c478bd9Sstevel@tonic-gateEOF
1047c478bd9Sstevel@tonic-gate}
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gatenotefile=""
1087c478bd9Sstevel@tonic-gaterelease=""
1093edf445cSabrevision=""
1107c478bd9Sstevel@tonic-gate
111*34ae5cdfSJosef 'Jeff' Sipekwhile getopts R:o:r: c
1127c478bd9Sstevel@tonic-gatedo
1137c478bd9Sstevel@tonic-gate	case $c in
1147c478bd9Sstevel@tonic-gate	o)
1157c478bd9Sstevel@tonic-gate		notefile=$OPTARG
1167c478bd9Sstevel@tonic-gate		;;
1177c478bd9Sstevel@tonic-gate	r)
1187c478bd9Sstevel@tonic-gate		release=$OPTARG
1197c478bd9Sstevel@tonic-gate		;;
1207c478bd9Sstevel@tonic-gate	R)
1213edf445cSab		revision=$OPTARG
1227c478bd9Sstevel@tonic-gate		;;
1237c478bd9Sstevel@tonic-gate	\?)
1247c478bd9Sstevel@tonic-gate		usage
1257c478bd9Sstevel@tonic-gate		exit 1
1267c478bd9Sstevel@tonic-gate		;;
1277c478bd9Sstevel@tonic-gate	esac
1287c478bd9Sstevel@tonic-gatedone
1297c478bd9Sstevel@tonic-gate
1303edf445cSabif [[ ( -z $notefile ) || ( -z $release ) || ( -z $revision ) ]]; then
1317c478bd9Sstevel@tonic-gate	usage
1327c478bd9Sstevel@tonic-gate	exit 1
1337c478bd9Sstevel@tonic-gatefi
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate
1367c478bd9Sstevel@tonic-gateif [[ $MACH = "sparc" ]]; then
1377c478bd9Sstevel@tonic-gate	build_sparcnote
1387c478bd9Sstevel@tonic-gateelif [[ $MACH = "i386" ]]; then
1397c478bd9Sstevel@tonic-gate	build_i386note
1407c478bd9Sstevel@tonic-gateelse
1417c478bd9Sstevel@tonic-gate	echo "I don't know how to build a vernote.s for ${MACH}, so sorry"
1427c478bd9Sstevel@tonic-gate	exit 1
1437c478bd9Sstevel@tonic-gatefi
144