This is the mail archive of the 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]
Other format: [Raw text]

[gold patch committed] Fix handling of DW_LNE_define_file opcode

Gold doesn't process the DW_LNE_define_file opcode correctly. For
extended opcodes such as this one, the DWARF representation provides
the length of the complete opcode, which gold decodes as OPLEN.
Instead of just skipping that many bytes as it should, gold reads the
three ULEB128 parameters, and adds their lengths to OPLEN, thereby
double-counting those bytes, and skipping too far ahead. I don't
believe this opcode has ever been observed in practice; I found this
only by examining the code.

I've committed the following patch, pre-approved by Ian.


2012-03-12  Cary Coutant  <>

	* (Sized_dwarf_line_info::process_one_opcode): Fix
	handling of DW_LNE_define_file.

commit 2117c5726085044e478d8710194aefcb7c7268ca
Author: Cary Coutant <>
Date:   Mon Mar 12 17:20:32 2012 -0700

    Fix to process DW_LNE_define_file correctly.

diff --git a/gold/ b/gold/
index d4f6b24..ac97f12 100644
--- a/gold/
+++ b/gold/
@@ -1780,17 +1780,16 @@ Sized_dwarf_line_info<size,
               start += templen;

               uint64_t dirindex = read_unsigned_LEB_128(start, &templen);
-              oplen += templen;

               if (dirindex >= this->directories_.back().size())
                 dirindex = 0;
 	      int dirindexi = static_cast<int>(dirindex);

-              read_unsigned_LEB_128(start, &templen);   // mod_time
-              oplen += templen;
-              read_unsigned_LEB_128(start, &templen);   // filelength
-              oplen += templen;
+              // This opcode takes two additional ULEB128 parameters
+              // (mod_time and filelength), but we don't use those
+              // values.  Because OPLEN already tells us how far to
+              // skip to the next opcode, we don't need to read
+              // them at all.


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