This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFA: binutils-all/readelf.exp patches for 64-bit output.


I'm diddling with the mmix binutils port.

I notice that the readelf tests aren't playing nice with the "64-bit
output" from readelf.  Here are some patches to remedy that.

Note that "readelf -s" (readelf.ss-64) still fails for ia64, since the
symbol table of that target has entries jumbled, compared to the order in
readelf.ss (and what readelf-mmix outputs, FWIW).  I decided to stay with
the order in readelf.ss on the assumption that either the ia64 port is in
a flux or further work is needed to e.g. add target-specific matching in
readelf.exp.  (See, I leave *some* of the fun bits to others. ;-)

I also made the same change as aoliva made to
gas/testsuite/lib/gas-defs.exp: regexp_diff is better off not breaking at
the first mismatch, we want to see them all.  A typo fix and log
formatting fix also thrown in.

Note that the ia64 port gives 8-byte alignment of its .long:s, so 
readelf.s-64 has to handle that.  All other matches in *-64 are supposed
to slavisly follow the same route as readelf.s and readelf.ss.

Ok to commit?

Sun Jun 11 23:29:35 2000  Hans-Peter Nilsson  <hp@bitrange.com>

	* binutils-all/readelf.exp (regexp_diff): Don't break on the first
	difference, list them all. 
	(readelf_find_size): New.
	(readelf_size): New global variable.
	(readelf_test): Add newline send_log of command.
	If $srcdir/$subdir/$regexp_file-$readelf_size exists, use it
	instead of $srcdir/$subdir/$regexp_file.
	(*-*elf test): Fix typo in message.
	* binutils-all/readelf.s-64: New.
	* binutils-all/readelf.ss-64: New.

Index: readelf.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/readelf.exp,v
retrieving revision 1.2
diff -p -c -r1.2 readelf.exp
*** readelf.exp	2000/05/02 12:47:19	1.2
--- readelf.exp	2000/06/11 21:19:57
***************
*** 1,4 ****
! #   Copyright (C) 1999 Free Software Foundation, Inc.
  
  # 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
--- 1,4 ----
! #   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
  
  # 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
*************** proc regexp_diff { file_1 file_2 } {
*** 103,109 ****
  		send_log "regexp_diff match failure\n"
  		send_log "regexp \"^$line_b$\"\nline   \"$line_a\"\n"
  		set differences 1
-                 break
              }
          }
      }
--- 103,108 ----
*************** proc regexp_diff { file_1 file_2 } {
*** 120,138 ****
      return $differences
  }
  
  # Run an individual readelf test.
  # Basically readelf is run on the binary_file with the given options.
  # Readelf's output is captured and then compared against the contents
! # of the regexp_file.
  
  proc readelf_test { options binary_file regexp_file xfails } {
  
      global READELF
      global READELFFLAGS
      global srcdir
      global subdir
      
!     send_log "exec $READELF $READELFFLAGS $options $binary_file > readelf.out"
      catch "exec $READELF $READELFFLAGS $options $binary_file > readelf.out" got
  
      if { [llength $xfails] != 0 } then {
--- 119,169 ----
      return $differences
  }
  
+ # Find out the size by reading the output of the EI_CLASS field.
+ # Similar to the test for readelf -h, but we're just looking for the
+ # EI_CLASS line here.
+ proc readelf_find_size { binary_file } {
+     global READELF
+     global READELFFLAGS
+     global readelf_size
+ 
+     set readelf_size ""
+     set testname "finding out ELF size with readelf -h"
+     catch "exec $READELF $READELFFLAGS -h $binary_file > readelf.out" got
+ 
+     if ![string match "" $got] then {
+ 	send_log $got
+ 	fail $testname
+ 	return
+     }
+ 
+     if { ! [regexp "\n\[ \]*Class:\[ \]*ELF(\[0-9\]+)\n" \
+ 	    [file_contents readelf.out] nil readelf_size] } {
+ 	verbose -log "EI_CLASS field not found in output"
+ 	verbose -log "output is \n[file_contents readelf.out]"
+ 	fail $testname
+ 	return
+     } else {
+ 	verbose -log "ELF size is $readelf_size"
+     }
+ 
+     pass $testname
+ }
+ 
  # Run an individual readelf test.
  # Basically readelf is run on the binary_file with the given options.
  # Readelf's output is captured and then compared against the contents
! # of the regexp_file-readelf_size if it exists, else regexp_file.
  
  proc readelf_test { options binary_file regexp_file xfails } {
  
      global READELF
      global READELFFLAGS
+     global readelf_size
      global srcdir
      global subdir
      
!     send_log "exec $READELF $READELFFLAGS $options $binary_file > readelf.out\n"
      catch "exec $READELF $READELFFLAGS $options $binary_file > readelf.out" got
  
      if { [llength $xfails] != 0 } then {
*************** proc readelf_test { options binary_file 
*** 145,150 ****
--- 176,185 ----
  	return
      }
  
+     if { [file exists $srcdir/$subdir/$regexp_file-$readelf_size] } then {
+ 	set regexp_file $regexp_file-$readelf_size
+     }
+ 
      if { [regexp_diff readelf.out $srcdir/$subdir/$regexp_file] } then {
  	fail "readelf $options"
  	verbose "output is \n[file_contents readelf.out]" 2
*************** proc readelf_test { options binary_file 
*** 161,167 ****
  # in the target string, then the target is not an ELF based port.
  
  if ![istarget "*-*elf"] then {
!     verbose "$READELF is only intenteded for ELF targets" 2
      return
  }
  
--- 196,202 ----
  # in the target string, then the target is not an ELF based port.
  
  if ![istarget "*-*elf"] then {
!     verbose "$READELF is only intended for ELF targets" 2
      return
  }
  
*************** if ![is_remote host] {
*** 186,193 ****
  } else {
      set tempfile [remote_download host tmpdir/bintest.o]
  }
  
! # Run the tests
  readelf_test -h $tempfile readelf.h  {}
  
  # The v850 fails the next two tests because it creates two special
--- 221,231 ----
  } else {
      set tempfile [remote_download host tmpdir/bintest.o]
  }
+ 
+ # First, determine the size, so specific output matchers can be used.
+ readelf_find_size $tempfile
  
! # Run the tests.
  readelf_test -h $tempfile readelf.h  {}
  
  # The v850 fails the next two tests because it creates two special

*** /dev/null	Tue Jan  1 05:00:00 1980
--- readelf.ss-64	Sun Jun 11 23:15:19 2000
***************
*** 0 ****
--- 1,13 ----
+ 
+ Symbol table '.symtab' contains .* entries:
+    Num:    Value          Size Type    Bind   Vis      Ndx Name
+      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+      1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 
+      2: 0000000000000000     0 SECTION LOCAL  DEFAULT    3 
+      3: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 
+      4: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    1 static_text_symbol
+      5: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    3 static_data_symbol
+ .*   .: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 text_symbol
+      .: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND external_symbol
+      .: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    3 data_symbol
+      .: 0000000000000004     4 OBJECT  GLOBAL DEFAULT  COM common_symbol

*** /dev/null	Tue Jan  1 05:00:00 1980
--- readelf.s-64	Sun Jun 11 23:03:44 2000
***************
*** 0 ****
--- 1,24 ----
+ There are .* section headers, starting at offset .*:
+ 
+ Section Headers:
+   \[Nr\] Name              Type             Address           Offset
+        Size              EntSize          Flags  Link  Info  Align
+   \[ 0\]                   NULL             0000000000000000  00000000
+        0000000000000000  0000000000000000           0     0     0
+   \[ 1\] .text             PROGBITS         0000000000000000  00000040
+        00000000000000..  0000000000000000  AX       0     0     .*
+   \[ 2\] .rel.+text +REL. +0+  0+.*
+        000000000000001.  000000000000001.           .     1     8
+   \[ 3\] .data             PROGBITS         0000000000000000  000000[45][08]
+        0000000000000004  0000000000000000  WA       0     0     .*
+   \[ 4\] .bss              NOBITS           0000000000000000  000000[45][c4]
+        0000000000000000  0000000000000000  WA       0     0     .*
+   \[ 5\] .shstrtab         STRTAB           0000000000000000  000000[45][c4]
+        00000000000000..  0000000000000000           0     0     .*
+   \[ 6\] .symtab           SYMTAB           0000000000000000  0+.*
+        0+.*  0000000000000018           7     6     8
+   \[ 7\] .strtab           STRTAB           0000000000000000  0+.*
+        0+.*  0000000000000000           0     0     1
+ Key to Flags: W \(write\), A \(alloc\), X \(execute\), M \(merge\), S \(strings\)
+               I \(info\), L \(link order\), O \(extra OS processing required\)
+               o \(os specific\), p \(processor specific\) x \(unknown\)

brgds, H-P



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]