* as.c (show_usage): Document --execstack and --noexecstack.
[binutils-gdb.git] / bfd / dwarf2.c
index e8ebd6215fe8e0e1e6e42dd0e2df16281207a277..7a9e5b00e31e1c63ccb4cb5e1737296f826356c1 100644 (file)
@@ -650,7 +650,7 @@ read_attribute_value (attr, form, unit, info_ptr)
   switch (form)
     {
     case DW_FORM_addr:
-      /* FIXME: DWARF3 draft sais DW_FORM_ref_addr is offset_size.  */
+      /* FIXME: DWARF3 draft says DW_FORM_ref_addr is offset_size.  */
     case DW_FORM_ref_addr:
       DW_ADDR (attr) = read_address (unit, info_ptr);
       info_ptr += unit->addr_size;
@@ -901,10 +901,19 @@ add_line_info (table, address, filename, line, column, end_sequence)
 
   /* Set member data of 'info'.  */
   info->address = address;
-  info->filename = filename;
   info->line = line;
   info->column = column;
   info->end_sequence = end_sequence;
+
+  amt = strlen (filename);
+  if (amt)
+    {
+      info->filename = bfd_alloc (table->abfd, amt + 1);
+      if (info->filename)
+       strcpy (info->filename, filename);
+    }
+  else
+    info->filename = NULL;
 }
 
 /* Extract a fully qualified filename from a line info table.
@@ -1918,26 +1927,34 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
       bfd_boolean found;
       unsigned int offset_size = addr_size;
 
-      if (addr_size == 4)
+      length = read_4_bytes (abfd, stash->info_ptr);
+      /* A 0xffffff length is the DWARF3 way of indicating we use
+        64-bit offsets, instead of 32-bit offsets.  */
+      if (length == 0xffffffff)
        {
-         length = read_4_bytes (abfd, stash->info_ptr);
-         if (length == 0xffffffff)
-           {
-             offset_size = 8;
-             length = read_8_bytes (abfd, stash->info_ptr + 4);
-             stash->info_ptr += 8;
-           }
-         else if (length == 0)
-           {
-             /* Handle (non-standard) 64-bit DWARF2 formats.  */
-             offset_size = 8;
-             length = read_4_bytes (abfd, stash->info_ptr + 4);
-             stash->info_ptr += 4;
-           }
+         offset_size = 8;
+         length = read_8_bytes (abfd, stash->info_ptr + 4);
+         stash->info_ptr += 12;
+       }
+      /* A zero length is the IRIX way of indicating 64-bit offsets,
+        mostly because the 64-bit length will generally fit in 32
+        bits, and the endianness helps.  */
+      else if (length == 0)
+       {
+         offset_size = 8;
+         length = read_4_bytes (abfd, stash->info_ptr + 4);
+         stash->info_ptr += 8;
+       }
+      /* In the absence of the hints above, we assume addr_size-sized
+        offsets, for backward-compatibility with pre-DWARF3 64-bit
+        platforms.  */
+      else if (addr_size == 8)
+       {
+         length = read_8_bytes (abfd, stash->info_ptr);
+         stash->info_ptr += 8;
        }
       else
-       length = read_8_bytes (abfd, stash->info_ptr);
-      stash->info_ptr += addr_size;
+       stash->info_ptr += 4;
 
       if (length > 0)
        {