This is the mail archive of the binutils@sourceware.cygnus.com 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]

patch for bfd/dwarf2.c, problem if .debug_info section was relocated


Hi!

I've found a small problem in bfd/dwarf2.c. If I wrote a linker
script that had all the *(.debug_info) sections at beginning, and I had
some undefined symbols during the link, the linker would abort without
any message.

If I write such bad linker script, the .debug_info sections gets relocated
before the undefined symbols are reported. In bfd/dwarf2.c, we call
'bfd_get_section_size_before_reloc' which aborts.

I propose the following fix that checks this situation before aborting
and print an error message. We also don't need to abort: in that case
the dwarf-2 debugging info can simply be ignored. The linker will print
the undefined symbol without the file/line information.

Can you integrate this patch?

Thanks,
        Stephane


2000-02-22  Stephane Carrez  <stcarrez@worldnet.fr>

	* dwarf2.c (_bfd_dwarf2_find_nearest_line): Don't abort if
	the .debug_info section was relocated, print an error message.
--- /src/gnu/cygnus/binutils/bfd/dwarf2.c	Wed Jul 14 10:49:38 1999
+++ bfd/dwarf2.c	Mon Feb 21 21:05:17 2000
@@ -1516,6 +1516,19 @@ _bfd_dwarf2_find_nearest_line (abfd, sec
 	  return false;
 	}
 
+      /* If the linker relocates some dwarf-2 sections before some others
+	 (.text, .data), we can't find the line of the symbol.	Complain
+	 and pretend there is no dwarf2 info.  Otherwise, the next call to
+	 'bfd_get_section_size_before_reloc' will abort.  This error can
+	 happen when the default indirect link order is used and the linker
+	 script indicates to relocate dwarf2 section before .text.  */
+      if (msec->reloc_done)
+	{
+	  (* _bfd_error_handler)
+	    ("Linker error: the .debug_info section has been relocated");
+	  return false;
+	}
+
       size = bfd_get_section_size_before_reloc (msec);
       if (size == 0)
 	return false;

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