From: Karim Yaghmour <karim@opersys.com>
To: Ingo Oeser <ioe-lkml@rameria.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Average instruction length in x86-built kernel?
Date: Sat, 30 Jul 2005 15:57:25 -0400 [thread overview]
Message-ID: <42EBDBA5.5090008@opersys.com> (raw)
In-Reply-To: <200507301549.32528.ioe-lkml@rameria.de>
Hello Ingo,
Ingo Oeser wrote:
> Just study the output od objdump -d and average the differences
> of the first hex number in a line printed, which are followed by a ":"
Here's a script that does what I was looking for:
#!/bin/bash
# Dissassemble
objdump -d $1 -j .text > $2-dissassembled-kernel
# Remove non-instruction lines:
sed /^[^c].*/d $2-dissassembled-kernel > $2-stage-1
# Remove empty lines:
sed /^'\t'*$/d $2-stage-1 > $2-stage-2
# Remove function names:
sed /^c[0-9,a-f]*' '\<.*\>:$/d $2-stage-2 > $2-stage-3
# Remove addresses:
sed s/^c[0-9,a-f]*:'\t'// $2-stage-3 > $2-stage-4
# Remove instruction text:
sed s/'\t'.*// $2-stage-4 > $2-stage-5
# Remove trailing whitespace:
sed s/'\s'*$// $2-stage-5 > $2-stage-6
# Separate instructions depending on size:
egrep "([0-9a-f]{2}[' ']*){5}" $2-stage-6 > $2-more-or-eq-5
egrep "^([0-9a-f]{2}[' ']*){0,4}$" $2-stage-6 > $2-less-or-eq-4
# Find out how much of each we've got:
wc -l $2-stage-6
wc -l $2-more-or-eq-5
wc -l $2-less-or-eq-4
The last part can easily be changed to iterate through and separate
those that are 1 byte, 2 bytes, etc. and automatically come up with
stats, but this was fine for what I was looking for.
I ran it on a 2.4.x and a 2.6.x kernel and about 3/4 of instructions
are 4 bytes or less.
Karim
--
Author, Speaker, Developer, Consultant
Pushing Embedded and Real-Time Linux Systems Beyond the Limits
http://www.opersys.com || karim@opersys.com || 1-866-677-4546
next prev parent reply other threads:[~2005-07-30 20:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-29 21:32 Average instruction length in x86-built kernel? Karim Yaghmour
2005-07-30 13:49 ` Ingo Oeser
2005-07-30 19:57 ` Karim Yaghmour [this message]
2005-08-01 7:35 ` David Weinehall
[not found] <4vKU4-3sU-21@gated-at.bofh.it>
[not found] ` <4w02Q-7e6-21@gated-at.bofh.it>
[not found] ` <4w5OQ-6Z9-25@gated-at.bofh.it>
2005-07-31 2:19 ` Bodo Eggert
2005-08-01 6:25 ` Jan Engelhardt
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=42EBDBA5.5090008@opersys.com \
--to=karim@opersys.com \
--cc=ioe-lkml@rameria.de \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox