public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jim Wilson <wilson@cygnus.com>
To: binutils@sourceware.cygnus.com
Cc: wilson@cygnus.com, rth@cygnus.com
Subject: patch for gas/dwarf2dbg.c, core dump and corrupted .debug_line section
Date: Wed, 25 Aug 1999 20:43:00 -0000	[thread overview]
Message-ID: <199908260343.UAA26025@ada.cygnus.com.cygnus.com> (raw)

This fixes 4 problems I noticed while trying to use this code from gcc.

1) The comments in get_filenum do not match the code.  The code is correct.
2) get_filenum performs an out-of-bounds array access if filenum is 0, which
   makes last == -1.
3) get_filenum does not update ls.last_filename when creating a new filetable
   entry.
4) dwarf2_gen_line_info saves seg/subseg info after it has already been
   clobbered by a subseg_new call.  This causes gas to accidentally emit code
   into the .debug_line section.

Wed Aug 25 20:20:33 1999  Jim Wilson  <wilson@cygnus.com>

	* dwarf2dbg.c (out_end_sequence): Correct comments.  Set last to
	ls.last_filename if last is less than zero.  Set ls.last_filename
	when allocating new entry.
	(dwarf2_gen_line_info): Save seg and subseg info before subseg_new
	call.

Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/dwarf2dbg.c,v
retrieving revision 1.7
diff -p -r1.7 dwarf2dbg.c
*** dwarf2dbg.c	1999/07/23 22:12:34	1.7
--- dwarf2dbg.c	1999/08/26 03:34:48
*************** out_end_sequence ()
*** 359,365 ****
  /* Look up a filenumber either by filename or by filenumber.  If both
     a filenumber and a filename are specified, lookup by filename takes
     precedence.  If the filename cannot be found, it is added to the
!    filetable the filenumber for the new entry is returned.  */
  static int
  get_filenum (filenum, file)
       int filenum;
--- 359,365 ----
  /* Look up a filenumber either by filename or by filenumber.  If both
     a filenumber and a filename are specified, lookup by filename takes
     precedence.  If the filename cannot be found, it is added to the
!    filetable and the filenumber for the new entry is returned.  */
  static int
  get_filenum (filenum, file)
       int filenum;
*************** get_filenum (filenum, file)
*** 368,377 ****
    int i, last = filenum - 1;
    char char0 = file[0];
  
!   if (last >= ls.num_filenames)
      last = ls.last_filename;
  
!   /* do a quick check against the previously used filename: */
    if (ls.num_filenames > 0 && ls.file[last].name[0] == char0
        && strcmp (ls.file[last].name + 1, file + 1) == 0)
      return last + 1;
--- 368,379 ----
    int i, last = filenum - 1;
    char char0 = file[0];
  
!   /* If filenum is out of range of the filename table, then try using the
!      table entry returned from the previous call.  */
!   if (last >= ls.num_filenames || last < 0)
      last = ls.last_filename;
  
!   /* Do a quick check against the specified or previously used filenum.  */
    if (ls.num_filenames > 0 && ls.file[last].name[0] == char0
        && strcmp (ls.file[last].name + 1, file + 1) == 0)
      return last + 1;
*************** get_filenum (filenum, file)
*** 395,400 ****
--- 397,403 ----
      }
    ls.file[ls.num_filenames].dir = 0;
    ls.file[ls.num_filenames].name = file;
+   ls.last_filename = ls.num_filenames;
    return ++ls.num_filenames;
  }
  
*************** dwarf2_gen_line_info (addr, l)
*** 425,430 ****
--- 428,438 ----
    else
      return;	/* no filename, no filnum => no play */
  
+   /* Must save these before the subseg_new call, as that call will change
+      them.  */
+   saved_seg = now_seg;
+   saved_subseg = now_subseg;
+ 
    if (!ls.line_seg)
      {
  #ifdef BFD_ASSEMBLER
*************** dwarf2_gen_line_info (addr, l)
*** 445,452 ****
  #endif
      }
  
-   saved_seg = now_seg;
-   saved_subseg = now_subseg;
    subseg_set (ls.line_seg, DL_BODY);
  
    if (ls.text_seg != saved_seg || ls.text_subseg != saved_subseg)
--- 453,458 ----

             reply	other threads:[~1999-08-25 20:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-25 20:43 Jim Wilson [this message]
1999-08-26  5:18 Nick Clifton

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=199908260343.UAA26025@ada.cygnus.com.cygnus.com \
    --to=wilson@cygnus.com \
    --cc=binutils@sourceware.cygnus.com \
    --cc=rth@cygnus.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).