From: Michal Ostrowski <mostrows@watson.ibm.com>
To: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] Provide mechanism for editing builtin command-line in zImage binary.
Date: Mon, 29 May 2006 22:27:02 -0400 [thread overview]
Message-ID: <1148956023.25048.83.camel@brick> (raw)
In-Reply-To: <11489544631499-git-send-email-mostrows@watson.ibm.com>
For reference, below is a shell script I use to edit the command-line
embedded in a zImage.
--
Michal Ostrowski <mostrows@watson.ibm.com>
#!/bin/bash
#
# Copyright (C) 2006 Michal Ostrowski <mostrows@watson.ibm.com>, IBM Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
usage(){
echo 'set_builtin_cmdline [--cmd <file>] <input_obj> [<output_obj>]'
echo ' Sets the builtin command line embedded in an object file.'
echo
echo ' If <output_obj> is not specified, <input_obj> is modified'
echo ' in place.'
echo ' If --cmd <file> argument is present contents of embedded'
echo ' command line will be copied from <file>, otherwise from stdin.'
exit 1
}
cmd_file=
while case "$#" in 0) break ;; esac
do
case "$1" in
--cmd)
case "$#" in
1)
usage ;;
*)
cmd_file="$2";
shift;;
esac;;
*)
set x "$@"
shift
break ;;
esac
shift
done
if [ "$#" -lt 1 ]; then
echo "No input object specified." ;
usage;
fi
if [ "$#" -gt 2 ]; then
echo "Unrecognized arguments: $@";
usage;
fi
infile=$1
shift;
if [ ! -r "$infile" ] ; then
echo "Can't read '$infile'.";
usage;
fi
if [ "$#" -eq 0 ] ; then
outfile=$infile;
else
outfile=$1;
if ! cp $infile $outfile ; then
echo "Can't create output: '$outfile' $?"
usage;
fi
shift;
fi
offset=$(objdump -h $infile | \
gawk -- '{if($2=="__builtin_cmdline") {print strtonum("0x" $6);}}')
size=$(objdump -h $infile | \
gawk -- '{if($2=="__builtin_cmdline") {print strtonum("0x" $3);}}')
if [ "$cmd_file" ] ; then
[ -r "$cmd_file" ] || (echo "Can't read '$cmd_file'." ; usage);
cmdline=$(cat $cmd_file);
else
cmdline=$(cat);
fi
if [ "x$offset" != "x" ] ; then
if [ "$offset" -ne 0 ] ; then
set -e
# Zero the destination buffer first
exec 2>/dev/null
dd if=/dev/zero of=$outfile bs=1 seek=$offset conv=notrunc count=$size
echo -n "$cmdline" | \
dd of=$outfile bs=1 seek=$offset conv=notrunc count=$size
exit $?
fi
fi
next prev parent reply other threads:[~2006-05-30 2:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-30 2:01 [PATCH] Provide mechanism for editing builtin command-line in zImage binary mostrows
2006-05-30 2:27 ` Michal Ostrowski [this message]
2006-05-30 20:41 ` Mark A. Greer
2006-05-30 21:12 ` Michal Ostrowski
2006-05-31 20:04 ` Mark A. Greer
2006-05-31 20:26 ` Michal Ostrowski
2006-05-31 20:35 ` Matthew McClintock
2006-05-31 21:04 ` Michal Ostrowski
2006-06-09 9:47 ` Paul Mackerras
2006-06-09 13:06 ` [PATCH] Editable kernel " mostrows
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1148956023.25048.83.camel@brick \
--to=mostrows@watson.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.