#!/bin/sh
if [ "x$1" == "x" ]; then
	echo "Please provide an argument or two"
	return 1;
fi

TARGET=$2

if [ "x$TARGET" == "x" ]; then
	TARGET=`basename "$1"`.binhex
fi

TMPFILE=`mktemp`

echo "Converting $1 to $TARGET"

objcopy -j.text -O binary "$1" "$TMPFILE"
hexdump -v -e '"0x%08x\n"' "$TMPFILE" > "$TARGET"

#!/bin/bash
if [ "x$1" == "x" ]; then
	echo "Please provide an argument or two"
	return 1;
fi

TARGET=$2

if [ "x$TARGET" == "x" ]; then
	TARGET=`basename "$1"`.binhex
fi

TMPFILE=`mktemp`

echo "Converting $1 to $TARGET"

objcopy -j.text -O binary "$1" "$TMPFILE"
readelf -h "$1" | grep "Entry point address:"| awk '{printf "0x%08x\n", strtonum($NF)}' > "$TARGET"
hexdump -v -e '"0x%08x\n"' "$TMPFILE" >> "$TARGET"

Put Entry point address at the beginning of binhex
Put Entry point address at the beginning of binhex

Signed-off-by: Zi Yan <a95843713135ee2454bfe7dac9a681dcd8c52c48@cs.rutgers.edu>
