# Copyright 2000, 2001 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # # The GNU MP Library is free software; you can redistribute it and/or modify # it under the terms of either: # # * the GNU Lesser General Public License as published by the Free # Software Foundation; either version 3 of the License, or (at your # option) any later version. # # or # # * 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. # # or both in parallel, as here. # # The GNU MP Library 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 copies of the GNU General Public License and the # GNU Lesser General Public License along with the GNU MP Library. If not, # see https://www.gnu.org/licenses/.
# Usage: cross.pl [filename.o]... # # Produce an annotated disassembly of the given object files, indicating # certain code alignment and addressing mode problems afflicting K6 chips. # "ZZ" is used on all annotations, so this can be searched for. # # With no arguments, all .o files corresponding to .asm files are processed. # This is good in the mpn object directory of a k6*-*-* build. # # Code alignments of 8 bytes or more are handled. When 32 is used, cache # line boundaries will fall in at offsets 0x20,0x40,etc and problems are # flagged at those locations. When 16 is used, the line boundaries can also # fall at offsets 0x10,0x30,0x50,etc, depending where the file is loaded, so # problems are identified there too. Likewise when 8 byte alignment is used # problems are flagged additionally at 0x08,0x18,0x28,etc. # # Usually 32 byte alignment is used for k6 routines, but less is certainly # possible if through good luck, or a little tweaking, cache line crossing # problems can be avoided at the extra locations. # # Bugs: # # Instructions without mod/rm bytes or which are already vector decoded are # unaffected by cache line boundary crossing, but not all of these have yet # been put in as exceptions. All that occur in practice in GMP are present # though. # # There's no messages for using the vector decoded addressing mode (%esi), # but that's easy to avoid when coding. # # Future: # # Warn about jump targets that are poorly aligned (less than 2 instructions # before a cache line boundary).
use strict;
sub disassemble {
my ($file) = @_;
my ($addr,$b1,$b2,$b3, $prefix,$opcode,$modrm);
my $align;
open (IN, "objdump -Srfh $file |")
|| die "Cannot open pipe from objdump\n"; while (<IN>) {
print;
# modrm of the form 00-xxx-100 with an 0F prefix is the problem case # for K6 and pre-CXT K6-2 if ($prefix =~ /0f/
&& $opcode !~ /^8/ # jcond disp32
&& $modrm =~ /^[0-3][4c]/) {
print "ZZ ($file) >3 bytes to determine instruction length [K6]\n";
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.