From e3d00d4584c20a81cebedbfd47f7eb20c6c7f674 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Wed, 28 Nov 2012 21:46:19 +0000 Subject: [PATCH] Use elfwrap :-) --- uts/debian/elfwrap | 101 +++++++++++++++++++++++++++++++++++++++++++++ uts/debian/rules | 4 ++ 2 files changed, 105 insertions(+) create mode 100755 uts/debian/elfwrap diff --git a/uts/debian/elfwrap b/uts/debian/elfwrap new file mode 100755 index 0000000..1a0ad51 --- /dev/null +++ b/uts/debian/elfwrap @@ -0,0 +1,101 @@ +#!/bin/sh + +set -e +set -u + +# Default output file name: +outputfile="a.wrap.o" + +# --32 or --64. Empty by default. To pass to GNU as. +bitness="" + +# Print assembler source code to stdout +# instead of compiling to ELF object +show_source="no" + +fatal () { + echo "$0: $@" >&2 + echo "$0: Type \`$0 -h' to get help" >&2 + exit 2 +} + +usage () { + echo "$0 [ -64 | -32 ] [ -o outputfile ] [ -s ] files ..." + exit 1 +} + + +files="" +collect() { + files="$files$1|" +} + +processing_options="yes" + +while [ $# != 0 ]; do + opt="$1" + shift + if [ "$processing_options" = yes ]; then + case "$opt" in + --) + processing_options="no" + ;; + -s) + show_source="yes" + ;; + -h|--help) + usage + ;; + -32|--32) + bitness="--32" + ;; + -64|--64) + bitness="--64" + ;; + -o) + [ $# != 0 ] || fatal "Option -o requires an argument" + outputfile="$1" + shift + ;; + -*) + fatal "Invalid option: $opt" + ;; + *) + collect "$opt" + ;; + esac + else + collect "$opt" + fi +done + + +if [ -z "$files" ]; then + fatal "No files given." +fi + +( +IFS='|' +set -- $files +for f in "$@"; do + base=`basename -- "$f" | sed -e 's,[^0-9a-zA-Z_],_,g' -e 's,^\([0-9]\),_\1,'` + echo ".section .${base}, \"a\", @progbits" + echo ".global ${base}_start" + echo ".global ${base}_end" + echo ".type ${base}_start, @object" + echo ".type ${base}_end, @object" + echo "${base}_start:" + echo ".incbin \"$f\"" + echo "${base}_end:" + echo +done +) | ( +if [ "$show_source" = yes ]; then + cat +else + as $bitness -o "$outputfile" -- +fi +) + +exit 0 + diff --git a/uts/debian/rules b/uts/debian/rules index be4dc1b..a22476b 100755 --- a/uts/debian/rules +++ b/uts/debian/rules @@ -11,6 +11,10 @@ unpack-stamp: dh_illumos_gate --build \ usr/src/uts \ usr/src/common + # this a shell script generating assembler source files + # and passing that source to as. + # Default output format is expected to be 32-bit: + echo "export ELFWRAP='$(CURDIR)/debian/elfwrap -32'" >> usr/env.sh touch $@ patch: patch-stamp