This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] Get rid of inner-loop call to bfd_octets_per_byte in objdump
- From: Cary Coutant <ccoutant at google dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Fri, 21 Aug 2009 16:34:26 -0700
- Subject: [patch] Get rid of inner-loop call to bfd_octets_per_byte in objdump
While profiling objdump, I found a call to bfd_octets_per_byte from
find_symbol_for_address, which seems wasteful given that the value is
already available in the info structure. Calling bfd_octets_per_byte
resuls in a call to bfd_lookup_arch for just about every line of
disassembly, which can be expensive especially if multiple targets are
enabled. This simple change cut 40% off the time it took to do an
objdump -d of a large binary when configured with
--enable-targets=all. (Of course, the savings will be substantially
less with only one or two targets enabled, but I still observed ~4%
improvement with just 2 targets -- i386 and x86 -- enabled.)
OK?
-cary
* objdump.c (find_symbol_for_address): Avoid costly call to
bfd_octets_per_byte.
Index: objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.162
diff -u -p -r1.162 objdump.c
--- objdump.c 27 Jul 2009 17:08:03 -0000 1.162
+++ objdump.c 21 Aug 2009 23:15:26 -0000
@@ -747,7 +747,7 @@ find_symbol_for_address (bfd_vma vma,
aux = (struct objdump_disasm_info *) info->application_data;
abfd = aux->abfd;
sec = aux->sec;
- opb = bfd_octets_per_byte (abfd);
+ opb = info->octets_per_byte;
/* Perform a binary search looking for the closest symbol to the
required value. We are searching the range (min, max]. */