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


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

objdump --stabs fails after -split-by-reloc is used.


objdump --stabs breaks on .o files produced by relocatable linking with
-split-by-reloc. Between each .stab[0-9]* section the file_string_table_offset
is reset to zero, resulting in incorrectly computed string table offsets for
all split sections after the first.

Note that simple test cases can easily produce lots of stabs which have almost
the same relative offsets, thus obscuring the bug because the objdump output
looks mostly (or totally!) correct.

Patch is relative to binutils devo checked out today.

Index: binutils/ChangeLog
===================================================================
RCS file: /cvs/binutils/binutils/binutils/ChangeLog,v
retrieving revision 1.94
diff -c -r1.94 ChangeLog
*** ChangeLog	1999/12/10 18:32:57	1.94
--- ChangeLog	1999/12/11 04:33:27
***************
*** 1,3 ****
--- 1,9 ----
+ 1999-12-10  Todd Whitesel  <toddpw@windriver.com>
+ 
+ 	* objdump.c (print_section_stabs): Printing of stabs that had been
+ 	worked over by -split-by-reloc was broken. Fix it.
+ 	(dump_section_stabs): Ditto.
+ 
  1999-12-10  Nick Clifton  <nickc@cygnus.com>
  
  	* readelf.c (print_vma): Support native 64bit ELF systems.
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/binutils/binutils/binutils/objdump.c,v
retrieving revision 1.14
diff -c -r1.14 objdump.c
*** objdump.c	1999/11/21 11:37:21	1.14
--- objdump.c	1999/12/11 04:33:30
***************
*** 217,224 ****
  static boolean
  read_section_stabs PARAMS ((bfd *, const char *, const char *));
  
! static void
! print_section_stabs PARAMS ((bfd *, const char *, const char *));
  
  static void
  usage (stream, status)
--- 217,224 ----
  static boolean
  read_section_stabs PARAMS ((bfd *, const char *, const char *));
  
! static unsigned int
! print_section_stabs PARAMS ((bfd *, const char *, const char *, unsigned int));
  
  static void
  usage (stream, status)
***************
*** 1928,1941 ****
  /* Print ABFD's stabs section STABSECT_NAME (in `stabs'),
     using string table section STRSECT_NAME (in `strtab').  */
  
! static void
! print_section_stabs (abfd, stabsect_name, strsect_name)
       bfd *abfd;
       const char *stabsect_name;
       const char *strsect_name ATTRIBUTE_UNUSED;
  {
    int i;
!   unsigned file_string_table_offset = 0, next_file_string_table_offset = 0;
    bfd_byte *stabp, *stabs_end;
  
    stabp = stabs;
--- 1928,1943 ----
  /* Print ABFD's stabs section STABSECT_NAME (in `stabs'),
     using string table section STRSECT_NAME (in `strtab').  */
  
! static unsigned int
! print_section_stabs (abfd, stabsect_name, strsect_name, string_table_offset)
       bfd *abfd;
       const char *stabsect_name;
       const char *strsect_name ATTRIBUTE_UNUSED;
+      unsigned int string_table_offset;
  {
    int i;
!   unsigned file_string_table_offset = string_table_offset;
!   unsigned next_file_string_table_offset = string_table_offset;
    bfd_byte *stabp, *stabs_end;
  
    stabp = stabs;
***************
*** 1998,2003 ****
--- 2000,2006 ----
  	}
      }
    printf ("\n\n");
+   return next_file_string_table_offset;
  }
  
  static void
***************
*** 2007,2012 ****
--- 2010,2016 ----
       char *strsect_name;
  {
    asection *s;
+   unsigned int string_table_offset = 0;
  
    /* Check for section names for which stabsect_name is a prefix, to
       handle .stab0, etc.  */
***************
*** 2027,2033 ****
  	{
  	  if (read_section_stabs (abfd, s->name, strsect_name))
  	    {
! 	      print_section_stabs (abfd, s->name, strsect_name);
  	      free (stabs);
  	      free (strtab);
  	    }
--- 2031,2039 ----
  	{
  	  if (read_section_stabs (abfd, s->name, strsect_name))
  	    {
! 	      string_table_offset = print_section_stabs (abfd, s->name,
! 							 strsect_name,
! 							 string_table_offset);
  	      free (stabs);
  	      free (strtab);
  	    }

-- 
Todd Whitesel
toddpw @ windriver.com

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