🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1893

BUG in GCC 1.30 with COFF line numbers using -g & -finline-functions

#1893
From: Ron Guilmette
Date: Wed, 26 Oct 1988 22:54
55 lines
2300 bytes
BUG in GCC 1.30  -- suggested fix included below

If you try to use -g and -finline-functions on GCC 1.30 (or earlier)
and if your system uses COFF (i.e. SDB_DEBUGGING_INFO is #defined)
then you may get ".ln <nnn>" COFF line number directives in the
assembly code produced by GCC, where the value of <nnn> is negative!
This will probably mess-up the mind of your assembler or your linker,
or your sdb(1) debugger.

This happens because COFF symbolics use RELATIVE line numbers (i.e.
relative the the first line of the CURRENT function).  Thus, when
preceeding code gets inline'd into the current function, the RELATIVE
line numbers for the inline'd code are, in fact, negative.

The following simple patch should prevent the negative ".ln <nnn>"
directives from being generated.

diff -rc2 1.30-old/final.c 1.30-new/final.c
*** 1.30-old/final.c	Fri Oct 14 15:19:54 1988
--- 1.30-new/final.c	Wed Oct 26 12:17:49 1988
***************
*** 842,845
  	  && !strcmp (filename, main_input_filename))
  	{
  #ifdef ASM_OUTPUT_SOURCE_LINE
  	  ASM_OUTPUT_SOURCE_LINE (file, last_linenum);

--- 838,843 -----
  	  && !strcmp (filename, main_input_filename))
  	{
+ 	  int relative_linenum;
+ 
  #ifdef ASM_OUTPUT_SOURCE_LINE
  	  ASM_OUTPUT_SOURCE_LINE (file, last_linenum);
***************
*** 845,851
  	  ASM_OUTPUT_SOURCE_LINE (file, last_linenum);
  #else
! 	  fprintf (file, "\t.ln\t%d\n",
! 		   (sdb_begin_function_line
! 		    ? last_linenum - sdb_begin_function_line : 1));
  #endif
  	}

--- 843,851 -----
  	  ASM_OUTPUT_SOURCE_LINE (file, last_linenum);
  #else
! 	  relative_linenum = last_linenum - sdb_begin_function_line;
! 	  /* Don't output negative line numbers for earlier inlined code.  */
! 	  if (relative_linenum > 0)
! 	    fprintf (file, "\t.ln\t%d\n",
! 		   (sdb_begin_function_line ? relative_linenum : 1));
  #endif
  	}
Technical Details
Message-ID: <8810262254.AA08198@nsc.NSC.COM>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!nsc.nsc.com!rfg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!nsc.nsc.com!rfg
From: rfg@nsc.nsc.com (Ron Guilmette)
Newsgroups: gnu.gcc.bug
Subject: BUG in GCC 1.30 with COFF line numbers using -g & -finline-functions
Message-ID: <8810262254.AA08198@nsc.NSC.COM>
Date: 26 Oct 88 22:54:17 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 54